Deleted Added
full compact
aac.c (112207) aac.c (112679)
1/*-
2 * Copyright (c) 2000 Michael Smith
3 * Copyright (c) 2001 Scott Long
4 * Copyright (c) 2000 BSDi
5 * Copyright (c) 2001 Adaptec, Inc.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 12 unchanged lines hidden (view full) ---

21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
1/*-
2 * Copyright (c) 2000 Michael Smith
3 * Copyright (c) 2001 Scott Long
4 * Copyright (c) 2000 BSDi
5 * Copyright (c) 2001 Adaptec, Inc.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 12 unchanged lines hidden (view full) ---

21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * $FreeBSD: head/sys/dev/aac/aac.c 112207 2003-03-13 22:56:11Z scottl $
29 * $FreeBSD: head/sys/dev/aac/aac.c 112679 2003-03-26 17:50:11Z scottl $
30 */
31
32/*
33 * Driver for the Adaptec 'FSA' family of PCI/SCSI RAID adapters.
34 */
35
36#include "opt_aac.h"
37

--- 62 unchanged lines hidden (view full) ---

100/* Falcon/PPC interface */
101static int aac_fa_get_fwstatus(struct aac_softc *sc);
102static void aac_fa_qnotify(struct aac_softc *sc, int qbit);
103static int aac_fa_get_istatus(struct aac_softc *sc);
104static void aac_fa_clear_istatus(struct aac_softc *sc, int mask);
105static void aac_fa_set_mailbox(struct aac_softc *sc, u_int32_t command,
106 u_int32_t arg0, u_int32_t arg1,
107 u_int32_t arg2, u_int32_t arg3);
30 */
31
32/*
33 * Driver for the Adaptec 'FSA' family of PCI/SCSI RAID adapters.
34 */
35
36#include "opt_aac.h"
37

--- 62 unchanged lines hidden (view full) ---

100/* Falcon/PPC interface */
101static int aac_fa_get_fwstatus(struct aac_softc *sc);
102static void aac_fa_qnotify(struct aac_softc *sc, int qbit);
103static int aac_fa_get_istatus(struct aac_softc *sc);
104static void aac_fa_clear_istatus(struct aac_softc *sc, int mask);
105static void aac_fa_set_mailbox(struct aac_softc *sc, u_int32_t command,
106 u_int32_t arg0, u_int32_t arg1,
107 u_int32_t arg2, u_int32_t arg3);
108static int aac_fa_get_mailboxstatus(struct aac_softc *sc);
108static int aac_fa_get_mailbox(struct aac_softc *sc, int mb);
109static void aac_fa_set_interrupts(struct aac_softc *sc, int enable);
110
111struct aac_interface aac_fa_interface = {
112 aac_fa_get_fwstatus,
113 aac_fa_qnotify,
114 aac_fa_get_istatus,
115 aac_fa_clear_istatus,
116 aac_fa_set_mailbox,
109static void aac_fa_set_interrupts(struct aac_softc *sc, int enable);
110
111struct aac_interface aac_fa_interface = {
112 aac_fa_get_fwstatus,
113 aac_fa_qnotify,
114 aac_fa_get_istatus,
115 aac_fa_clear_istatus,
116 aac_fa_set_mailbox,
117 aac_fa_get_mailboxstatus,
117 aac_fa_get_mailbox,
118 aac_fa_set_interrupts
119};
120
121/* StrongARM interface */
122static int aac_sa_get_fwstatus(struct aac_softc *sc);
123static void aac_sa_qnotify(struct aac_softc *sc, int qbit);
124static int aac_sa_get_istatus(struct aac_softc *sc);
125static void aac_sa_clear_istatus(struct aac_softc *sc, int mask);
126static void aac_sa_set_mailbox(struct aac_softc *sc, u_int32_t command,
127 u_int32_t arg0, u_int32_t arg1,
128 u_int32_t arg2, u_int32_t arg3);
118 aac_fa_set_interrupts
119};
120
121/* StrongARM interface */
122static int aac_sa_get_fwstatus(struct aac_softc *sc);
123static void aac_sa_qnotify(struct aac_softc *sc, int qbit);
124static int aac_sa_get_istatus(struct aac_softc *sc);
125static void aac_sa_clear_istatus(struct aac_softc *sc, int mask);
126static void aac_sa_set_mailbox(struct aac_softc *sc, u_int32_t command,
127 u_int32_t arg0, u_int32_t arg1,
128 u_int32_t arg2, u_int32_t arg3);
129static int aac_sa_get_mailboxstatus(struct aac_softc *sc);
129static int aac_sa_get_mailbox(struct aac_softc *sc, int mb);
130static void aac_sa_set_interrupts(struct aac_softc *sc, int enable);
131
132struct aac_interface aac_sa_interface = {
133 aac_sa_get_fwstatus,
134 aac_sa_qnotify,
135 aac_sa_get_istatus,
136 aac_sa_clear_istatus,
137 aac_sa_set_mailbox,
130static void aac_sa_set_interrupts(struct aac_softc *sc, int enable);
131
132struct aac_interface aac_sa_interface = {
133 aac_sa_get_fwstatus,
134 aac_sa_qnotify,
135 aac_sa_get_istatus,
136 aac_sa_clear_istatus,
137 aac_sa_set_mailbox,
138 aac_sa_get_mailboxstatus,
138 aac_sa_get_mailbox,
139 aac_sa_set_interrupts
140};
141
142/* i960Rx interface */
143static int aac_rx_get_fwstatus(struct aac_softc *sc);
144static void aac_rx_qnotify(struct aac_softc *sc, int qbit);
145static int aac_rx_get_istatus(struct aac_softc *sc);
146static void aac_rx_clear_istatus(struct aac_softc *sc, int mask);
147static void aac_rx_set_mailbox(struct aac_softc *sc, u_int32_t command,
148 u_int32_t arg0, u_int32_t arg1,
149 u_int32_t arg2, u_int32_t arg3);
139 aac_sa_set_interrupts
140};
141
142/* i960Rx interface */
143static int aac_rx_get_fwstatus(struct aac_softc *sc);
144static void aac_rx_qnotify(struct aac_softc *sc, int qbit);
145static int aac_rx_get_istatus(struct aac_softc *sc);
146static void aac_rx_clear_istatus(struct aac_softc *sc, int mask);
147static void aac_rx_set_mailbox(struct aac_softc *sc, u_int32_t command,
148 u_int32_t arg0, u_int32_t arg1,
149 u_int32_t arg2, u_int32_t arg3);
150static int aac_rx_get_mailboxstatus(struct aac_softc *sc);
150static int aac_rx_get_mailbox(struct aac_softc *sc, int mb);
151static void aac_rx_set_interrupts(struct aac_softc *sc, int enable);
152
153struct aac_interface aac_rx_interface = {
154 aac_rx_get_fwstatus,
155 aac_rx_qnotify,
156 aac_rx_get_istatus,
157 aac_rx_clear_istatus,
158 aac_rx_set_mailbox,
151static void aac_rx_set_interrupts(struct aac_softc *sc, int enable);
152
153struct aac_interface aac_rx_interface = {
154 aac_rx_get_fwstatus,
155 aac_rx_qnotify,
156 aac_rx_get_istatus,
157 aac_rx_clear_istatus,
158 aac_rx_set_mailbox,
159 aac_rx_get_mailboxstatus,
159 aac_rx_get_mailbox,
160 aac_rx_set_interrupts
161};
162
163/* Debugging and Diagnostics */
164static void aac_describe_controller(struct aac_softc *sc);
165static char *aac_describe_code(struct aac_code_lookup *table,
166 u_int32_t code);
167

--- 115 unchanged lines hidden (view full) ---

283
284 /* Register the shutdown method to only be called post-dump */
285 if ((sc->eh = EVENTHANDLER_REGISTER(shutdown_final, aac_shutdown,
286 sc->aac_dev, SHUTDOWN_PRI_DEFAULT)) == NULL)
287 device_printf(sc->aac_dev,
288 "shutdown event registration failed\n");
289
290 /* Register with CAM for the non-DASD devices */
160 aac_rx_set_interrupts
161};
162
163/* Debugging and Diagnostics */
164static void aac_describe_controller(struct aac_softc *sc);
165static char *aac_describe_code(struct aac_code_lookup *table,
166 u_int32_t code);
167

--- 115 unchanged lines hidden (view full) ---

