ahb.c (46743) | ahb.c (49360) |
---|---|
1/* 2 * CAM SCSI device driver for the Adaptec 174X SCSI Host adapter 3 * 4 * Copyright (c) 1998 Justin T. Gibbs 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 11 unchanged lines hidden (view full) --- 20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * | 1/* 2 * CAM SCSI device driver for the Adaptec 174X SCSI Host adapter 3 * 4 * Copyright (c) 1998 Justin T. Gibbs 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 11 unchanged lines hidden (view full) --- 20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * |
28 * $Id: ahb.c,v 1.11 1999/05/06 20:16:31 ken Exp $ | 28 * $Id: ahb.c,v 1.12 1999/05/08 21:59:17 dfr Exp $ |
29 */ 30 31#include "eisa.h" 32#if NEISA > 0 33#include <stddef.h> /* For offsetof() */ 34 35#include <sys/param.h> 36#include <sys/systm.h> --- 164 unchanged lines hidden (view full) --- 201 202static int 203ahbprobe(device_t dev) 204{ 205 const char *desc; 206 u_int32_t iobase; 207 u_int32_t irq; 208 u_int8_t intdef; | 29 */ 30 31#include "eisa.h" 32#if NEISA > 0 33#include <stddef.h> /* For offsetof() */ 34 35#include <sys/param.h> 36#include <sys/systm.h> --- 164 unchanged lines hidden (view full) --- 201 202static int 203ahbprobe(device_t dev) 204{ 205 const char *desc; 206 u_int32_t iobase; 207 u_int32_t irq; 208 u_int8_t intdef; |
209 int shared; |
|
209 210 desc = ahbmatch(eisa_get_id(dev)); 211 if (!desc) 212 return (ENXIO); 213 device_set_desc(dev, desc); 214 215 iobase = (eisa_get_slot(dev) * EISA_SLOT_SIZE) + 216 AHB_EISA_SLOT_OFFSET; --- 25 unchanged lines hidden (view full) --- 242 "irq setting %d\n", eisa_get_slot(dev), 243 (intdef & 0x7)); 244 irq = 0; 245 break; 246 } 247 if (irq == 0) 248 return ENXIO; 249 | 210 211 desc = ahbmatch(eisa_get_id(dev)); 212 if (!desc) 213 return (ENXIO); 214 device_set_desc(dev, desc); 215 216 iobase = (eisa_get_slot(dev) * EISA_SLOT_SIZE) + 217 AHB_EISA_SLOT_OFFSET; --- 25 unchanged lines hidden (view full) --- 243 "irq setting %d\n", eisa_get_slot(dev), 244 (intdef & 0x7)); 245 irq = 0; 246 break; 247 } 248 if (irq == 0) 249 return ENXIO; 250 |
250 eisa_add_intr(dev, irq); | 251 shared = (inb(INTDEF + iobase) & INTLEVEL) ? 252 EISA_TRIGGER_LEVEL : EISA_TRIGGER_EDGE; |
251 | 253 |
254 eisa_add_intr(dev, irq, shared); 255 |
|
252 return 0; 253} 254 255static int 256ahbattach(device_t dev) 257{ 258 /* 259 * find unit and check we have that many defined 260 */ 261 struct ahb_softc *ahb; 262 struct ecb* next_ecb; 263 struct resource *io = 0; 264 struct resource *irq = 0; | 256 return 0; 257} 258 259static int 260ahbattach(device_t dev) 261{ 262 /* 263 * find unit and check we have that many defined 264 */ 265 struct ahb_softc *ahb; 266 struct ecb* next_ecb; 267 struct resource *io = 0; 268 struct resource *irq = 0; |
265 int shared, rid; | 269 int rid; |
266 void *ih; 267 268 rid = 0; 269 io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 270 0, ~0, 1, RF_ACTIVE); 271 if (!io) { 272 device_printf(dev, "No I/O space?!\n"); 273 return ENOMEM; 274 } 275 276 if ((ahb = ahballoc(device_get_unit(dev), rman_get_start(io))) == NULL) { 277 goto error_exit2; 278 } 279 280 if (ahbreset(ahb) != 0) 281 goto error_exit; 282 | 270 void *ih; 271 272 rid = 0; 273 io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 274 0, ~0, 1, RF_ACTIVE); 275 if (!io) { 276 device_printf(dev, "No I/O space?!\n"); 277 return ENOMEM; 278 } 279 280 if ((ahb = ahballoc(device_get_unit(dev), rman_get_start(io))) == NULL) { 281 goto error_exit2; 282 } 283 284 if (ahbreset(ahb) != 0) 285 goto error_exit; 286 |
283 shared = (ahb_inb(ahb, INTDEF) & INTLEVEL) ? RF_SHAREABLE : 0; | |
284 rid = 0; 285 irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, | 287 rid = 0; 288 irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, |
286 0, ~0, 1, shared | RF_ACTIVE); | 289 0, ~0, 1, RF_ACTIVE); |
287 if (!irq) { 288 device_printf(dev, "Can't allocate interrupt\n"); 289 goto error_exit; 290 } 291 292 /* 293 * Create our DMA tags. These tags define the kinds of device 294 * accessable memory allocations and memory mappings we will --- 446 unchanged lines hidden (view full) --- 741 break; 742 case HS_CMD_ABORTED_HOST: 743 case HS_CMD_ABORTED_ADAPTER: 744 case HS_ATN_TARGET_FAILED: 745 case HS_SCSI_RESET_ADAPTER: 746 case HS_SCSI_RESET_INCOMING: 747 ccb->ccb_h.status = CAM_SCSI_BUS_RESET; 748 break; | 290 if (!irq) { 291 device_printf(dev, "Can't allocate interrupt\n"); 292 goto error_exit; 293 } 294 295 /* 296 * Create our DMA tags. These tags define the kinds of device 297 * accessable memory allocations and memory mappings we will --- 446 unchanged lines hidden (view full) --- 744 break; 745 case HS_CMD_ABORTED_HOST: 746 case HS_CMD_ABORTED_ADAPTER: 747 case HS_ATN_TARGET_FAILED: 748 case HS_SCSI_RESET_ADAPTER: 749 case HS_SCSI_RESET_INCOMING: 750 ccb->ccb_h.status = CAM_SCSI_BUS_RESET; 751 break; |
752 case HS_INVALID_ECB_PARAM: 753 printf("ahb%ld: opcode 0x%02x, flag_word1 0x%02x, flag_word2 0x%02x\n", 754 ahb->unit, hecb->opcode, hecb->flag_word1, hecb->flag_word2); 755 ccb->ccb_h.status = CAM_SCSI_BUS_RESET; 756 break; |
|
749 case HS_DUP_TCB_RECEIVED: 750 case HS_INVALID_OPCODE: 751 case HS_INVALID_CMD_LINK: | 757 case HS_DUP_TCB_RECEIVED: 758 case HS_INVALID_OPCODE: 759 case HS_INVALID_CMD_LINK: |
752 case HS_INVALID_ECB_PARAM: | |
753 case HS_PROGRAM_CKSUM_ERROR: 754 panic("ahb%ld: Can't happen host status %x occurred", 755 ahb->unit, status->ha_status); 756 break; 757 } 758 if (ccb->ccb_h.status != CAM_REQ_CMP) { 759 xpt_freeze_devq(ccb->ccb_h.path, /*count*/1); 760 ccb->ccb_h.status |= CAM_DEV_QFRZN; --- 597 unchanged lines hidden --- | 760 case HS_PROGRAM_CKSUM_ERROR: 761 panic("ahb%ld: Can't happen host status %x occurred", 762 ahb->unit, status->ha_status); 763 break; 764 } 765 if (ccb->ccb_h.status != CAM_REQ_CMP) { 766 xpt_freeze_devq(ccb->ccb_h.path, /*count*/1); 767 ccb->ccb_h.status |= CAM_DEV_QFRZN; --- 597 unchanged lines hidden --- |