The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/ic/aacvar.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $OpenBSD: aacvar.h,v 1.16 2022/01/09 05:42:37 jsg Exp $ */
    2 
    3 /*-
    4  * Copyright (c) 2000 Michael Smith
    5  * Copyright (c) 2000 BSDi
    6  * Copyright (c) 2000 Niklas Hallqvist
    7  * All rights reserved.
    8  *
    9  * Redistribution and use in source and binary forms, with or without
   10  * modification, are permitted provided that the following conditions
   11  * are met:
   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.
   17  *
   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
   28  * SUCH DAMAGE.
   29  *
   30  *      $FreeBSD: /c/ncvs/src/sys/dev/aac/aacvar.h,v 1.1 2000/09/13 03:20:34 msmith Exp $
   31  */
   32 
   33 /*
   34  * This driver would not have rewritten for OpenBSD if it was not for the
   35  * hardware donation from Nocom.  I want to thank them for their support.
   36  * Of course, credit should go to Mike Smith for the original work he did
   37  * in the FreeBSD driver where I found lots of inspiration.
   38  * - Niklas Hallqvist
   39  */
   40 
   41 /* Debugging */
   42 // #define AAC_DEBUG 0x0
   43 
   44 #ifdef AAC_DEBUG
   45 #define AAC_DPRINTF(mask, args) if (aac_debug & (mask)) printf args
   46 #define AAC_D_INTR      0x001
   47 #define AAC_D_MISC      0x002
   48 #define AAC_D_CMD       0x004
   49 #define AAC_D_QUEUE     0x008
   50 #define AAC_D_IO        0x010
   51 #define AAC_D_IOCTL     0x020
   52 #define AAC_D_LOCK      0x040
   53 #define AAC_D_THREAD    0x080
   54 #define AAC_D_FIB       0x100
   55 extern int aac_debug;
   56 
   57 #define AAC_PRINT_FIB(sc, fib)  do { \
   58         if (aac_debug & AAC_D_FIB) \
   59                 aac_print_fib((sc), (fib), __func__); \
   60 } while (0)
   61 #else
   62 #define AAC_DPRINTF(mask, args)
   63 #define AAC_PRINT_FIB(sc, fib)
   64 #endif
   65 
   66 struct aac_code_lookup {
   67         char    *string;
   68         u_int32_t code;
   69 };
   70 
   71 struct aac_softc;
   72 
   73 /*
   74  * We allocate a small set of FIBs for the adapter to use to send us messages.
   75  */
   76 #define AAC_ADAPTER_FIBS        8
   77 
   78 /*
   79  * FIBs are allocated in page-size chunks and can grow up to the 512
   80  * limit imposed by the hardware.
   81  */
   82 #define AAC_FIB_COUNT           (PAGE_SIZE/sizeof(struct aac_fib))
   83 #define AAC_MAX_FIBS            512
   84 #define AAC_FIBMAP_SIZE         (PAGE_SIZE)
   85 
   86 /*
   87  * The controller reports status events in AIFs.  We hang on to a number of
   88  * these in order to pass them out to user-space management tools.
   89  */
   90 #define AAC_AIFQ_LENGTH         64
   91 
   92 /*
   93  * Firmware messages are passed in the printf buffer.
   94  */
   95 #define AAC_PRINTF_BUFSIZE      256
   96 
   97 /*
   98  * We wait this many seconds for the adapter to come ready if it is still
   99  * booting.
  100  */
  101 #define AAC_BOOT_TIMEOUT        (3 * 60)
  102 
  103 /*
  104  * Timeout for immediate commands.
  105  */
  106 #define AAC_IMMEDIATE_TIMEOUT   30
  107 
  108 /*
  109  * Timeout for normal commands
  110  */
  111 #define AAC_CMD_TIMEOUT         30              /* seconds */
  112 
  113 /*
  114  * Rate at which we periodically check for timed out commands and kick the
  115  * controller.
  116  */
  117 #define AAC_PERIODIC_INTERVAL   20              /* seconds */
  118 
  119 /*
  120  * Wait this long for a lost interrupt to get detected.
  121  */
  122 #define AAC_WATCH_TIMEOUT       10000           /* 10000 * 1ms = 10s */
  123 
  124 /*
  125  * Delay 20ms after the qnotify in sync operations.  Experimentally deduced.
  126  */
  127 #define AAC_SYNC_DELAY 20000
  128 
  129 /*
  130  * The firmware interface allows for a 16-bit s/g list length.  We limit 
  131  * ourselves to a reasonable maximum and ensure alignment.
  132  */
  133 #define AAC_MAXSGENTRIES        64      /* max S/G entries, limit 65535 */              
  134 
  135 /*
  136  * We gather a number of adapter-visible items into a single structure.
  137  *
  138  * The ordering of this structure may be important; we copy the Linux driver:
  139  *
  140  * Adapter FIBs
  141  * Init struct
  142  * Queue headers (Comm Area)
  143  * Printf buffer
  144  *
  145  * In addition, we add:
  146  * Sync Fib
  147  */
  148 struct aac_common {
  149         /* fibs for the controller to send us messages */
  150         struct aac_fib ac_fibs[AAC_ADAPTER_FIBS];
  151 
  152         /* the init structure */
  153         struct aac_adapter_init ac_init;
  154 
  155         /* arena within which the queue structures are kept */
  156         u_int8_t ac_qbuf[sizeof(struct aac_queue_table) + AAC_QUEUE_ALIGN];
  157 
  158         /* buffer for text messages from the controller */
  159         char    ac_printf[AAC_PRINTF_BUFSIZE];
  160     
  161         /* fib for synchronous commands */
  162         struct aac_fib ac_sync_fib;
  163 };
  164 #define AAC_COMMON_ALLOCSIZE (8192 + sizeof(struct aac_common))
  165 
  166 /*
  167  * Interface operations
  168  */
  169 struct aac_interface {
  170         int     (*aif_get_fwstatus)(struct aac_softc *);
  171         void    (*aif_qnotify)(struct aac_softc *, int);
  172         int     (*aif_get_istatus)(struct aac_softc *);
  173         void    (*aif_set_istatus)(struct aac_softc *, int);
  174         void    (*aif_set_mailbox)(struct aac_softc *, u_int32_t,
  175             u_int32_t, u_int32_t, u_int32_t, u_int32_t);
  176         int     (*aif_get_mailbox)(struct aac_softc *, int mb);
  177         void    (*aif_set_interrupts)(struct aac_softc *, int);
  178 };
  179 extern struct aac_interface aac_fa_interface;
  180 extern struct aac_interface aac_sa_interface;
  181 extern struct aac_interface aac_rx_interface;
  182 extern struct aac_interface aac_rkt_interface;
  183 
  184 #define AAC_GET_FWSTATUS(sc)            ((sc)->aac_if.aif_get_fwstatus(sc))
  185 #define AAC_QNOTIFY(sc, qbit) \
  186         ((sc)->aac_if.aif_qnotify((sc), (qbit)))
  187 #define AAC_GET_ISTATUS(sc)             ((sc)->aac_if.aif_get_istatus(sc))
  188 #define AAC_CLEAR_ISTATUS(sc, mask) \
  189         ((sc)->aac_if.aif_set_istatus((sc), (mask)))
  190 #define AAC_SET_MAILBOX(sc, command, arg0, arg1, arg2, arg3) \
  191         do {                                                            \
  192                 ((sc)->aac_if.aif_set_mailbox((sc), (command), (arg0),  \
  193                     (arg1), (arg2), (arg3)));                           \
  194         } while(0)
  195 #define AAC_GET_MAILBOX(sc, mb) \
  196         ((sc)->aac_if.aif_get_mailbox(sc, (mb)))
  197 #define AAC_MASK_INTERRUPTS(sc) \
  198         ((sc)->aac_if.aif_set_interrupts((sc), 0))
  199 #define AAC_UNMASK_INTERRUPTS(sc) \
  200         ((sc)->aac_if.aif_set_interrupts((sc), 1))
  201 
  202 #define AAC_SETREG4(sc, reg, val) \
  203         bus_space_write_4((sc)->aac_memt, (sc)->aac_memh, (reg), (val))
  204 #define AAC_GETREG4(sc, reg) \
  205         bus_space_read_4((sc)->aac_memt, (sc)->aac_memh, (reg))
  206 #define AAC_SETREG2(sc, reg, val) \
  207         bus_space_write_2((sc)->aac_memt, (sc)->aac_memh, (reg), (val))
  208 #define AAC_GETREG2(sc, reg) \
  209         bus_space_read_2((sc)->aac_memt, (sc)->aac_memh, (reg))
  210 #define AAC_SETREG1(sc, reg, val) \
  211         bus_space_write_1((sc)->aac_memt, (sc)->aac_memh, (reg), (val))
  212 #define AAC_GETREG1(sc, reg) \
  213         bus_space_read_1((sc)->aac_memt, (sc)->aac_memh, (reg))
  214 
  215 /* Define the OS version specific locks */
  216 typedef struct rwlock aac_lock_t;
  217 #define AAC_LOCK_INIT(l, s)     do { \
  218     rw_init((l), "aaclock"); \
  219     AAC_DPRINTF(AAC_D_LOCK, ("%s: init lock @%s: %d\n", \
  220                 sc->aac_dev.dv_xname, __FUNCTION__, __LINE__)); \
  221 } while (0)
  222 
  223 #define AAC_LOCK_ACQUIRE(l) do { \
  224     AAC_DPRINTF(AAC_D_LOCK, ("%s: lock @%s: %d\n", \
  225                 sc->aac_dev.dv_xname, __FUNCTION__, __LINE__)); \
  226     rw_enter_write((l)); \
  227 } while (0)
  228 
  229 #define AAC_LOCK_RELEASE(l) do { \
  230     rw_exit_write((l)); \
  231     AAC_DPRINTF(AAC_D_LOCK, ("%s: unlock @%s: %d\n", \
  232                 sc->aac_dev.dv_xname, __FUNCTION__, __LINE__)); \
  233 } while (0)
  234 
  235 /*
  236  * Per-container data structure
  237  */
  238 struct aac_container
  239 {
  240         struct aac_mntobj co_mntobj;
  241         int                             co_found;
  242         TAILQ_ENTRY(aac_container)      co_link;
  243 };
  244 
  245 /*
  246  * A command control block, one for each corresponding command index of the
  247  * controller.
  248  */
  249 struct aac_command
  250 {
  251         TAILQ_ENTRY(aac_command) cm_link;       /* list linkage */
  252 
  253         struct aac_softc        *cm_sc;         /* controller that owns us */
  254 
  255         struct aac_fib          *cm_fib;        /* FIB for this command */
  256         bus_addr_t              cm_fibphys;     /* bus address of the FIB */
  257         void                    *cm_data;
  258         size_t                  cm_datalen;
  259         bus_dmamap_t            cm_datamap;
  260         struct aac_sg_table     *cm_sgtable;    /* pointer to s/g table */
  261 
  262         u_int                   cm_flags;
  263 #define AAC_CMD_MAPPED          (1<<0)  /* command has had its data mapped */
  264 #define AAC_CMD_DATAIN          (1<<1)  /* command involves data moving
  265                                          * from controller to host */
  266 #define AAC_CMD_DATAOUT         (1<<2)  /* command involves data moving
  267                                          * from host to controller */
  268 #define AAC_CMD_COMPLETED       (1<<3)  /* command has been completed */
  269 #define AAC_CMD_TIMEDOUT        (1<<4)  /* command taken too long */
  270 #define AAC_ON_AACQ_FREE        (1<<5)
  271 #define AAC_ON_AACQ_READY       (1<<6)
  272 #define AAC_ON_AACQ_BUSY        (1<<7)
  273 #define AAC_ON_AACQ_BIO         (1<<8)
  274 #define AAC_ON_AACQ_MASK        ((1<<5)|(1<<6)|(1<<7)|(1<<8))
  275 #define AAC_QUEUE_FRZN          (1<<9)  /* Freeze the processing of
  276                                          * commands on the queue. */
  277 #define AAC_ACF_WATCHDOG        (1<<10)
  278 
  279         void                    (*cm_complete)(struct aac_command *);
  280         void                    *cm_private;
  281         u_int32_t               cm_blkno;
  282         u_int32_t               cm_bcount;
  283         time_t                  cm_timestamp;   /* command creation time */
  284         int                     cm_queue;
  285         int                     cm_index;
  286 };
  287 
  288 struct aac_fibmap {
  289         TAILQ_ENTRY(aac_fibmap) fm_link;        /* list linkage */
  290         struct aac_fib          *aac_fibs;
  291         bus_dmamap_t            aac_fibmap;
  292         bus_dma_segment_t       aac_seg;
  293         int                     aac_nsegs;
  294         struct aac_command      *aac_commands;
  295 };
  296 
  297 /*
  298  * Command queue statistics
  299  */
  300 #define AACQ_FREE       0
  301 #define AACQ_BIO        1
  302 #define AACQ_READY      2
  303 #define AACQ_BUSY       3
  304 #define AACQ_COUNT      4       /* total number of queues */
  305 
  306 struct aac_qstat {
  307         u_int32_t       q_length;
  308         u_int32_t       q_max;
  309 };
  310 
  311 /*
  312  * Per-controller structure.
  313  */
  314 struct aac_softc
  315 {
  316         struct device aac_dev;
  317         void   *aac_ih;
  318 
  319         bus_space_tag_t aac_memt;
  320         bus_space_handle_t aac_memh;
  321         bus_dma_tag_t aac_dmat;         /* parent DMA tag */
  322 
  323         /* controller features, limits and status */
  324         int     aac_state;
  325 #define AAC_STATE_SUSPEND       (1<<0)
  326 #define AAC_STATE_OPEN          (1<<1)
  327 #define AAC_STATE_INTERRUPTS_ON (1<<2)
  328 #define AAC_STATE_AIF_SLEEPER   (1<<3)
  329         struct FsaRevision aac_revision;
  330 
  331         int     aac_hwif;       /* controller hardware interface */
  332 #define AAC_HWIF_I960RX         0
  333 #define AAC_HWIF_STRONGARM      1
  334 #define AAC_HWIF_FALCON         2
  335 #define AAC_HWIF_RKT            3
  336 #define AAC_HWIF_UNKNOWN        -1
  337 
  338         struct aac_common *aac_common;
  339         bus_dmamap_t            aac_common_map;
  340         u_int32_t aac_common_busaddr;
  341         struct aac_interface aac_if;
  342 
  343         /* command/fib resources */
  344         TAILQ_HEAD(,aac_fibmap) aac_fibmap_tqh;
  345         u_int                   total_fibs;
  346         struct aac_command      *aac_commands;
  347         struct scsi_iopool      aac_iopool;
  348 
  349         /* command management */
  350         struct mutex             aac_free_mtx;
  351         TAILQ_HEAD(,aac_command) aac_free;      /* command structures 
  352                                                  * available for reuse */
  353         TAILQ_HEAD(,aac_command) aac_ready;     /* commands on hold for
  354                                                  * controller resources */
  355         TAILQ_HEAD(,aac_command) aac_busy;
  356         TAILQ_HEAD(,aac_command) aac_bio;
  357 
  358         /* command management */
  359         struct aac_queue_table *aac_queues;
  360         struct aac_queue_entry *aac_qentries[AAC_QUEUE_COUNT];
  361 
  362         struct aac_qstat        aac_qstat[AACQ_COUNT];  /* queue statistics */
  363 
  364         /* connected containers */
  365         TAILQ_HEAD(,aac_container)      aac_container_tqh;
  366         aac_lock_t              aac_container_lock;
  367 
  368         /* Protect the sync fib */
  369 #define AAC_SYNC_LOCK_FORCE     (1 << 0)
  370         aac_lock_t              aac_sync_lock;
  371 
  372         aac_lock_t              aac_io_lock;
  373 
  374         struct {
  375                 u_int8_t hd_present;
  376                 u_int8_t hd_is_logdrv;
  377                 u_int8_t hd_is_arraydrv;
  378                 u_int8_t hd_is_master;
  379                 u_int8_t hd_is_parity;
  380                 u_int8_t hd_is_hotfix;
  381                 u_int8_t hd_master_no;
  382                 u_int8_t hd_lock;
  383                 u_int8_t hd_heads;
  384                 u_int8_t hd_secs;
  385                 u_int16_t hd_devtype;
  386                 u_int32_t hd_size;
  387                 u_int8_t hd_ldr_no;
  388                 u_int8_t hd_rw_attribs;
  389                 u_int32_t hd_start_sec;
  390         } aac_hdr[AAC_MAX_CONTAINERS];
  391         int                     aac_container_count;
  392 
  393         /* management interface */
  394         aac_lock_t              aac_aifq_lock;
  395         struct aac_aif_command  aac_aifq[AAC_AIFQ_LENGTH];
  396         int                     aac_aifq_head;
  397         int                     aac_aifq_tail;
  398         struct selinfo          aac_select;
  399         struct proc             *aifthread;
  400         int                     aifflags;
  401 #define AAC_AIFFLAGS_RUNNING    (1 << 0)
  402 #define AAC_AIFFLAGS_AIF        (1 << 1)
  403 #define AAC_AIFFLAGS_EXIT       (1 << 2)
  404 #define AAC_AIFFLAGS_EXITED     (1 << 3)
  405 #define AAC_AIFFLAGS_COMPLETE   (1 << 4)
  406 #define AAC_AIFFLAGS_PRINTF     (1 << 5)
  407 #define AAC_AIFFLAGS_PENDING    (AAC_AIFFLAGS_AIF | AAC_AIFFLAGS_COMPLETE | \
  408                                  AAC_AIFFLAGS_PRINTF)
  409 
  410         u_int32_t               flags;
  411 #define AAC_FLAGS_PERC2QC       (1 << 0)
  412 #define AAC_FLAGS_ENABLE_CAM    (1 << 1)        /* No SCSI passthrough */
  413 #define AAC_FLAGS_CAM_NORESET   (1 << 2)        /* Fake SCSI resets */
  414 #define AAC_FLAGS_CAM_PASSONLY  (1 << 3)        /* Only create pass devices */
  415 #define AAC_FLAGS_SG_64BIT      (1 << 4)        /* Use 64-bit S/G addresses */
  416 #define AAC_FLAGS_4GB_WINDOW    (1 << 5)        /* Device can access host mem
  417                                                  * 2GB-4GB range */
  418 #define AAC_FLAGS_NO4GB         (1 << 6)        /* Can't access host mem >2GB*/
  419 #define AAC_FLAGS_256FIBS       (1 << 7)        /* Can only do 256 commands */
  420 #define AAC_FLAGS_BROKEN_MEMMAP (1 << 8)        /* Broken HostPhysMemPages */
  421 
  422         u_int32_t               supported_options;
  423         int                     aac_max_fibs;
  424         void                    *aac_sdh;
  425 };
  426 
  427 int     aac_attach(struct aac_softc *);
  428 int     aac_intr(void *);
  429 
  430 /* These all require correctly aligned buffers */
  431 static __inline__ void
  432 aac_enc16(addr, value)
  433         u_int8_t *addr;
  434         u_int16_t value;
  435 {
  436         *(u_int16_t *)addr = htole16(value);
  437 }
  438 
  439 static __inline__ void
  440 aac_enc32(addr, value)
  441         u_int8_t *addr;
  442         u_int32_t value;
  443 {
  444         *(u_int32_t *)addr = htole32(value);
  445 }
  446 
  447 static __inline__ u_int16_t
  448 aac_dec16(addr)
  449         u_int8_t *addr;
  450 {
  451         return letoh16(*(u_int16_t *)addr);
  452 }
  453 
  454 static __inline__ u_int32_t
  455 aac_dec32(addr)
  456         u_int8_t *addr;
  457 {
  458         return letoh32(*(u_int32_t *)addr);
  459 }
  460 
  461 /* Declarations copied from aac.c */
  462 #ifdef AAC_DEBUG
  463 void aac_print_fib(struct aac_softc *, struct aac_fib *, const char *);
  464 void aac_print_aif(struct aac_softc *, struct aac_aif_command *);
  465 #endif
  466 void aac_handle_aif(struct aac_softc *, struct aac_fib *);
  467 
  468 
  469 
  470 
  471 
  472 /*
  473  * Queue primitives for driver queues.
  474  */
  475 #define AACQ_ADD(sc, qname)                                     \
  476         do {                                                    \
  477                 struct aac_qstat *qs;                           \
  478                                                                 \
  479                 qs = &(sc)->aac_qstat[qname];                   \
  480                                                                 \
  481                 qs->q_length++;                                 \
  482                 if (qs->q_length > qs->q_max)                   \
  483                         qs->q_max = qs->q_length;               \
  484         } while (0)
  485 
  486 #define AACQ_REMOVE(sc, qname)    (sc)->aac_qstat[qname].q_length--
  487 #define AACQ_INIT(sc, qname)                            \
  488         do {                                            \
  489                 sc->aac_qstat[qname].q_length = 0;      \
  490                 sc->aac_qstat[qname].q_max = 0;         \
  491         } while (0)
  492 
  493 
  494 #define AACQ_COMMAND_QUEUE(name, index)                                 \
  495 static __inline void                                                    \
  496 aac_initq_ ## name (struct aac_softc *sc)                               \
  497 {                                                                       \
  498         TAILQ_INIT(&sc->aac_ ## name);                                  \
  499         AACQ_INIT(sc, index);                                           \
  500 }                                                                       \
  501 static __inline void                                                    \
  502 aac_enqueue_ ## name (struct aac_command *cm)                           \
  503 {                                                                       \
  504         AAC_DPRINTF(AAC_D_CMD, (": enqueue " #name));                   \
  505         if ((cm->cm_flags & AAC_ON_AACQ_MASK) != 0) {                   \
  506                 printf("command %p is on another queue, flags = %#x\n", \
  507                        cm, cm->cm_flags);                               \
  508                 panic("command is on another queue");                   \
  509         }                                                               \
  510         TAILQ_INSERT_TAIL(&cm->cm_sc->aac_ ## name, cm, cm_link);       \
  511         cm->cm_flags |= AAC_ON_ ## index;                               \
  512         AACQ_ADD(cm->cm_sc, index);                                     \
  513 }                                                                       \
  514 static __inline void                                                    \
  515 aac_requeue_ ## name (struct aac_command *cm)                           \
  516 {                                                                       \
  517         AAC_DPRINTF(AAC_D_CMD, (": requeue " #name));                   \
  518         if ((cm->cm_flags & AAC_ON_AACQ_MASK) != 0) {                   \
  519                 printf("command %p is on another queue, flags = %#x\n", \
  520                        cm, cm->cm_flags);                               \
  521                 panic("command is on another queue");                   \
  522         }                                                               \
  523         TAILQ_INSERT_HEAD(&cm->cm_sc->aac_ ## name, cm, cm_link);       \
  524         cm->cm_flags |= AAC_ON_ ## index;                               \
  525         AACQ_ADD(cm->cm_sc, index);                                     \
  526 }                                                                       \
  527 static __inline struct aac_command *                                    \
  528 aac_dequeue_ ## name (struct aac_softc *sc)                             \
  529 {                                                                       \
  530         struct aac_command *cm;                                         \
  531                                                                         \
  532         if ((cm = TAILQ_FIRST(&sc->aac_ ## name)) != NULL) {            \
  533                 AAC_DPRINTF(AAC_D_CMD, (": dequeue " #name));           \
  534                 if ((cm->cm_flags & AAC_ON_ ## index) == 0) {           \
  535                         printf("dequeue - command %p not in queue, flags = %#x, "       \
  536                                "bit = %#x\n", cm, cm->cm_flags,         \
  537                                AAC_ON_ ## index);                       \
  538                         panic("command not in queue");                  \
  539                 }                                                       \
  540                 TAILQ_REMOVE(&sc->aac_ ## name, cm, cm_link);           \
  541                 cm->cm_flags &= ~AAC_ON_ ## index;                      \
  542                 AACQ_REMOVE(sc, index);                                 \
  543         }                                                               \
  544         return(cm);                                                     \
  545 }                                                                       \
  546 static __inline void                                                    \
  547 aac_remove_ ## name (struct aac_command *cm)                            \
  548 {                                                                       \
  549         AAC_DPRINTF(AAC_D_CMD, (": remove " #name));                    \
  550         if ((cm->cm_flags & AAC_ON_ ## index) == 0) {                   \
  551                 printf("remove - command %p not in queue, flags = %#x, "                \
  552                        "bit = %#x\n", cm, cm->cm_flags,                 \
  553                        AAC_ON_ ## index);                               \
  554                 panic("command not in queue");                          \
  555         }                                                               \
  556         TAILQ_REMOVE(&cm->cm_sc->aac_ ## name, cm, cm_link);            \
  557         cm->cm_flags &= ~AAC_ON_ ## index;                              \
  558         AACQ_REMOVE(cm->cm_sc, index);                                  \
  559 }                                                                       \
  560 struct hack
  561 
  562 AACQ_COMMAND_QUEUE(free, AACQ_FREE);
  563 AACQ_COMMAND_QUEUE(ready, AACQ_READY);
  564 AACQ_COMMAND_QUEUE(busy, AACQ_BUSY);
  565 AACQ_COMMAND_QUEUE(bio, AACQ_BIO);
  566 
  567 static __inline void
  568 aac_print_printf(struct aac_softc *sc)
  569 {
  570         /*
  571          * XXX We have the ability to read the length of the printf string
  572          * from out of the mailboxes.
  573          */
  574         printf("** %s: %.*s", sc->aac_dev.dv_xname, AAC_PRINTF_BUFSIZE,
  575                sc->aac_common->ac_printf);
  576         sc->aac_common->ac_printf[0] = 0;
  577         AAC_QNOTIFY(sc, AAC_DB_PRINTF);
  578 }

Cache object: 994fb77a0a1d64900943aeb598bf3045


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.