283
284 /* Register the shutdown method to only be called post-dump */
285 if ((sc->eh = EVENTHANDLER_REGISTER(shutdown_final, aac_shutdown,
286 sc->aac_dev, SHUTDOWN_PRI_DEFAULT)) == NULL)
287 device_printf(sc->aac_dev,
288 "shutdown event registration failed\n");
289
290 /* Register with CAM for the non-DASD devices */
291 if (!(sc->quirks & AAC_QUIRK_NOCAM)) {
291 if ((sc->flags & AAC_FLAGS_ENABLE_CAM) != 0) {
292 TAILQ_INIT(&sc->aac_sim_tqh);
293 aac_get_bus_info(sc);
294 }
295
296 return(0);
297}
298
299/*

--- 799 unchanged lines hidden (view full) ---

1099static int
1100aac_alloc_commands(struct aac_softc *sc)
1101{
1102 struct aac_command *cm;
1103 struct aac_fibmap *fm;
1104 uint32_t fibphys;
1105 int i, error;
1106
292 TAILQ_INIT(&sc->aac_sim_tqh);
293 aac_get_bus_info(sc);
294 }
295
296 return(0);
297}
298
299/*

--- 799 unchanged lines hidden (view full) ---

1099static int
1100aac_alloc_commands(struct aac_softc *sc)
1101{
1102 struct aac_command *cm;
1103 struct aac_fibmap *fm;
1104 uint32_t fibphys;
1105 int i, error;
1106
1107 debug_called(1);
1107 debug_called(2);
1108
1108
1109 if (sc->total_fibs + AAC_FIB_COUNT > AAC_MAX_FIBS)
1109 if (sc->total_fibs + AAC_FIB_COUNT > sc->aac_max_fibs)
1110 return (ENOMEM);
1111
1112 fm = malloc(sizeof(struct aac_fibmap), M_AACBUF, M_NOWAIT|M_ZERO);
1110 return (ENOMEM);
1111
1112 fm = malloc(sizeof(struct aac_fibmap), M_AACBUF, M_NOWAIT|M_ZERO);
1113 if (fm == NULL)
1114 return (ENOMEM);
1113
1114 /* allocate the FIBs in DMAable memory and load them */
1115 if (bus_dmamem_alloc(sc->aac_fib_dmat, (void **)&fm->aac_fibs,
1116 BUS_DMA_NOWAIT, &fm->aac_fibmap)) {
1117 device_printf(sc->aac_dev,
1118 "Not enough contiguous memory available.\n");
1119 free(fm, M_AACBUF);
1120 return (ENOMEM);

--- 18 unchanged lines hidden (view full) ---

1139 aac_release_command(cm);
1140 else
1141 break;
1142 sc->total_fibs++;
1143 }
1144
1145 if (i > 0) {
1146 TAILQ_INSERT_TAIL(&sc->aac_fibmap_tqh, fm, fm_link);
1115
1116 /* allocate the FIBs in DMAable memory and load them */
1117 if (bus_dmamem_alloc(sc->aac_fib_dmat, (void **)&fm->aac_fibs,
1118 BUS_DMA_NOWAIT, &fm->aac_fibmap)) {
1119 device_printf(sc->aac_dev,
1120 "Not enough contiguous memory available.\n");
1121 free(fm, M_AACBUF);
1122 return (ENOMEM);

--- 18 unchanged lines hidden (view full) ---

1141 aac_release_command(cm);
1142 else
1143 break;
1144 sc->total_fibs++;
1145 }
1146
1147 if (i > 0) {
1148 TAILQ_INSERT_TAIL(&sc->aac_fibmap_tqh, fm, fm_link);
1149 debug(1, "total_fibs= %d\n", sc->total_fibs);
1147 return (0);
1148 }
1149
1150 bus_dmamap_unload(sc->aac_fib_dmat, fm->aac_fibmap);
1151 bus_dmamem_free(sc->aac_fib_dmat, fm->aac_fibs, fm->aac_fibmap);
1152 free(fm, M_AACBUF);
1153 return (ENOMEM);
1154}

--- 132 unchanged lines hidden (view full) ---

1287
1288 debug_called(1);
1289
1290 sc = (struct aac_softc *)arg;
1291
1292 sc->aac_common_busaddr = segs[0].ds_addr;
1293}
1294
1150 return (0);
1151 }
1152
1153 bus_dmamap_unload(sc->aac_fib_dmat, fm->aac_fibmap);
1154 bus_dmamem_free(sc->aac_fib_dmat, fm->aac_fibs, fm->aac_fibmap);
1155 free(fm, M_AACBUF);
1156 return (ENOMEM);
1157}

--- 132 unchanged lines hidden (view full) ---

