Changeset 39347 in vbox for trunk/src/VBox/Devices/PC/BIOS-new
- Timestamp:
- Nov 17, 2011 2:53:03 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 74929
- Location:
- trunk/src/VBox/Devices/PC/BIOS-new
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/BIOS-new/disk.c
r39346 r39347 73 73 uint16_t count; 74 74 uint8_t device, status; 75 ebda_data_t __far *ebda_data;75 bio_dsk_t __far *bios_dsk; 76 76 77 77 BX_DEBUG_INT13_HD("%s: AX=%04x BX=%04x CX=%04x DX=%04x ES=%04x\n", __func__, AX, BX, CX, DX, ES); 78 78 79 ebda_data = read_word(0x0040,0x000E) :> 0;79 bios_dsk = read_word(0x0040,0x000E) :> &EbdaData->bdisk; 80 80 write_byte(0x0040, 0x008e, 0); // clear completion flag 81 81 … … 87 87 88 88 // Get the ata channel 89 device = ebda_data->bdisk.hdidmap[GET_ELDL()-0x80];89 device = bios_dsk->hdidmap[GET_ELDL()-0x80]; 90 90 91 91 // basic check : device has to be valid … … 132 132 133 133 /* Get the logical CHS geometry. */ 134 nlc = ebda_data->bdisk.devices[device].lchs.cylinders;135 nlh = ebda_data->bdisk.devices[device].lchs.heads;136 nlspt = ebda_data->bdisk.devices[device].lchs.spt;134 nlc = bios_dsk->devices[device].lchs.cylinders; 135 nlh = bios_dsk->devices[device].lchs.heads; 136 nlspt = bios_dsk->devices[device].lchs.spt; 137 137 138 138 /* Sanity check the geometry. */ … … 147 147 148 148 /* Now get relevant the physical geometry information. */ 149 nph = ebda_data->bdisk.devices[device].pchs.heads;150 npspt = ebda_data->bdisk.devices[device].pchs.spt;149 nph = bios_dsk->devices[device].pchs.heads; 150 npspt = bios_dsk->devices[device].pchs.spt; 151 151 152 152 /* If required, translate LCHS to LBA and execute command. */ … … 165 165 #endif 166 166 { 167 ebda_data->bdisk.devices[device].blksize = count * 0x200;167 bios_dsk->devices[device].blksize = count * 0x200; 168 168 status=ata_cmd_data_in(device, ATA_CMD_READ_MULTIPLE, count, cylinder, head, sector, lba, MK_FP(ES, BX)); 169 ebda_data->bdisk.devices[device].blksize = 0x200;169 bios_dsk->devices[device].blksize = 0x200; 170 170 } 171 171 } else { … … 179 179 180 180 // Set nb of sector transferred 181 SET_AL( ebda_data->bdisk.trsfsectors);181 SET_AL(bios_dsk->trsfsectors); 182 182 183 183 if (status != 0) { … … 199 199 200 200 /* Get the logical geometry from internal table. */ 201 nlc = ebda_data->bdisk.devices[device].lchs.cylinders;202 nlh = ebda_data->bdisk.devices[device].lchs.heads;203 nlspt = ebda_data->bdisk.devices[device].lchs.spt;204 205 count = ebda_data->bdisk.hdcount;201 nlc = bios_dsk->devices[device].lchs.cylinders; 202 nlh = bios_dsk->devices[device].lchs.heads; 203 nlspt = bios_dsk->devices[device].lchs.spt; 204 205 count = bios_dsk->hdcount; 206 206 /* Maximum cylinder number is just one less than the number of cylinders. */ 207 207 nlc = nlc - 1; /* 0 based , last sector not used */ … … 222 222 223 223 // Read the status from controller 224 status = inb( ebda_data->bdisk.channels[device/2].iobase1 + ATA_CB_STAT);224 status = inb(bios_dsk->channels[device/2].iobase1 + ATA_CB_STAT); 225 225 if ( (status & ( ATA_CB_STAT_BSY | ATA_CB_STAT_RDY )) == ATA_CB_STAT_RDY ) { 226 226 goto int13_success; … … 234 234 235 235 /* Get the physical geometry from internal table. */ 236 npc = ebda_data->bdisk.devices[device].pchs.cylinders;237 nph = ebda_data->bdisk.devices[device].pchs.heads;238 npspt = ebda_data->bdisk.devices[device].pchs.spt;236 npc = bios_dsk->devices[device].pchs.cylinders; 237 nph = bios_dsk->devices[device].pchs.heads; 238 npspt = bios_dsk->devices[device].pchs.spt; 239 239 240 240 /* Calculate sector count seen by old style INT 13h. */ … … 289 289 uint16_t size, count; 290 290 uint8_t device, status; 291 ebda_data_t __far *ebda_data;291 bio_dsk_t __far *bios_dsk; 292 292 int13ext_t __far *i13_ext; 293 293 dpt_t __far *dpt; 294 294 295 ebda_data = ebda_seg :> 0;295 bios_dsk = read_word(0x0040,0x000E) :> &EbdaData->bdisk; 296 296 297 297 BX_DEBUG_INT13_HD("%s: AX=%04x BX=%04x CX=%04x DX=%04x ES=%04x\n", __func__, AX, BX, CX, DX, ES); … … 306 306 307 307 // Get the ata channel 308 device = ebda_data->bdisk.hdidmap[GET_ELDL()-0x80];308 device = bios_dsk->hdidmap[GET_ELDL()-0x80]; 309 309 310 310 // basic check : device has to be valid … … 344 344 lba = i13_ext->lba1; 345 345 346 if (lba >= ebda_data->bdisk.devices[device].sectors) {346 if (lba >= bios_dsk->devices[device].sectors) { 347 347 BX_INFO("%s: function %02x. LBA out of range\n", __func__, GET_AH()); 348 348 goto int13x_fail; … … 363 363 status=ata_cmd_data_in(device, ATA_CMD_READ_SECTORS_EXT, count, 0, 0, 0, lba, MK_FP(segment, offset)); 364 364 else { 365 ebda_data->bdisk.devices[device].blksize = count * 0x200;365 bios_dsk->devices[device].blksize = count * 0x200; 366 366 status=ata_cmd_data_in(device, ATA_CMD_READ_MULTIPLE, count, 0, 0, 0, lba, MK_FP(segment, offset)); 367 ebda_data->bdisk.devices[device].blksize = 0x200;367 bios_dsk->devices[device].blksize = 0x200; 368 368 } 369 369 } … … 381 381 } 382 382 383 count = ebda_data->bdisk.trsfsectors;383 count = bios_dsk->trsfsectors; 384 384 i13_ext->count = count; 385 385 … … 415 415 uint16_t blksize; 416 416 417 npc = ebda_data->bdisk.devices[device].pchs.cylinders;418 nph = ebda_data->bdisk.devices[device].pchs.heads;419 npspt = ebda_data->bdisk.devices[device].pchs.spt;420 lba = ebda_data->bdisk.devices[device].sectors;421 blksize = ebda_data->bdisk.devices[device].blksize;417 npc = bios_dsk->devices[device].pchs.cylinders; 418 nph = bios_dsk->devices[device].pchs.heads; 419 npspt = bios_dsk->devices[device].pchs.spt; 420 lba = bios_dsk->devices[device].sectors; 421 blksize = bios_dsk->devices[device].blksize; 422 422 423 423 dpt->size = 0x1a; … … 442 442 // Fill in dpte 443 443 channel = device / 2; 444 iobase1 = ebda_data->bdisk.channels[channel].iobase1;445 iobase2 = ebda_data->bdisk.channels[channel].iobase2;446 irq = ebda_data->bdisk.channels[channel].irq;447 mode = ebda_data->bdisk.devices[device].mode;448 translation = ebda_data->bdisk.devices[device].translation;444 iobase1 = bios_dsk->channels[channel].iobase1; 445 iobase2 = bios_dsk->channels[channel].iobase2; 446 irq = bios_dsk->channels[channel].irq; 447 mode = bios_dsk->devices[device].mode; 448 translation = bios_dsk->devices[device].translation; 449 449 450 450 options = (translation == ATA_TRANSLATION_NONE ? 0 : 1 << 3); // chs translation … … 454 454 options |= (translation==ATA_TRANSLATION_RECHS ? 3 : 0 << 9); 455 455 456 ebda_data->bdisk.dpte.iobase1 = iobase1;457 ebda_data->bdisk.dpte.iobase2 = iobase2;458 ebda_data->bdisk.dpte.prefix = (0xe | (device % 2)) << 4;459 ebda_data->bdisk.dpte.unused = 0xcb;460 ebda_data->bdisk.dpte.irq = irq;461 ebda_data->bdisk.dpte.blkcount = 1;462 ebda_data->bdisk.dpte.dma = 0;463 ebda_data->bdisk.dpte.pio = 0;464 ebda_data->bdisk.dpte.options = options;465 ebda_data->bdisk.dpte.reserved = 0;466 ebda_data->bdisk.dpte.revision = 0x11;456 bios_dsk->dpte.iobase1 = iobase1; 457 bios_dsk->dpte.iobase2 = iobase2; 458 bios_dsk->dpte.prefix = (0xe | (device % 2)) << 4; 459 bios_dsk->dpte.unused = 0xcb; 460 bios_dsk->dpte.irq = irq; 461 bios_dsk->dpte.blkcount = 1; 462 bios_dsk->dpte.dma = 0; 463 bios_dsk->dpte.pio = 0; 464 bios_dsk->dpte.options = options; 465 bios_dsk->dpte.reserved = 0; 466 bios_dsk->dpte.revision = 0x11; 467 467 468 468 checksum = 0; … … 470 470 checksum += read_byte(ebda_seg, (uint16_t)&EbdaData->bdisk.dpte + i); 471 471 checksum = -checksum; 472 ebda_data->bdisk.dpte.checksum = checksum;472 bios_dsk->dpte.checksum = checksum; 473 473 } 474 474 … … 479 479 480 480 channel = device / 2; 481 iface = ebda_data->bdisk.channels[channel].iface;482 iobase1 = ebda_data->bdisk.channels[channel].iobase1;481 iface = bios_dsk->channels[channel].iface; 482 iobase1 = bios_dsk->channels[channel].iobase1; 483 483 484 484 dpt->size = 0x42; -
trunk/src/VBox/Devices/PC/BIOS-new/scsi.c
r39346 r39347 147 147 uint8_t rc; 148 148 uint8_t aCDB[10]; 149 uint16_t io_base , ebda_seg;149 uint16_t io_base; 150 150 uint8_t target_id; 151 ebda_data_t __far *ebda_data;151 bio_dsk_t __far *bios_dsk; 152 152 153 153 if (device_id > BX_MAX_SCSI_DEVICES) 154 154 BX_PANIC("scsi_read_sectors: device_id out of range %d\n", device_id); 155 155 156 ebda_seg = read_word(0x0040, 0x000E); 157 ebda_data = MK_FP(ebda_seg, 0); 158 159 // Reset count of transferred data 160 ebda_data->bdisk.trsfsectors = 0; 161 ebda_data->bdisk.trsfbytes = 0; 156 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; 162 161 163 162 /* Prepare CDB */ … … 174 173 aCDB[9] = 0; 175 174 176 io_base = ebda_data->bdisk.scsidev[device_id].io_base;177 target_id = ebda_data->bdisk.scsidev[device_id].target_id;175 io_base = bios_dsk->scsidev[device_id].io_base; 176 target_id = bios_dsk->scsidev[device_id].target_id; 178 177 179 178 rc = scsi_cmd_data_in(io_base, target_id, aCDB, 10, buffer, (count * 512)); … … 181 180 if (!rc) 182 181 { 183 ebda_data->bdisk.trsfsectors = count;184 ebda_data->bdisk.trsfbytes = count * 512;182 bios_dsk->trsfsectors = count; 183 bios_dsk->trsfbytes = count * 512; 185 184 } 186 185 … … 201 200 uint8_t rc; 202 201 uint8_t aCDB[10]; 203 uint16_t io_base , ebda_seg;202 uint16_t io_base; 204 203 uint8_t target_id; 205 ebda_data_t __far *ebda_data;204 bio_dsk_t __far *bios_dsk; 206 205 207 206 if (device_id > BX_MAX_SCSI_DEVICES) 208 207 BX_PANIC("scsi_write_sectors: device_id out of range %d\n", device_id); 209 208 210 ebda_seg = read_word(0x0040, 0x000E); 211 ebda_data = MK_FP(ebda_seg, 0); 209 bios_dsk = read_word(0x0040, 0x000E) :> &EbdaData->bdisk; 212 210 213 211 // Reset count of transferred data 214 ebda_data->bdisk.trsfsectors = 0;215 ebda_data->bdisk.trsfbytes = 0;212 bios_dsk->trsfsectors = 0; 213 bios_dsk->trsfbytes = 0; 216 214 217 215 /* Prepare CDB */ … … 228 226 aCDB[9] = 0; 229 227 230 io_base = ebda_data->bdisk.scsidev[device_id].io_base;231 target_id = ebda_data->bdisk.scsidev[device_id].target_id;228 io_base = bios_dsk->scsidev[device_id].io_base; 229 target_id = bios_dsk->scsidev[device_id].target_id; 232 230 233 231 rc = scsi_cmd_data_out(io_base, target_id, aCDB, 10, buffer, (count * 512)); … … 235 233 if (!rc) 236 234 { 237 ebda_data->bdisk.trsfsectors = count;238 ebda_data->bdisk.trsfbytes = (count * 512);235 bios_dsk->trsfsectors = count; 236 bios_dsk->trsfbytes = (count * 512); 239 237 } 240 238 … … 252 250 int i; 253 251 uint8_t buffer[0x0200]; 254 uint16_t ebda_seg; 255 ebda_data_t __far *ebda_data; 256 257 ebda_seg = read_word(0x0040, 0x000E); 258 ebda_data = MK_FP(ebda_seg, 0); 252 bio_dsk_t __far *bios_dsk; 253 254 bios_dsk = read_word(0x0040, 0x000E) :> &EbdaData->bdisk; 259 255 260 256 /* Go through target devices. */ … … 282 278 283 279 /* We add the disk only if the maximum is not reached yet. */ 284 if ( ebda_data->bdisk.scsi_hdcount < BX_MAX_SCSI_DEVICES)280 if (bios_dsk->scsi_hdcount < BX_MAX_SCSI_DEVICES) 285 281 { 286 282 uint32_t sectors, sector_size, cylinders; … … 335 331 } 336 332 cylinders = (uint32_t)(sectors / (heads * sectors_per_track)); 337 hdcount_scsi = ebda_data->bdisk.scsi_hdcount;333 hdcount_scsi = bios_dsk->scsi_hdcount; 338 334 339 335 /* Calculate index into the generic disk table. */ 340 336 hd_index = hdcount_scsi + BX_MAX_ATA_DEVICES; 341 337 342 ebda_data->bdisk.scsidev[hdcount_scsi].io_base = io_base;343 ebda_data->bdisk.scsidev[hdcount_scsi].target_id = i;344 ebda_data->bdisk.devices[hd_index].type = ATA_TYPE_SCSI;345 ebda_data->bdisk.devices[hd_index].device = ATA_DEVICE_HD;346 ebda_data->bdisk.devices[hd_index].removable = 0;347 ebda_data->bdisk.devices[hd_index].lock = 0;348 ebda_data->bdisk.devices[hd_index].mode = ATA_MODE_PIO16;349 ebda_data->bdisk.devices[hd_index].blksize = sector_size;350 ebda_data->bdisk.devices[hd_index].translation = ATA_TRANSLATION_LBA;338 bios_dsk->scsidev[hdcount_scsi].io_base = io_base; 339 bios_dsk->scsidev[hdcount_scsi].target_id = i; 340 bios_dsk->devices[hd_index].type = ATA_TYPE_SCSI; 341 bios_dsk->devices[hd_index].device = ATA_DEVICE_HD; 342 bios_dsk->devices[hd_index].removable = 0; 343 bios_dsk->devices[hd_index].lock = 0; 344 bios_dsk->devices[hd_index].mode = ATA_MODE_PIO16; 345 bios_dsk->devices[hd_index].blksize = sector_size; 346 bios_dsk->devices[hd_index].translation = ATA_TRANSLATION_LBA; 351 347 352 348 /* Write LCHS values. */ 353 ebda_data->bdisk.devices[hd_index].lchs.heads = heads;354 ebda_data->bdisk.devices[hd_index].lchs.spt = sectors_per_track;349 bios_dsk->devices[hd_index].lchs.heads = heads; 350 bios_dsk->devices[hd_index].lchs.spt = sectors_per_track; 355 351 if (cylinders > 1024) 356 ebda_data->bdisk.devices[hd_index].lchs.cylinders = 1024;352 bios_dsk->devices[hd_index].lchs.cylinders = 1024; 357 353 else 358 ebda_data->bdisk.devices[hd_index].lchs.cylinders = (uint16_t)cylinders;354 bios_dsk->devices[hd_index].lchs.cylinders = (uint16_t)cylinders; 359 355 360 356 /* Write PCHS values. */ 361 ebda_data->bdisk.devices[hd_index].pchs.heads = heads;362 ebda_data->bdisk.devices[hd_index].pchs.spt = sectors_per_track;357 bios_dsk->devices[hd_index].pchs.heads = heads; 358 bios_dsk->devices[hd_index].pchs.spt = sectors_per_track; 363 359 if (cylinders > 1024) 364 ebda_data->bdisk.devices[hd_index].pchs.cylinders = 1024;360 bios_dsk->devices[hd_index].pchs.cylinders = 1024; 365 361 else 366 ebda_data->bdisk.devices[hd_index].pchs.cylinders = (uint16_t)cylinders;367 368 ebda_data->bdisk.devices[hd_index].sectors = sectors;362 bios_dsk->devices[hd_index].pchs.cylinders = (uint16_t)cylinders; 363 364 bios_dsk->devices[hd_index].sectors = sectors; 369 365 370 366 /* Store the id of the disk in the ata hdidmap. */ 371 hdcount = ebda_data->bdisk.hdcount;372 ebda_data->bdisk.hdidmap[hdcount] = hdcount_scsi + BX_MAX_ATA_DEVICES;367 hdcount = bios_dsk->hdcount; 368 bios_dsk->hdidmap[hdcount] = hdcount_scsi + BX_MAX_ATA_DEVICES; 373 369 hdcount++; 374 ebda_data->bdisk.hdcount = hdcount;370 bios_dsk->hdcount = hdcount; 375 371 376 372 /* Update hdcount in the BDA. */ … … 380 376 381 377 hdcount_scsi++; 382 ebda_data->bdisk.scsi_hdcount = hdcount_scsi;378 bios_dsk->scsi_hdcount = hdcount_scsi; 383 379 } 384 380 else … … 398 394 void BIOSCALL scsi_init(void) 399 395 { 400 uint8_t identifier;401 uint16_t ebda_seg;402 403 404 ebda_seg = read_word(0x0040, 0x000E); 405 write_byte(ebda_seg, (uint16_t)&EbdaData->bdisk.scsi_hdcount, 0);396 uint8_t identifier; 397 bio_dsk_t __far *bios_dsk; 398 399 bios_dsk = read_word(0x0040, 0x000E) :> &EbdaData->bdisk; 400 401 bios_dsk->scsi_hdcount = 0; 406 402 407 403 identifier = 0;
Note:
See TracChangeset
for help on using the changeset viewer.