Index: twe.c =================================================================== RCS file: /host/ziplok/local0/cvs/src/sys/dev/twe/twe.c,v retrieving revision 1.1.2.5 diff -u -r1.1.2.5 twe.c --- twe.c 26 Feb 2001 20:14:04 -0000 1.1.2.5 +++ twe.c 18 Feb 2002 09:17:40 -0000 @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/twe/twe.c,v 1.1.2.5 2001/02/26 20:14:04 msmith Exp $ + * $FreeBSD: src/sys/dev/twe/twe.c,v 1.9 2001/05/07 21:46:44 msmith Exp $ */ /* @@ -96,7 +96,6 @@ */ static char *twe_format_aen(struct twe_softc *sc, u_int16_t aen); static int twe_report_request(struct twe_request *tr); -static int twe_request_qlen(struct twe_request *tr); static void twe_panic(struct twe_softc *sc, char *reason); /******************************************************************************** @@ -112,6 +111,7 @@ twe_setup(struct twe_softc *sc) { struct twe_request *tr; + u_int32_t status_reg; int i; debug_called(4); @@ -146,6 +146,12 @@ } /* + * Check status register for errors, clear them. + */ + status_reg = TWE_STATUS(sc); + twe_check_bits(sc, status_reg); + + /* * Wait for the controller to come ready. */ if (twe_wait_status(sc, TWE_STATUS_MICROCONTROLLER_READY, 60)) { @@ -563,6 +569,8 @@ twe_reset(sc); break; + /* XXX implement ATA PASSTHROUGH */ + /* nothing we understand */ default: error = ENOTTY; @@ -912,12 +920,16 @@ struct twe_request *tr; int i, s; - twe_printf(sc, "controller reset in progress...\n"); + /* + * Sleep for a short period to allow AENs to be signalled. + */ + tsleep(NULL, PRIBIO, "twereset", hz); /* * Disable interrupts from the controller, and mask any accidental entry * into our interrupt handler. */ + twe_printf(sc, "controller reset in progress...\n"); twe_disable_interrupts(sc); s = splbio(); @@ -1171,10 +1183,11 @@ TWE_SOFT_RESET(sc); - if (twe_wait_status(sc, TWE_STATUS_ATTENTION_INTERRUPT, 15)) { + if (twe_wait_status(sc, TWE_STATUS_ATTENTION_INTERRUPT, 30)) { twe_printf(sc, "no attention interrupt\n"); return(1); } + TWE_CONTROL(sc, TWE_CONTROL_CLEAR_ATTENTION_INTERRUPT); if (twe_drain_aen_queue(sc)) { twe_printf(sc, "can't drain AEN queue\n"); return(1); @@ -1579,6 +1592,14 @@ lastwarn[1] = time_second; } result = 1; + if (status_reg & TWE_STATUS_PCI_PARITY_ERROR) { + twe_printf(sc, "PCI parity error: Reseat card, move card or buggy device present."); + twe_clear_pci_parity_error(sc); + } + if (status_reg & TWE_STATUS_PCI_ABORT) { + twe_printf(sc, "PCI abort, clearing."); + twe_clear_pci_abort(sc); + } } return(result); @@ -1609,7 +1630,7 @@ if (!bootverbose) return(NULL); /* FALLTHROUGH */ - case 'p': + case 'a': return(msg); case 'c': @@ -1620,6 +1641,12 @@ msg, TWE_AEN_UNIT(aen)); } return(buf); + + case 'p': + sprintf(buf, "twe%d: port %d: %s", device_get_unit(sc->twe_dev), TWE_AEN_UNIT(aen), + msg); + return(buf); + case 'x': default: @@ -1638,32 +1665,58 @@ { struct twe_softc *sc = tr->tr_sc; TWE_Command *cmd = &tr->tr_command; - int result; - - switch (cmd->generic.flags) { - case TWE_FLAGS_SUCCESS: - result = 0; - break; - case TWE_FLAGS_INFORMATIONAL: - case TWE_FLAGS_WARNING: - twe_printf(sc, "command completed - %s\n", - twe_describe_code(twe_table_status, cmd->generic.status)); - result = 0; - break; + int result = 0; - case TWE_FLAGS_FATAL: - default: - twe_printf(sc, "command failed - %s\n", - twe_describe_code(twe_table_status, cmd->generic.status)); + /* + * Check the command status value and handle accordingly. + */ + if (cmd->generic.status == TWE_STATUS_RESET) { + /* + * The status code 0xff requests a controller reset. + */ + twe_printf(sc, "command returned with controller rest request\n"); + twe_reset(sc); result = 1; - + } else if (cmd->generic.status > TWE_STATUS_FATAL) { /* - * The status code 0xff requests a controller reset + * Fatal errors that don't require controller reset. + * + * We know a few special flags values. */ - if (cmd->generic.status == 0xff) - twe_reset(sc); - break; + switch (cmd->generic.flags) { + case 0x1b: + device_printf(sc->twe_drive[cmd->generic.unit].td_disk, + "drive timeout"); + break; + case 0x51: + device_printf(sc->twe_drive[cmd->generic.unit].td_disk, + "unrecoverable drive error"); + break; + default: + device_printf(sc->twe_drive[cmd->generic.unit].td_disk, + "controller error - %s (flags = 0x%x)\n", + twe_describe_code(twe_table_status, cmd->generic.status), + cmd->generic.flags); + result = 1; + } + } else if (cmd->generic.status > TWE_STATUS_WARNING) { + /* + * Warning level status. + */ + device_printf(sc->twe_drive[cmd->generic.unit].td_disk, + "warning - %s (flags = 0x%x)\n", + twe_describe_code(twe_table_status, cmd->generic.status), + cmd->generic.flags); + } else if (cmd->generic.status > 0x40) { + /* + * Info level status. + */ + device_printf(sc->twe_drive[cmd->generic.unit].td_disk, + "attention - %s (flags = 0x%x)\n", + twe_describe_code(twe_table_status, cmd->generic.status), + cmd->generic.flags); } + return(result); } Index: twe_compat.h =================================================================== RCS file: /host/ziplok/local0/cvs/src/sys/dev/twe/twe_compat.h,v retrieving revision 1.1.2.2 diff -u -r1.1.2.2 twe_compat.h --- twe_compat.h 27 Oct 2000 06:04:02 -0000 1.1.2.2 +++ twe_compat.h 18 Feb 2002 07:48:19 -0000 @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/twe/twe_compat.h,v 1.1.2.2 2000/10/27 06:04:02 msmith Exp $ + * $FreeBSD: src/sys/dev/twe/twe_compat.h,v 1.3 2001/05/07 21:46:44 msmith Exp $ */ /* * Portability and compatibility interfaces. @@ -130,8 +130,11 @@ #define twe_printf(sc, fmt, args...) device_printf(sc->twe_dev, fmt , ##args) #define twed_printf(twed, fmt, args...) device_printf(twed->twed_dev, fmt , ##args) -#if __FreeBSD_version < 500003 /* old buf style */ -# include +#if __FreeBSD_version < 500003 +# include +# define INTR_ENTROPY 0 + +# include /* old buf style */ typedef struct buf twe_bio; typedef struct buf_queue_head twe_bioq; # define TWE_BIO_QINIT(bq) bufq_init(&bq); Index: twe_disk.c =================================================================== RCS file: twe_disk.c diff -N twe_disk.c --- twe_disk.c 27 Oct 2000 06:04:02 -0000 1.1.2.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,290 +0,0 @@ -/*- - * Copyright (c) 2000 Michael Smith - * Copyright (c) 2000 BSDi - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: src/sys/dev/twe/twe_disk.c,v 1.1.2.3 2000/10/27 06:04:02 msmith dead $ - */ - -#include -#include -#include - -#if __FreeBSD_version < 500000 -# include -#else -# include -#endif -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -/* - * Interface to controller. - */ -static int twed_probe(device_t dev); -static int twed_attach(device_t dev); -static int twed_detach(device_t dev); - -/* - * Interface to the device switch - */ -static d_open_t twed_open; -static d_close_t twed_close; -static d_strategy_t twed_strategy; - -#define TWED_CDEV_MAJOR 147 - -static struct cdevsw twed_cdevsw = { - /* open */ twed_open, - /* close */ twed_close, - /* read */ physread, - /* write */ physwrite, - /* ioctl */ noioctl, - /* poll */ nopoll, - /* mmap */ nommap, - /* strategy */ twed_strategy, - /* name */ "twed", - /* maj */ TWED_CDEV_MAJOR, - /* dump */ nodump, - /* psize */ nopsize, - /* flags */ D_DISK, - /* bmaj */ -1 -}; - -devclass_t twed_devclass; -static struct cdevsw tweddisk_cdevsw; -#ifdef FREEBSD_4 -static int disks_registered = 0; -#endif - -static device_method_t twed_methods[] = { - DEVMETHOD(device_probe, twed_probe), - DEVMETHOD(device_attach, twed_attach), - DEVMETHOD(device_detach, twed_detach), - { 0, 0 } -}; - -static driver_t twed_driver = { - "twed", - twed_methods, - sizeof(struct twed_softc) -}; - -DRIVER_MODULE(twed, twe, twed_driver, twed_devclass, 0, 0); - -/******************************************************************************** - * Handle open from generic layer. - * - * Note that this is typically only called by the diskslice code, and not - * for opens on subdevices (eg. slices, partitions). - */ -static int -twed_open(dev_t dev, int flags, int fmt, struct proc *p) -{ - struct twed_softc *sc = (struct twed_softc *)dev->si_drv1; - struct disklabel *label; - - debug_called(4); - - if (sc == NULL) - return (ENXIO); - - /* check that the controller is up and running */ - if (sc->twed_controller->twe_state & TWE_STATE_SHUTDOWN) - return(ENXIO); - - /* build synthetic label */ - label = &sc->twed_disk.d_label; - bzero(label, sizeof(*label)); - label->d_type = DTYPE_ESDI; - label->d_secsize = TWE_BLOCK_SIZE; - label->d_nsectors = sc->twed_drive->td_sectors; - label->d_ntracks = sc->twed_drive->td_heads; - label->d_ncylinders = sc->twed_drive->td_cylinders; - label->d_secpercyl = sc->twed_drive->td_sectors * sc->twed_drive->td_heads; - label->d_secperunit = sc->twed_drive->td_size; - - sc->twed_flags |= TWED_OPEN; - return (0); -} - -/******************************************************************************** - * Handle last close of the disk device. - */ -static int -twed_close(dev_t dev, int flags, int fmt, struct proc *p) -{ - struct twed_softc *sc = (struct twed_softc *)dev->si_drv1; - - debug_called(4); - - if (sc == NULL) - return (ENXIO); - - sc->twed_flags &= ~TWED_OPEN; - return (0); -} - -/******************************************************************************** - * Handle an I/O request. - */ -static void -twed_strategy(struct bio *bp) -{ - struct twed_softc *sc = (struct twed_softc *)bp->bio_dev->si_drv1; - - debug_called(4); - - /* bogus disk? */ - if (sc == NULL) { - bp->bio_flags |= BIO_ERROR; - bp->bio_error = EINVAL; - return; - } - - /* do-nothing operation? */ - if (bp->bio_bcount == 0) { - bp->bio_resid = bp->bio_bcount; - biodone(bp); - return; - } - - /* perform accounting */ - devstat_start_transaction(&sc->twed_stats); - - /* pass the bio to the controller - it can work out who we are */ - twe_submit_buf(sc->twed_controller, bp); - return; -} - -/******************************************************************************** - * Handle completion of an I/O request. - */ -void -twed_intr(void *data) -{ - struct bio *bp = (struct bio *)data; - struct twed_softc *sc = (struct twed_softc *)bp->bio_dev->si_drv1; - - debug_called(4); - - /* check for error from controller code */ - if (bp->bio_flags & BIO_ERROR) { - bp->bio_error = EIO; - } else { - bp->bio_resid = 0; - } - - devstat_end_transaction_bio(&sc->twed_stats, bp); - biodone(bp); -} - -/******************************************************************************** - * Stub to provide device identification when probed. - */ -static int -twed_probe(device_t dev) -{ - - debug_called(4); - - device_set_desc(dev, "3ware RAID unit"); - return (0); -} - -/******************************************************************************** - * Attach a unit to the controller. - */ -static int -twed_attach(device_t dev) -{ - struct twed_softc *sc = (struct twed_softc *)device_get_softc(dev); - device_t parent; - dev_t dsk; - - debug_called(4); - - /* initialise our softc */ - parent = device_get_parent(dev); - sc->twed_controller = (struct twe_softc *)device_get_softc(parent); - sc->twed_drive = device_get_ivars(dev); - sc->twed_dev = dev; - - /* report the drive */ - device_printf(dev, "%uMB (%u sectors)\n", - sc->twed_drive->td_size / ((1024 * 1024) / TWE_BLOCK_SIZE), - sc->twed_drive->td_size); - - devstat_add_entry(&sc->twed_stats, "twed", device_get_unit(dev), TWE_BLOCK_SIZE, - DEVSTAT_NO_ORDERED_TAGS, - DEVSTAT_TYPE_STORARRAY | DEVSTAT_TYPE_IF_OTHER, - DEVSTAT_PRIORITY_ARRAY); - - /* attach a generic disk device to ourselves */ - dsk = disk_create(device_get_unit(dev), &sc->twed_disk, 0, &twed_cdevsw, &tweddisk_cdevsw); - dsk->si_drv1 = sc; - sc->twed_dev_t = dsk; -#ifdef FREEBSD_4 - disks_registered++; -#endif - - /* set the maximum I/O size to the theoretical maximum allowed by the S/G list size */ - dsk->si_iosize_max = (TWE_MAX_SGL_LENGTH - 1) * PAGE_SIZE; - - return (0); -} - -/******************************************************************************** - * Disconnect ourselves from the system. - */ -static int -twed_detach(device_t dev) -{ - struct twed_softc *sc = (struct twed_softc *)device_get_softc(dev); - - debug_called(4); - - if (sc->twed_flags & TWED_OPEN) - return(EBUSY); - - devstat_remove_entry(&sc->twed_stats); -#ifdef FREEBSD_4 - if (--disks_registered == 0) - cdevsw_remove(&tweddisk_cdevsw); -#else - disk_destroy(sc->twed_dev_t); -#endif - - return(0); -} - Index: twe_freebsd.c =================================================================== RCS file: /host/ziplok/local0/cvs/src/sys/dev/twe/twe_freebsd.c,v retrieving revision 1.2.2.3 diff -u -r1.2.2.3 twe_freebsd.c --- twe_freebsd.c 26 Jul 2001 21:54:54 -0000 1.2.2.3 +++ twe_freebsd.c 18 Feb 2002 09:18:28 -0000 @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/twe/twe_freebsd.c,v 1.2.2.3 2001/07/26 21:54:54 ps Exp $ + * $FreeBSD: src/sys/dev/twe/twe_freebsd.c,v 1.11 2001/11/13 01:08:54 ps Exp $ */ /* @@ -83,15 +83,14 @@ TWE_CDEV_MAJOR, nodump, nopsize, - 0, - -1 + 0 }; /******************************************************************************** * Accept an open operation on the control device. */ static int -twe_open(dev_t dev, int flags, int fmt, struct proc *p) +twe_open(dev_t dev, int flags, int fmt, d_thread_t *td) { int unit = minor(dev); struct twe_softc *sc = devclass_get_softc(twe_devclass, unit); @@ -104,7 +103,7 @@ * Accept the last close on the control device. */ static int -twe_close(dev_t dev, int flags, int fmt, struct proc *p) +twe_close(dev_t dev, int flags, int fmt, d_thread_t *td) { int unit = minor(dev); struct twe_softc *sc = devclass_get_softc(twe_devclass, unit); @@ -117,7 +116,7 @@ * Handle controller-specific control operations. */ static int -twe_ioctl_wrapper(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct proc *p) +twe_ioctl_wrapper(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, d_thread_t *td) { struct twe_softc *sc = (struct twe_softc *)dev->si_drv1; @@ -258,7 +257,7 @@ twe_free(sc); return(ENXIO); } - if (bus_setup_intr(sc->twe_dev, sc->twe_irq, INTR_TYPE_BIO, twe_pci_intr, sc, &sc->twe_intr)) { + if (bus_setup_intr(sc->twe_dev, sc->twe_irq, INTR_TYPE_BIO | INTR_ENTROPY, twe_pci_intr, sc, &sc->twe_intr)) { twe_printf(sc, "can't set up interrupt\n"); twe_free(sc); return(ENXIO); @@ -514,6 +513,26 @@ } /******************************************************************************** + * Clear a PCI parity error. + */ +void +twe_clear_pci_parity_error(struct twe_softc *sc) +{ + TWE_CONTROL(sc, TWE_CONTROL_CLEAR_PARITY_ERROR); + pci_write_config(sc->twe_dev, PCIR_STATUS, TWE_PCI_CLEAR_PARITY_ERROR, 2); +} + +/******************************************************************************** + * Clear a PCI abort. + */ +void +twe_clear_pci_abort(struct twe_softc *sc) +{ + TWE_CONTROL(sc, TWE_CONTROL_CLEAR_PCI_ABORT); + pci_write_config(sc->twe_dev, PCIR_STATUS, TWE_PCI_CLEAR_PCI_ABORT, 2); +} + +/******************************************************************************** ******************************************************************************** Disk device ******************************************************************************** @@ -585,8 +604,7 @@ TWED_CDEV_MAJOR, twed_dump, nopsize, - D_DISK, - -1 + D_DISK }; static struct cdevsw tweddisk_cdevsw; @@ -601,7 +619,7 @@ * for opens on subdevices (eg. slices, partitions). */ static int -twed_open(dev_t dev, int flags, int fmt, struct proc *p) +twed_open(dev_t dev, int flags, int fmt, d_thread_t *td) { struct twed_softc *sc = (struct twed_softc *)dev->si_drv1; struct disklabel *label; @@ -634,7 +652,7 @@ * Handle last close of the disk device. */ static int -twed_close(dev_t dev, int flags, int fmt, struct proc *p) +twed_close(dev_t dev, int flags, int fmt, d_thread_t *td) { struct twed_softc *sc = (struct twed_softc *)dev->si_drv1; @@ -668,14 +686,6 @@ return; } - /* do-nothing operation? */ - if (TWE_BIO_LENGTH(bp) == 0) { - TWE_BIO_RESID(bp) = 0; - TWE_BIO_DONE(bp); - TWED_BIO_OUT; - return; - } - /* perform accounting */ TWE_BIO_STATS_START(bp); @@ -729,7 +739,7 @@ return(error); - if (dumpstatus(addr, (long)(count * DEV_BSIZE)) < 0) + if (dumpstatus(addr, (off_t)count * DEV_BSIZE) < 0) return(EINTR); blkno += blkcnt * dumppages; @@ -888,7 +898,7 @@ * * These routines ensure that the data which the controller is going to try to * access is actually visible to the controller, in a machine-independant - * fasion. Due to a hardware limitation, I/O buffers must be 512-byte aligned + * fashion. Due to a hardware limitation, I/O buffers must be 512-byte aligned * and we take care of that here as well. */ static void Index: twe_tables.h =================================================================== RCS file: /host/ziplok/local0/cvs/src/sys/dev/twe/twe_tables.h,v retrieving revision 1.1.2.1 diff -u -r1.1.2.1 twe_tables.h --- twe_tables.h 27 Oct 2000 06:04:02 -0000 1.1.2.1 +++ twe_tables.h 18 Feb 2002 08:49:39 -0000 @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/twe/twe_tables.h,v 1.1.2.1 2000/10/27 06:04:02 msmith Exp $ + * $FreeBSD: src/sys/dev/twe/twe_tables.h,v 1.1 2000/10/25 06:59:05 msmith Exp $ */ /* @@ -118,7 +118,7 @@ {"q queue empty", 0x00}, {"q soft reset", 0x01}, {"c degraded mirror", 0x02}, - {"p controller error", 0x03}, + {"a controller error", 0x03}, {"c rebuild fail", 0x04}, {"c rebuild done", 0x05}, {"c incomplete unit", 0x06}, @@ -127,7 +127,23 @@ {"c drive timeout", 0x09}, {"c drive error", 0x0a}, {"c rebuild started", 0x0b}, - {"p aen queue full", 0xff}, + {"c init started", 0x0c}, + {"c logical unit deleted", 0x0d}, + {"p SMART threshold exceeded", 0x0f}, + {"p ATA UDMA downgrade", 0x21}, + {"p ATA UDMA upgrade", 0x22}, + {"p sector repair occurred", 0x23}, + {"a SBUF integrity check failure", 0x24}, + {"p lost cached write", 0x25}, + {"p drive ECC error detected", 0x26}, + {"p DCB checksum error", 0x27}, + {"p DCB unsupported version", 0x28}, + {"c verify started", 0x29}, + {"c verify failed", 0x2a}, + {"c verify complete", 0x2b}, + {"p overwrote bad sector during rebuild", 0x2c}, + {"p encountered bad sector during rebuild", 0x2d}, + {"a aen queue full", 0xff}, {NULL, 0}, {"x unknown AEN", 0} }; Index: tweio.h =================================================================== RCS file: /host/ziplok/local0/cvs/src/sys/dev/twe/tweio.h,v retrieving revision 1.1.2.1 retrieving revision 1.1 diff -u -r1.1.2.1 -r1.1 --- tweio.h 27 Oct 2000 06:04:02 -0000 1.1.2.1 +++ tweio.h 25 Oct 2000 06:59:05 -0000 1.1 @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/twe/tweio.h,v 1.1.2.1 2000/10/27 06:04:02 msmith Exp $ + * $FreeBSD: src/sys/dev/twe/tweio.h,v 1.1 2000/10/25 06:59:05 msmith Exp $ */ Index: twereg.h =================================================================== RCS file: /host/ziplok/local0/cvs/src/sys/dev/twe/twereg.h,v retrieving revision 1.1.2.3 diff -u -r1.1.2.3 twereg.h --- twereg.h 27 Oct 2000 06:04:02 -0000 1.1.2.3 +++ twereg.h 18 Feb 2002 09:18:57 -0000 @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/twe/twereg.h,v 1.1.2.3 2000/10/27 06:04:02 msmith Exp $ + * $FreeBSD: src/sys/dev/twe/twereg.h,v 1.5 2001/05/07 21:46:44 msmith Exp $ */ /* @@ -47,6 +47,8 @@ #define TWE_CONTROL_ENABLE_INTERRUPTS 0x00000080 #define TWE_CONTROL_DISABLE_INTERRUPTS 0x00000040 #define TWE_CONTROL_ISSUE_HOST_INTERRUPT 0x00000020 +#define TWE_CONTROL_CLEAR_PARITY_ERROR 0x00800000 +#define TWE_CONTROL_CLEAR_PCI_ABORT 0x00100000 #define TWE_SOFT_RESET(sc) TWE_CONTROL(sc, TWE_CONTROL_ISSUE_SOFT_RESET | \ TWE_CONTROL_CLEAR_HOST_INTERRUPT | \ @@ -100,6 +102,8 @@ #define TWE_VENDOR_ID 0x13C1 #define TWE_DEVICE_ID 0x1000 #define TWE_DEVICE_ID_ASIC 0x1001 +#define TWE_PCI_CLEAR_PARITY_ERROR 0xc100 +#define TWE_PCI_CLEAR_PCI_ABORT 0x2000 /* command packet opcodes */ #define TWE_OP_NOP 0x00 @@ -123,6 +127,14 @@ #define TWE_OP_SECTOR_INFO 0x1a #define TWE_OP_AEN_LISTEN 0x1c #define TWE_OP_CMD_PACKET 0x1d +#define TWE_OP_ATA_PASSTHROUGH 0x1e +#define TWE_OP_CMD_WITH_DATA 0x1f + +/* command status values */ +#define TWE_STATUS_RESET 0xff /* controller requests reset */ +#define TWE_STATUS_FATAL 0xc0 /* fatal errors not requiring reset */ +#define TWE_STATUS_WARNING 0x80 /* warnings */ +#define TWE_STAUS_INFO 0x40 /* informative status */ /* misc defines */ #define TWE_ALIGNMENT 0x200 @@ -132,6 +144,8 @@ #define TWE_SHUTDOWN_MESSAGE_CREDITS 0x001 #define TWE_INIT_COMMAND_PACKET_SIZE 0x3 #define TWE_MAX_SGL_LENGTH 62 +#define TWE_MAX_ATA_SGL_LENGTH 60 +#define TWE_MAX_PASSTHROUGH 4096 #define TWE_Q_LENGTH TWE_INIT_MESSAGE_CREDITS #define TWE_Q_START 0 #define TWE_MAX_RESET_TRIES 3 @@ -266,6 +280,26 @@ u_int8_t unit:4; u_int8_t host_id:4; u_int8_t status; + u_int16_t param; + u_int16_t features; + u_int16_t sector_count; + u_int16_t sector_num; + u_int16_t cylinder_lo; + u_int16_t cylinder_hi; + u_int8_t drive_head; + u_int8_t command; + TWE_SG_Entry sgl[TWE_MAX_ATA_SGL_LENGTH]; +} TWE_Command_ATA __attribute__ ((packed)); + +typedef struct +{ + u_int8_t opcode:5; + u_int8_t sgl_offset:3; + u_int8_t size; + u_int8_t request_id; + u_int8_t unit:4; + u_int8_t host_id:4; + u_int8_t status; u_int8_t flags; #define TWE_FLAGS_SUCCESS 0x00 #define TWE_FLAGS_INFORMATIONAL 0x01 @@ -284,6 +318,7 @@ TWE_Command_CHECKSTATUS checkstatus; TWE_Command_REBUILDUNIT rebuildunit; TWE_Command_SETATAFEATURE setatafeature; + TWE_Command_ATA ata; TWE_Command_Generic generic; u_int8_t pad[512]; } TWE_Command; @@ -454,3 +489,4 @@ u_int8_t parameter_size_bytes; u_int8_t data[0]; } TWE_Param __attribute__ ((packed)); + Index: twevar.h =================================================================== RCS file: /host/ziplok/local0/cvs/src/sys/dev/twe/twevar.h,v retrieving revision 1.1.2.3 diff -u -r1.1.2.3 twevar.h --- twevar.h 7 Dec 2000 08:08:45 -0000 1.1.2.3 +++ twevar.h 18 Feb 2002 08:43:02 -0000 @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/twe/twevar.h,v 1.1.2.3 2000/12/07 08:08:45 ps Exp $ + * $FreeBSD: src/sys/dev/twe/twevar.h,v 1.4 2001/05/07 21:46:44 msmith Exp $ */ #ifdef TWE_DEBUG @@ -145,6 +145,8 @@ extern void twe_attach_drive(struct twe_softc *sc, struct twe_drive *dr); /* attach drive when found in twe_init */ +extern void twe_clear_pci_parity_error(struct twe_softc *sc); +extern void twe_clear_pci_abort(struct twe_softc *sc); extern void twed_intr(twe_bio *bp); /* return bio from core */ extern struct twe_request *twe_allocate_request(struct twe_softc *sc); /* allocate request structure */ extern void twe_free_request(struct twe_request *tr); /* free request structure */ @@ -240,7 +242,7 @@ } static __inline void -twe_enqueue_bio(struct twe_softc *sc, struct bio *bp) +twe_enqueue_bio(struct twe_softc *sc, twe_bio *bp) { int s; @@ -250,11 +252,11 @@ splx(s); } -static __inline struct bio * +static __inline twe_bio * twe_dequeue_bio(struct twe_softc *sc) { int s; - struct bio *bp; + twe_bio *bp; s = splbio(); if ((bp = TWE_BIO_QFIRST(sc->twe_bioq)) != NULL) {