1290
1291 debug_called(1);
1292
1293 sc = (struct aac_softc *)arg;
1294
1295 sc->aac_common_busaddr = segs[0].ds_addr;
1296}
1297
1295/*
1296 * Retrieve the firmware version numbers. Dell PERC2/QC cards with
1297 * firmware version 1.x are not compatible with this driver.
1298 */
1299static int
1300aac_check_firmware(struct aac_softc *sc)
1301{
1298static int
1299aac_check_firmware(struct aac_softc *sc)
1300{
1302 u_int32_t major, minor;
1301 u_int32_t major, minor, options;
1303
1304 debug_called(1);
1305
1302
1303 debug_called(1);
1304
1306 if (sc->quirks & AAC_QUIRK_PERC2QC) {
1305 /*
1306 * Retrieve the firmware version numbers. Dell PERC2/QC cards with
1307 * firmware version 1.x are not compatible with this driver.
1308 */
1309 if (sc->flags & AAC_FLAGS_PERC2QC) {
1307 if (aac_sync_command(sc, AAC_MONKER_GETKERNVER, 0, 0, 0, 0,
1308 NULL)) {
1309 device_printf(sc->aac_dev,
1310 "Error reading firmware version\n");
1311 return (EIO);
1312 }
1313
1314 /* These numbers are stored as ASCII! */
1310 if (aac_sync_command(sc, AAC_MONKER_GETKERNVER, 0, 0, 0, 0,
1311 NULL)) {
1312 device_printf(sc->aac_dev,
1313 "Error reading firmware version\n");
1314 return (EIO);
1315 }
1316
1317 /* These numbers are stored as ASCII! */
1315 major = (AAC_GETREG4(sc, AAC_SA_MAILBOX + 4) & 0xff) - 0x30;
1316 minor = (AAC_GETREG4(sc, AAC_SA_MAILBOX + 8) & 0xff) - 0x30;
1318 major = (AAC_GET_MAILBOX(sc, 1) & 0xff) - 0x30;
1319 minor = (AAC_GET_MAILBOX(sc, 2) & 0xff) - 0x30;
1317 if (major == 1) {
1318 device_printf(sc->aac_dev,
1319 "Firmware version %d.%d is not supported.\n",
1320 major, minor);
1321 return (EINVAL);
1322 }
1323 }
1324
1320 if (major == 1) {
1321 device_printf(sc->aac_dev,
1322 "Firmware version %d.%d is not supported.\n",
1323 major, minor);
1324 return (EINVAL);
1325 }
1326 }
1327
1328 /*
1329 * Retrieve the capabilities/supported options word so we know what
1330 * work-arounds to enable.
1331 */
1332 if (aac_sync_command(sc, AAC_MONKER_GETINFO, 0, 0, 0, 0, NULL)) {
1333 device_printf(sc->aac_dev, "RequestAdapterInfo failed\n");
1334 return (EIO);
1335 }
1336 options = AAC_GET_MAILBOX(sc, 1);
1337 sc->supported_options = options;
1338
1339 if ((options & AAC_SUPPORTED_4GB_WINDOW) != 0 &&
1340 (sc->flags & AAC_FLAGS_NO4GB) == 0)
1341 sc->flags |= AAC_FLAGS_4GB_WINDOW;
1342 if (options & AAC_SUPPORTED_NONDASD)
1343 sc->flags |= AAC_FLAGS_ENABLE_CAM;
1344#if 0
1345 if (options & AAC_SUPPORTED_SGMAP_HOST64 && sizeof(bus_addr_t) > 4) {
1346 device_printf(sc->aac_dev, "Enabling 64-bit address support\n");
1347 sc->flags |= AAC_FLAGS_SG_64BIT;
1348 }
1349#endif
1350
1351 /* Check for broken hardware that does a lower number of commands */
1352 if ((sc->flags & AAC_FLAGS_256FIBS) == 0)
1353 sc->aac_max_fibs = AAC_MAX_FIBS;
1354 else
1355 sc->aac_max_fibs = 256;
1356
1325 return (0);
1326}
1327
1328static int
1329aac_init(struct aac_softc *sc)
1330{
1331 struct aac_adapter_init *ip;
1332 time_t then;
1333 u_int32_t code;
1334 u_int8_t *qaddr;
1357 return (0);
1358}
1359
1360static int
1361aac_init(struct aac_softc *sc)
1362{
1363 struct aac_adapter_init *ip;
1364 time_t then;
1365 u_int32_t code;
1366 u_int8_t *qaddr;
1367 int error;
1335
1336 debug_called(1);
1337
1338 /*
1339 * First wait for the adapter to come ready.
1340 */
1341 then = time_second;
1342 do {

--- 10 unchanged lines hidden (view full) ---

1353 if (time_second > (then + AAC_BOOT_TIMEOUT)) {
1354 device_printf(sc->aac_dev,
1355 "FATAL: controller not coming ready, "
1356 "status %x\n", code);
1357 return(ENXIO);
1358 }
1359 } while (!(code & AAC_UP_AND_RUNNING));
1360
1368
1369 debug_called(1);
1370
1371 /*
1372 * First wait for the adapter to come ready.
1373 */
1374 then = time_second;
1375 do {

--- 10 unchanged lines hidden (view full) ---

1386 if (time_second > (then + AAC_BOOT_TIMEOUT)) {
1387 device_printf(sc->aac_dev,
1388 "FATAL: controller not coming ready, "
1389 "status %x\n", code);
1390 return(ENXIO);
1391 }
1392 } while (!(code & AAC_UP_AND_RUNNING));
1393
1394 error = ENOMEM;
1361 /*
1395 /*
1396 * Create DMA tag for mapping buffers into controller-addressable space.
1397 */
1398 if (bus_dma_tag_create(sc->aac_parent_dmat, /* parent */
1399 1, 0, /* algnmnt, boundary */
1400 (sc->flags & AAC_FLAGS_SG_64BIT) ?
1401 BUS_SPACE_MAXADDR :
1402 BUS_SPACE_MAXADDR_32BIT, /* lowaddr */
1403 BUS_SPACE_MAXADDR, /* highaddr */
1404 NULL, NULL, /* filter, filterarg */
1405 MAXBSIZE, /* maxsize */
1406 AAC_MAXSGENTRIES, /* nsegments */
1407 MAXBSIZE, /* maxsegsize */
1408 BUS_DMA_ALLOCNOW, /* flags */
1409 &sc->aac_buffer_dmat)) {
1410 device_printf(sc->aac_dev, "can't allocate buffer DMA tag\n");
1411 goto out;
1412 }
1413
1414 /*
1415 * Create DMA tag for mapping FIBs into controller-addressable space..
1416 */
1417 if (bus_dma_tag_create(sc->aac_parent_dmat, /* parent */
1418 1, 0, /* algnmnt, boundary */
1419 (sc->flags & AAC_FLAGS_4GB_WINDOW) ?
1420 BUS_SPACE_MAXADDR_32BIT :
1421 0x7fffffff, /* lowaddr */
1422 BUS_SPACE_MAXADDR, /* highaddr */
1423 NULL, NULL, /* filter, filterarg */
1424 AAC_FIB_COUNT *
1425 sizeof(struct aac_fib), /* maxsize */
1426 1, /* nsegments */
1427 AAC_FIB_COUNT *
1428 sizeof(struct aac_fib), /* maxsegsize */
1429 BUS_DMA_ALLOCNOW, /* flags */
1430 &sc->aac_fib_dmat)) {
1431 device_printf(sc->aac_dev, "can't allocate FIB DMA tag\n");;
1432 goto out;
1433 }
1434
1435 /*
1362 * Create DMA tag for the common structure and allocate it.
1363 */
1364 if (bus_dma_tag_create(sc->aac_parent_dmat, /* parent */
1365 1, 0, /* algnmnt, boundary */
1436 * Create DMA tag for the common structure and allocate it.
1437 */
1438 if (bus_dma_tag_create(sc->aac_parent_dmat, /* parent */
1439 1, 0, /* algnmnt, boundary */
1366 BUS_SPACE_MAXADDR_32BIT, /* lowaddr */
1440 (sc->flags & AAC_FLAGS_4GB_WINDOW) ?
1441 BUS_SPACE_MAXADDR_32BIT :
1442 0x7fffffff, /* lowaddr */
1367 BUS_SPACE_MAXADDR, /* highaddr */
1368 NULL, NULL, /* filter, filterarg */
1369 8192 + sizeof(struct aac_common), /* maxsize */
1370 1, /* nsegments */
1371 BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */
1443 BUS_SPACE_MAXADDR, /* highaddr */
1444 NULL, NULL, /* filter, filterarg */
1445 8192 + sizeof(struct aac_common), /* maxsize */
1446 1, /* nsegments */
1447 BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */
1372 0, /* flags */
1448 BUS_DMA_ALLOCNOW, /* flags */
1373 &sc->aac_common_dmat)) {
1374 device_printf(sc->aac_dev,
1375 "can't allocate common structure DMA tag\n");
1449 &sc->aac_common_dmat)) {
1450 device_printf(sc->aac_dev,
1451 "can't allocate common structure DMA tag\n");
1376 return(ENOMEM);
1452 goto out;
1377 }
1378 if (bus_dmamem_alloc(sc->aac_common_dmat, (void **)&sc->aac_common,
1379 BUS_DMA_NOWAIT, &sc->aac_common_dmamap)) {
1380 device_printf(sc->aac_dev, "can't allocate common structure\n");
1453 }
1454 if (bus_dmamem_alloc(sc->aac_common_dmat, (void **)&sc->aac_common,
1455 BUS_DMA_NOWAIT, &sc->aac_common_dmamap)) {
1456 device_printf(sc->aac_dev, "can't allocate common structure\n");
1381 return(ENOMEM);
1457 goto out;
1382 }
1383
1384 /*
1385 * Work around a bug in the 2120 and 2200 that cannot DMA commands
1386 * below address 8192 in physical memory.
1387 * XXX If the padding is not needed, can it be put to use instead
1388 * of ignored?
1389 */

--- 11 unchanged lines hidden (view full) ---

1401 TAILQ_INIT(&sc->aac_fibmap_tqh);
1402 sc->aac_commands = malloc(AAC_MAX_FIBS * sizeof(struct aac_command),
1403 M_AACBUF, M_WAITOK|M_ZERO);
1404 while (sc->total_fibs < AAC_PREALLOCATE_FIBS) {
1405 if (aac_alloc_commands(sc) != 0)
1406 break;
1407 }
1408 if (sc->total_fibs == 0)
1458 }
1459
1460 /*
1461 * Work around a bug in the 2120 and 2200 that cannot DMA commands
1462 * below address 8192 in physical memory.
1463 * XXX If the padding is not needed, can it be put to use instead
1464 * of ignored?
1465 */

--- 11 unchanged lines hidden (view full) ---

1477 TAILQ_INIT(&sc->aac_fibmap_tqh);
1478 sc->aac_commands = malloc(AAC_MAX_FIBS * sizeof(struct aac_command),
1479 M_AACBUF, M_WAITOK|M_ZERO);
1480 while (sc->total_fibs < AAC_PREALLOCATE_FIBS) {
1481 if (aac_alloc_commands(sc) != 0)
1482 break;
1483 }
1484 if (sc->total_fibs == 0)
1409 return (ENOMEM);
1485 goto out;
1410
1411 /*
1412 * Fill in the init structure. This tells the adapter about the
1413 * physical location of various important shared data structures.
1414 */
1415 ip = &sc->aac_common->ac_init;
1416 ip->InitStructRevision = AAC_INIT_STRUCT_REVISION;
1417 ip->MiniPortRevision = AAC_INIT_STRUCT_MINIPORT_REVISION;

--- 97 unchanged lines hidden (view full) ---

1515 * Give the init structure to the controller.
1516 */
1517 if (aac_sync_command(sc, AAC_MONKER_INITSTRUCT,
1518 sc->aac_common_busaddr +
1519 offsetof(struct aac_common, ac_init), 0, 0, 0,
1520 NULL)) {
1521 device_printf(sc->aac_dev,
1522 "error establishing init structure\n");
1486
1487 /*
1488 * Fill in the init structure. This tells the adapter about the
1489 * physical location of various important shared data structures.
1490 */
1491 ip = &sc->aac_common->ac_init;
1492 ip->InitStructRevision = AAC_INIT_STRUCT_REVISION;
1493 ip->MiniPortRevision = AAC_INIT_STRUCT_MINIPORT_REVISION;

--- 97 unchanged lines hidden (view full) ---

1591 * Give the init structure to the controller.
1592 */
1593 if (aac_sync_command(sc, AAC_MONKER_INITSTRUCT,
1594 sc->aac_common_busaddr +
1595 offsetof(struct aac_common, ac_init), 0, 0, 0,
1596 NULL)) {
1597 device_printf(sc->aac_dev,
1598 "error establishing init structure\n");
1523 return(EIO);
1599 error = EIO;
1600 goto out;
1524 }
1525
1601 }
1602
1526 return(0);
1603 error = 0;
1604out:
1605 return(error);
1527}
1528
1529/*
1530 * Send a synchronous command to the controller and wait for a result.
1531 */
1532static int
1533aac_sync_command(struct aac_softc *sc, u_int32_t command,
1534 u_int32_t arg0, u_int32_t arg1, u_int32_t arg2, u_int32_t arg3,

--- 12 unchanged lines hidden (view full) ---

1547
1548 /* then set it to signal the adapter */
1549 AAC_QNOTIFY(sc, AAC_DB_SYNC_COMMAND);
1550
1551 /* spin waiting for the command to complete */
1552 then = time_second;
1553 do {
1554 if (time_second > (then + AAC_IMMEDIATE_TIMEOUT)) {
1606}
1607
1608/*
1609 * Send a synchronous command to the controller and wait for a result.
1610 */
1611static int
1612aac_sync_command(struct aac_softc *sc, u_int32_t command,
1613 u_int32_t arg0, u_int32_t arg1, u_int32_t arg2, u_int32_t arg3,

--- 12 unchanged lines hidden (view full) ---

1626
1627 /* then set it to signal the adapter */
1628 AAC_QNOTIFY(sc, AAC_DB_SYNC_COMMAND);
1629
1630 /* spin waiting for the command to complete */
1631 then = time_second;
1632 do {
1633 if (time_second > (then + AAC_IMMEDIATE_TIMEOUT)) {
1555 debug(2, "timed out");
1634 debug(1, "timed out");
1556 return(EIO);
1557 }
1558 } while (!(AAC_GET_ISTATUS(sc) & AAC_DB_SYNC_COMMAND));
1559
1560 /* clear the completion flag */
1561 AAC_CLEAR_ISTATUS(sc, AAC_DB_SYNC_COMMAND);
1562
1563 /* get the command status */
1635 return(EIO);
1636 }
1637 } while (!(AAC_GET_ISTATUS(sc) & AAC_DB_SYNC_COMMAND));
1638
1639 /* clear the completion flag */
1640 AAC_CLEAR_ISTATUS(sc, AAC_DB_SYNC_COMMAND);
1641
1642 /* get the command status */
1564 status = AAC_GET_MAILBOXSTATUS(sc);
1643 status = AAC_GET_MAILBOX(sc, 0);
1565 if (sp != NULL)
1566 *sp = status;
1567 return(0);
1568}
1569
1570/*
1571 * Grab the sync fib area.
1572 */

--- 445 unchanged lines hidden (view full) ---

2018 AAC_SETREG4(sc, AAC_FA_MAILBOX + 16, arg3);
2019 AAC_FA_HACK(sc);
2020}
2021
2022/*
2023 * Fetch the immediate command status word
2024 */
2025static int
1644 if (sp != NULL)
1645 *sp = status;
1646 return(0);
1647}
1648
1649/*
1650 * Grab the sync fib area.
1651 */

