Changeset 39355 in vbox for trunk/src/VBox/Devices/PC/BIOS-new/scsi.c
- Timestamp:
- Nov 17, 2011 5:25:25 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 74940
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/BIOS-new/scsi.c
r39347 r39355 24 24 25 25 26 //#define VBOX_SCSI_DEBUG 1 /* temporary */ 27 28 #ifdef VBOX_SCSI_DEBUG 29 # define VBSCSI_DEBUG(...) BX_INFO(__VA_ARGS__) 30 #else 31 # define VBSCSI_DEBUG(...) 32 #endif 33 34 #define VBSCSI_BUSY (1 << 0) 35 26 36 /* The I/O port of the BusLogic SCSI adapter. */ 27 37 #define BUSLOGIC_ISA_IO_PORT 0x330 … … 49 59 #define SCSI_TXDIR_TO_DEVICE 1 50 60 51 #define VBSCSI_BUSY (1 << 0) 52 53 //#define VBOX_SCSI_DEBUG 1 /* temporary */ 54 55 #ifdef VBOX_SCSI_DEBUG 56 # define VBSCSI_DEBUG(...) BX_INFO(__VA_ARGS__) 57 #else 58 # define VBSCSI_DEBUG(...) 59 #endif 61 #pragma pack(1) 62 63 /* READ_10/WRITE_10 CDB layout. */ 64 typedef struct { 65 uint16_t command; /* Command. */ 66 uint32_t lba; /* LBA, MSB first! */ 67 uint8_t pad1; /* Unused. */ 68 uint16_t nsect; /* Sector count, MSB first! */ 69 uint8_t pad2; /* Unused. */ 70 } cdb_rw10; 71 72 #pragma pack() 73 74 ct_assert(sizeof(cdb_rw10) == 10); 60 75 61 76 int scsi_cmd_data_in(uint16_t io_base, uint8_t device_id, uint8_t __far *aCDB, … … 146 161 { 147 162 uint8_t rc; 148 uint8_t aCDB[10];163 cdb_rw10 cdb; 149 164 uint16_t io_base; 150 165 uint8_t target_id; … … 154 169 BX_PANIC("scsi_read_sectors: device_id out of range %d\n", device_id); 155 170 171 /* Prepare a CDB. */ 172 cdb.command = SCSI_READ_10; 173 cdb.lba = swap_32(lba); 174 cdb.pad1 = 0; 175 cdb.nsect = swap_16(count); 176 cdb.pad2 = 0; 177 156 178 bios_dsk = read_word(0x0040, 0x000E) :> &EbdaData->bdisk; 157 158 /* Reset the count of transferred sectors/bytes. */159 bios_dsk->trsfsectors = 0;160 bios_dsk->trsfbytes = 0;161 162 /* Prepare CDB */163 //@todo: make CDB a struct, this is stupid164 aCDB[0] = SCSI_READ_10;165 aCDB[1] = 0;166 aCDB[2] = (uint8_t)(lba >> 24);167 aCDB[3] = (uint8_t)(lba >> 16);168 aCDB[4] = (uint8_t)(lba >> 8);169 aCDB[5] = (uint8_t)(lba);170 aCDB[6] = 0;171 aCDB[7] = (uint8_t)(count >> 8);172 aCDB[8] = (uint8_t)(count);173 aCDB[9] = 0;174 179 175 180 io_base = bios_dsk->scsidev[device_id].io_base; 176 181 target_id = bios_dsk->scsidev[device_id].target_id; 177 182 178 rc = scsi_cmd_data_in(io_base, target_id, aCDB, 10, buffer, (count * 512));183 rc = scsi_cmd_data_in(io_base, target_id, (void __far *)&cdb, 10, buffer, (count * 512)); 179 184 180 185 if (!rc) 181 186 { 182 bios_dsk-> trsfsectors = count;183 bios_dsk-> trsfbytes = count * 512;187 bios_dsk->drqp.trsfsectors = count; 188 bios_dsk->drqp.trsfbytes = count * 512; 184 189 } 185 190 … … 199 204 { 200 205 uint8_t rc; 201 uint8_t aCDB[10];206 cdb_rw10 cdb; 202 207 uint16_t io_base; 203 208 uint8_t target_id; … … 207 212 BX_PANIC("scsi_write_sectors: device_id out of range %d\n", device_id); 208 213 214 /* Prepare a CDB. */ 215 cdb.command = SCSI_WRITE_10; 216 cdb.lba = swap_32(lba); 217 cdb.pad1 = 0; 218 cdb.nsect = swap_16(count); 219 cdb.pad2 = 0; 220 209 221 bios_dsk = read_word(0x0040, 0x000E) :> &EbdaData->bdisk; 210 211 // Reset count of transferred data212 bios_dsk->trsfsectors = 0;213 bios_dsk->trsfbytes = 0;214 215 /* Prepare CDB */216 //@todo: make CDB a struct, this is stupid217 aCDB[0] = SCSI_WRITE_10;218 aCDB[1] = 0;219 aCDB[2] = (uint8_t)(lba >> 24);220 aCDB[3] = (uint8_t)(lba >> 16);221 aCDB[4] = (uint8_t)(lba >> 8);222 aCDB[5] = (uint8_t)(lba);223 aCDB[6] = 0;224 aCDB[7] = (uint8_t)(count >> 8);225 aCDB[8] = (uint8_t)(count);226 aCDB[9] = 0;227 222 228 223 io_base = bios_dsk->scsidev[device_id].io_base; 229 224 target_id = bios_dsk->scsidev[device_id].target_id; 230 225 231 rc = scsi_cmd_data_out(io_base, target_id, aCDB, 10, buffer, (count * 512));226 rc = scsi_cmd_data_out(io_base, target_id, (void __far *)&cdb, 10, buffer, (count * 512)); 232 227 233 228 if (!rc) 234 229 { 235 bios_dsk-> trsfsectors = count;236 bios_dsk-> trsfbytes = (count * 512);230 bios_dsk->drqp.trsfsectors = count; 231 bios_dsk->drqp.trsfbytes = (count * 512); 237 232 } 238 233
Note:
See TracChangeset
for help on using the changeset viewer.