Changeset 48122 in vbox for trunk/src/VBox/Devices/PC
- Timestamp:
- Aug 28, 2013 11:52:38 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/BIOS/disk.c
r44528 r48122 94 94 95 95 96 /* 96 /* 97 97 * Build translated CHS geometry given a disk size in sectors. Based on 98 98 * Phoenix EDD 3.0. This is used as a fallback to generate sane logical … … 104 104 unsigned heads = 255; 105 105 int i; 106 106 107 107 /* Start with ~4GB limit, go down to 504MB. */ 108 108 for (i = 0; i < 4; ++i) { … … 133 133 bios_dsk = read_word(0x0040,0x000E) :> &EbdaData->bdisk; 134 134 write_byte(0x0040, 0x008e, 0); // clear completion flag 135 135 136 136 // basic check : device has to be defined 137 137 if ( (GET_ELDL() < 0x80) || (GET_ELDL() >= 0x80 + BX_MAX_STORAGE_DEVICES) ) { … … 139 139 goto int13_fail; 140 140 } 141 141 142 142 // Get the ata channel 143 143 device = bios_dsk->hdidmap[GET_ELDL()-0x80]; 144 144 145 145 // basic check : device has to be valid 146 146 if (device >= BX_MAX_STORAGE_DEVICES) { … … 178 178 sector = (GET_CL() & 0x3f); 179 179 head = GET_DH(); 180 181 /* Segment and offset are in ES:BX. */ 180 181 /* Segment and offset are in ES:BX. */ 182 182 if ( (count > 128) || (count == 0) ) { 183 183 BX_INFO("%s: function %02x, count out of range!\n", __func__, GET_AH()); … … 195 195 goto int13_fail; 196 196 } 197 197 198 198 // FIXME verify 199 199 if ( GET_AH() == 0x04 ) … … 206 206 sector = 0; // this forces the command to be lba 207 207 } 208 209 BX_DEBUG_INT13_HD("%s: %d sectors from lba %lu @ %04x:%04x\n", __func__, 210 count, lba, ES, BX); 208 211 209 212 /* Clear the count of transferred sectors/bytes. */ … … 225 228 // Set nb of sector transferred 226 229 SET_AL(bios_dsk->drqp.trsfsectors); 227 230 228 231 if (status != 0) { 229 232 BX_INFO("%s: function %02x, error %02x !\n", __func__, GET_AH(), status); … … 231 234 goto int13_fail_noah; 232 235 } 233 236 234 237 goto int13_success; 235 238 break; … … 256 259 SET_DH(nlh - 1); 257 260 SET_DL(count); /* FIXME returns 0, 1, or n hard drives */ 258 261 259 262 // FIXME should set ES & DI 260 263 // @todo: Actually, the above comment is nonsense. 261 264 262 265 goto int13_success; 263 266 break; … … 287 290 CX = lba >> 16; 288 291 DX = lba & 0xffff; 289 292 290 293 SET_AH(3); // hard disk accessible 291 294 goto int13_success_noah; … … 341 344 bios_dsk = read_word(0x0040,0x000E) :> &EbdaData->bdisk; 342 345 343 BX_DEBUG_INT13_HD("%s: AX=%04x BX=%04x CX=%04x DX=%04x ES=%04x\n", __func__, AX, BX, CX, DX, ES); 344 346 BX_DEBUG_INT13_HD("%s: AX=%04x BX=%04x CX=%04x DX=%04x ES=%04x DS=%04x SI=%04x\n", 347 __func__, AX, BX, CX, DX, ES, DS, SI); 348 345 349 write_byte(0x0040, 0x008e, 0); // clear completion flag 346 350 347 351 // basic check : device has to be defined 348 352 if ( (GET_ELDL() < 0x80) || (GET_ELDL() >= 0x80 + BX_MAX_STORAGE_DEVICES) ) { … … 350 354 goto int13x_fail; 351 355 } 352 356 353 357 // Get the ata channel 354 358 device = bios_dsk->hdidmap[GET_ELDL()-0x80]; 355 359 356 360 // basic check : device has to be valid 357 361 if (device >= BX_MAX_STORAGE_DEVICES) { … … 380 384 offset = i13_ext->offset; 381 385 382 BX_DEBUG_INT13_HD("%s: %d sectors from lba % u @ %04x:%04x\n", __func__,386 BX_DEBUG_INT13_HD("%s: %d sectors from lba %lu @ %04x:%04x\n", __func__, 383 387 count, i13_ext->lba1, segment, offset); 384 388 … … 389 393 goto int13x_fail; 390 394 } 391 395 392 396 // Get 32 bits lba and check 393 397 lba = i13_ext->lba1; … … 414 418 bios_dsk->drqp.sector = 0; /* Indicate LBA. */ 415 419 bios_dsk->drqp.dev_id = device; 416 420 417 421 /* Execute the read or write command. */ 418 422 status = dskacc[type].a[GET_AH() - 0x42](bios_dsk); 419 423 count = bios_dsk->drqp.trsfsectors; 420 424 i13_ext->count = count; 421 425 422 426 if (status != 0) { 423 427 BX_INFO("%s: function %02x, error %02x !\n", __func__, GET_AH(), status); … … 425 429 goto int13x_fail_noah; 426 430 } 427 431 428 432 goto int13x_success; 429 433 break; … … 446 450 if (size < 0x1a) 447 451 goto int13x_fail; 448 452 449 453 /* Fill in EDD 1.x table. */ 450 454 if (size >= 0x1a) { … … 471 475 uint8_t channel, irq, mode, checksum, i, translation; 472 476 uint16_t iobase1, iobase2, options; 473 477 474 478 dpt->size = 0x1e; 475 479 dpt->dpte_segment = ebda_seg; 476 480 dpt->dpte_offset = (uint16_t)&EbdaData->bdisk.dpte; 477 481 478 482 // Fill in dpte 479 483 channel = device / 2; … … 483 487 mode = bios_dsk->devices[device].mode; 484 488 translation = bios_dsk->devices[device].translation; 485 489 486 490 options = (translation == GEO_TRANSLATION_NONE ? 0 : 1 << 3); // chs translation 487 491 options |= (1 << 4); // lba translation … … 489 493 options |= (translation == GEO_TRANSLATION_LBA ? 1 : 0 << 9); 490 494 options |= (translation == GEO_TRANSLATION_RECHS ? 3 : 0 << 9); 491 495 492 496 bios_dsk->dpte.iobase1 = iobase1; 493 497 bios_dsk->dpte.iobase2 = iobase2; … … 501 505 bios_dsk->dpte.reserved = 0; 502 506 bios_dsk->dpte.revision = 0x11; 503 507 504 508 checksum = 0; 505 509 for (i = 0; i < 15; ++i) … … 517 521 iface = bios_dsk->channels[channel].iface; 518 522 iobase1 = bios_dsk->channels[channel].iobase1; 519 523 520 524 dpt->size = 0x42; 521 525 dpt->key = 0xbedd; … … 523 527 dpt->reserved1 = 0; 524 528 dpt->reserved2 = 0; 525 529 526 530 if (iface == ATA_IFACE_ISA) { 527 531 dpt->host_bus[0] = 'I'; … … 541 545 dpt->iface_type[6] = ' '; 542 546 dpt->iface_type[7] = ' '; 543 547 544 548 if (iface == ATA_IFACE_ISA) { 545 549 ((uint16_t __far *)dpt->iface_path)[0] = iobase1; … … 553 557 ((uint16_t __far *)dpt->device_path)[1] = 0; 554 558 ((uint32_t __far *)dpt->device_path)[1] = 0; 555 559 556 560 checksum = 0; 557 561 for (i = 30; i < 64; i++)
Note:
See TracChangeset
for help on using the changeset viewer.