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 #include <sys/sensors.h>
31
32 struct ami_mem {
33 bus_dmamap_t am_map;
34 bus_dma_segment_t am_seg;
35 size_t am_size;
36 caddr_t am_kva;
37 };
38
39 #define AMIMEM_MAP(_am) ((_am)->am_map)
40 #define AMIMEM_DVA(_am) ((_am)->am_map->dm_segs[0].ds_addr)
41 #define AMIMEM_KVA(_am) ((void *)(_am)->am_kva)
42
43 struct ami_ccbmem {
44 struct ami_passthrough cd_pt;
45 struct ami_sgent cd_sg[AMI_SGEPERCMD];
46 };
47
48 struct ami_softc;
49
50 struct ami_ccb {
51 struct ami_softc *ccb_sc;
52
53 struct ami_iocmd ccb_cmd;
54 struct ami_passthrough *ccb_pt;
55 paddr_t ccb_ptpa;
56 struct ami_sgent *ccb_sglist;
57 paddr_t ccb_sglistpa;
58 int ccb_offset;
59 bus_dmamap_t ccb_dmamap;
60
61 struct scsi_xfer *ccb_xs;
62 void (*ccb_done)(struct ami_softc *sc,
63 struct ami_ccb *ccb);
64
65 volatile enum {
66 AMI_CCB_FREE,
67 AMI_CCB_READY,
68 AMI_CCB_QUEUED,
69 AMI_CCB_PREQUEUED
70 } ccb_state;
71 int ccb_flags;
72 #define AMI_CCB_F_ERR (1<<0)
73 TAILQ_ENTRY(ami_ccb) ccb_link;
74 };
75
76 TAILQ_HEAD(ami_ccb_list, ami_ccb);
77
78 struct ami_rawsoftc {
79 struct scsi_link sc_link;
80 struct ami_softc *sc_softc;
81 u_int8_t sc_channel;
82
83 int sc_proctarget;
84 char sc_procdev[16];
85 };
86
87 struct ami_softc {
88 struct device sc_dev;
89 void *sc_ih;
90 struct scsi_link sc_link;
91
92 int sc_flags;
93 #define AMI_CHECK_SIGN 0x0001
94 #define AMI_BROKEN 0x0002
95 #define AMI_QUARTZ 0x0008
96
97
98 int (*sc_init)(struct ami_softc *sc);
99 int (*sc_exec)(struct ami_softc *sc,
100 struct ami_iocmd *);
101 int (*sc_done)(struct ami_softc *sc,
102 struct ami_iocmd *);
103 int (*sc_poll)(struct ami_softc *sc,
104 struct ami_iocmd *);
105 int (*sc_ioctl)(struct device *, u_long, caddr_t);
106
107 bus_space_tag_t sc_iot;
108 bus_space_handle_t sc_ioh;
109 bus_dma_tag_t sc_dmat;
110
111 struct ami_mem *sc_mbox_am;
112 volatile struct ami_iocmd *sc_mbox;
113 paddr_t sc_mbox_pa;
114
115 struct ami_ccb *sc_ccbs;
116 struct ami_ccb_list sc_ccb_freeq, sc_ccb_preq, sc_ccb_runq;
117
118 struct ami_mem *sc_ccbmem_am;
119
120 int sc_timeout;
121 struct timeout sc_run_tmo;
122 int sc_dis_poll;
123
124 struct rwlock sc_lock;
125
126 char sc_fwver[16];
127 char sc_biosver[16];
128 int sc_maxcmds;
129 int sc_memory;
130 int sc_targets;
131 int sc_channels;
132 int sc_maxunits;
133 int sc_nunits;
134 struct {
135 u_int8_t hd_present;
136 u_int8_t hd_is_logdrv;
137 u_int8_t hd_prop;
138 u_int8_t hd_stat;
139 u_int32_t hd_size;
140 char dev[16];
141 } sc_hdr[AMI_BIG_MAX_LDRIVES];
142 struct ami_rawsoftc *sc_rawsoftcs;
143
144 struct ksensor *sc_sensors;
145 struct ksensordev sc_sensordev;
146 struct ami_big_diskarray *sc_bd;
147 };
148
149 int ami_attach(struct ami_softc *sc);
150 int ami_intr(void *);
151
152 int ami_quartz_init(struct ami_softc *sc);
153 int ami_quartz_exec(struct ami_softc *sc, struct ami_iocmd *);
154 int ami_quartz_done(struct ami_softc *sc, struct ami_iocmd *);
155 int ami_quartz_poll(struct ami_softc *sc, struct ami_iocmd *);
156
157 int ami_schwartz_init(struct ami_softc *sc);
158 int ami_schwartz_exec(struct ami_softc *sc, struct ami_iocmd *);
159 int ami_schwartz_done(struct ami_softc *sc, struct ami_iocmd *);
160 int ami_schwartz_poll(struct ami_softc *sc, struct ami_iocmd *);
161
162 #ifdef AMI_DEBUG
163 void ami_print_mbox(struct ami_iocmd *);
164 #endif