2 * Copyright (c) 2000 Michael Smith
3 * Copyright (c) 2001 Scott Long
4 * Copyright (c) 2000 BSDi
5 * Copyright (c) 2001-2010 Adaptec, Inc.
6 * Copyright (c) 2010-2012 PMC-Sierra, Inc.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #if __FreeBSD_version >= 800000
35 #include <sys/callout.h>
38 #include <sys/mutex.h>
39 #include <sys/taskqueue.h>
40 #include <sys/selinfo.h>
41 #include <geom/geom_disk.h>
43 #define AAC_TYPE_DEVO 1
44 #define AAC_TYPE_ALPHA 2
45 #define AAC_TYPE_BETA 3
46 #define AAC_TYPE_RELEASE 4
48 #define AAC_DRIVER_MAJOR_VERSION 3
49 #define AAC_DRIVER_MINOR_VERSION 1
50 #define AAC_DRIVER_BUGFIX_LEVEL 1
51 #define AAC_DRIVER_TYPE AAC_TYPE_RELEASE
53 #ifndef AAC_DRIVER_BUILD
54 # define AAC_DRIVER_BUILD 1
57 #if __FreeBSD_version <= 601000
58 #define bus_get_dma_tag(x) NULL
61 /* **************************** NewBUS interrupt Crock ************************/
62 #if __FreeBSD_version < 700031
63 #define aac_bus_setup_intr(d, i, f, U, if, ifa, hp) \
64 bus_setup_intr(d, i, f, if, ifa, hp)
66 #define aac_bus_setup_intr bus_setup_intr
69 /* **************************** NewBUS CAM Support ****************************/
70 #if __FreeBSD_version < 700049
71 #define aac_xpt_bus_register(sim, parent, bus) \
72 xpt_bus_register(sim, bus)
74 #define aac_xpt_bus_register xpt_bus_register
77 /**************************** Kernel Thread Support ***************************/
78 #if __FreeBSD_version > 800001
79 #define aac_kthread_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg) \
80 kproc_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg)
81 #define aac_kthread_exit(status) \
84 #define aac_kthread_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg) \
85 kthread_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg)
86 #define aac_kthread_exit(status) \
91 * Driver Parameter Definitions
95 * We allocate a small set of FIBs for the adapter to use to send us messages.
97 #define AAC_ADAPTER_FIBS 8
100 * The controller reports status events in AIFs. We hang on to a number of
101 * these in order to pass them out to user-space management tools.
103 #define AAC_AIFQ_LENGTH 64
106 * Firmware messages are passed in the printf buffer.
108 #define AAC_PRINTF_BUFSIZE 256
111 * We wait this many seconds for the adapter to come ready if it is still
114 #define AAC_BOOT_TIMEOUT (3 * 60)
117 * Timeout for immediate commands.
119 #define AAC_IMMEDIATE_TIMEOUT 30 /* seconds */
122 * Timeout for normal commands
124 #define AAC_CMD_TIMEOUT 120 /* seconds */
127 * Rate at which we periodically check for timed out commands and kick the
130 #define AAC_PERIODIC_INTERVAL 20 /* seconds */
132 #define PASSTHROUGH_BUS 0
133 #define CONTAINER_BUS 1
135 * Per-container data structure
139 struct aac_mntobj co_mntobj;
142 TAILQ_ENTRY(aac_container) co_link;
146 * Per-SIM data structure
156 struct aac_softc *aac_sc;
157 struct aac_cam *aac_cam;
158 TAILQ_ENTRY(aac_sim) sim_link;
167 struct aac_softc *ad_controller;
168 struct aac_container *ad_container;
169 struct disk *ad_disk;
171 #define AAC_DISK_OPEN (1<<0)
180 * Per-command control structure.
184 TAILQ_ENTRY(aac_command) cm_link; /* list linkage */
186 struct aac_softc *cm_sc; /* controller that owns us */
188 struct aac_fib *cm_fib; /* FIB associated with this
190 u_int64_t cm_fibphys; /* bus address of the FIB */
191 struct bio *cm_data; /* pointer to data in kernel
193 u_int32_t cm_datalen; /* data length */
194 bus_dmamap_t cm_datamap; /* DMA map for bio data */
195 struct aac_sg_table *cm_sgtable; /* pointer to s/g table in
198 #define AAC_CMD_MAPPED (1<<0) /* command has had its data
200 #define AAC_CMD_DATAIN (1<<1) /* command involves data moving
201 * from controller to host */
202 #define AAC_CMD_DATAOUT (1<<2) /* command involves data moving
203 * from host to controller */
204 #define AAC_CMD_COMPLETED (1<<3) /* command has been completed */
205 #define AAC_CMD_TIMEDOUT (1<<4) /* command taken too long */
206 #define AAC_ON_AACQ_FREE (1<<5)
207 #define AAC_ON_AACQ_READY (1<<6)
208 #define AAC_ON_AACQ_BUSY (1<<7)
209 #define AAC_ON_AACQ_AIF (1<<8)
210 #define AAC_ON_AACQ_NORM (1<<10)
211 #define AAC_ON_AACQ_MASK ((1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<10))
212 #define AAC_CMD_RESET (1<<9)
213 #define AAC_CMD_FASTRESP (1<<11)
214 #define AAC_CMD_WAIT (1<<12)
216 void (* cm_complete)(struct aac_command *cm);
218 time_t cm_timestamp; /* command creation time */
220 bus_dma_tag_t cm_passthr_dmat; /* passthrough buffer/command
225 TAILQ_ENTRY(aac_fibmap) fm_link; /* list linkage */
226 struct aac_fib *aac_fibs;
227 bus_dmamap_t aac_fibmap;
228 struct aac_command *aac_commands;
232 * We gather a number of adapter-visible items into a single structure.
234 * The ordering of this strucure may be important; we copy the Linux driver:
238 * Queue headers (Comm Area)
241 * In addition, we add:
245 /* fibs for the controller to send us messages */
246 struct aac_fib ac_fibs[AAC_ADAPTER_FIBS];
248 /* the init structure */
249 struct aac_adapter_init ac_init;
251 /* buffer for text messages from the controller */
252 char ac_printf[AAC_PRINTF_BUFSIZE];
254 /* fib for synchronous commands */
255 struct aac_fib ac_sync_fib;
257 /* response buffer for SRC (new comm. type1) - must be last element */
258 u_int32_t ac_host_rrq[0];
262 * Interface operations
266 int (*aif_get_fwstatus)(struct aac_softc *sc);
267 void (*aif_qnotify)(struct aac_softc *sc, int qbit);
268 int (*aif_get_istatus)(struct aac_softc *sc);
269 void (*aif_clr_istatus)(struct aac_softc *sc, int mask);
270 void (*aif_set_mailbox)(struct aac_softc *sc, u_int32_t command,
271 u_int32_t arg0, u_int32_t arg1,
272 u_int32_t arg2, u_int32_t arg3);
273 int (*aif_get_mailbox)(struct aac_softc *sc, int mb);
274 void (*aif_set_interrupts)(struct aac_softc *sc, int enable);
275 int (*aif_send_command)(struct aac_softc *sc, struct aac_command *cm);
276 int (*aif_get_outb_queue)(struct aac_softc *sc);
277 void (*aif_set_outb_queue)(struct aac_softc *sc, int index);
279 extern struct aac_interface aacraid_src_interface;
280 extern struct aac_interface aacraid_srcv_interface;
282 #define AAC_GET_FWSTATUS(sc) ((sc)->aac_if.aif_get_fwstatus((sc)))
283 #define AAC_QNOTIFY(sc, qbit) ((sc)->aac_if.aif_qnotify((sc), (qbit)))
284 #define AAC_GET_ISTATUS(sc) ((sc)->aac_if.aif_get_istatus((sc)))
285 #define AAC_CLEAR_ISTATUS(sc, mask) ((sc)->aac_if.aif_clr_istatus((sc), \
287 #define AAC_SET_MAILBOX(sc, command, arg0, arg1, arg2, arg3) \
288 ((sc)->aac_if.aif_set_mailbox((sc), (command), (arg0), (arg1), (arg2), \
290 #define AAC_GET_MAILBOX(sc, mb) ((sc)->aac_if.aif_get_mailbox((sc), \
292 #define AAC_MASK_INTERRUPTS(sc) ((sc)->aac_if.aif_set_interrupts((sc), \
294 #define AAC_UNMASK_INTERRUPTS(sc) ((sc)->aac_if.aif_set_interrupts((sc), \
296 #define AAC_SEND_COMMAND(sc, cm) ((sc)->aac_if.aif_send_command((sc), (cm)))
297 #define AAC_GET_OUTB_QUEUE(sc) ((sc)->aac_if.aif_get_outb_queue((sc)))
298 #define AAC_SET_OUTB_QUEUE(sc, idx) ((sc)->aac_if.aif_set_outb_queue((sc), (idx)))
300 #define AAC_MEM0_SETREG4(sc, reg, val) bus_space_write_4(sc->aac_btag0, \
301 sc->aac_bhandle0, reg, val)
302 #define AAC_MEM0_GETREG4(sc, reg) bus_space_read_4(sc->aac_btag0, \
303 sc->aac_bhandle0, reg)
304 #define AAC_MEM0_SETREG2(sc, reg, val) bus_space_write_2(sc->aac_btag0, \
305 sc->aac_bhandle0, reg, val)
306 #define AAC_MEM0_GETREG2(sc, reg) bus_space_read_2(sc->aac_btag0, \
307 sc->aac_bhandle0, reg)
308 #define AAC_MEM0_SETREG1(sc, reg, val) bus_space_write_1(sc->aac_btag0, \
309 sc->aac_bhandle0, reg, val)
310 #define AAC_MEM0_GETREG1(sc, reg) bus_space_read_1(sc->aac_btag0, \
311 sc->aac_bhandle0, reg)
313 #define AAC_MEM1_SETREG4(sc, reg, val) bus_space_write_4(sc->aac_btag1, \
314 sc->aac_bhandle1, reg, val)
315 #define AAC_MEM1_GETREG4(sc, reg) bus_space_read_4(sc->aac_btag1, \
316 sc->aac_bhandle1, reg)
317 #define AAC_MEM1_SETREG2(sc, reg, val) bus_space_write_2(sc->aac_btag1, \
318 sc->aac_bhandle1, reg, val)
319 #define AAC_MEM1_GETREG2(sc, reg) bus_space_read_2(sc->aac_btag1, \
320 sc->aac_bhandle1, reg)
321 #define AAC_MEM1_SETREG1(sc, reg, val) bus_space_write_1(sc->aac_btag1, \
322 sc->aac_bhandle1, reg, val)
323 #define AAC_MEM1_GETREG1(sc, reg) bus_space_read_1(sc->aac_btag1, \
324 sc->aac_bhandle1, reg)
326 /* fib context (IOCTL) */
327 struct aac_fib_context {
331 struct aac_fib_context *next, *prev;
335 * Per-controller structure.
339 /* bus connections */
341 struct resource *aac_regs_res0, *aac_regs_res1; /* reg. if. window */
342 int aac_regs_rid0, aac_regs_rid1; /* resource ID */
343 bus_space_handle_t aac_bhandle0, aac_bhandle1; /* bus space handle */
344 bus_space_tag_t aac_btag0, aac_btag1; /* bus space tag */
345 bus_dma_tag_t aac_parent_dmat; /* parent DMA tag */
346 bus_dma_tag_t aac_buffer_dmat; /* data buffer/command
348 struct resource *aac_irq; /* interrupt */
350 void *aac_intr; /* interrupt handle */
352 #if __FreeBSD_version >= 800000
353 struct callout aac_daemontime; /* clock daemon callout */
355 struct callout_handle timeout_id; /* timeout handle */
358 /* controller features, limits and status */
360 #define AAC_STATE_SUSPEND (1<<0)
361 #define AAC_STATE_UNUSED0 (1<<1)
362 #define AAC_STATE_INTERRUPTS_ON (1<<2)
363 #define AAC_STATE_AIF_SLEEPER (1<<3)
364 #define AAC_STATE_RESET (1<<4)
365 struct FsaRevision aac_revision;
367 /* controller hardware interface */
369 #define AAC_HWIF_SRC 5
370 #define AAC_HWIF_SRCV 6
371 #define AAC_HWIF_UNKNOWN -1
372 bus_dma_tag_t aac_common_dmat; /* common structure
374 bus_dmamap_t aac_common_dmamap; /* common structure
376 struct aac_common *aac_common;
377 u_int32_t aac_common_busaddr;
378 u_int32_t aac_host_rrq_idx;
379 struct aac_interface aac_if;
381 /* command/fib resources */
382 bus_dma_tag_t aac_fib_dmat; /* DMA tag for allocing FIBs */
383 TAILQ_HEAD(,aac_fibmap) aac_fibmap_tqh;
385 struct aac_command *aac_commands;
387 /* command management */
388 TAILQ_HEAD(,aac_command) aac_free; /* command structures
389 * available for reuse */
390 TAILQ_HEAD(,aac_command) aac_ready; /* commands on hold for
391 * controller resources */
392 TAILQ_HEAD(,aac_command) aac_busy;
393 TAILQ_HEAD(,aac_event) aac_ev_cmfree;
394 struct bio_queue_head aac_bioq;
396 struct aac_qstat aac_qstat[AACQ_COUNT]; /* queue statistics */
398 /* connected containters */
399 TAILQ_HEAD(,aac_container) aac_container_tqh;
400 struct mtx aac_container_lock;
403 * The general I/O lock. This protects the sync fib, the lists, the
404 * queues, and the registers.
406 struct mtx aac_io_lock;
408 struct intr_config_hook aac_ich;
410 /* sync. transfer mode */
411 struct aac_command *aac_sync_cm;
413 /* management interface */
414 struct cdev *aac_dev_t;
415 struct mtx aac_aifq_lock;
416 struct aac_fib aac_aifq[AAC_AIFQ_LENGTH];
420 struct aac_fib_context *fibctx;
421 struct selinfo rcv_select;
422 struct proc *aifthread;
424 #define AAC_AIFFLAGS_RUNNING (1 << 0)
425 #define AAC_AIFFLAGS_AIF (1 << 1)
426 #define AAC_AIFFLAGS_EXIT (1 << 2)
427 #define AAC_AIFFLAGS_EXITED (1 << 3)
428 #define AAC_AIFFLAGS_PRINTF (1 << 4)
429 #define AAC_AIFFLAGS_ALLOCFIBS (1 << 5)
430 #define AAC_AIFFLAGS_PENDING (AAC_AIFFLAGS_AIF | AAC_AIFFLAGS_PRINTF | \
431 AAC_AIFFLAGS_ALLOCFIBS)
433 #define AAC_FLAGS_PERC2QC (1 << 0)
434 #define AAC_FLAGS_ENABLE_CAM (1 << 1) /* No SCSI passthrough */
435 #define AAC_FLAGS_CAM_NORESET (1 << 2) /* Fake SCSI resets */
436 #define AAC_FLAGS_CAM_PASSONLY (1 << 3) /* Only create pass devices */
437 #define AAC_FLAGS_SG_64BIT (1 << 4) /* Use 64-bit S/G addresses */
438 #define AAC_FLAGS_4GB_WINDOW (1 << 5) /* Device can access host mem
440 #define AAC_FLAGS_NO4GB (1 << 6) /* Can't access host mem >2GB */
441 #define AAC_FLAGS_256FIBS (1 << 7) /* Can only do 256 commands */
442 #define AAC_FLAGS_BROKEN_MEMMAP (1 << 8) /* Broken HostPhysMemPages */
443 #define AAC_FLAGS_SLAVE (1 << 9)
444 #define AAC_FLAGS_MASTER (1 << 10)
445 #define AAC_FLAGS_NEW_COMM (1 << 11) /* New comm. interface supported */
446 #define AAC_FLAGS_RAW_IO (1 << 12) /* Raw I/O interface */
447 #define AAC_FLAGS_ARRAY_64BIT (1 << 13) /* 64-bit array size */
448 #define AAC_FLAGS_LBA_64BIT (1 << 14) /* 64-bit LBA support */
449 #define AAC_QUEUE_FRZN (1 << 15) /* Freeze the processing of
450 * commands on the queue. */
451 #define AAC_FLAGS_NEW_COMM_TYPE1 (1 << 16) /* New comm. type1 supported */
452 #define AAC_FLAGS_NEW_COMM_TYPE2 (1 << 17) /* New comm. type2 supported */
453 #define AAC_FLAGS_NEW_COMM_TYPE34 (1 << 18) /* New comm. type3/4 */
454 #define AAC_FLAGS_SYNC_MODE (1 << 18) /* Sync. transfer mode */
455 u_int32_t hint_flags; /* driver parameters */
456 int sim_freezed; /* flag for sim_freeze/release */
457 u_int32_t supported_options;
458 u_int32_t scsi_method_id;
459 TAILQ_HEAD(,aac_sim) aac_sim_tqh;
461 u_int32_t aac_max_fibs; /* max. FIB count */
462 u_int32_t aac_max_fibs_alloc; /* max. alloc. per alloc_commands() */
463 u_int32_t aac_max_fib_size; /* max. FIB size */
464 u_int32_t aac_sg_tablesize; /* max. sg count from host */
465 u_int32_t aac_max_sectors; /* max. I/O size from host (blocks) */
466 u_int32_t aac_feature_bits; /* feature bits from suppl. info */
467 u_int32_t aac_support_opt2; /* supp. options from suppl. info */
468 u_int32_t aac_max_aif; /* max. AIF count */
469 #define AAC_CAM_TARGET_WILDCARD ~0
470 void (*cam_rescan_cb)(struct aac_softc *, uint32_t,
472 u_int32_t DebugFlags; /* Debug print flags bitmap */
473 u_int32_t DebugOffset; /* Offset from DPMEM start */
474 u_int32_t DebugHeaderSize; /* Size of debug header */
475 u_int32_t FwDebugFlags; /* FW Debug Flags */
476 u_int32_t FwDebugBufferSize; /* FW Debug Buffer size */
480 * Event callback mechanism for the driver
482 #define AAC_EVENT_NONE 0x00
483 #define AAC_EVENT_CMFREE 0x01
484 #define AAC_EVENT_MASK 0xff
485 #define AAC_EVENT_REPEAT 0x100
487 typedef void aac_event_cb_t(struct aac_softc *sc, struct aac_event *event,
490 TAILQ_ENTRY(aac_event) ev_links;
492 aac_event_cb_t *ev_callback;
499 extern void aacraid_free(struct aac_softc *sc);
500 extern int aacraid_attach(struct aac_softc *sc);
501 extern int aacraid_detach(device_t dev);
502 extern int aacraid_shutdown(device_t dev);
503 extern int aacraid_suspend(device_t dev);
504 extern int aacraid_resume(device_t dev);
505 extern void aacraid_new_intr_type1(void *arg);
506 extern void aacraid_submit_bio(struct bio *bp);
507 extern void aacraid_biodone(struct bio *bp);
508 extern void aacraid_startio(struct aac_softc *sc);
509 extern int aacraid_alloc_command(struct aac_softc *sc,
510 struct aac_command **cmp);
511 extern void aacraid_release_command(struct aac_command *cm);
512 extern void aacraid_add_event(struct aac_softc *sc, struct aac_event
514 extern void aacraid_map_command_sg(void *arg, bus_dma_segment_t *segs,
515 int nseg, int error);
516 extern int aacraid_wait_command(struct aac_command *cmp);
518 /* #define AACRAID_DEBUG */
521 # define fwprintf(sc, flags, fmt, args...) \
522 aacraid_fw_printf(sc, flags, "%s: " fmt, __func__, ##args);
524 extern void aacraid_print_queues(struct aac_softc *sc);
525 extern void aacraid_print_fib(struct aac_softc *sc, struct aac_fib *fib,
527 extern void aacraid_print_aif(struct aac_softc *sc,
528 struct aac_aif_command *aif);
530 #define AAC_PRINT_FIB(sc, fib) aacraid_print_fib(sc, fib, __func__)
533 # define fwprintf(sc, flags, fmt, args...)
535 # define aacraid_print_queues(sc)
537 # define AAC_PRINT_FIB(sc, fib)
538 # define aacraid_print_aif(sc, aac_aif_command)
541 struct aac_code_lookup {
547 * Queue primitives for driver queues.
549 #define AACQ_ADD(sc, qname) \
551 struct aac_qstat *qs; \
553 qs = &(sc)->aac_qstat[qname]; \
556 if (qs->q_length > qs->q_max) \
557 qs->q_max = qs->q_length; \
560 #define AACQ_REMOVE(sc, qname) (sc)->aac_qstat[qname].q_length--
561 #define AACQ_INIT(sc, qname) \
563 sc->aac_qstat[qname].q_length = 0; \
564 sc->aac_qstat[qname].q_max = 0; \
568 #define AACQ_COMMAND_QUEUE(name, index) \
569 static __inline void \
570 aac_initq_ ## name (struct aac_softc *sc) \
572 TAILQ_INIT(&sc->aac_ ## name); \
573 AACQ_INIT(sc, index); \
575 static __inline void \
576 aac_enqueue_ ## name (struct aac_command *cm) \
578 if ((cm->cm_flags & AAC_ON_AACQ_MASK) != 0) { \
579 printf("command %p is on another queue, flags = %#x\n", \
581 panic("command is on another queue"); \
583 TAILQ_INSERT_TAIL(&cm->cm_sc->aac_ ## name, cm, cm_link); \
584 cm->cm_flags |= AAC_ON_ ## index; \
585 AACQ_ADD(cm->cm_sc, index); \
587 static __inline void \
588 aac_requeue_ ## name (struct aac_command *cm) \
590 if ((cm->cm_flags & AAC_ON_AACQ_MASK) != 0) { \
591 printf("command %p is on another queue, flags = %#x\n", \
593 panic("command is on another queue"); \
595 TAILQ_INSERT_HEAD(&cm->cm_sc->aac_ ## name, cm, cm_link); \
596 cm->cm_flags |= AAC_ON_ ## index; \
597 AACQ_ADD(cm->cm_sc, index); \
599 static __inline struct aac_command * \
600 aac_dequeue_ ## name (struct aac_softc *sc) \
602 struct aac_command *cm; \
604 if ((cm = TAILQ_FIRST(&sc->aac_ ## name)) != NULL) { \
605 if ((cm->cm_flags & AAC_ON_ ## index) == 0) { \
606 printf("command %p not in queue, flags = %#x, " \
607 "bit = %#x\n", cm, cm->cm_flags, \
609 panic("command not in queue"); \
611 TAILQ_REMOVE(&sc->aac_ ## name, cm, cm_link); \
612 cm->cm_flags &= ~AAC_ON_ ## index; \
613 AACQ_REMOVE(sc, index); \
617 static __inline void \
618 aac_remove_ ## name (struct aac_command *cm) \
620 if ((cm->cm_flags & AAC_ON_ ## index) == 0) { \
621 printf("command %p not in queue, flags = %#x, " \
622 "bit = %#x\n", cm, cm->cm_flags, \
624 panic("command not in queue"); \
626 TAILQ_REMOVE(&cm->cm_sc->aac_ ## name, cm, cm_link); \
627 cm->cm_flags &= ~AAC_ON_ ## index; \
628 AACQ_REMOVE(cm->cm_sc, index); \
632 AACQ_COMMAND_QUEUE(free, AACQ_FREE);
633 AACQ_COMMAND_QUEUE(ready, AACQ_READY);
634 AACQ_COMMAND_QUEUE(busy, AACQ_BUSY);
637 aac_print_printf(struct aac_softc *sc)
640 * XXX We have the ability to read the length of the printf string
641 * from out of the mailboxes.
643 device_printf(sc->aac_dev, "**Monitor** %.*s", AAC_PRINTF_BUFSIZE,
644 sc->aac_common->ac_printf);
645 sc->aac_common->ac_printf[0] = 0;
646 AAC_QNOTIFY(sc, AAC_DB_PRINTF);
650 aac_alloc_sync_fib(struct aac_softc *sc, struct aac_fib **fib)
653 mtx_assert(&sc->aac_io_lock, MA_OWNED);
654 *fib = &sc->aac_common->ac_sync_fib;
659 aac_release_sync_fib(struct aac_softc *sc)
662 mtx_assert(&sc->aac_io_lock, MA_OWNED);