Deleted Added
full compact
aic7xxx.seq (41299) aic7xxx.seq (41646)
1/*
2 * Adaptec 274x/284x/294x device driver firmware for Linux and FreeBSD.
3 *
4 * Copyright (c) 1994-1998 Justin Gibbs.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 18 unchanged lines hidden (view full) ---

27 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
1/*
2 * Adaptec 274x/284x/294x device driver firmware for Linux and FreeBSD.
3 *
4 * Copyright (c) 1994-1998 Justin Gibbs.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 18 unchanged lines hidden (view full) ---

27 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * $Id: aic7xxx.seq,v 1.79 1998/09/21 16:46:13 gibbs Exp $
35 * $Id: aic7xxx.seq,v 1.80 1998/11/23 01:33:47 gibbs Exp $
36 */
37
38#include <dev/aic7xxx/aic7xxx.reg>
39#include <cam/scsi/scsi_message.h>
40
41/*
42 * A few words on the waiting SCB list:
43 * After starting the selection hardware, we check for reconnecting targets

--- 9 unchanged lines hidden (view full) ---

53 * SCB_LIST_NULL is 0xff which is out of range. An entry is also added to
54 * this list everytime a request sense occurs or after completing a non-tagged
55 * command for which a second SCB has been queued. The sequencer will
56 * automatically consume the entries.
57 */
58
59reset:
60 clr SCSISIGO; /* De-assert BSY */
36 */
37
38#include <dev/aic7xxx/aic7xxx.reg>
39#include <cam/scsi/scsi_message.h>
40
41/*
42 * A few words on the waiting SCB list:
43 * After starting the selection hardware, we check for reconnecting targets

--- 9 unchanged lines hidden (view full) ---

53 * SCB_LIST_NULL is 0xff which is out of range. An entry is also added to
54 * this list everytime a request sense occurs or after completing a non-tagged
55 * command for which a second SCB has been queued. The sequencer will
56 * automatically consume the entries.
57 */
58
59reset:
60 clr SCSISIGO; /* De-assert BSY */
61 and SXFRCTL1, ~BITBUCKET;
61 /* Always allow reselection */
62 if ((ahc->flags & AHC_TARGETMODE) != 0) {
63 mvi SCSISEQ, ENSELI|ENRSELI|ENAUTOATNP;
64 } else {
65 mvi SCSISEQ, ENRSELI|ENAUTOATNP;
66 }
67
68 if ((ahc->features & AHC_CMD_CHAN) != 0) {

--- 111 unchanged lines hidden (view full) ---

180 and A, TID, SCB_TCL; /* Get target ID */
181 and SCSIID, OID; /* Clear old target */
182 or SCSIID, A;
183 }
184 if ((ahc->flags & AHC_TARGETMODE) != 0) {
185 and SINDEX, TARGET_SCB, SCB_CONTROL;
186 or SCSISEQ, ENSELO|ENAUTOATNO|ENSELI
187 |ENRSELI|ENAUTOATNP, SINDEX ret ;
62 /* Always allow reselection */
63 if ((ahc->flags & AHC_TARGETMODE) != 0) {
64 mvi SCSISEQ, ENSELI|ENRSELI|ENAUTOATNP;
65 } else {
66 mvi SCSISEQ, ENRSELI|ENAUTOATNP;
67 }
68
69 if ((ahc->features & AHC_CMD_CHAN) != 0) {

--- 111 unchanged lines hidden (view full) ---

181 and A, TID, SCB_TCL; /* Get target ID */
182 and SCSIID, OID; /* Clear old target */
183 or SCSIID, A;
184 }
185 if ((ahc->flags & AHC_TARGETMODE) != 0) {
186 and SINDEX, TARGET_SCB, SCB_CONTROL;
187 or SCSISEQ, ENSELO|ENAUTOATNO|ENSELI
188 |ENRSELI|ENAUTOATNP, SINDEX ret ;
188 } else {
189 } else if ((ahc->flags & AHC_INITIATORMODE) != 0) {
189 mvi SCSISEQ, ENSELO|ENAUTOATNO|ENRSELI|ENAUTOATNP ret;
190 }
191
192/*
193 * Initialize transfer settings and clear the SCSI channel.
194 * SINDEX should contain any additional bit's the client wants
195 * set in SXFRCTL0. We also assume that the current SCB is
196 * a valid SCB for the target we wish to talk to.

--- 14 unchanged lines hidden (view full) ---

211 mov SCSIRATE, SCB_SCSIRATE ret;
212 }
213
214selection:
215 test SSTAT0,SELDO jnz select_out;
216 mvi CLRSINT0, CLRSELDI;
217select_in:
218 if ((ahc->flags & AHC_TARGETMODE) != 0) {
190 mvi SCSISEQ, ENSELO|ENAUTOATNO|ENRSELI|ENAUTOATNP ret;
191 }
192
193/*
194 * Initialize transfer settings and clear the SCSI channel.
195 * SINDEX should contain any additional bit's the client wants
196 * set in SXFRCTL0. We also assume that the current SCB is
197 * a valid SCB for the target we wish to talk to.

--- 14 unchanged lines hidden (view full) ---

212 mov SCSIRATE, SCB_SCSIRATE ret;
213 }
214
215selection:
216 test SSTAT0,SELDO jnz select_out;
217 mvi CLRSINT0, CLRSELDI;
218select_in:
219 if ((ahc->flags & AHC_TARGETMODE) != 0) {
219 test SSTAT0, TARGET jz initiator_reselect;
220 if ((ahc->flags & AHC_INITIATORMODE) != 0) {
221 test SSTAT0, TARGET jz initiator_reselect;
222 }
220 /*
221 * We've just been selected. Assert BSY and
222 * setup the phase for receiving messages
223 * from the target.
224 */
223 /*
224 * We've just been selected. Assert BSY and
225 * setup the phase for receiving messages
226 * from the target.
227 */
228
225 mvi SCSISIGO, P_MESGOUT|BSYO;
229 mvi SCSISIGO, P_MESGOUT|BSYO;
230 mvi CLRSINT1, CLRBUSFREE;
226
227 /*
228 * LAST_MSG gives an indication to the host of what
229 * went wrong should we need to terminate this selection
230 * before doing real work. Initialize it to SCB_LIST_NULL to
231 * indicate an improper initiator selection.
232 */
233 mvi LAST_MSG, SCB_LIST_NULL;

--- 45 unchanged lines hidden (view full) ---

279 */
280 test SCSISIGI, ATNI jz target_busfree;
281
282 /*
283 * Watch ATN closely now as we pull in messages from the
284 * initiator. We follow the guidlines from section 6.5
285 * of the SCSI-2 spec for what messages are allowed when.
286 */
231
232 /*
233 * LAST_MSG gives an indication to the host of what
234 * went wrong should we need to terminate this selection
235 * before doing real work. Initialize it to SCB_LIST_NULL to
236 * indicate an improper initiator selection.
237 */
238 mvi LAST_MSG, SCB_LIST_NULL;

--- 45 unchanged lines hidden (view full) ---

284 */
285 test SCSISIGI, ATNI jz target_busfree;
286
287 /*
288 * Watch ATN closely now as we pull in messages from the
289 * initiator. We follow the guidlines from section 6.5
290 * of the SCSI-2 spec for what messages are allowed when.
291 */
287 call targ_inb;
292 call target_inb;
288
289 /*
290 * Our first message must be one of IDENTIFY, ABORT, or
291 * BUS_DEVICE_RESET.
292 */
293 /* XXX May need to be more lax here for older initiators... */
294 test DINDEX, MSG_IDENTIFYFLAG jz more_first_messages;
295 /* Store for host */

--- 4 unchanged lines hidden (view full) ---

300 }
301
302 /* Remember for disconnection decision */
303 test DINDEX, MSG_IDENTIFY_DISCFLAG jnz . + 2;
304 /* XXX Honor per target settings too */
305 or SEQ_FLAGS, NO_DISCONNECT;
306
307 test SCSISIGI, ATNI jz ident_messages_done;
293
294 /*
295 * Our first message must be one of IDENTIFY, ABORT, or
296 * BUS_DEVICE_RESET.
297 */
298 /* XXX May need to be more lax here for older initiators... */
299 test DINDEX, MSG_IDENTIFYFLAG jz more_first_messages;
300 /* Store for host */

