發展軟體
主控電腦使用
Advance SCSI Programming Interface(ASPI)下達命令Adaptec公司提供一套SCSI介面發展軟體(ASPI for Windows),我們只要在其規劃好的SRB_ExecSCSICmd6結構中(圖3)填好欲下達的CDB碼,透過WINASPI.DLL(Dynamic Link Library)中的SendASPICommand模組,就可將CDB碼送至SCSI介面上以供Target接收。表6中有此結構的說明。
typedef struct { // Structure for 6-byte CDBs
BYTE SRB_Cmd; // ASPI command code
// = SC_EXEC_SCSI_CMD
BYTE SRB_Status; // ASPI command status byte
BYTE SRB_HaId; // ASPI host adapter number
BYTE SRB_Flags; // ASPI request flags
DWORD SRB_Hdr_Rsvd; // Reserved, MUST = 0
BYTE SRB_Target; // Target's SCSI ID
BYTE SRB_Lun; // Target's LUN number
DWORD SRB_BufLen; // Data Allocation Length
BYTE SRB_SenseLen; // Sense Allocation Length
BYTE far *SRB_BufPointer; // Data Buffer Pointer
DWORD SRB_Rsvd1; // Reserved, MUST = 0
BYTE SRB_CDBLen; // CDB Length = 6
BYTE SRB_HaStat; // Host Adapter Status
BYTE SRB_TargStat; // Target Status
FARPROC SRB_PostProc; // Post routine
BYTE SRB_Rsvd2[34]; // Reserved, MUST = 0
BYTE CDBByte[6]; // SCSI CDB
BYTE SenseArea6[SENSE_LEN]; // Request Sense buffer
} SRB_ExecSCSICmd6;
圖
3 SRB_ExecSCSICmd6的結構
表
6. SRB_ExecSCSICmd6結構的意義
變數名稱 |
R/W |
意義描述 |
SRB_Cmd |
W |
設定為 SC_EXEC_SCSI_CMD表示要作命令的傳送。 |
SRB_Status |
R |
Target 端接收完命令後會回應一個狀態給Initiator。 |
SRB_HaId |
- |
Reserved 。設定成0。 |
SRB_Flags |
W |
設定為 SRB_DIR_SCSI表示直接傳送命令。 |
SRB_Hdr_Rsvd |
- |
Reserved 。設定成0。 |
SRB_Target |
W |
週邊裝置的 Target ID。 |
SRB_Lun |
W |
週邊裝置的 LUN。 |
SRB_BufLen |
W |
傳送資料長度。若只傳送命令則將其設為 0即可。 |
SRB_SenceLen |
W |
若只傳送命令將其設為 0即可。 |
SRB_BufPointer |
W |
指向 Data Buffer的位址。 |
SRB_CDBLen |
W |
傳送命令的長度。 |
SRB_HaStat |
R |
傳回 host adapter status。 |
SRB_TargStat |
R |
傳回 target status。 |
SRB_PostProc |
W |
暫未用到。 |
CDBByte[...] |
W |
將命令碼依序寫入此。 |
SenseArea[...] |
R |
暫未用到。 |