|
|
1.1 root 1: /* SCSI Bus and Disk emulation */
2:
3:
4: /* Opcodes */
5: /* The following are multi-sector transfers with seek implied */
6: #define HD_VERIFY_TRACK 0x05 /* Verify track */
7: #define HD_FORMAT_TRACK 0x06 /* Format track */
8: #define HD_READ_SECTOR 0x08 /* Read sector */
9: #define HD_READ_SECTOR1 0x28 /* Read sector (class 1) */
10: #define HD_WRITE_SECTOR 0x0A /* Write sector */
11: #define HD_WRITE_SECTOR1 0x2A /* Write sector (class 1) */
12:
13: /* other codes */
14: #define HD_TEST_UNIT_RDY 0x00 /* Test unit ready */
15: #define HD_FORMAT_DRIVE 0x04 /* Format the whole drive */
16: #define HD_SEEK 0x0B /* Seek */
17: #define HD_CORRECTION 0x0D /* Correction */
18: #define HD_INQUIRY 0x12 /* Inquiry */
19: #define HD_MODESELECT 0x15 /* Mode select */
20: #define HD_MODESENSE 0x1A /* Mode sense */
21: #define HD_REQ_SENSE 0x03 /* Request sense */
22: #define HD_SHIP 0x1B /* Ship drive */
23: #define HD_READ_CAPACITY1 0x25 /* Read capacity (class 1) */
24:
25: /* Status codes */
26: #define HD_STATUS_OK 0x00 /* OK */
27: #define HD_STATUS_ERROR 0x02 /* Check Condition */
28: #define HD_STATUS_CONDMET 0x04 /* Condition Met */
29: #define HD_STATUS_BUSY 0x08 /* Busy */
30:
31: /* Error codes for REQUEST SENSE: */
32: #define HD_REQSENS_OK 0x00 /* OK return status */
33: #define HD_REQSENS_NOSECTOR 0x01 /* No index or sector */
34: #define HD_REQSENS_WRITEERR 0x03 /* Write fault */
35: #define HD_REQSENS_OPCODE 0x20 /* Opcode not supported */
36: #define HD_REQSENS_INVADDR 0x21 /* Invalid block address */
37: #define HD_REQSENS_INVARG 0x24 /* Invalid argument */
38: #define HD_REQSENS_NODRIVE 0x25 /* Invalid drive */
39:
40:
41: typedef struct {
42: int readCount; /* count of number of command bytes written */
43: unsigned char source_busid;
44: unsigned char target;
45: unsigned char lun;
46: unsigned char opcode;
47: bool nodevice;
48: bool timeout;
49: int transfer_data_len;
50: int transferdirection_todevice;
51: bool extended;
52:
53: int byteCount; /* count of number of command bytes written */
54: unsigned char command[10];
55: short int returnCode; /* return code from the HDC operation */
56: } SCSICOMMAND;
57:
58: /* SCSI globals */
59: SCSICOMMAND SCSIcommand;
60:
61: /* Mode Pages */
62: #define MODEPAGE_MAX_SIZE 24
63: typedef struct {
64: Uint8 current[MODEPAGE_MAX_SIZE];
65: Uint8 changeable[MODEPAGE_MAX_SIZE];
66: Uint8 modepage[MODEPAGE_MAX_SIZE]; // default values
67: Uint8 saved[MODEPAGE_MAX_SIZE];
68: Uint8 pagesize;
69: } MODEPAGE;
70:
71:
72:
73:
74: void SCSI_Init(void);
75: void SCSI_Uninit(void);
76: void SCSI_Reset(void);
77: void scsi_command_analyzer(Uint8 command[], int size, int target,int lun);
78:
79: /* Helpers */
80: int SCSI_GetTransferLength(void);
81: unsigned long SCSI_GetOffset(void);
82: int SCSI_GetCount(void);
83: MODEPAGE SCSI_GetModePage(Uint8 pagecode);
84:
85:
86: void SCSI_Emulate_Command(void);
87:
88: /* SCSI Commands */
89: void SCSI_Inquiry (void);
90: void SCSI_StartStop(void);
91: void SCSI_TestUnitReady(void);
92: void SCSI_ReadCapacity(void);
93: void SCSI_ReadSector(void);
1.1.1.2 ! root 94: void SCSI_WriteSector(void);
1.1 root 95: void SCSI_RequestSense(void);
96: void SCSI_ModeSense(void);
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.