--- 4 unchanged lines hidden (view full) ---

305 }
306
307 /* Remember for disconnection decision */
308 test DINDEX, MSG_IDENTIFY_DISCFLAG jnz . + 2;
309 /* XXX Honor per target settings too */
310 or SEQ_FLAGS, NO_DISCONNECT;
311
312 test SCSISIGI, ATNI jz ident_messages_done;
308 call targ_inb;
313 call target_inb;
309 /*
310 * If this is a tagged request, the tagged message must
311 * immediately follow the identify. We test for a valid
312 * tag message by seeing if it is >= MSG_SIMPLE_Q_TAG and
313 * < MSG_IGN_WIDE_RESIDUE.
314 */
315 add A, -MSG_SIMPLE_Q_TAG, DINDEX;
316 jnc ident_messages_done;

--- 10 unchanged lines hidden (view full) ---

327 * If the initiator doesn't feel like providing a tag number,
328 * we've got a failed selection and must transition to bus
329 * free.
330 */
331 test SCSISIGI, ATNI jz target_busfree;
332 /*
333 * Store the tag for the host.
334 */
314 /*
315 * If this is a tagged request, the tagged message must
316 * immediately follow the identify. We test for a valid
317 * tag message by seeing if it is >= MSG_SIMPLE_Q_TAG and
318 * < MSG_IGN_WIDE_RESIDUE.
319 */
320 add A, -MSG_SIMPLE_Q_TAG, DINDEX;
321 jnc ident_messages_done;

--- 10 unchanged lines hidden (view full) ---

332 * If the initiator doesn't feel like providing a tag number,
333 * we've got a failed selection and must transition to bus
334 * free.
335 */
336 test SCSISIGI, ATNI jz target_busfree;
337 /*
338 * Store the tag for the host.
339 */
335 call targ_inb;
340 call target_inb;
336 if ((ahc->features & AHC_CMD_CHAN) != 0) {
337 mov CCSCBRAM, DINDEX;
338 } else {
339 mov DFDAT, DINDEX;
340 }
341 jmp ident_messages_done;
342
341 if ((ahc->features & AHC_CMD_CHAN) != 0) {
342 mov CCSCBRAM, DINDEX;
343 } else {
344 mov DFDAT, DINDEX;
345 }
346 jmp ident_messages_done;
347
348 /*
349 * Pushed message loop to allow the kernel to
350 * run it's own message state engine. To avoid an
351 * extra nop instruction after signaling the kernel,
352 * we perform the phase_lock before checking to see
353 * if we should exit the loop and skip the phase_lock
354 * in the ITloop. Performing back to back phase_locks
355 * shouldn't hurt, but why do it twice...
356 */
357host_target_message_loop:
358 mvi INTSTAT, HOST_MSG_LOOP;
359 nop;
360 cmp RETURN_1, EXIT_MSG_LOOP je target_ITloop;
361 test SSTAT0, SPIORDY jz .;
362 jmp host_target_message_loop;
363
343more_first_messages:
344 /*
345 * Hmm. Now we're down to only accepting
346 * either an ABORT or BDR.
347 */
348 cmp DINDEX, MSG_ABORT je . + 2;
349 cmp DINDEX, MSG_BUS_DEV_RESET jne target_busfree;
350

--- 5 unchanged lines hidden (view full) ---

356 mvi LAST_MSG, MSG_NOOP; /* We are so far successful */
357 /* Terminate the ident list */
358 if ((ahc->features & AHC_CMD_CHAN) != 0) {
359 mvi CCSCBRAM, SCB_LIST_NULL;
360 } else {
361 mvi DFDAT, SCB_LIST_NULL;
362 }
363 or SEQ_FLAGS, TARG_CMD_PENDING;
364more_first_messages:
365 /*
366 * Hmm. Now we're down to only accepting
367 * either an ABORT or BDR.
368 */
369 cmp DINDEX, MSG_ABORT je . + 2;
370 cmp DINDEX, MSG_BUS_DEV_RESET jne target_busfree;
371

--- 5 unchanged lines hidden (view full) ---

