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

📄 initiator_reselection.c

📁 基于FAS466的SCSI控制器的启动器模式的C源代码。
💻 C
字号:
#define	GLB extern

#include <stdio.h>
#include <conio.h>
#include <sys\types.h>
#include <sys\timeb.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <dos.h>

#include "fas466defs.h"
#include "fas466regs.h"
#include "fas466globalvars.h"

//       This is a work around for reselection problem ( HPR #1744)


void Initiator_Reselection()
{
		long Disable_Status = 0x00;
		long EIGS  = 0x00;
		long SCcontrol  = 0x00;

//1. Write 0x01 to the SC Selection Disable register (to request the SC to
//  disable itself for selection/re-selection)
    	 
Step1:	RegWrite (SC_Selection_Disable, 0x01 );   // request for disable selection

//2. Read the SC Selection Disable register.
	Disable_Status = RegRead (SC_Selection_Disable);

//   - If the value returned == 0x01, then goto step 7 (the SC has either been 
//     reselected or the SC has been DISABLED for selection/reselection)
	if (Disable_Status == 0x01) 
		goto Step7;

//   - If the value returned == 0x00, then continue at step 3 ( the SC is 
//     either being reselected or the SC is not enabled for selection/reselection
//     and the SEL signal is active on the SCSI bus).
	if (Disable_Status == 0x00) 
		goto Step3;


//3. Write 0x07 to Probe Address register
Step3:	
	RegWrite (SC_Probe_Address, 0x07 );

//4. Read the Probe Data register ( this checks the internal State Machine)
	if (RegRead (SC_Probe_Data) != 00)
		goto Step1;
//   - If value returned is != 0x00, then the SC is still enabled for selection/
//     reselection, or is in the process of begin selected/re-selected.  Return
//     to step 1.
		else
		goto Step5;
//   - If the value returned == 0x00, then the SC has been either reselected or 
//     is DISABLED for selection/reselection, then continue at step 5.

//5. Read the Probe Data register again.
Step5:
	if (RegRead (SC_Probe_Data) != 00)
		goto Step1;

 //  - If value returned is != 0x00, then the SC is still enabled for selection/
 //    reselection, or is in the process of begin selected/re-selected.  Return
 //    to step 1.

 //  - If the value returned == 0x00, then the SC has been either reselected or 
  //   is DISABLED for selection/reselection, then continue at step 5a.
	else
	goto EOP;


//5a. Service a bus-initiated reselect interrupt if it exists.  Continue at step 6.

//6. Setup SC FIFO (message, commands) and issue "selection" type command.  <End of procedure>.

//7. Check EIGS by reading the SCSI Control register (bit 3)
	EIGS = (RegRead (SC_SCSI_Control) & 0x08) ;
//   - If EIGS == 0, then the SC is DISABLED for selection/reselection, goto step 6.
//   - If EIGS == 1, then the SC has been reselected, goto step 8.
	if (EIGS == 0) goto EOP;
	else 

//8. Check REQ by reading the SCSI Control register (bit 12)
	do
	{
		SCcontrol = RegRead (SC_SCSI_Control);
	}
	while ((SCcontrol & 0x1000) == 0);

//   - If REQ == 0, then the Target has not yet asserted REQ, repeat step 8.
//   - If REQ == 1, then the Target has asserted REQ, continue at step 9.
/*	

9. Check Command Interrupt Status register

   - If Command Interrupt Status == 0x00, continue at step 10

   - If Command Interrupt Status != 0x00, reselect interrupt was correctly generated,
     continue with your interrupt handler.  The SC should now have 2 bytes (ID and MSG byte)
     and the ACK should be asserted on the bus.

10. Check Command Interrupt Status register again ( There is about approximately 200ns 
    delay between the assertion of REQ on the bus and the generation of an interrupt within
    the SC )

   - If Command Interrupt Status == 0x00, continue at step 11

   - If Command Interrupt Status != 0x00, reselect interrupt was correctly generated,
     continue with your interrupt handler.  The SC should now have 2 bytes (ID and MSG byte)
     and the ACK should be asserted on the bus.

11. The SC is now waiting for an interrupt which will not occur due to Selection Disable Request
    after the SC was reselected but before the Target has asserted REQ.  The firmware
    must now perform the following steps to recover from this condition.  Continue at step 12.

12. Write 0x02 to Command Interrupt Status register (this will generate a bus-initiated 
    reselection interrupt). Continue at step 13.

13. If the Current phase is Message In, execute Transfer Information Command (Opcode 0x10) to
    receive the message byte.  When the interrupt occurs for this command, the SC should have
    completed all the steps within the Bus-Initiated re-selection flow chart. <End of Procedure>
EOP:
*/
} // Initiator_Mode_tur

⌨️ 快捷键说明

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