Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / dev / pci / amrvar.h
blob280e1f70f9610a009912a2b4b2376a3ad35b0d60
1 /* $NetBSD: amrvar.h,v 1.7 2007/07/09 21:00:52 ad Exp $ */
3 /*-
4 * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Andrew Doran.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
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.
45 struct amr_logdrive {
46 u_int al_size;
47 u_short al_state;
48 u_short al_properties;
49 struct device *al_dv;
53 * Per-controller state.
55 struct amr_softc {
56 struct device amr_dv;
57 bus_space_tag_t amr_iot;
58 bus_space_handle_t amr_ioh;
59 bus_size_t amr_ios;
60 bus_dma_tag_t amr_dmat;
61 pci_chipset_tag_t amr_pc;
62 void *amr_ih;
63 struct lwp *amr_thread;
64 int amr_flags;
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;
70 int amr_dmasize;
71 void *amr_enqbuf;
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;
80 int amr_maxqueuecnt;
82 int (*amr_get_work)(struct amr_softc *, struct amr_mailbox_resp *);
83 int (*amr_submit)(struct amr_softc *sc, struct amr_ccb *);
85 int amr_numdrives;
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
101 /* General flags. */
102 #define AMRF_THREAD_EXIT 0x00010000
103 #define AMRF_OPEN 0x00020000
106 * Command control block.
108 struct amr_ccb {
109 union {
110 SIMPLEQ_ENTRY(amr_ccb) simpleq;
111 SLIST_ENTRY(amr_ccb) slist;
112 TAILQ_ENTRY(amr_ccb) tailq;
113 } ac_chain;
115 u_int ac_flags;
116 u_int ac_status;
117 u_int ac_ident;
118 u_int ac_xfer_size;
119 time_t ac_start_time;
120 bus_dmamap_t ac_xfer_map;
121 void (*ac_handler)(struct amr_ccb *);
122 void *ac_context;
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 {
134 int amra_unit;
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_ */