377 mvi LAST_MSG, MSG_NOOP; /* We are so far successful */
378 /* Terminate the ident list */
379 if ((ahc->features & AHC_CMD_CHAN) != 0) {
380 mvi CCSCBRAM, SCB_LIST_NULL;
381 } else {
382 mvi DFDAT, SCB_LIST_NULL;
383 }
384 or SEQ_FLAGS, TARG_CMD_PENDING;
385 test SCSISIGI, ATNI jnz target_mesgout_pending_msg;
364 jmp target_ITloop;
365
366/*
367 * We carefully toggle SPIOEN to allow us to return the
368 * message byte we receive so it can be checked prior to
369 * driving REQ on the bus for the next byte.
370 */
386 jmp target_ITloop;
387
388/*
389 * We carefully toggle SPIOEN to allow us to return the
390 * message byte we receive so it can be checked prior to
391 * driving REQ on the bus for the next byte.
392 */
371targ_inb:
372 /* Drive REQ on the bus by enabling SCSI PIO */
393target_inb:
394 /*
395 * Drive REQ on the bus by enabling SCSI PIO.
396 */
373 or SXFRCTL0, SPIOEN;
374 /* Wait for the byte */
375 test SSTAT0, SPIORDY jz .;
376 /* Prevent our read from triggering another REQ */
377 and SXFRCTL0, ~SPIOEN;
397 or SXFRCTL0, SPIOEN;
398 /* Wait for the byte */
399 test SSTAT0, SPIORDY jz .;
400 /* Prevent our read from triggering another REQ */
401 and SXFRCTL0, ~SPIOEN;
402 /* Save latched contents */
378 mov DINDEX, SCSIDATL ret;
379 }
380
403 mov DINDEX, SCSIDATL ret;
404 }
405
406if ((ahc->flags & AHC_INITIATORMODE) != 0) {
381/*
382 * Reselection has been initiated by a target. Make a note that we've been
383 * reselected, but haven't seen an IDENTIFY message from the target yet.
384 */
385initiator_reselect:
386 /* XXX test for and handle ONE BIT condition */
387 and SAVED_TCL, SELID_MASK, SELID;
388 if ((ahc->features & AHC_TWIN) != 0) {
389 test SBLKCTL, SELBUSB jz . + 2;
390 or SAVED_TCL, SELBUSB;
391 }
407/*
408 * Reselection has been initiated by a target. Make a note that we've been
409 * reselected, but haven't seen an IDENTIFY message from the target yet.
410 */
411initiator_reselect:
412 /* XXX test for and handle ONE BIT condition */
413 and SAVED_TCL, SELID_MASK, SELID;
414 if ((ahc->features & AHC_TWIN) != 0) {
415 test SBLKCTL, SELBUSB jz . + 2;
416 or SAVED_TCL, SELBUSB;
417 }
392 or SXFRCTL0, SPIOEN|CLRCHN;
418 or SXFRCTL0, SPIOEN|CLRSTCNT|CLRCHN;
393 mvi CLRSINT1,CLRBUSFREE;
394 or SIMODE1, ENBUSFREE; /*
395 * We aren't expecting a
396 * bus free, so interrupt
397 * the kernel driver if it
398 * happens.
399 */
400 mvi MSG_OUT, MSG_NOOP; /* No message to send */
401 jmp ITloop;
419 mvi CLRSINT1,CLRBUSFREE;
420 or SIMODE1, ENBUSFREE; /*
421 * We aren't expecting a
422 * bus free, so interrupt
423 * the kernel driver if it
424 * happens.
425 */
426 mvi MSG_OUT, MSG_NOOP; /* No message to send */
427 jmp ITloop;
428}
402
403/*
404 * After the selection, remove this SCB from the "waiting SCB"
405 * list. This is achieved by simply moving our "next" pointer into
406 * WAITING_SCBH. Our next pointer will be set to null the next time this
407 * SCB is used, so don't bother with it now.
408 */
409select_out:
410 /* Turn off the selection hardware */
411 if ((ahc->flags & AHC_TARGETMODE) != 0) {
412 mvi SCSISEQ, ENSELI|ENRSELI|ENAUTOATNP;
429
430/*
431 * After the selection, remove this SCB from the "waiting SCB"
432 * list. This is achieved by simply moving our "next" pointer into
433 * WAITING_SCBH. Our next pointer will be set to null the next time this
434 * SCB is used, so don't bother with it now.
435 */
436select_out:
437 /* Turn off the selection hardware */
438 if ((ahc->flags & AHC_TARGETMODE) != 0) {
439 mvi SCSISEQ, ENSELI|ENRSELI|ENAUTOATNP;
413 } else {
440 } else if ((ahc->flags & AHC_INITIATORMODE) != 0) {
414 mvi SCSISEQ, ENRSELI|ENAUTOATNP;
415 }
416 mvi CLRSINT0, CLRSELDO;
417 mov SCBPTR, WAITING_SCBH;
418 mov WAITING_SCBH,SCB_NEXT;
419 mov SAVED_TCL, SCB_TCL;
420 if ((ahc->flags & AHC_TARGETMODE) != 0) {
421 test SSTAT0, TARGET jz initiator_select;
422
423 /*
424 * We've just re-selected an initiator.
425 * Assert BSY and setup the phase for
426 * sending our identify messages.
427 */
441 mvi SCSISEQ, ENRSELI|ENAUTOATNP;
442 }
443 mvi CLRSINT0, CLRSELDO;
444 mov SCBPTR, WAITING_SCBH;
445 mov WAITING_SCBH,SCB_NEXT;
446 mov SAVED_TCL, SCB_TCL;
447 if ((ahc->flags & AHC_TARGETMODE) != 0) {
448 test SSTAT0, TARGET jz initiator_select;
449
450 /*
451 * We've just re-selected an initiator.
452 * Assert BSY and setup the phase for
453 * sending our identify messages.
454 */
428 mvi SCSISIGO, P_MESGIN|BSYO;
455 mvi P_MESGIN|BSYO call change_phase;
456 mvi CLRSINT1,CLRBUSFREE;
429
430 /*
431 * Start out with a simple identify message.
432 */
433 and A, LID, SCB_TCL;
434 or A, MSG_IDENTIFYFLAG call target_outb;
435
436 /*

--- 7 unchanged lines hidden (view full) ---

444 /*
445 * Now determine what phases the host wants us
446 * to go through.
447 */
448 mov SEQ_FLAGS, SCB_TARGET_PHASES;
449
450target_ITloop:
451 /*
457
458 /*
459 * Start out with a simple identify message.
460 */
461 and A, LID, SCB_TCL;
462 or A, MSG_IDENTIFYFLAG call target_outb;
463
464 /*

--- 7 unchanged lines hidden (view full) ---

472 /*
473 * Now determine what phases the host wants us
474 * to go through.
475 */
476 mov SEQ_FLAGS, SCB_TARGET_PHASES;
477
478target_ITloop:
479 /*
452 * XXX Start honoring ATN signals now that
453 * we properly identified ourself.
480 * Start honoring ATN signals now that
481 * we properly identified ourself.
454 */
482 */
483 test SCSISIGI, ATNI jnz target_mesgout;
455 test SEQ_FLAGS, CMDPHASE_PENDING jnz target_cmdphase;
456 test SEQ_FLAGS, DPHASE_PENDING jnz target_dphase;
457 test SEQ_FLAGS, SPHASE_PENDING jnz target_sphase;
458
459 /*
460 * No more work to do. Either disconnect or not depending
461 * on the state of NO_DISCONNECT.
462 */
463 test SEQ_FLAGS, NO_DISCONNECT jz target_disconnect;
464 if ((ahc->flags & AHC_PAGESCBS) != 0) {
465 mov ALLZEROS call get_free_or_disc_scb;
466 }
484 test SEQ_FLAGS, CMDPHASE_PENDING jnz target_cmdphase;
485 test SEQ_FLAGS, DPHASE_PENDING jnz target_dphase;
486 test SEQ_FLAGS, SPHASE_PENDING jnz target_sphase;
487
488 /*
489 * No more work to do. Either disconnect or not depending
490 * on the state of NO_DISCONNECT.
491 */
492 test SEQ_FLAGS, NO_DISCONNECT jz target_disconnect;
493 if ((ahc->flags & AHC_PAGESCBS) != 0) {
494 mov ALLZEROS call get_free_or_disc_scb;
495 }
496 mov RETURN_1, ALLZEROS;
467 call complete_target_cmd;
497 call complete_target_cmd;
498 cmp RETURN_1, CONT_MSG_LOOP jne .;
468 mvi DMAPARAMS, HDMAEN|DIRECTION|FIFORESET;
469 mov SCB_TAG call dma_scb;
470 jmp target_synccmd;
471
499 mvi DMAPARAMS, HDMAEN|DIRECTION|FIFORESET;
500 mov SCB_TAG call dma_scb;
501 jmp target_synccmd;
502
503target_mesgout:
504 mvi SCSISIGO, P_MESGOUT|BSYO;
505 call target_inb;
506 /* Local Processing goes here... */
507target_mesgout_pending_msg:
508 jmp host_target_message_loop;
509
472target_disconnect:
510target_disconnect:
473 mvi SCSISIGO, P_MESGIN|BSYO;
511 mvi P_MESGIN|BSYO call change_phase;
474 mvi MSG_DISCONNECT call target_outb;
475
476target_busfree:
512 mvi MSG_DISCONNECT call target_outb;
513
514target_busfree:
477 and SXFRCTL0, ~SPIOEN;
478 clr SCSISIGO;
479 call complete_target_cmd;
480 cmp LAST_MSG, MSG_NOOP je . + 2;
481 mvi INTSTAT, TARGET_MSG_HELP;
482 call clear_target_state;
483 jmp poll_for_work;
484
485target_cmdphase:
515 clr SCSISIGO;
516 call complete_target_cmd;
517 cmp LAST_MSG, MSG_NOOP je . + 2;
518 mvi INTSTAT, TARGET_MSG_HELP;
519 call clear_target_state;
520 jmp poll_for_work;
521
522target_cmdphase:
486 mvi SCSISIGO, P_COMMAND|BSYO;
487 call targ_inb;
523 mvi P_COMMAND|BSYO call change_phase;
524 call target_inb;
488 mov A, DINDEX;
489 /* Store for host */
490 if ((ahc->features & AHC_CMD_CHAN) != 0) {
491 mov CCSCBRAM, A;
492 } else {
493 mov DFDAT, A;
494 }
495

--- 27 unchanged lines hidden (view full) ---

523 and SEQ_FLAGS, ~CMDPHASE_PENDING;
524 jmp target_ITloop;
525
526target_dphase:
527 /*
528 * Data direction flags are from the
529 * perspective of the initiator.
530 */
525 mov A, DINDEX;
526 /* Store for host */
527 if ((ahc->features & AHC_CMD_CHAN) != 0) {
528 mov CCSCBRAM, A;
529 } else {
530 mov DFDAT, A;
531 }
532

--- 27 unchanged lines hidden (view full) ---

560 and SEQ_FLAGS, ~CMDPHASE_PENDING;
561 jmp target_ITloop;
562
563target_dphase:
564 /*
565 * Data direction flags are from the
566 * perspective of the initiator.
567 */
531 and SXFRCTL0, ~SPIOEN;
532 or SXFRCTL0, CLRCHN;
568 mov ALLZEROS call initialize_channel;
533 test SCB_TARGET_PHASES[1], TARGET_DATA_IN jz . + 4;
569 test SCB_TARGET_PHASES[1], TARGET_DATA_IN jz . + 4;
534 mvi SCSISIGO, P_DATAIN|BSYO;
535 mvi LASTPHASE, P_DATAOUT;
570 mvi LASTPHASE, P_DATAOUT;
571 mvi P_DATAIN|BSYO call change_phase;
536 jmp p_data;
572 jmp p_data;
537 mvi SCSISIGO, P_DATAOUT|BSYO;
538 mvi LASTPHASE, P_DATAIN;
573 mvi LASTPHASE, P_DATAIN;
574 mvi P_DATAOUT|BSYO call change_phase;
539 jmp p_data;
540
541target_sphase:
575 jmp p_data;
576
577target_sphase:
542 mvi SCSISIGO, P_STATUS|BSYO;
578 mvi P_STATUS|BSYO call change_phase;
579 mvi LASTPHASE, P_STATUS;
543 mov SCB_TARGET_STATUS call target_outb;
580 mov SCB_TARGET_STATUS call target_outb;
544 /* XXX Watch for ATN for parity errors??? */
581 /* XXX Watch for ATN or parity errors??? */
545 mvi SCSISIGO, P_MESGIN|BSYO;
546 /* MSG_CMDCMPLT is 0, but we can't do an immediate of 0 */
547 mov ALLZEROS call target_outb;
548 jmp target_busfree;
549
550complete_target_cmd:
551 test SEQ_FLAGS, TARG_CMD_PENDING jnz . + 2;
552 mov SCB_TAG jmp complete_post;

--- 12 unchanged lines hidden (view full) ---

565 mov DFDAT, ALLONES;
566 mvi HCNT[0], 28;
567 clr HCNT[1];
568 clr HCNT[2];
569 or DFCNTRL, HDMAEN|FIFOFLUSH;
570 call dma_finish;
571 }
572 inc TQINPOS;
582 mvi SCSISIGO, P_MESGIN|BSYO;
583 /* MSG_CMDCMPLT is 0, but we can't do an immediate of 0 */
584 mov ALLZEROS call target_outb;
585 jmp target_busfree;
586
587complete_target_cmd:
588 test SEQ_FLAGS, TARG_CMD_PENDING jnz . + 2;
589 mov SCB_TAG jmp complete_post;

--- 12 unchanged lines hidden (view full) ---

602 mov DFDAT, ALLONES;
603 mvi HCNT[0], 28;
604 clr HCNT[1];
605 clr HCNT[2];
606 or DFCNTRL, HDMAEN|FIFOFLUSH;
607 call dma_finish;
608 }
609 inc TQINPOS;
573 test SEQ_FLAGS, NO_DISCONNECT jz . + 2;
574 mvi INTSTAT,TARGET_SYNC_CMD|CMDCMPLT ret;
575 mvi INTSTAT,CMDCMPLT ret;
576 }
610 mvi INTSTAT,CMDCMPLT ret;
611 }
612
613if ((ahc->flags & AHC_INITIATORMODE) != 0) {
577initiator_select:
578 mvi SPIOEN call initialize_channel;
614initiator_select:
615 mvi SPIOEN call initialize_channel;
579/*
580 * We aren't expecting a bus free, so interrupt
581 * the kernel driver if it happens.
582 */
616
617 /*
618 * We aren't expecting a bus free, so interrupt
619 * the kernel driver if it happens.
620 */
583 mvi CLRSINT1,CLRBUSFREE;
584 or SIMODE1, ENBUSFREE;
621 mvi CLRSINT1,CLRBUSFREE;
622 or SIMODE1, ENBUSFREE;
585/*
586 * As soon as we get a successful selection, the target should go
587 * into the message out phase since we have ATN asserted.
588 */
623
624 /*
625 * As soon as we get a successful selection, the target
626 * should go into the message out phase since we have ATN
627 * asserted.
628 */
589 mvi MSG_OUT, MSG_IDENTIFYFLAG;
590 or SEQ_FLAGS, IDENTIFY_SEEN;
591
629 mvi MSG_OUT, MSG_IDENTIFYFLAG;
630 or SEQ_FLAGS, IDENTIFY_SEEN;
631
592/*
593 * Main loop for information transfer phases. Wait for the target
594 * to assert REQ before checking MSG, C/D and I/O for the bus phase.
595 */
632 /*
633 * Main loop for information transfer phases. Wait for the
634 * target to assert REQ before checking MSG, C/D and I/O for
635 * the bus phase.
636 */
596ITloop:
597 call phase_lock;
598
599 mov A, LASTPHASE;
600
601 test A, ~P_DATAIN jz p_data;
602 cmp A,P_COMMAND je p_command;
603 cmp A,P_MESGOUT je p_mesgout;
604 cmp A,P_STATUS je p_status;
605 cmp A,P_MESGIN je p_mesgin;
606
637ITloop:
638 call phase_lock;
639
640 mov A, LASTPHASE;
641
642 test A, ~P_DATAIN jz p_data;
643 cmp A,P_COMMAND je p_command;
644 cmp A,P_MESGOUT je p_mesgout;
645 cmp A,P_STATUS je p_status;
646 cmp A,P_MESGIN je p_mesgin;
647
607 mvi INTSTAT,BAD_PHASE; /* unknown phase - signal driver */
648 mvi INTSTAT,BAD_PHASE;
608 jmp ITloop; /* Try reading the bus again. */
609
610await_busfree:
611 and SIMODE1, ~ENBUSFREE;
612 call clear_target_state;
613 mov NONE, SCSIDATL; /* Ack the last byte */
614 and SXFRCTL0, ~SPIOEN;
615 test SSTAT1,REQINIT|BUSFREE jz .;
616 test SSTAT1, BUSFREE jnz poll_for_work;
617 mvi INTSTAT, BAD_PHASE;
649 jmp ITloop; /* Try reading the bus again. */
650
651await_busfree:
652 and SIMODE1, ~ENBUSFREE;
653 call clear_target_state;
654 mov NONE, SCSIDATL; /* Ack the last byte */
655 and SXFRCTL0, ~SPIOEN;
656 test SSTAT1,REQINIT|BUSFREE jz .;
657 test SSTAT1, BUSFREE jnz poll_for_work;
658 mvi INTSTAT, BAD_PHASE;
659}
618
619clear_target_state:
660
661clear_target_state:
620 clr DFCNTRL; /*
621 * We assume that the kernel driver
622 * may reset us at any time, even
623 * in the middle of a DMA, so clear
624 * DFCNTRL too.
625 */
626 clr SCSIRATE; /*
627 * We don't know the target we will
628 * connect to, so default to narrow
629 * transfers to avoid parity problems.
630 */
631 and SXFRCTL0, ~(FAST20);
662 /*
663 * We assume that the kernel driver may reset us
664 * at any time, even in the middle of a DMA, so
665 * clear DFCNTRL too.
666 */
667 clr DFCNTRL;
668
669 /*
670 * We don't know the target we will connect to,
671 * so default to narrow transfers to avoid
672 * parity problems.
673 */
674 if ((ahc->features & AHC_ULTRA2) != 0) {
675 bmov SCSIRATE, ALLZEROS, 2;
676 } else {
677 clr SCSIRATE;
678 and SXFRCTL0, ~(FAST20);
679 }
632 mvi LASTPHASE, P_BUSFREE;
633 /* clear target specific flags */
634 clr SEQ_FLAGS ret;
635
636/*
637 * If we re-enter the data phase after going through another phase, the
638 * STCNT may have been cleared, so restore it from the residual field.
639 */

