Lines Matching defs:hd
65 static int wait_for_select(volatile struct scsidevice *hd);
68 static int ixfer_in(volatile struct scsidevice *hd, int, uint8_t *);
121 volatile struct scsidevice *hd;
126 hd = (void *)hs->sc_addr;
127 hd->scsi_id = 0xFF;
132 hd->scsi_csr = 0;
133 hd->scsi_sctl = SCTL_DISABLE | SCTL_CTRLRST;
134 hd->scsi_scmd = 0;
135 hd->scsi_tmod = 0;
136 hd->scsi_pctl = 0;
137 hd->scsi_temp = 0;
138 hd->scsi_tch = 0;
139 hd->scsi_tcm = 0;
140 hd->scsi_tcl = 0;
141 hd->scsi_ints = 0;
147 i = (~hd->scsi_hconf) & 0x7;
149 hd->scsi_bdid = i;
150 if (hd->scsi_hconf & HCONF_PARITY)
151 hd->scsi_sctl = SCTL_DISABLE | SCTL_ABRT_ENAB |
155 hd->scsi_sctl = SCTL_DISABLE | SCTL_ABRT_ENAB |
158 hd->scsi_sctl &=~ SCTL_DISABLE;
163 scsiabort(struct scsi_softc *hs, volatile struct scsidevice *hd)
173 issue_select(volatile struct scsidevice *hd, uint8_t target, uint8_t our_addr)
176 if (hd->scsi_ssts & (SSTS_INITIATOR|SSTS_TARGET|SSTS_BUSY))
179 if (hd->scsi_ints & INTS_DISCON)
180 hd->scsi_ints = INTS_DISCON;
182 hd->scsi_pctl = 0;
183 hd->scsi_temp = (1 << target) | our_addr;
185 hd->scsi_tch = 2;
186 hd->scsi_tcm = 113;
187 hd->scsi_tcl = 3;
189 hd->scsi_scmd = SCMD_SELECT;
194 wait_for_select(volatile struct scsidevice *hd)
200 while ((ints = hd->scsi_ints) == 0) {
205 hd->scsi_ints = ints;
206 return !(hd->scsi_ssts & SSTS_INITIATOR);
210 ixfer_start(volatile struct scsidevice *hd, int len, uint8_t phase, int wait)
213 hd->scsi_tch = len >> 16;
214 hd->scsi_tcm = len >> 8;
215 hd->scsi_tcl = len;
216 hd->scsi_pctl = phase;
217 hd->scsi_tmod = 0; /*XXX*/
218 hd->scsi_scmd = SCMD_XFR | SCMD_PROG_XFR;
221 while ((hd->scsi_ssts & SSTS_BUSY) == 0) {
222 if (hd->scsi_ints || --wait < 0)
230 ixfer_out(volatile struct scsidevice *hd, int len, uint8_t *buf)
235 while (hd->scsi_ssts & SSTS_DREG_FULL) {
236 if (hd->scsi_ints || --wait < 0)
240 hd->scsi_dreg = *buf++;
246 ixfer_in(volatile struct scsidevice *hd, int len, uint8_t *buf)
251 while (hd->scsi_ssts & SSTS_DREG_EMPTY) {
252 if (hd->scsi_ints || --wait < 0) {
253 while (! (hd->scsi_ssts & SSTS_DREG_EMPTY)) {
254 *buf++ = hd->scsi_dreg;
261 *buf++ = hd->scsi_dreg;
270 volatile struct scsidevice *hd = (void *)hs->sc_addr;
275 if (issue_select(hd, target, hs->sc_scsi_addr))
277 if (wait_for_select(hd))
290 if (ixfer_start(hd, clen, phase, wait))
291 if (ixfer_out(hd, clen, cbuf))
300 if (ixfer_start(hd, len, phase, wait) ||
301 !(hd->scsi_ssts & SSTS_DREG_EMPTY))
302 ixfer_in(hd, len, buf);
310 if (ixfer_start(hd, len, phase, wait))
311 if (ixfer_out(hd, len, buf))
318 if (ixfer_start(hd, sizeof(hs->sc_stat), phase, wait) ||
319 !(hd->scsi_ssts & SSTS_DREG_EMPTY))
320 ixfer_in(hd, sizeof(hs->sc_stat),
326 if (ixfer_start(hd, sizeof(hs->sc_msg), phase, wait) ||
327 !(hd->scsi_ssts & SSTS_DREG_EMPTY)) {
328 ixfer_in(hd, sizeof(hs->sc_msg),
330 hd->scsi_scmd = SCMD_RST_ACK;
353 while ((ints = hd->scsi_ints) == 0) {
358 hd->scsi_ints = ints;
360 phase = hd->scsi_psns & PHASE;
367 scsiabort(hs, hd);