icpvar.h revision 1.1.6.2 1 1.1.6.2 nathanw /* $NetBSD: icpvar.h,v 1.1.6.2 2002/06/20 03:44:41 nathanw Exp $ */
2 1.1.6.2 nathanw
3 1.1.6.2 nathanw /*-
4 1.1.6.2 nathanw * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 1.1.6.2 nathanw * All rights reserved.
6 1.1.6.2 nathanw *
7 1.1.6.2 nathanw * This code is derived from software contributed to The NetBSD Foundation
8 1.1.6.2 nathanw * by Andrew Doran.
9 1.1.6.2 nathanw *
10 1.1.6.2 nathanw * Redistribution and use in source and binary forms, with or without
11 1.1.6.2 nathanw * modification, are permitted provided that the following conditions
12 1.1.6.2 nathanw * are met:
13 1.1.6.2 nathanw * 1. Redistributions of source code must retain the above copyright
14 1.1.6.2 nathanw * notice, this list of conditions and the following disclaimer.
15 1.1.6.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
16 1.1.6.2 nathanw * notice, this list of conditions and the following disclaimer in the
17 1.1.6.2 nathanw * documentation and/or other materials provided with the distribution.
18 1.1.6.2 nathanw * 3. All advertising materials mentioning features or use of this software
19 1.1.6.2 nathanw * must display the following acknowledgement:
20 1.1.6.2 nathanw * This product includes software developed by the NetBSD
21 1.1.6.2 nathanw * Foundation, Inc. and its contributors.
22 1.1.6.2 nathanw * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1.6.2 nathanw * contributors may be used to endorse or promote products derived
24 1.1.6.2 nathanw * from this software without specific prior written permission.
25 1.1.6.2 nathanw *
26 1.1.6.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1.6.2 nathanw * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1.6.2 nathanw * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1.6.2 nathanw * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1.6.2 nathanw * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1.6.2 nathanw * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1.6.2 nathanw * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1.6.2 nathanw * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1.6.2 nathanw * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1.6.2 nathanw * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1.6.2 nathanw * POSSIBILITY OF SUCH DAMAGE.
37 1.1.6.2 nathanw */
38 1.1.6.2 nathanw
39 1.1.6.2 nathanw #ifndef _IC_ICPVAR_H_
40 1.1.6.2 nathanw #define _IC_ICPVAR_H_
41 1.1.6.2 nathanw
42 1.1.6.2 nathanw #include "locators.h"
43 1.1.6.2 nathanw
44 1.1.6.2 nathanw /*
45 1.1.6.2 nathanw * Miscellaneous constants.
46 1.1.6.2 nathanw */
47 1.1.6.2 nathanw #define ICP_RETRIES 6
48 1.1.6.2 nathanw #define ICP_WATCHDOG_FREQ 5
49 1.1.6.2 nathanw #define ICP_BUSY_WAIT_MS 2500
50 1.1.6.2 nathanw #define ICP_MAX_XFER 65536
51 1.1.6.2 nathanw #define ICP_SCRATCH_SIZE 8192
52 1.1.6.2 nathanw #define ICP_SCRATCH_SENSE \
53 1.1.6.2 nathanw (ICP_SCRATCH_SIZE - sizeof(struct scsipi_sense_data) * ICP_NCCBS)
54 1.1.6.2 nathanw
55 1.1.6.2 nathanw #define ICP_NCCBS ICP_MAX_CMDS
56 1.1.6.2 nathanw #define ICP_NCCB_RESERVE 4
57 1.1.6.2 nathanw
58 1.1.6.2 nathanw /*
59 1.1.6.2 nathanw * Context structure for interrupt service.
60 1.1.6.2 nathanw */
61 1.1.6.2 nathanw struct icp_intr_ctx {
62 1.1.6.2 nathanw u_int32_t info;
63 1.1.6.2 nathanw u_int32_t info2;
64 1.1.6.2 nathanw u_int16_t cmd_status;
65 1.1.6.2 nathanw u_int16_t service;
66 1.1.6.2 nathanw u_int8_t istatus;
67 1.1.6.2 nathanw };
68 1.1.6.2 nathanw
69 1.1.6.2 nathanw /*
70 1.1.6.2 nathanw * Command control block.
71 1.1.6.2 nathanw */
72 1.1.6.2 nathanw struct icp_ccb {
73 1.1.6.2 nathanw SIMPLEQ_ENTRY(icp_ccb) ic_chain;
74 1.1.6.2 nathanw u_int ic_service;
75 1.1.6.2 nathanw u_int ic_flags;
76 1.1.6.2 nathanw u_int ic_status;
77 1.1.6.2 nathanw u_int ic_ident;
78 1.1.6.2 nathanw u_int ic_nsgent;
79 1.1.6.2 nathanw u_int ic_cmdlen;
80 1.1.6.2 nathanw u_int ic_xfer_size;
81 1.1.6.2 nathanw bus_dmamap_t ic_xfer_map;
82 1.1.6.2 nathanw struct icp_sg *ic_sg;
83 1.1.6.2 nathanw struct device *ic_dv;
84 1.1.6.2 nathanw void *ic_context;
85 1.1.6.2 nathanw void (*ic_intr)(struct icp_ccb *);
86 1.1.6.2 nathanw struct icp_cmd ic_cmd;
87 1.1.6.2 nathanw };
88 1.1.6.2 nathanw #define IC_XFER_IN 0x01 /* Map describes inbound xfer */
89 1.1.6.2 nathanw #define IC_XFER_OUT 0x02 /* Map describes outbound xfer */
90 1.1.6.2 nathanw #define IC_WAITING 0x04 /* We have waiters */
91 1.1.6.2 nathanw #define IC_COMPLETE 0x08 /* Command completed */
92 1.1.6.2 nathanw #define IC_ALLOCED 0x10 /* CCB allocated */
93 1.1.6.2 nathanw
94 1.1.6.2 nathanw /*
95 1.1.6.2 nathanw * Logical drive information.
96 1.1.6.2 nathanw */
97 1.1.6.2 nathanw struct icp_cachedrv {
98 1.1.6.2 nathanw u_int cd_size;
99 1.1.6.2 nathanw u_int cd_type;
100 1.1.6.2 nathanw };
101 1.1.6.2 nathanw
102 1.1.6.2 nathanw /*
103 1.1.6.2 nathanw * Per-controller context.
104 1.1.6.2 nathanw */
105 1.1.6.2 nathanw struct icp_softc {
106 1.1.6.2 nathanw struct device icp_dv;
107 1.1.6.2 nathanw void *icp_ih;
108 1.1.6.2 nathanw bus_dma_tag_t icp_dmat;
109 1.1.6.2 nathanw bus_space_tag_t icp_dpmemt;
110 1.1.6.2 nathanw bus_space_handle_t icp_dpmemh;
111 1.1.6.2 nathanw bus_addr_t icp_dpmembase;
112 1.1.6.2 nathanw bus_space_tag_t icp_iot;
113 1.1.6.2 nathanw bus_space_handle_t icp_ioh;
114 1.1.6.2 nathanw bus_addr_t icp_iobase;
115 1.1.6.2 nathanw
116 1.1.6.2 nathanw int icp_class;
117 1.1.6.2 nathanw u_int16_t icp_ic_all_size;
118 1.1.6.2 nathanw u_int8_t icp_bus_cnt;
119 1.1.6.2 nathanw u_int8_t icp_bus_id[ICP_MAXBUS];
120 1.1.6.2 nathanw struct icp_cachedrv icp_cdr[ICP_MAX_HDRIVES];
121 1.1.6.2 nathanw int icp_ndevs;
122 1.1.6.2 nathanw int icp_openings;
123 1.1.6.2 nathanw
124 1.1.6.2 nathanw u_int32_t icp_info;
125 1.1.6.2 nathanw u_int32_t icp_info2;
126 1.1.6.2 nathanw u_int16_t icp_status;
127 1.1.6.2 nathanw
128 1.1.6.2 nathanw bus_dmamap_t icp_scr_dmamap;
129 1.1.6.2 nathanw bus_dma_segment_t icp_scr_seg[1];
130 1.1.6.2 nathanw caddr_t icp_scr;
131 1.1.6.2 nathanw
132 1.1.6.2 nathanw struct icp_ccb *icp_ccbs;
133 1.1.6.2 nathanw u_int icp_nccbs;
134 1.1.6.2 nathanw SIMPLEQ_HEAD(,icp_ccb) icp_ccb_freelist;
135 1.1.6.2 nathanw SIMPLEQ_HEAD(,icp_ccb) icp_ccb_queue;
136 1.1.6.2 nathanw struct callout icp_wdog_callout;
137 1.1.6.2 nathanw
138 1.1.6.2 nathanw void (*icp_copy_cmd)(struct icp_softc *, struct icp_ccb *);
139 1.1.6.2 nathanw u_int8_t (*icp_get_status)(struct icp_softc *);
140 1.1.6.2 nathanw void (*icp_intr)(struct icp_softc *, struct icp_intr_ctx *);
141 1.1.6.2 nathanw void (*icp_release_event)(struct icp_softc *,
142 1.1.6.2 nathanw struct icp_ccb *);
143 1.1.6.2 nathanw void (*icp_set_sema0)(struct icp_softc *);
144 1.1.6.2 nathanw int (*icp_test_busy)(struct icp_softc *);
145 1.1.6.2 nathanw };
146 1.1.6.2 nathanw
147 1.1.6.2 nathanw #define ICP_ISA 0x01
148 1.1.6.2 nathanw #define ICP_EISA 0x02
149 1.1.6.2 nathanw #define ICP_PCI 0x03
150 1.1.6.2 nathanw #define ICP_PCINEW 0x04
151 1.1.6.2 nathanw #define ICP_MPR 0x05
152 1.1.6.2 nathanw #define ICP_CLASS_MASK 0x07
153 1.1.6.2 nathanw #define ICP_FC 0x10
154 1.1.6.2 nathanw #define ICP_CLASS(icp) ((icp)->icp_class & ICP_CLASS_MASK)
155 1.1.6.2 nathanw
156 1.1.6.2 nathanw int icp_init(struct icp_softc *, const char *);
157 1.1.6.2 nathanw int icp_intr(void *);
158 1.1.6.2 nathanw
159 1.1.6.2 nathanw /*
160 1.1.6.2 nathanw * Consumer interface.
161 1.1.6.2 nathanw */
162 1.1.6.2 nathanw struct icp_attach_args {
163 1.1.6.2 nathanw int icpa_unit;
164 1.1.6.2 nathanw };
165 1.1.6.2 nathanw
166 1.1.6.2 nathanw #define icpacf_unit cf_loc[ICPCF_UNIT]
167 1.1.6.2 nathanw
168 1.1.6.2 nathanw #define ICPA_UNIT_SCSI 100
169 1.1.6.2 nathanw
170 1.1.6.2 nathanw struct icp_ccb *icp_ccb_alloc(struct icp_softc *);
171 1.1.6.2 nathanw void icp_ccb_enqueue(struct icp_softc *, struct icp_ccb *);
172 1.1.6.2 nathanw void icp_ccb_free(struct icp_softc *, struct icp_ccb *);
173 1.1.6.2 nathanw int icp_ccb_map(struct icp_softc *, struct icp_ccb *, void *, int, int);
174 1.1.6.2 nathanw int icp_ccb_poll(struct icp_softc *, struct icp_ccb *, int);
175 1.1.6.2 nathanw void icp_ccb_unmap(struct icp_softc *, struct icp_ccb *);
176 1.1.6.2 nathanw int icp_ccb_wait(struct icp_softc *, struct icp_ccb *, int);
177 1.1.6.2 nathanw int icp_cmd(struct icp_softc *, u_int8_t, u_int16_t, u_int32_t, u_int32_t,
178 1.1.6.2 nathanw u_int32_t);
179 1.1.6.2 nathanw
180 1.1.6.2 nathanw #endif /* !_IC_ICPVAR_H_ */
181