--- 173 unchanged lines hidden (view full) ---

813 }
814 }
815
816/* Advance the SG pointer */
817 clr A; /* add sizeof(struct scatter) */
818 add SG_NEXT[0],SG_SIZEOF;
819 adc SG_NEXT[1],A;
820
680 mvi LASTPHASE, P_BUSFREE;
681 /* clear target specific flags */
682 clr SEQ_FLAGS ret;
683
684/*
685 * If we re-enter the data phase after going through another phase, the
686 * STCNT may have been cleared, so restore it from the residual field.
687 */

--- 173 unchanged lines hidden (view full) ---

861 }
862 }
863
864/* Advance the SG pointer */
865 clr A; /* add sizeof(struct scatter) */
866 add SG_NEXT[0],SG_SIZEOF;
867 adc SG_NEXT[1],A;
868
869 if ((ahc->flags & AHC_TARGETMODE) != 0) {
870 test SSTAT0, TARGET jnz data_phase_loop;
871 }
872 test SSTAT1, REQINIT jz .;
821 test SSTAT1,PHASEMIS jz data_phase_loop;
873 test SSTAT1,PHASEMIS jz data_phase_loop;
874
822 /* Ensure the last seg is visable at the shaddow layer */
823 if ((ahc->features & AHC_ULTRA2) != 0) {
824 or DFCNTRL, PRELOADEN;
825 }
826
827data_phase_finish:
828 if ((ahc->features & AHC_ULTRA2) != 0) {
829 call ultra2_dmafinish;

--- 12 unchanged lines hidden (view full) ---

842 }
843 mov SCB_RESID_SGCNT, SG_COUNT;
844
845 if ((ahc->features & AHC_ULTRA2) != 0) {
846 or SXFRCTL0, CLRSTCNT|CLRCHN;
847 }
848
849 if ((ahc->flags & AHC_TARGETMODE) != 0) {
875 /* Ensure the last seg is visable at the shaddow layer */
876 if ((ahc->features & AHC_ULTRA2) != 0) {
877 or DFCNTRL, PRELOADEN;
878 }
879
880data_phase_finish:
881 if ((ahc->features & AHC_ULTRA2) != 0) {
882 call ultra2_dmafinish;

--- 12 unchanged lines hidden (view full) ---

895 }
896 mov SCB_RESID_SGCNT, SG_COUNT;
897
898 if ((ahc->features & AHC_ULTRA2) != 0) {
899 or SXFRCTL0, CLRSTCNT|CLRCHN;
900 }
901
902 if ((ahc->flags & AHC_TARGETMODE) != 0) {
850 test SEQ_FLAGS, DPHASE_PENDING jz . + 3;
903 test SEQ_FLAGS, DPHASE_PENDING jz ITloop;
851 and SEQ_FLAGS, ~DPHASE_PENDING;
852 jmp target_ITloop;
853 }
854 jmp ITloop;
855
856data_phase_overrun:
857 if ((ahc->features & AHC_ULTRA2) != 0) {
858 call ultra2_dmafinish;

--- 14 unchanged lines hidden (view full) ---

873 or DFCNTRL, FIFOFLUSH;
874 test DFSTATUS, FIFOEMP jz . - 1;
875ultra2_dmahalt:
876 and DFCNTRL, ~(SCSIEN|HDMAEN);
877 test DFCNTRL, HDMAEN jnz .;
878 ret;
879 }
880
904 and SEQ_FLAGS, ~DPHASE_PENDING;
905 jmp target_ITloop;
906 }
907 jmp ITloop;
908
909data_phase_overrun:
910 if ((ahc->features & AHC_ULTRA2) != 0) {
911 call ultra2_dmafinish;

--- 14 unchanged lines hidden (view full) ---

926 or DFCNTRL, FIFOFLUSH;
927 test DFSTATUS, FIFOEMP jz . - 1;
928ultra2_dmahalt:
929 and DFCNTRL, ~(SCSIEN|HDMAEN);
930 test DFCNTRL, HDMAEN jnz .;
931 ret;
932 }
933
934if ((ahc->flags & AHC_INITIATORMODE) != 0) {
881/*
882 * Command phase. Set up the DMA registers and let 'er rip.
883 */
884p_command:
885 call assert;
886
887 if ((ahc->features & AHC_CMD_CHAN) != 0) {
888 mov HCNT[0], SCB_CMDLEN;

--- 40 unchanged lines hidden (view full) ---

929 */
930p_status:
931 call assert;
932
933 mov SCB_TARGET_STATUS, SCSIDATL;
934 jmp ITloop;
935
936/*
935/*
936 * Command phase. Set up the DMA registers and let 'er rip.
937 */
938p_command:
939 call assert;
940
941 if ((ahc->features & AHC_CMD_CHAN) != 0) {
942 mov HCNT[0], SCB_CMDLEN;

--- 40 unchanged lines hidden (view full) ---

983 */
984p_status:
985 call assert;
986
987 mov SCB_TARGET_STATUS, SCSIDATL;
988 jmp ITloop;
989
990/*
937 * Message out phase. If MSG_OUT is 0x80, build I full indentify message
938 * sequence and send it to the target. In addition, if the MK_MESSAGE bit
939 * is set in the SCB_CONTROL byte, interrupt the host and allow it to send
940 * it's own message.
991 * Message out phase. If MSG_OUT is MSG_IDENTIFYFLAG, build a full
992 * indentify message sequence and send it to the target. The host may
993 * override this behavior by setting the MK_MESSAGE bit in the SCB
994 * control byte. This will cause us to interrupt the host and allow
995 * it to handle the message phase completely on its own. If the bit
996 * associated with this target is set, we will also interrupt the host,
997 * thereby allowing it to send a message on the next selection regardless
998 * of the transaction being sent.
941 *
942 * If MSG_OUT is == HOST_MSG, also interrupt the host and take a message.
999 *
1000 * If MSG_OUT is == HOST_MSG, also interrupt the host and take a message.
943 * This is done to allow the hsot to send messages outside of an identify
1001 * This is done to allow the host to send messages outside of an identify
944 * sequence while protecting the seqencer from testing the MK_MESSAGE bit
945 * on an SCB that might not be for the current nexus. (For example, a
946 * BDR message in responce to a bad reselection would leave us pointed to
947 * an SCB that doesn't have anything to do with the current target).
1002 * sequence while protecting the seqencer from testing the MK_MESSAGE bit
1003 * on an SCB that might not be for the current nexus. (For example, a
1004 * BDR message in responce to a bad reselection would leave us pointed to
1005 * an SCB that doesn't have anything to do with the current target).
1006 *
948 * Otherwise, treat MSG_OUT as a 1 byte message to send (abort, abort tag,
949 * bus device reset).
950 *
951 * When there are no messages to send, MSG_OUT should be set to MSG_NOOP,
952 * in case the target decides to put us in this phase for some strange
953 * reason.
954 */
1007 * Otherwise, treat MSG_OUT as a 1 byte message to send (abort, abort tag,
1008 * bus device reset).
1009 *
1010 * When there are no messages to send, MSG_OUT should be set to MSG_NOOP,
1011 * in case the target decides to put us in this phase for some strange
1012 * reason.
1013 */
1014p_mesgout_retry:
1015 or SCSISIGO,ATNO,LASTPHASE;/* turn on ATN for the retry */
955p_mesgout:
956 mov SINDEX, MSG_OUT;
957 cmp SINDEX, MSG_IDENTIFYFLAG jne p_mesgout_from_host;
1016p_mesgout:
1017 mov SINDEX, MSG_OUT;
1018 cmp SINDEX, MSG_IDENTIFYFLAG jne p_mesgout_from_host;
1019 test SCB_CONTROL,MK_MESSAGE jnz host_message_loop;
1020 mov FUNCTION1, SCB_TCL;
1021 mov A, FUNCTION1;
1022 mov SINDEX, TARGET_MSG_REQUEST[0];
1023 if ((ahc->features & AHC_TWIN) != 0) {
1024 /* Second Channel uses high byte bits */
1025 test SCB_TCL, SELBUSB jz . + 2;
1026 mov SINDEX, TARGET_MSG_REQUEST[1];
1027 } else if ((ahc->features & AHC_WIDE) != 0) {
1028 test SCB_TCL, 0x80 jz . + 2; /* target > 7 */
1029 mov SINDEX, TARGET_MSG_REQUEST[1];
1030 }
1031 test SINDEX, A jnz host_message_loop;
958p_mesgout_identify:
959 and SINDEX,LID,SCB_TCL; /* lun */
960 and A,DISCENB,SCB_CONTROL; /* mask off disconnect privledge */
961 or SINDEX,A; /* or in disconnect privledge */
962 or SINDEX,MSG_IDENTIFYFLAG;
1032p_mesgout_identify:
1033 and SINDEX,LID,SCB_TCL; /* lun */
1034 and A,DISCENB,SCB_CONTROL; /* mask off disconnect privledge */
1035 or SINDEX,A; /* or in disconnect privledge */
1036 or SINDEX,MSG_IDENTIFYFLAG;
963p_mesgout_mk_message:
964 test SCB_CONTROL,MK_MESSAGE jz p_mesgout_tag;
965 mov SCSIDATL, SINDEX; /* Send the last byte */
966 jmp p_mesgout_from_host + 1;/* Skip HOST_MSG test */
967/*
968 * Send a tag message if TAG_ENB is set in the SCB control block.
969 * Use SCB_TAG (the position in the kernel's SCB array) as the tag value.
970 */
971p_mesgout_tag:
972 test SCB_CONTROL,TAG_ENB jz p_mesgout_onebyte;
973 mov SCSIDATL, SINDEX; /* Send the identify message */
974 call phase_lock;
975 cmp LASTPHASE, P_MESGOUT jne p_mesgout_done;
976 and SCSIDATL,TAG_ENB|SCB_TAG_TYPE,SCB_CONTROL;
977 call phase_lock;
978 cmp LASTPHASE, P_MESGOUT jne p_mesgout_done;
979 mov SCB_TAG jmp p_mesgout_onebyte;
980/*
1037/*
1038 * Send a tag message if TAG_ENB is set in the SCB control block.
1039 * Use SCB_TAG (the position in the kernel's SCB array) as the tag value.
1040 */
1041p_mesgout_tag:
1042 test SCB_CONTROL,TAG_ENB jz p_mesgout_onebyte;
1043 mov SCSIDATL, SINDEX; /* Send the identify message */
1044 call phase_lock;
1045 cmp LASTPHASE, P_MESGOUT jne p_mesgout_done;
1046 and SCSIDATL,TAG_ENB|SCB_TAG_TYPE,SCB_CONTROL;
1047 call phase_lock;
1048 cmp LASTPHASE, P_MESGOUT jne p_mesgout_done;
1049 mov SCB_TAG jmp p_mesgout_onebyte;
1050/*
981 * Interrupt the driver, and allow it to send a message
982 * if it asks.
1051 * Interrupt the driver, and allow it to handle this message
1052 * phase and any required retries.
983 */
984p_mesgout_from_host:
985 cmp SINDEX, HOST_MSG jne p_mesgout_onebyte;
1053 */
1054p_mesgout_from_host:
1055 cmp SINDEX, HOST_MSG jne p_mesgout_onebyte;
986 mvi INTSTAT,AWAITING_MSG;
987 nop;
988 /*
989 * Did the host detect a phase change?
990 */
991 cmp RETURN_1, MSGOUT_PHASEMIS je p_mesgout_done;
1056 jmp host_message_loop;
992
993p_mesgout_onebyte:
994 mvi CLRSINT1, CLRATNO;
995 mov SCSIDATL, SINDEX;
996
997/*
1057
1058p_mesgout_onebyte:
1059 mvi CLRSINT1, CLRATNO;
1060 mov SCSIDATL, SINDEX;
1061
1062/*
998 * If the next bus phase after ATN drops is a message out, it means
1063 * If the next bus phase after ATN drops is message out, it means
999 * that the target is requesting that the last message(s) be resent.
1000 */
1001 call phase_lock;
1064 * that the target is requesting that the last message(s) be resent.
1065 */
1066 call phase_lock;
1002 cmp LASTPHASE, P_MESGOUT jne p_mesgout_done;
1003 or SCSISIGO,ATNO,LASTPHASE;/* turn on ATN for the retry */
1004 jmp p_mesgout;
1067 cmp LASTPHASE, P_MESGOUT je p_mesgout_retry;
1005
1006p_mesgout_done:
1007 mvi CLRSINT1,CLRATNO; /* Be sure to turn ATNO off */
1008 mov LAST_MSG, MSG_OUT;
1068
1069p_mesgout_done:
1070 mvi CLRSINT1,CLRATNO; /* Be sure to turn ATNO off */
1071 mov LAST_MSG, MSG_OUT;
1009 cmp MSG_OUT, MSG_IDENTIFYFLAG jne . + 2;
1010 and SCB_CONTROL, ~MK_MESSAGE;
1011 mvi MSG_OUT, MSG_NOOP; /* No message left */
1012 jmp ITloop;
1013
1014/*
1072 mvi MSG_OUT, MSG_NOOP; /* No message left */
1073 jmp ITloop;
1074
1075/*
1076 * Pushed message loop to allow the kernel to
1077 * RUN IT's own message state engine. To avoid an
1078 * extra nop instruction after signaling the kernel,
1079 * we perform the phase_lock before checking to see
1080 * if we should exit the loop and skip the phase_lock
1081 * in the ITloop. Performing back to back phase_locks
1082 * shouldn't hurt, but why do it twice...
1083 */
1084host_message_loop:
1085 mvi INTSTAT, HOST_MSG_LOOP;
1086 call phase_lock;
1087 cmp RETURN_1, EXIT_MSG_LOOP je ITloop + 1;
1088 jmp host_message_loop;
1089
1090/*
1015 * Message in phase. Bytes are read using Automatic PIO mode.
1016 */
1017p_mesgin:
1018 mvi ACCUM call inb_first; /* read the 1st message byte */
1019
1020 test A,MSG_IDENTIFYFLAG jnz mesgin_identify;
1021 cmp A,MSG_DISCONNECT je mesgin_disconnect;
1022 cmp A,MSG_SAVEDATAPOINTER je mesgin_sdptrs;
1023 cmp ALLZEROS,A je mesgin_complete;
1024 cmp A,MSG_RESTOREPOINTERS je mesgin_rdptrs;
1091 * Message in phase. Bytes are read using Automatic PIO mode.
1092 */
1093p_mesgin:
1094 mvi ACCUM call inb_first; /* read the 1st message byte */
1095
1096 test A,MSG_IDENTIFYFLAG jnz mesgin_identify;
1097 cmp A,MSG_DISCONNECT je mesgin_disconnect;
1098 cmp A,MSG_SAVEDATAPOINTER je mesgin_sdptrs;
1099 cmp ALLZEROS,A je mesgin_complete;
1100 cmp A,MSG_RESTOREPOINTERS je mesgin_rdptrs;
1025 cmp A,MSG_EXTENDED je mesgin_extended;
1101 cmp A,MSG_EXTENDED je host_message_loop;
1026 cmp A,MSG_MESSAGE_REJECT je mesgin_reject;
1027 cmp A,MSG_NOOP je mesgin_done;
1028
1029rej_mesgin:
1030/*
1031 * We have no idea what this message in is, so we issue a message reject
1032 * and hope for the best. In any case, rejection should be a rare
1033 * occurrence - signal the driver when it happens.

--- 60 unchanged lines hidden (view full) ---

1094 mvi SCB_LIST_NULL call post_byte;
1095
1096complete_queue:
1097 mov SCB_TAG call complete_post;
1098
1099add_to_free_list:
1100 call add_scb_to_free_list;
1101 jmp await_busfree;
1102 cmp A,MSG_MESSAGE_REJECT je mesgin_reject;
1103 cmp A,MSG_NOOP je mesgin_done;
1104
1105rej_mesgin:
1106/*
1107 * We have no idea what this message in is, so we issue a message reject
1108 * and hope for the best. In any case, rejection should be a rare
1109 * occurrence - signal the driver when it happens.

--- 60 unchanged lines hidden (view full) ---

1170 mvi SCB_LIST_NULL call post_byte;
1171
1172complete_queue:
1173 mov SCB_TAG call complete_post;
1174
1175add_to_free_list:
1176 call add_scb_to_free_list;
1177 jmp await_busfree;
1178}
1102
1103complete_post:
1104 /* Post the SCBID in SINDEX and issue an interrupt */
1105 mov ARG_1, SINDEX;
1106 if ((ahc->features & AHC_QUEUE_REGS) != 0) {
1107 mov A, SDSCB_QOFF;
1108 } else {
1109 mov A, QOUTPOS;
1110 }
1111 mvi QOUTFIFO_OFFSET call post_byte_setup;
1112 mov ARG_1 call post_byte;
1113 if ((ahc->features & AHC_QUEUE_REGS) == 0) {
1114 inc QOUTPOS;
1115 }
1179
1180complete_post:
1181 /* Post the SCBID in SINDEX and issue an interrupt */
1182 mov ARG_1, SINDEX;
1183 if ((ahc->features & AHC_QUEUE_REGS) != 0) {
1184 mov A, SDSCB_QOFF;
1185 } else {
1186 mov A, QOUTPOS;
1187 }
1188 mvi QOUTFIFO_OFFSET call post_byte_setup;
1189 mov ARG_1 call post_byte;
1190 if ((ahc->features & AHC_QUEUE_REGS) == 0) {
1191 inc QOUTPOS;
1192 }
1116 if ((ahc->flags & AHC_TARGETMODE) != 0) {
1117 test SEQ_FLAGS, NO_DISCONNECT jz . + 2;
1118 mvi INTSTAT,TARGET_SYNC_CMD|CMDCMPLT ret;
1119 }
1120 mvi INTSTAT,CMDCMPLT ret;
1121
1193 mvi INTSTAT,CMDCMPLT ret;
1194
1195if ((ahc->flags & AHC_INITIATORMODE) != 0) {
1122/*
1196/*
1123 * Is it an extended message? Copy the message to our message buffer and
1124 * notify the host. The host will tell us whether to reject this message,
1125 * respond to it with the message that the host placed in our message buffer,
1126 * or simply to do nothing.
1127 */
1128mesgin_extended:
1129 mvi INTSTAT,EXTENDED_MSG; /* let driver know */
1130 jmp ITloop;
1131
1132/*
1133 * Is it a disconnect message? Set a flag in the SCB to remind us
1134 * and await the bus going free.
1135 */
1136mesgin_disconnect:
1137 or SCB_CONTROL,DISCONNECTED;
1138 call add_scb_to_disc_list;
1139 jmp await_busfree;
1140

--- 165 unchanged lines hidden (view full) ---

1306 test SSTAT1, SCSIPERR jnz inb_next_wait;
1307 and LASTPHASE, PHASE_MASK, SCSISIGI;
1308 cmp LASTPHASE, P_MESGIN jne mesgin_phasemis;
1309inb_first:
1310 mov DINDEX,SINDEX;
1311 mov DINDIR,SCSIBUSL ret; /*read byte directly from bus*/
1312inb_last:
1313 mov NONE,SCSIDATL ret; /*dummy read from latch to ACK*/
1197 * Is it a disconnect message? Set a flag in the SCB to remind us
1198 * and await the bus going free.
1199 */
1200mesgin_disconnect:
1201 or SCB_CONTROL,DISCONNECTED;
1202 call add_scb_to_disc_list;
1203 jmp await_busfree;
1204

--- 165 unchanged lines hidden (view full) ---

1370 test SSTAT1, SCSIPERR jnz inb_next_wait;
1371 and LASTPHASE, PHASE_MASK, SCSISIGI;
1372 cmp LASTPHASE, P_MESGIN jne mesgin_phasemis;
1373inb_first:
1374 mov DINDEX,SINDEX;
1375 mov DINDIR,SCSIBUSL ret; /*read byte directly from bus*/
1376inb_last:
1377 mov NONE,SCSIDATL ret; /*dummy read from latch to ACK*/
1378}
1314
1315if ((ahc->flags & AHC_TARGETMODE) != 0) {
1379
1380if ((ahc->flags & AHC_TARGETMODE) != 0) {
1316 /*
1317 * Send a byte to an initiator in Automatic PIO mode.
1318 * SPIOEN must be on prior to calling this routine.
1319 */
1381/*
1382 * Change to a new phase. If we are changing the state of the I/O signal,
1383 * from out to in, wait an additional data release delay before continuing.
1384 */
1385change_phase:
1386 and DINDEX, IOI, SCSISIGI;
1387 mov SCSISIGO, SINDEX;
1388 and A, IOI, SINDEX;
1389 cmp DINDEX, A je change_phase_wait;
1390 test SINDEX, IOI jz change_phase_wait;
1391 call change_phase_wait;
1392change_phase_wait:
1393 nop;
1394 nop;
1395 nop;
1396 nop ret;
1397
1398/*
1399 * Send a byte to an initiator in Automatic PIO mode.
1400 */
1320target_outb:
1321 or SXFRCTL0, SPIOEN;
1322 test SSTAT0, SPIORDY jz .;
1323 mov SCSIDATL, SINDEX;
1324 test SSTAT0, SPIORDY jz .;
1401target_outb:
1402 or SXFRCTL0, SPIOEN;
1403 test SSTAT0, SPIORDY jz .;
1404 mov SCSIDATL, SINDEX;
1405 test SSTAT0, SPIORDY jz .;
1325 ret;
1406 and SXFRCTL0, ~SPIOEN ret;
1326}
1327
1328mesgin_phasemis:
1329/*
1330 * We expected to receive another byte, but the target changed phase
1331 */
1332 mvi INTSTAT, MSGIN_PHASEMIS;
1333 jmp ITloop;

--- 202 unchanged lines hidden (view full) ---

1536get_SCBID_from_host:
1537 mov A, SAVED_TCL;
1538 mvi UNTAGGEDSCB_OFFSET call fetch_byte;
1539 mov RETURN_1, RETURN_2 ret;
1540
1541phase_lock:
1542 test SSTAT1, REQINIT jz phase_lock;
1543 test SSTAT1, SCSIPERR jnz phase_lock;
1407}
1408
1409mesgin_phasemis:
1410/*
1411 * We expected to receive another byte, but the target changed phase
1412 */
1413 mvi INTSTAT, MSGIN_PHASEMIS;
1414 jmp ITloop;

--- 202 unchanged lines hidden (view full) ---

1617get_SCBID_from_host:
1618 mov A, SAVED_TCL;
1619 mvi UNTAGGEDSCB_OFFSET call fetch_byte;
1620 mov RETURN_1, RETURN_2 ret;
1621
1622phase_lock:
1623 test SSTAT1, REQINIT jz phase_lock;
1624 test SSTAT1, SCSIPERR jnz phase_lock;
1544 and LASTPHASE, PHASE_MASK, SCSISIGI;
1545 mov SCSISIGO, LASTPHASE ret;
1625 and SCSISIGO, PHASE_MASK, SCSISIGI;
1626 and LASTPHASE, PHASE_MASK, SCSISIGI ret;
1546
1547if ((ahc->features & AHC_CMD_CHAN) == 0) {
1548set_stcnt_from_hcnt:
1549 mov STCNT[0], HCNT[0];
1550 mov STCNT[1], HCNT[1];
1551 mov STCNT[2], HCNT[2] ret;
1552
1553bcopy_7:

--- 169 unchanged lines hidden ---
1627
1628if ((ahc->features & AHC_CMD_CHAN) == 0) {
1629set_stcnt_from_hcnt:
1630 mov STCNT[0], HCNT[0];
1631 mov STCNT[1], HCNT[1];
1632 mov STCNT[2], HCNT[2] ret;
1633
1634bcopy_7:

--- 169 unchanged lines hidden ---