--- 445 unchanged lines hidden (view full) ---

2097 AAC_SETREG4(sc, AAC_FA_MAILBOX + 16, arg3);
2098 AAC_FA_HACK(sc);
2099}
2100
2101/*
2102 * Fetch the immediate command status word
2103 */
2104static int
2026aac_sa_get_mailboxstatus(struct aac_softc *sc)
2105aac_sa_get_mailbox(struct aac_softc *sc, int mb)
2027{
2028 debug_called(4);
2029
2106{
2107 debug_called(4);
2108
2030 return(AAC_GETREG4(sc, AAC_SA_MAILBOX));
2109 return(AAC_GETREG4(sc, AAC_SA_MAILBOX + (mb * 4)));
2031}
2032
2033static int
2110}
2111
2112static int
2034aac_rx_get_mailboxstatus(struct aac_softc *sc)
2113aac_rx_get_mailbox(struct aac_softc *sc, int mb)
2035{
2036 debug_called(4);
2037
2114{
2115 debug_called(4);
2116
2038 return(AAC_GETREG4(sc, AAC_RX_MAILBOX));
2117 return(AAC_GETREG4(sc, AAC_RX_MAILBOX + (mb * 4)));
2039}
2040
2041static int
2118}
2119
2120static int
2042aac_fa_get_mailboxstatus(struct aac_softc *sc)
2121aac_fa_get_mailbox(struct aac_softc *sc, int mb)
2043{
2044 int val;
2045
2046 debug_called(4);
2047
2122{
2123 int val;
2124
2125 debug_called(4);
2126
2048 val = AAC_GETREG4(sc, AAC_FA_MAILBOX);
2127 val = AAC_GETREG4(sc, AAC_FA_MAILBOX + (mb * 4));
2049 return (val);
2050}
2051
2052/*
2053 * Set/clear interrupt masks
2054 */
2055static void
2056aac_sa_set_interrupts(struct aac_softc *sc, int enable)

--- 51 unchanged lines hidden (view full) ---

2108 aac_alloc_sync_fib(sc, &fib, 0);
2109
2110 fib->data[0] = 0;
2111 if (aac_sync_fib(sc, RequestAdapterInfo, 0, fib, 1)) {
2112 device_printf(sc->aac_dev, "RequestAdapterInfo failed\n");
2113 aac_release_sync_fib(sc);
2114 return;
2115 }
2128 return (val);
2129}
2130
2131/*
2132 * Set/clear interrupt masks
2133 */
2134static void
2135aac_sa_set_interrupts(struct aac_softc *sc, int enable)

