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 #ifndef _IC_CACVAR_H_
41 #define _IC_CACVAR_H_
42
43 #define CAC_MAX_CCBS 128
44 #define CAC_MAX_XFER (0xffff * 512)
45 #define CAC_SG_SIZE 32
46 #define CAC_SECTOR_SIZE 512
47
48 #define cac_inb(sc, port) \
49 bus_space_read_1((sc)->sc_iot, (sc)->sc_ioh, port)
50 #define cac_inw(sc, port) \
51 bus_space_read_2((sc)->sc_iot, (sc)->sc_ioh, port)
52 #define cac_inl(sc, port) \
53 bus_space_read_4((sc)->sc_iot, (sc)->sc_ioh, port)
54 #define cac_outb(sc, port, val) \
55 bus_space_write_1((sc)->sc_iot, (sc)->sc_ioh, port, val)
56 #define cac_outw(sc, port, val) \
57 bus_space_write_2((sc)->sc_iot, (sc)->sc_ioh, port, val)
58 #define cac_outl(sc, port, val) \
59 bus_space_write_4((sc)->sc_iot, (sc)->sc_ioh, port, val)
60
61
62
63
64
65 #define CAC_GET1(x) \
66 (((u_char *)&(x))[0])
67 #define CAC_GET2(x) \
68 (((u_char *)&(x))[0] | (((u_char *)&(x))[1] << 8))
69 #define CAC_GET4(x) \
70 ((((u_char *)&(x))[0] | (((u_char *)&(x))[1] << 8)) | \
71 (((u_char *)&(x))[0] << 16 | (((u_char *)&(x))[1] << 24)))
72
73 struct cac_ccb {
74
75 struct cac_hdr ccb_hdr;
76 struct cac_req ccb_req;
77 struct cac_sgb ccb_seg[CAC_SG_SIZE];
78
79
80 int ccb_flags;
81 int ccb_datasize;
82 paddr_t ccb_paddr;
83 bus_dmamap_t ccb_dmamap_xfer;
84 SIMPLEQ_ENTRY(cac_ccb) ccb_chain;
85 struct scsi_xfer *ccb_xs;
86 };
87
88 #define CAC_CCB_DATA_IN 0x0001
89 #define CAC_CCB_DATA_OUT 0x0002
90 #define CAC_CCB_ACTIVE 0x0004
91
92 struct cac_softc;
93
94 struct cac_linkage {
95 struct cac_ccb *(*cl_completed)(struct cac_softc *);
96 int (*cl_fifo_full)(struct cac_softc *);
97 void (*cl_intr_enable)(struct cac_softc *, int);
98 int (*cl_intr_pending)(struct cac_softc *);
99 void (*cl_submit)(struct cac_softc *, struct cac_ccb *);
100 };
101
102 struct cac_softc {
103 struct device sc_dv;
104 bus_space_tag_t sc_iot;
105 bus_space_handle_t sc_ioh;
106 bus_dma_tag_t sc_dmat;
107 bus_dmamap_t sc_dmamap;
108 int sc_nunits;
109 void *sc_ih;
110 struct scsi_link sc_link;
111 const struct cac_linkage *sc_cl;
112 caddr_t sc_ccbs;
113 paddr_t sc_ccbs_paddr;
114 SIMPLEQ_HEAD(, cac_ccb) sc_ccb_free;
115 SIMPLEQ_HEAD(, cac_ccb) sc_ccb_queue;
116 struct cac_drive_info *sc_dinfos;
117 };
118
119 int cac_init(struct cac_softc *, int);
120 int cac_intr(void *);
121
122 extern const struct cac_linkage cac_l0;
123
124 #endif