This source file includes following definitions.
- ahc_timer_reset
- ahc_scb_timer_reset
- ahc_flush_device_writes
- ahc_set_transaction_status
- ahc_set_scsi_status
- ahc_get_transaction_status
- ahc_get_scsi_status
- ahc_set_transaction_tag
- ahc_get_transfer_length
- ahc_get_transfer_dir
- ahc_set_residual
- ahc_set_sense_residual
- ahc_get_residual
- ahc_perform_autosense
- ahc_get_sense_bufsize
- ahc_freeze_scb
- ahc_platform_freeze_devq
- ahc_platform_abort_scbs
- ahc_platform_scb_free
- ahc_pci_read_config
- ahc_pci_write_config
- ahc_get_pci_function
- ahc_get_pci_slot
- ahc_get_pci_bus
- AHC_POWER_STATE_D0
- AHC_POWER_STATE_D1
- AHC_POWER_STATE_D2
- AHC_POWER_STATE_D3
- ahc_power_state
- ahc_print_path
- ahc_platform_dump_card_state
- ahc_platform_flushwork
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 #ifndef _AIC7XXX_OPENBSD_H_
45 #define _AIC7XXX_OPENBSD_H_
46
47 #include "pci.h"
48
49 #include <sys/param.h>
50 #include <sys/kernel.h>
51 #include <sys/systm.h>
52 #include <sys/device.h>
53 #include <sys/malloc.h>
54 #include <sys/buf.h>
55 #include <sys/proc.h>
56 #include <sys/queue.h>
57
58 #include <dev/pci/pcireg.h>
59 #include <dev/pci/pcivar.h>
60
61 #include <machine/bus.h>
62 #include <machine/intr.h>
63
64 #include <scsi/scsi_all.h>
65 #include <scsi/scsi_message.h>
66 #include <scsi/scsi_debug.h>
67 #include <scsi/scsiconf.h>
68
69 #include <uvm/uvm_extern.h>
70
71 #ifdef CAM_NEW_TRAN_CODE
72 #define AHC_NEW_TRAN_SETTINGS
73 #endif
74
75 #if NPCI > 0
76 #define AHC_PCI_CONFIG 1
77 #endif
78
79 #if 0
80 #define AHC_DEBUG AHC_SHOW_SENSE | AHC_SHOW_MISC | AHC_SHOW_CMDS
81 #endif
82
83 #ifdef DEBUG
84 #define bootverbose 1
85 #else
86 #define bootverbose 0
87 #endif
88
89
90 #define SCSI_IS_SCSIBUS_B(ahc, sc_link) \
91 ((sc_link)->scsibus == (ahc)->sc_channel_b.scsibus)
92 #define SCSI_SCSI_ID(ahc, sc_link) \
93 (SCSI_IS_SCSIBUS_B(ahc, sc_link) ? ahc->our_id_b : ahc->our_id)
94 #define SCSI_CHANNEL(ahc, sc_link) \
95 (SCSI_IS_SCSIBUS_B(ahc, sc_link) ? 'B' : 'A')
96 #define BUILD_SCSIID(ahc, sc_link, target_id, our_id) \
97 ((((target_id) << TID_SHIFT) & TID) | (our_id) \
98 | (SCSI_IS_SCSIBUS_B(ahc, sc_link) ? TWIN_CHNLB : 0))
99
100 #ifndef offsetof
101 #define offsetof(type, member) ((size_t)(&((type *)0)->member))
102 #endif
103
104 typedef struct pci_attach_args * ahc_dev_softc_t;
105
106
107
108
109 #define ahc_dmamap_sync(ahc, dma_tag, dmamap, offset, len, op) \
110 bus_dmamap_sync(dma_tag, dmamap, offset, len, op)
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125 #define AHC_NSEG (roundup(btoc(MAXPHYS) + 1, 16))
126
127
128
129
130 #include <dev/ic/aic7xxxvar.h>
131
132
133 struct ahc_platform_data {
134 };
135
136 struct scb_platform_data {
137 };
138
139
140
141
142
143 #ifndef ISABUS_DMA_32BIT
144 #define ISABUS_DMA_32BIT BUS_DMA_BUS1
145 #endif
146
147
148 typedef struct timeout ahc_timer_t;
149
150
151 #if AHC_REG_PRETTY_PRINT
152 #define AIC_DEBUG_REGISTERS 1
153 #else
154 #define AIC_DEBUG_REGISTERS 0
155 #endif
156
157
158 void ahc_timeout(void*);
159
160 #define ahc_timer_init callout_init
161 #define ahc_timer_stop callout_stop
162
163 static __inline void
164 ahc_timer_reset(ahc_timer_t *timer, u_int usec, ahc_callback_t *func, void *arg)
165 {
166 callout_reset(timer, (usec * hz)/1000000, func, arg);
167 }
168
169 static __inline void
170 ahc_scb_timer_reset(struct scb *scb, u_int usec)
171 {
172 if (!(scb->xs->xs_control & XS_CTL_POLL)) {
173 callout_reset(&scb->xs->xs_callout,
174 (usec * hz)/1000000, ahc_timeout, scb);
175 }
176 }
177
178
179 #define ahc_inb(ahc, port) \
180 bus_space_read_1((ahc)->tag, (ahc)->bsh, port)
181
182 #define ahc_outb(ahc, port, value) \
183 bus_space_write_1((ahc)->tag, (ahc)->bsh, port, value)
184
185 #define ahc_outsb(ahc, port, valp, count) \
186 bus_space_write_multi_1((ahc)->tag, (ahc)->bsh, port, valp, count)
187
188 #define ahc_insb(ahc, port, valp, count) \
189 bus_space_read_multi_1((ahc)->tag, (ahc)->bsh, port, valp, count)
190
191 static __inline void ahc_flush_device_writes(struct ahc_softc *);
192
193 static __inline void
194 ahc_flush_device_writes(struct ahc_softc *ahc)
195 {
196
197 ahc_inb(ahc, INTSTAT);
198 }
199
200
201
202
203
204
205 static __inline void ahc_set_transaction_status(struct scb *, uint32_t);
206 static __inline void ahc_set_scsi_status(struct scb *, uint32_t);
207 static __inline uint32_t ahc_get_transaction_status(struct scb *);
208 static __inline uint32_t ahc_get_scsi_status(struct scb *);
209 static __inline void ahc_set_transaction_tag(struct scb *, int, u_int);
210 static __inline u_long ahc_get_transfer_length(struct scb *);
211 static __inline int ahc_get_transfer_dir(struct scb *);
212 static __inline void ahc_set_residual(struct scb *, u_long);
213 static __inline void ahc_set_sense_residual(struct scb *, u_long);
214 static __inline u_long ahc_get_residual(struct scb *);
215 static __inline int ahc_perform_autosense(struct scb *);
216 static __inline uint32_t ahc_get_sense_bufsize(struct ahc_softc *,
217 struct scb *);
218 static __inline void ahc_freeze_scb(struct scb *);
219 static __inline void ahc_platform_freeze_devq(struct ahc_softc *, struct scb *);
220 static __inline int ahc_platform_abort_scbs(struct ahc_softc *, int, char,
221 int, u_int, role_t, uint32_t);
222
223 static __inline
224 void ahc_set_transaction_status(struct scb *scb, uint32_t status)
225 {
226 scb->xs->error = status;
227 }
228
229 static __inline
230 void ahc_set_scsi_status(struct scb *scb, uint32_t status)
231 {
232 scb->xs->status = status;
233 }
234
235 static __inline
236 uint32_t ahc_get_transaction_status(struct scb *scb)
237 {
238 if (scb->xs->flags & ITSDONE)
239 return CAM_REQ_CMP;
240 else
241 return scb->xs->error;
242 }
243
244 static __inline
245 uint32_t ahc_get_scsi_status(struct scb *scb)
246 {
247 return (scb->xs->status);
248 }
249
250 static __inline
251 void ahc_set_transaction_tag(struct scb *scb, int enabled, u_int type)
252 {
253 }
254
255 static __inline
256 u_long ahc_get_transfer_length(struct scb *scb)
257 {
258 return (scb->xs->datalen);
259 }
260
261 static __inline
262 int ahc_get_transfer_dir(struct scb *scb)
263 {
264 return (scb->xs->flags & (SCSI_DATA_IN | SCSI_DATA_OUT));
265 }
266
267 static __inline
268 void ahc_set_residual(struct scb *scb, u_long resid)
269 {
270 scb->xs->resid = resid;
271 }
272
273 static __inline
274 void ahc_set_sense_residual(struct scb *scb, u_long resid)
275 {
276 scb->xs->resid = resid;
277 }
278
279 static __inline
280 u_long ahc_get_residual(struct scb *scb)
281 {
282 return (scb->xs->resid);
283 }
284
285 static __inline
286 int ahc_perform_autosense(struct scb *scb)
287 {
288
289 return (1);
290 }
291
292 static __inline uint32_t
293 ahc_get_sense_bufsize(struct ahc_softc *ahc, struct scb *scb)
294 {
295 return (sizeof(struct scsi_sense_data));
296 }
297
298 static __inline void
299 ahc_freeze_scb(struct scb *scb)
300 {
301 }
302
303 static __inline void
304 ahc_platform_freeze_devq(struct ahc_softc *ahc, struct scb *scb)
305 {
306 }
307
308 static __inline int
309 ahc_platform_abort_scbs(struct ahc_softc *ahc, int target,
310 char channel, int lun, u_int tag,
311 role_t role, uint32_t status)
312 {
313 return (0);
314 }
315
316 static __inline void
317 ahc_platform_scb_free(struct ahc_softc *ahc, struct scb *scb)
318 {
319 int s;
320
321 s = splbio();
322
323 if ((ahc->flags & AHC_RESOURCE_SHORTAGE) != 0) {
324 ahc->flags &= ~AHC_RESOURCE_SHORTAGE;
325 }
326
327 timeout_del(&scb->xs->stimeout);
328
329 splx(s);
330 }
331
332
333 #ifdef AHC_PCI_CONFIG
334 static __inline uint32_t ahc_pci_read_config(ahc_dev_softc_t, int, int);
335 static __inline void ahc_pci_write_config(ahc_dev_softc_t, int, uint32_t,
336 int);
337 static __inline int ahc_get_pci_function(ahc_dev_softc_t);
338 static __inline int ahc_get_pci_slot(ahc_dev_softc_t);
339 static __inline int ahc_get_pci_bus(ahc_dev_softc_t);
340
341 int ahc_pci_map_registers(struct ahc_softc *);
342 int ahc_pci_map_int(struct ahc_softc *);
343
344 static __inline uint32_t
345 ahc_pci_read_config(ahc_dev_softc_t pci, int reg, int width)
346 {
347 return (pci_conf_read(pci->pa_pc, pci->pa_tag, reg));
348 }
349
350 static __inline void
351 ahc_pci_write_config(ahc_dev_softc_t pci, int reg, uint32_t value, int width)
352 {
353 pci_conf_write(pci->pa_pc, pci->pa_tag, reg, value);
354 }
355
356 static __inline int
357 ahc_get_pci_function(ahc_dev_softc_t pci)
358 {
359 return (pci->pa_function);
360 }
361
362 static __inline int
363 ahc_get_pci_slot(ahc_dev_softc_t pci)
364 {
365 return (pci->pa_device);
366 }
367
368 static __inline int
369 ahc_get_pci_bus(ahc_dev_softc_t pci)
370 {
371 return (pci->pa_bus);
372 }
373
374 typedef enum
375 {
376 AHC_POWER_STATE_D0,
377 AHC_POWER_STATE_D1,
378 AHC_POWER_STATE_D2,
379 AHC_POWER_STATE_D3
380 } ahc_power_state;
381
382 void ahc_power_state_change(struct ahc_softc *, ahc_power_state);
383 #endif
384
385 int aic7770_map_registers(struct ahc_softc *, u_int);
386 int aic7770_map_int(struct ahc_softc *, int);
387
388
389 static __inline void ahc_print_path(struct ahc_softc *, struct scb *);
390 static __inline void ahc_platform_dump_card_state(struct ahc_softc *);
391
392 static __inline void
393 ahc_print_path(struct ahc_softc *ahc, struct scb *scb)
394 {
395 sc_print_addr(scb->xs->sc_link);
396 }
397
398 static __inline void
399 ahc_platform_dump_card_state(struct ahc_softc *ahc)
400 {
401
402 printf("FEATURES = 0x%x, FLAGS = 0x%x, CHIP = 0x%x BUGS =0x%x\n",
403 ahc->features, ahc->flags, ahc->chip, ahc->bugs);
404 }
405
406 void ahc_notify_xfer_settings_change(struct ahc_softc *,
407 struct ahc_devinfo *);
408 void ahc_platform_set_tags(struct ahc_softc *, struct ahc_devinfo *, int);
409
410
411 int ahc_platform_alloc(struct ahc_softc *, void *);
412 void ahc_platform_free(struct ahc_softc *);
413 int ahc_map_int(struct ahc_softc *);
414 int ahc_attach(struct ahc_softc *);
415 int ahc_softc_comp(struct ahc_softc *, struct ahc_softc *);
416 int ahc_detach(struct device *, int);
417
418
419 int ahc_platform_intr(void *);
420 static __inline void ahc_platform_flushwork(struct ahc_softc *);
421 static __inline void
422 ahc_platform_flushwork(struct ahc_softc *ahc)
423 {
424 }
425
426
427 void ahc_done(struct ahc_softc *, struct scb *);
428 void ahc_send_async(struct ahc_softc *, char, u_int, u_int, ac_code,
429 void *);
430
431 #endif