--- 51 unchanged lines hidden (view full) ---

2187 aac_alloc_sync_fib(sc, &fib, 0);
2188
2189 fib->data[0] = 0;
2190 if (aac_sync_fib(sc, RequestAdapterInfo, 0, fib, 1)) {
2191 device_printf(sc->aac_dev, "RequestAdapterInfo failed\n");
2192 aac_release_sync_fib(sc);
2193 return;
2194 }
2116 info = (struct aac_adapter_info *)&fib->data[0];
2195 info = (struct aac_adapter_info *)&fib->data[0];
2117
2118 device_printf(sc->aac_dev, "%s %dMHz, %dMB cache memory, %s\n",
2119 aac_describe_code(aac_cpu_variant, info->CpuVariant),
2120 info->ClockSpeed, info->BufferMem / (1024 * 1024),
2121 aac_describe_code(aac_battery_platform,
2122 info->batteryPlatform));
2123
2124 /* save the kernel revision structure for later use */
2125 sc->aac_revision = info->KernelRevision;
2126 device_printf(sc->aac_dev, "Kernel %d.%d-%d, Build %d, S/N %6X\n",
2127 info->KernelRevision.external.comp.major,
2128 info->KernelRevision.external.comp.minor,
2129 info->KernelRevision.external.comp.dash,
2130 info->KernelRevision.buildNumber,
2131 (u_int32_t)(info->SerialNumber & 0xffffff));
2132
2133 aac_release_sync_fib(sc);
2196
2197 device_printf(sc->aac_dev, "%s %dMHz, %dMB cache memory, %s\n",
2198 aac_describe_code(aac_cpu_variant, info->CpuVariant),
2199 info->ClockSpeed, info->BufferMem / (1024 * 1024),
2200 aac_describe_code(aac_battery_platform,
2201 info->batteryPlatform));
2202
2203 /* save the kernel revision structure for later use */
2204 sc->aac_revision = info->KernelRevision;
2205 device_printf(sc->aac_dev, "Kernel %d.%d-%d, Build %d, S/N %6X\n",
2206 info->KernelRevision.external.comp.major,
2207 info->KernelRevision.external.comp.minor,
2208 info->KernelRevision.external.comp.dash,
2209 info->KernelRevision.buildNumber,
2210 (u_int32_t)(info->SerialNumber & 0xffffff));
2211
2212 aac_release_sync_fib(sc);
2213
2214 if (1 || bootverbose) {
2215 device_printf(sc->aac_dev, "Supported Options=%b\n",
2216 sc->supported_options,
2217 "\20"
2218 "\1SNAPSHOT"
2219 "\2CLUSTERS"
2220 "\3WCACHE"
2221 "\4DATA64"
2222 "\5HOSTTIME"
2223 "\6RAID50"
2224 "\7WINDOW4GB"
2225 "\10SCSIUPGD"
2226 "\11SOFTERR"
2227 "\12NORECOND"
2228 "\13SGMAP64"
2229 "\14ALARM"
2230 "\15NONDASD");
2231 }
2134}
2135
2136/*
2137 * Look up a text description of a numeric error code and return a pointer to
2138 * same.
2139 */
2140static char *
2141aac_describe_code(struct aac_code_lookup *table, u_int32_t code)

--- 651 unchanged lines hidden ---
2232}
2233
2234/*
2235 * Look up a text description of a numeric error code and return a pointer to
2236 * same.
2237 */
2238static char *
2239aac_describe_code(struct aac_code_lookup *table, u_int32_t code)

--- 651 unchanged lines hidden ---