⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aic7xxx.seq

📁 基于组件方式开发操作系统的OSKIT源代码
💻 SEQ
📖 第 1 页 / 共 4 页
字号:
		 * For data-in phases, wait for any pending acks from the		 * initiator before changing phase.		 */		test	DFCNTRL, DIRECTION jz target_ITloop;		test	SSTAT1, REQINIT	jnz .;		jmp	target_ITloop;	}	jmp	ITloop;data_phase_overrun:	if ((ahc->features & AHC_ULTRA2) != 0) {		call	ultra2_dmafinish;		or	SXFRCTL0, CLRSTCNT|CLRCHN;	}/* * Turn off BITBUCKET mode and notify the host */	and	SXFRCTL1, ~BITBUCKET;	mvi	INTSTAT,DATA_OVERRUN;	jmp	ITloop;ultra2_dmafinish:	if ((ahc->features & AHC_ULTRA2) != 0) {		test	DFCNTRL, DIRECTION jnz ultra2_dmahalt;		and	DFCNTRL, ~SCSIEN;		test	DFCNTRL, SCSIEN jnz .;		or	DFCNTRL, FIFOFLUSH;		test	DFSTATUS, FIFOEMP jz . - 1;ultra2_dmahalt:		and     DFCNTRL, ~(SCSIEN|HDMAEN);		test	DFCNTRL, HDMAEN jnz .;		ret;	}if ((ahc->flags & AHC_INITIATORMODE) != 0) {/* * Command phase.  Set up the DMA registers and let 'er rip. */p_command:	call	assert;	if ((ahc->features & AHC_CMD_CHAN) != 0) {		mov	HCNT[0], SCB_CMDLEN;		bmov	HCNT[1], ALLZEROS, 2;		if ((ahc->features & AHC_ULTRA2) == 0) {			bmov	STCNT, HCNT, 3;		}		add	NONE, -17, SCB_CMDLEN;		jc	dma_cmd_data;		if ((ahc->features & AHC_ULTRA2) != 0) {			mvi	DFCNTRL, (PRELOADEN|SCSIEN|DIRECTION);		} else {			mvi	DFCNTRL, (SCSIEN|SDMAEN|DIRECTION|FIFORESET);		}		bmov   DFDAT, SCB_CMDSTORE, 16; 		jmp	cmd_loop;dma_cmd_data:		bmov	HADDR, SCB_CMDPTR, 4;	} else {		mvi	DINDEX, HADDR;		mvi	SCB_CMDPTR	call bcopy_5;		clr	HCNT[1];		clr	HCNT[2];	}	if ((ahc->features & AHC_ULTRA2) == 0) {		if ((ahc->features & AHC_CMD_CHAN) == 0) {			call	set_stcnt_from_hcnt;		}		mvi	DFCNTRL, (SCSIEN|SDMAEN|HDMAEN|DIRECTION|FIFORESET);	} else {		mvi	DFCNTRL, (PRELOADEN|SCSIEN|HDMAEN|DIRECTION);	}cmd_loop:	test	SSTAT0, SDONE jnz . + 2;	test    SSTAT1, PHASEMIS jz cmd_loop;	and	DFCNTRL, ~(SCSIEN|HDMAEN|SDMAEN);	test	DFCNTRL, (SCSIEN|SDMAEN|HDMAEN) jnz .;	jmp	ITloop;/* * Status phase.  Wait for the data byte to appear, then read it * and store it into the SCB. */p_status:	call	assert;	mov	SCB_TARGET_STATUS, SCSIDATL;	jmp	ITloop;/* * Message out phase.  If MSG_OUT is MSG_IDENTIFYFLAG, build a full * indentify message sequence and send it to the target.  The host may * override this behavior by setting the MK_MESSAGE bit in the SCB * control byte.  This will cause us to interrupt the host and allow * it to handle the message phase completely on its own.  If the bit * associated with this target is set, we will also interrupt the host, * thereby allowing it to send a message on the next selection regardless * of the transaction being sent. *  * If MSG_OUT is == HOST_MSG, also interrupt the host and take a message. * This is done to allow the host to send messages outside of an identify * sequence while protecting the seqencer from testing the MK_MESSAGE bit * on an SCB that might not be for the current nexus. (For example, a * BDR message in responce to a bad reselection would leave us pointed to * an SCB that doesn't have anything to do with the current target). * * Otherwise, treat MSG_OUT as a 1 byte message to send (abort, abort tag, * bus device reset). * * When there are no messages to send, MSG_OUT should be set to MSG_NOOP, * in case the target decides to put us in this phase for some strange * reason. */p_mesgout_retry:	or	SCSISIGO,ATNO,LASTPHASE;/* turn on ATN for the retry */p_mesgout:	mov	SINDEX, MSG_OUT;	cmp	SINDEX, MSG_IDENTIFYFLAG jne p_mesgout_from_host;	test	SCB_CONTROL,MK_MESSAGE	jnz host_message_loop;	mov	FUNCTION1, SCB_TCL;	mov	A, FUNCTION1;	mov	SINDEX, TARGET_MSG_REQUEST[0];	if ((ahc->features & AHC_HS_MAILBOX) != 0) {		/*		 * Work around a pausing bug in at least the aic7890.		 * If the host needs to update the TARGET_MSG_REQUEST		 * bit field, it will set the HS_MAILBOX to 1.  In		 * response, we pause with a specific interrupt code		 * asking for the mask to be updated before we continue.		 * Ugh.		 */		test	HS_MAILBOX, 0xF0	jz . + 2;		mvi	INTSTAT, UPDATE_TMSG_REQ;	}	if ((ahc->features & AHC_TWIN) != 0) {		/* Second Channel uses high byte bits */		test	SCB_TCL, SELBUSB	jz . + 2;		mov	SINDEX, TARGET_MSG_REQUEST[1];	} else if ((ahc->features & AHC_WIDE) != 0) {		test	SCB_TCL, 0x80		jz . + 2; /* target > 7 */		mov	SINDEX, TARGET_MSG_REQUEST[1];	}	test	SINDEX, A	jnz host_message_loop;p_mesgout_identify:	and	SINDEX,LID,SCB_TCL;	/* lun */	and	A,DISCENB,SCB_CONTROL;	/* mask off disconnect privledge */	or	SINDEX,A;		/* or in disconnect privledge */	or	SINDEX,MSG_IDENTIFYFLAG;/* * Send a tag message if TAG_ENB is set in the SCB control block. * Use SCB_TAG (the position in the kernel's SCB array) as the tag value. */p_mesgout_tag:	test	SCB_CONTROL,TAG_ENB jz  p_mesgout_onebyte;	mov	SCSIDATL, SINDEX;	/* Send the identify message */	call	phase_lock;	cmp	LASTPHASE, P_MESGOUT	jne p_mesgout_done;	and	SCSIDATL,TAG_ENB|SCB_TAG_TYPE,SCB_CONTROL;	call	phase_lock;	cmp	LASTPHASE, P_MESGOUT	jne p_mesgout_done;	mov	SCB_TAG	jmp p_mesgout_onebyte;/* * Interrupt the driver, and allow it to handle this message * phase and any required retries. */p_mesgout_from_host:	cmp	SINDEX, HOST_MSG	jne p_mesgout_onebyte;	jmp	host_message_loop;p_mesgout_onebyte:	mvi	CLRSINT1, CLRATNO;	mov	SCSIDATL, SINDEX;/* * If the next bus phase after ATN drops is message out, it means * that the target is requesting that the last message(s) be resent. */	call	phase_lock;	cmp	LASTPHASE, P_MESGOUT	je p_mesgout_retry;p_mesgout_done:	mvi	CLRSINT1,CLRATNO;	/* Be sure to turn ATNO off */	mov	LAST_MSG, MSG_OUT;	mvi	MSG_OUT, MSG_NOOP;	/* No message left */	jmp	ITloop;/* * Message in phase.  Bytes are read using Automatic PIO mode. */p_mesgin:	mvi	ACCUM		call inb_first;	/* read the 1st message byte */	test	A,MSG_IDENTIFYFLAG	jnz mesgin_identify;	cmp	A,MSG_DISCONNECT	je mesgin_disconnect;	cmp	A,MSG_SAVEDATAPOINTER	je mesgin_sdptrs;	cmp	ALLZEROS,A		je mesgin_complete;	cmp	A,MSG_RESTOREPOINTERS	je mesgin_rdptrs;	cmp	A,MSG_NOOP		je mesgin_done;/* * Pushed message loop to allow the kernel to * RUN IT's own message state engine.  To avoid an * extra nop instruction after signaling the kernel, * we perform the phase_lock before checking to see * if we should exit the loop and skip the phase_lock * in the ITloop.  Performing back to back phase_locks * shouldn't hurt, but why do it twice... */host_message_loop:	mvi	INTSTAT, HOST_MSG_LOOP;	call	phase_lock;	cmp	RETURN_1, EXIT_MSG_LOOP	je ITloop + 1;	jmp	host_message_loop;mesgin_done:	mov	NONE,SCSIDATL;		/*dummy read from latch to ACK*/	jmp	ITloop;mesgin_complete:/* * We got a "command complete" message, so put the SCB_TAG into the QOUTFIFO, * and trigger a completion interrupt.  Before doing so, check to see if there * is a residual or the status byte is something other than STATUS_GOOD (0). * In either of these conditions, we upload the SCB back to the host so it can * process this information.  In the case of a non zero status byte, we  * additionally interrupt the kernel driver synchronously, allowing it to * decide if sense should be retrieved.  If the kernel driver wishes to request * sense, it will fill the kernel SCB with a request sense command and set * RETURN_1 to SEND_SENSE.  If RETURN_1 is set to SEND_SENSE we redownload * the SCB, and process it as the next command by adding it to the waiting list. * If the kernel driver does not wish to request sense, it need only clear * RETURN_1, and the command is allowed to complete normally.  We don't bother * to post to the QOUTFIFO in the error cases since it would require extra * work in the kernel driver to ensure that the entry was removed before the * command complete code tried processing it. *//* * First check for residuals */	test	SCB_RESID_SGCNT,0xff	jnz upload_scb;	test	SCB_TARGET_STATUS,0xff	jz complete;	/* Good Status? */upload_scb:	mvi	DMAPARAMS, FIFORESET;	mov	SCB_TAG		call dma_scb;check_status:	test	SCB_TARGET_STATUS,0xff	jz complete;	/* Just a residual? */	mvi	INTSTAT,BAD_STATUS;			/* let driver know */	nop;	cmp	RETURN_1, SEND_SENSE	jne complete;	/* This SCB becomes the next to execute as it will retrieve sense */	mvi	DMAPARAMS, HDMAEN|DIRECTION|FIFORESET;	mov	SCB_TAG		call dma_scb;add_to_waiting_list:	mov	SCB_NEXT,WAITING_SCBH;	mov	WAITING_SCBH, SCBPTR;	/*	 * Prepare our selection hardware before the busfree so we have a	 * high probability of winning arbitration.	 */	call	start_selection;	jmp	await_busfree;complete:	/* If we are untagged, clear our address up in host ram */	test	SCB_CONTROL, TAG_ENB jnz complete_queue;	mov	A, SAVED_TCL;	mvi	UNTAGGEDSCB_OFFSET call post_byte_setup;	mvi	SCB_LIST_NULL call post_byte;complete_queue:	mov	SCB_TAG call complete_post;	jmp	await_busfree;}complete_post:	/* Post the SCBID in SINDEX and issue an interrupt */	call	add_scb_to_free_list;	mov	ARG_1, SINDEX;	if ((ahc->features & AHC_QUEUE_REGS) != 0) {		mov	A, SDSCB_QOFF;	} else {		mov	A, QOUTPOS;	}	mvi	QOUTFIFO_OFFSET call post_byte_setup;	mov	ARG_1 call post_byte;	if ((ahc->features & AHC_QUEUE_REGS) == 0) {		inc 	QOUTPOS;	}	mvi	INTSTAT,CMDCMPLT ret;if ((ahc->flags & AHC_INITIATORMODE) != 0) {/* * Is it a disconnect message?  Set a flag in the SCB to remind us * and await the bus going free. */mesgin_disconnect:	or	SCB_CONTROL,DISCONNECTED;	call	add_scb_to_disc_list;	jmp	await_busfree;/* * Save data pointers message: * Copying RAM values back to SCB, for Save Data Pointers message, but * only if we've actually been into a data phase to change them.  This * protects against bogus data in scratch ram and the residual counts * since they are only initialized when we go into data_in or data_out. */mesgin_sdptrs:	test	SEQ_FLAGS, DPHASE	jz mesgin_done;	/*	 * The SCB SGPTR becomes the next one we'll download,	 * and the SCB DATAPTR becomes the current SHADDR.	 * Use the residual number since STCNT is corrupted by	 * any message transfer.	 */	if ((ahc->features & AHC_CMD_CHAN) != 0) {		bmov	SCB_SGCOUNT, SG_COUNT, 5;		bmov	SCB_DATAPTR, SHADDR, 4;		bmov	SCB_DATACNT, SCB_RESID_DCNT, 3;	} else {		mvi	DINDEX, SCB_SGCOUNT;		mvi	SG_COUNT call bcopy_5;			mvi	DINDEX, SCB_DATAPTR;		mvi	SHADDR		call bcopy_4;		mvi	SCB_RESID_DCNT	call bcopy_3;	}	jmp	mesgin_done;/* * Restore pointers message?  Data pointers are recopied from the * SCB anytime we enter a data phase for the first time, so all * we need to do is clear the DPHASE flag and let the data phase * code do the rest. */mesgin_rdptrs:	and	SEQ_FLAGS, ~DPHASE;		/*						 * We'll reload them						 * the next time through						 * the dataphase.						 */	jmp	mesgin_done;/* * Identify message?  For a reconnecting target, this tells us the lun * that the reconnection is for - find the correct SCB and switch to it, * clearing the "disconnected" bit so we don't "find" it by accident later. */mesgin_identify:		if ((ahc->features & AHC_WIDE) != 0) {		and	A,0x0f;		/* lun in lower four bits */	} else {		and	A,0x07;		/* lun in lower three bits */	}	or      SAVED_TCL,A;		/* SAVED_TCL should be complete now */	mvi	ARG_2, SCB_LIST_NULL;	/* SCBID of prev SCB in disc List */	call	get_untagged_SCBID;	cmp	ARG_1, SCB_LIST_NULL	je snoop_tag;	if ((ahc->flags & AHC_PAGESCBS) != 0) {		test	SEQ_FLAGS, SCBPTR_VALID	jz use_retrieveSCB;	}	/*	 * If the SCB was found in the disconnected list (as is	 * always the case in non-paging scenarios), SCBPTR is already	 * set to the correct SCB.  So, simply setup the SCB and get	 * on with things.	 */	call	rem_scb_from_disc_list;	jmp	setup_SCB;/* * Here we "snoop" the bus looking for a SIMPLE QUEUE TAG message. * If we get one, we use the tag returned to find the proper * SCB.  With SCB paging, this requires using search for both tagged * and non-tagged transactions since the SCB may exist in any slot. * If we're not using SCB paging, we can use the tag as the direct * index to the SCB. */snoop_tag:	mov	NONE,SCSIDATL;		/* ACK Identify MSG */snoop_tag_loop:	call	phase_lock;	cmp	LASTPHASE, P_MESGIN	jne not_found;	cmp	SCSIBUSL,MSG_SIMPLE_Q_TAG jne not_found;get_tag:	mvi	ARG_1	call inb_next;	/* tag value */	/*	 * Ensure that the SCB the tag points to is for	 * an SCB transaction to the reconnecting target.	 */use_retrieveSCB:	call	retrieveSCB;setup_SCB:	mov	A, SAVED_TCL;	cmp	SCB_TCL, A	jne not_found_cleanup_scb;	test	SCB_CONTROL,DISCONNECTED jz not_found_cleanup_scb;	and	SCB_CONTROL,~DISCONNECTED;	or	SEQ_FLAGS,IDENTIFY_SEEN;	  /* make note of IDENTIFY */	call	set_transfer_settings;	/* See if the host wants to send a message upon reconnection */	test	SCB_CONTROL, MK_MESSAGE jz mesgin_done;	and	SCB_CONTROL, ~MK_MESSAGE;	mvi	HOST_MSG	call mk_mesg;	jmp	mesgin_done;not_found_cleanup_scb:	test	SCB_CONTROL, DISCONNECTED jz . + 3;	call	add_scb_to_disc_list;	jmp	not_found;	call	add_scb_to_free_list;not_found:	mvi	INTSTAT, NO_MATCH;	jmp	mesgin_done;/* * [ ADD MORE MESSAGE HANDLING HERE ] *//* * Locking the driver out, build a one-byte message passed in SINDEX * if there is no active message already.  SINDEX is returned intact. */mk_mesg:	or	SCSISIGO,ATNO,LASTPHASE;/* turn on ATNO */	mov	MSG_OUT,SINDEX ret;/* * Functions to read data in Automatic PIO mode. * * According to Adaptec's documentation, an ACK is not sent on input from * the target until SCSIDATL is read from.  So we wait until SCSIDATL is * latched (the usual way), then read the data byte directly off the bus * using SCSIBUSL.  When we have pulled the ATN line, or we just want to * acknowledge the byte, then we do a dummy read from SCISDATL.  The SCSI * spec guarantees that the target will hold the data byte on the bus until * we send our ACK. * * The assumption here is that these are called in a particular sequence, * and that REQ is already set when inb_first is called.  inb_{first,next} * use the same calling convention as inb. */inb_next:	mov	NONE,SCSIDATL;		/*dummy read from latch to ACK*/inb_next_wait:	/*

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -