1 /* $NetBSD: amrvar.h,v 1.7 2007/07/09 21:00:52 ad Exp $ */
4 * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #ifndef _PCI_AMRVAR_H_
33 #define _PCI_AMRVAR_H_
35 #define AMR_MAX_UNITS 16
36 #define AMR_WDOG_TICKS (hz * 5)
37 #define AMR_NCCB_RESV 2
38 #define AMR_ENQUIRY_BUFSIZE 2048
39 #define AMR_SGL_SIZE (sizeof(struct amr_sgentry) * AMR_MAX_SEGS)
40 #define AMR_TIMEOUT 30
43 * Logical drive information.
48 u_short al_properties
;
53 * Per-controller state.
57 bus_space_tag_t amr_iot
;
58 bus_space_handle_t amr_ioh
;
60 bus_dma_tag_t amr_dmat
;
61 pci_chipset_tag_t amr_pc
;
63 struct lwp
*amr_thread
;
66 struct amr_mailbox
*amr_mbox
;
67 bus_addr_t amr_mbox_paddr
;
68 bus_dmamap_t amr_dmamap
;
69 bus_dma_segment_t amr_dmaseg
;
73 struct amr_sgentry
*amr_sgls
;
74 bus_addr_t amr_sgls_paddr
;
76 struct amr_ccb
*amr_ccbs
;
77 SLIST_HEAD(, amr_ccb
) amr_ccb_freelist
;
78 SIMPLEQ_HEAD(, amr_ccb
) amr_ccb_queue
;
79 TAILQ_HEAD(, amr_ccb
) amr_ccb_active
;
82 int (*amr_get_work
)(struct amr_softc
*, struct amr_mailbox_resp
*);
83 int (*amr_submit
)(struct amr_softc
*sc
, struct amr_ccb
*);
86 struct amr_logdrive amr_drive
[AMR_MAX_UNITS
];
89 /* What resources are allocated? */
90 #define AMRF_INTR 0x00000001
91 #define AMRF_DMA_LOAD 0x00000002
92 #define AMRF_DMA_MAP 0x00000004
93 #define AMRF_DMA_ALLOC 0x00000008
94 #define AMRF_DMA_CREATE 0x00000010
95 #define AMRF_PCI_INTR 0x00000020
96 #define AMRF_PCI_REGS 0x00000040
97 #define AMRF_CCBS 0x00000080
98 #define AMRF_ENQBUF 0x00000100
99 #define AMRF_THREAD 0x00000200
102 #define AMRF_THREAD_EXIT 0x00010000
103 #define AMRF_OPEN 0x00020000
106 * Command control block.
110 SIMPLEQ_ENTRY(amr_ccb
) simpleq
;
111 SLIST_ENTRY(amr_ccb
) slist
;
112 TAILQ_ENTRY(amr_ccb
) tailq
;
119 time_t ac_start_time
;
120 bus_dmamap_t ac_xfer_map
;
121 void (*ac_handler
)(struct amr_ccb
*);
123 struct device
*ac_dv
;
124 struct amr_mailbox_cmd ac_cmd
;
126 #define AC_XFER_IN 0x01 /* Map describes inbound xfer */
127 #define AC_XFER_OUT 0x02 /* Map describes outbound xfer */
128 #define AC_COMPLETE 0x04 /* Command completed */
129 #define AC_ACTIVE 0x08 /* Command active */
130 #define AC_NOSGL 0x10 /* No scatter/gather list */
131 #define AC_MOAN 0x20 /* We have already moaned */
133 struct amr_attach_args
{
137 int amr_ccb_alloc(struct amr_softc
*, struct amr_ccb
**);
138 void amr_ccb_enqueue(struct amr_softc
*, struct amr_ccb
*);
139 void amr_ccb_free(struct amr_softc
*, struct amr_ccb
*);
140 int amr_ccb_map(struct amr_softc
*, struct amr_ccb
*, void *, int, int);
141 int amr_ccb_poll(struct amr_softc
*, struct amr_ccb
*, int);
142 void amr_ccb_unmap(struct amr_softc
*, struct amr_ccb
*);
143 int amr_ccb_wait(struct amr_softc
*, struct amr_ccb
*);
144 const char *amr_drive_state(int, int *);
146 extern int amr_max_xfer
;
148 #endif /* !_PCI_AMRVAR_H_ */