Changeset 39651 in vbox
- Timestamp:
- Dec 17, 2011 1:13:49 PM (13 years ago)
- Location:
- trunk/src/VBox/Devices/PC/BIOS-new
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/BIOS-new/ahci.c
r39619 r39651 674 674 675 675 bios_dsk->ahcidev[devcount_ahci].port = u8Port; 676 bios_dsk->devices[hd_index].type = ATA_TYPE_AHCI;677 bios_dsk->devices[hd_index].device = ATA_DEVICE_HD;676 bios_dsk->devices[hd_index].type = DSK_TYPE_AHCI; 677 bios_dsk->devices[hd_index].device = DSK_DEVICE_HD; 678 678 bios_dsk->devices[hd_index].removable = removable; 679 679 bios_dsk->devices[hd_index].lock = 0; 680 680 bios_dsk->devices[hd_index].blksize = 512; 681 bios_dsk->devices[hd_index].translation = ATA_TRANSLATION_LBA;681 bios_dsk->devices[hd_index].translation = GEO_TRANSLATION_LBA; 682 682 bios_dsk->devices[hd_index].sectors = cSectors; 683 683 … … 704 704 idxCmosChsBase = 0; 705 705 } 706 if (idxCmosChsBase != 0)706 if (idxCmosChsBase && inb_cmos(idxCmosChsBase+7)) 707 707 { 708 708 cCylinders = inb_cmos(idxCmosChsBase) + (inb_cmos(idxCmosChsBase+1) << 8); … … 712 712 else 713 713 { 714 #if 0 // LCHS equals PCHS? 714 715 cCylinders = 0; 715 716 cHeads = 0; 716 717 cSectorsPerTrack = 0; 718 #endif 717 719 } 718 720 DBG_AHCI("AHCI: Dev %d LCHS=%d/%d/%d\n", … … 751 753 752 754 bios_dsk->ahcidev[devcount_ahci].port = u8Port; 753 bios_dsk->devices[hd_index].type = ATA_TYPE_AHCI;754 bios_dsk->devices[hd_index].device = ATA_DEVICE_CDROM;755 bios_dsk->devices[hd_index].type = DSK_TYPE_AHCI; 756 bios_dsk->devices[hd_index].device = DSK_DEVICE_CDROM; 755 757 bios_dsk->devices[hd_index].removable = removable; 756 758 bios_dsk->devices[hd_index].blksize = 2048; -
trunk/src/VBox/Devices/PC/BIOS-new/ata.c
r39560 r39651 96 96 // Devices info init. 97 97 for (device=0; device<BX_MAX_ATA_DEVICES; device++) { 98 bios_dsk->devices[device].type = ATA_TYPE_NONE;99 bios_dsk->devices[device].device = ATA_DEVICE_NONE;98 bios_dsk->devices[device].type = DSK_TYPE_NONE; 99 bios_dsk->devices[device].device = DSK_DEVICE_NONE; 100 100 bios_dsk->devices[device].removable = 0; 101 101 bios_dsk->devices[device].lock = 0; 102 102 bios_dsk->devices[device].mode = ATA_MODE_NONE; 103 103 bios_dsk->devices[device].blksize = 0x200; 104 bios_dsk->devices[device].translation = ATA_TRANSLATION_NONE;104 bios_dsk->devices[device].translation = GEO_TRANSLATION_NONE; 105 105 bios_dsk->devices[device].lchs.heads = 0; 106 106 bios_dsk->devices[device].lchs.cylinders = 0; … … 159 159 outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15 | ATA_CB_DC_NIEN); 160 160 161 if (bios_dsk->devices[device].type != ATA_TYPE_NONE) {161 if (bios_dsk->devices[device].type != DSK_TYPE_NONE) { 162 162 // 8.2.1 (g) -- check for sc==sn==0x01 163 163 // select device … … 429 429 430 430 if ( (sc == 0x55) && (sn == 0xaa) ) { 431 bios_dsk->devices[device].type = ATA_TYPE_UNKNOWN;431 bios_dsk->devices[device].type = DSK_TYPE_UNKNOWN; 432 432 433 433 // reset the channel … … 444 444 445 445 if ((cl==0x14) && (ch==0xeb)) { 446 bios_dsk->devices[device].type = ATA_TYPE_ATAPI;446 bios_dsk->devices[device].type = DSK_TYPE_ATAPI; 447 447 } else if ((cl==0x00) && (ch==0x00) && (st!=0x00)) { 448 bios_dsk->devices[device].type = ATA_TYPE_ATA;448 bios_dsk->devices[device].type = DSK_TYPE_ATA; 449 449 } else if ((cl==0xff) && (ch==0xff)) { 450 bios_dsk->devices[device].type = ATA_TYPE_NONE;450 bios_dsk->devices[device].type = DSK_TYPE_NONE; 451 451 } 452 452 } … … 459 459 460 460 // Now we send a IDENTIFY command to ATA device 461 if (type == ATA_TYPE_ATA) {461 if (type == DSK_TYPE_ATA) { 462 462 uint32_t sectors; 463 463 uint16_t cylinders, heads, spt, blksize; … … 467 467 468 468 //Temporary values to do the transfer 469 bios_dsk->devices[device].device = ATA_DEVICE_HD;469 bios_dsk->devices[device].device = DSK_DEVICE_HD; 470 470 bios_dsk->devices[device].mode = ATA_MODE_PIO16; 471 471 bios_dsk->drqp.buffer = buffer; … … 531 531 cylinders,heads, spt, lcylinders, lheads, lspt); 532 532 533 bios_dsk->devices[device].device = ATA_DEVICE_HD;533 bios_dsk->devices[device].device = DSK_DEVICE_HD; 534 534 bios_dsk->devices[device].removable = removable; 535 535 bios_dsk->devices[device].mode = mode; … … 576 576 577 577 // Now we send an IDENTIFY command to ATAPI device 578 if (type == ATA_TYPE_ATAPI) {578 if (type == DSK_TYPE_ATAPI) { 579 579 uint8_t type, removable, mode; 580 580 uint16_t blksize; 581 581 582 582 // Temporary values to do the transfer 583 bios_dsk->devices[device].device = ATA_DEVICE_CDROM;583 bios_dsk->devices[device].device = DSK_DEVICE_CDROM; 584 584 bios_dsk->devices[device].mode = ATA_MODE_PIO16; 585 585 bios_dsk->drqp.buffer = buffer; … … 611 611 612 612 switch (type) { 613 case ATA_TYPE_ATA:613 case DSK_TYPE_ATA: 614 614 sizeinmb = bios_dsk->devices[device].sectors; 615 615 sizeinmb >>= 11; 616 case ATA_TYPE_ATAPI:616 case DSK_TYPE_ATAPI: 617 617 // Read ATA/ATAPI version 618 618 ataversion = ((uint16_t)(*(buffer+161))<<8) | *(buffer+160); … … 644 644 switch (type) { 645 645 int c; 646 case ATA_TYPE_ATA:646 case DSK_TYPE_ATA: 647 647 printf("ata%d %s: ", channel, slave ? " slave" : "master"); 648 648 i=0; … … 651 651 printf(" ATA-%d Hard-Disk (%lu MBytes)\n", version, sizeinmb); 652 652 break; 653 case ATA_TYPE_ATAPI:653 case DSK_TYPE_ATAPI: 654 654 printf("ata%d %s: ", channel, slave ? " slave" : "master"); 655 655 i=0; 656 656 while(c=*(model+i++)) 657 657 printf("%c", c); 658 if (bios_dsk->devices[device].device == ATA_DEVICE_CDROM)658 if (bios_dsk->devices[device].device == DSK_DEVICE_CDROM) 659 659 printf(" ATAPI-%d CD-ROM/DVD-ROM\n", version); 660 660 else 661 661 printf(" ATAPI-%d Device\n", version); 662 662 break; 663 case ATA_TYPE_UNKNOWN:663 case DSK_TYPE_UNKNOWN: 664 664 printf("ata%d %s: Unknown device\n", channel , slave ? " slave" : "master"); 665 665 break; -
trunk/src/VBox/Devices/PC/BIOS-new/disk.c
r39610 r39651 52 52 # define BX_DEBUG_INT13_HD(...) 53 53 #endif 54 55 /* Generic disk read/write routine signature. */ 56 typedef __fastcall (* dsk_rw_func)(bio_dsk_t __far *bios_dsk); 57 58 /* Controller specific disk access routines. Declared as a union to reduce 59 * the need for conditionals when choosing between read/write functions. 60 * Note that we get away with using near pointers, which is nice. 61 */ 62 typedef union { 63 struct { 64 dsk_rw_func read; 65 dsk_rw_func write; 66 } s; 67 dsk_rw_func a[2]; 68 } dsk_acc_t; 69 70 /* Pointers to HW specific disk access routines. */ 71 dsk_acc_t dskacc[DSKTYP_CNT] = { 72 [DSK_TYPE_ATA] = { ata_read_sectors, ata_write_sectors }, 73 #ifdef VBOX_WITH_AHCI 74 [DSK_TYPE_AHCI] = { ahci_read_sectors, ahci_write_sectors }, 75 #endif 76 #ifdef VBOX_WITH_SCSI 77 [DSK_TYPE_SCSI] = { scsi_read_sectors, scsi_write_sectors }, 78 #endif 79 }; 80 54 81 55 82 //@todo: put in a header … … 167 194 bios_dsk->drqp.dev_id = device; 168 195 169 if ( GET_AH() == 0x02 ) 170 { 171 #ifdef VBOX_WITH_AHCI 172 if (VBOX_IS_AHCI_DEVICE(device)) 173 status = ahci_read_sectors(bios_dsk); 174 else 175 #endif 176 #ifdef VBOX_WITH_SCSI 177 if (VBOX_IS_SCSI_DEVICE(device)) 178 status = scsi_read_sectors(bios_dsk); 179 else 180 #endif 181 status = ata_read_sectors(bios_dsk); 182 } else { 183 #ifdef VBOX_WITH_AHCI 184 if (VBOX_IS_AHCI_DEVICE(device)) 185 status = ahci_write_sectors(bios_dsk); 186 else 187 #endif 188 #ifdef VBOX_WITH_SCSI 189 if (VBOX_IS_SCSI_DEVICE(device)) 190 status = scsi_write_sectors(bios_dsk); 191 else 192 #endif 193 status = ata_write_sectors(bios_dsk); 194 } 196 status = dskacc[bios_dsk->devices[device].type].a[GET_AH() - 0x02](bios_dsk); 195 197 196 198 // Set nb of sector transferred … … 305 307 uint16_t size, count; 306 308 uint8_t device, status; 309 uint8_t type; 307 310 bio_dsk_t __far *bios_dsk; 308 311 int13ext_t __far *i13_ext; … … 363 366 lba = i13_ext->lba1; 364 367 368 type = bios_dsk->devices[device].type; 365 369 if (lba >= bios_dsk->devices[device].sectors) { 366 370 BX_INFO("%s: function %02x. LBA out of range\n", __func__, GET_AH()); … … 368 372 } 369 373 370 / / If verify or seek374 /* Don't bother with seek or verify. */ 371 375 if (( GET_AH() == 0x44 ) || ( GET_AH() == 0x47 )) 372 376 goto int13x_success; … … 384 388 bios_dsk->drqp.dev_id = device; 385 389 386 // Execute the command 387 if ( GET_AH() == 0x42 ) { 388 #ifdef VBOX_WITH_AHCI 389 if (VBOX_IS_AHCI_DEVICE(device)) 390 status = ahci_read_sectors(bios_dsk); 391 else 392 #endif 393 #ifdef VBOX_WITH_SCSI 394 if (VBOX_IS_SCSI_DEVICE(device)) 395 status = scsi_read_sectors(bios_dsk); 396 else 397 #endif 398 status = ata_read_sectors(bios_dsk); 399 } else { 400 #ifdef VBOX_WITH_AHCI 401 if (VBOX_IS_AHCI_DEVICE(device)) 402 status = ahci_write_sectors(bios_dsk); 403 else 404 #endif 405 #ifdef VBOX_WITH_SCSI 406 if (VBOX_IS_SCSI_DEVICE(device)) 407 status = scsi_write_sectors(bios_dsk); 408 else 409 #endif 410 status = ata_write_sectors(bios_dsk); 411 } 412 413 count = bios_dsk->drqp.trsfsectors; 390 /* Execute the read or write command. */ 391 status = dskacc[type].a[GET_AH() - 0x42](bios_dsk); 392 count = bios_dsk->drqp.trsfsectors; 414 393 i13_ext->count = count; 415 394 … … 478 457 translation = bios_dsk->devices[device].translation; 479 458 480 options = (translation == ATA_TRANSLATION_NONE ? 0 : 1 << 3); // chs translation459 options = (translation == GEO_TRANSLATION_NONE ? 0 : 1 << 3); // chs translation 481 460 options |= (1 << 4); // lba translation 482 461 options |= (mode == ATA_MODE_PIO32 ? 1 : 0 << 7); 483 options |= (translation ==ATA_TRANSLATION_LBA ? 1 : 0 << 9);484 options |= (translation ==ATA_TRANSLATION_RECHS ? 3 : 0 << 9);462 options |= (translation == GEO_TRANSLATION_LBA ? 1 : 0 << 9); 463 options |= (translation == GEO_TRANSLATION_RECHS ? 3 : 0 << 9); 485 464 486 465 bios_dsk->dpte.iobase1 = iobase1; -
trunk/src/VBox/Devices/PC/BIOS-new/ebda.h
r39597 r39651 72 72 #define BX_MAX_STORAGE_DEVICES (BX_MAX_ATA_DEVICES + BX_MAX_SCSI_DEVICES + BX_MAX_AHCI_DEVICES) 73 73 74 /* Generic storage device types. Bit of a misnomer! */ 75 #define ATA_TYPE_NONE 0x00 76 #define ATA_TYPE_UNKNOWN 0x01 77 #define ATA_TYPE_ATA 0x02 78 #define ATA_TYPE_ATAPI 0x03 79 #define ATA_TYPE_SCSI 0x04 // SCSI disk 80 #define ATA_TYPE_AHCI 0x05 // SATA disk 81 82 #define ATA_DEVICE_NONE 0x00 83 #define ATA_DEVICE_HD 0xFF 84 #define ATA_DEVICE_CDROM 0x05 85 86 #define ATA_TRANSLATION_NONE 0 87 #define ATA_TRANSLATION_LBA 1 88 #define ATA_TRANSLATION_LARGE 2 89 #define ATA_TRANSLATION_RECHS 3 74 /* Generic storage device types. These depend on the controller type and 75 * determine which device access routines should be called. 76 */ 77 enum dsk_type_enm { 78 DSK_TYPE_NONE, /* Unknown device. */ 79 DSK_TYPE_UNKNOWN, /* Unknown ATA device. */ 80 DSK_TYPE_ATA, /* ATA disk. */ 81 DSK_TYPE_ATAPI, /* ATAPI device. */ 82 DSK_TYPE_SCSI, /* SCSI disk. */ 83 DSK_TYPE_AHCI, /* SATA disk via AHCI. */ 84 DSKTYP_CNT /* Number of disk types. */ 85 }; 86 87 /* Disk device types. */ 88 //@todo: Do we really need these? 89 #define DSK_DEVICE_NONE 0x00 /* No device attached. */ 90 #define DSK_DEVICE_HD 0xFF /* Device is a hard disk. */ 91 #define DSK_DEVICE_CDROM 0x05 /* Device is a CD-ROM. */ 92 93 /* Geometry translation modes. */ 94 enum geo_xlat_enm { 95 GEO_TRANSLATION_NONE, /* No geometry translation. */ 96 GEO_TRANSLATION_LBA, /* LBA translation. */ 97 GEO_TRANSLATION_LARGE, /* Large CHS translation. */ 98 GEO_TRANSLATION_RECHS 99 }; 90 100 91 101 #if 1 //BX_USE_ATADRV … … 205 215 } disk_req_t; 206 216 217 uint16_t ahci_cmd_packet(uint16_t device_id, uint8_t cmdlen, char __far *cmdbuf, 218 uint16_t header, uint32_t length, uint8_t inout, char __far *buffer); 219 220 uint16_t ata_cmd_packet(uint16_t device, uint8_t cmdlen, char __far *cmdbuf, 221 uint16_t header, uint32_t length, uint8_t inout, char __far *buffer); 222 207 223 /* All BIOS disk information. Disk-related code in the BIOS should not need 208 224 * anything outside of this structure. … … 299 315 int __fastcall ahci_write_sectors(bio_dsk_t __far *bios_dsk); 300 316 301 302 uint16_t ahci_cmd_packet(uint16_t device_id, uint8_t cmdlen, char __far *cmdbuf,303 uint16_t header, uint32_t length, uint8_t inout, char __far *buffer);304 305 uint16_t ata_cmd_packet(uint16_t device, uint8_t cmdlen, char __far *cmdbuf,306 uint16_t header, uint32_t length, uint8_t inout, char __far *buffer);307 308 317 // @todo: put this elsewhere (and change/eliminate?) 309 318 #define SET_DISK_RET_STATUS(status) write_byte(0x0040, 0x0074, status) -
trunk/src/VBox/Devices/PC/BIOS-new/eltorito.c
r39610 r39651 213 213 return 0; 214 214 215 // if (bios_dsk->devices[device].type != ATA_TYPE_ATAPI)215 // if (bios_dsk->devices[device].type != DSK_TYPE_ATAPI) 216 216 // return 0; 217 217 218 if (bios_dsk->devices[device].device != ATA_DEVICE_CDROM)218 if (bios_dsk->devices[device].device != DSK_DEVICE_CDROM) 219 219 return 0; 220 220 -
trunk/src/VBox/Devices/PC/BIOS-new/scsi.c
r39372 r39651 334 334 bios_dsk->scsidev[hdcount_scsi].io_base = io_base; 335 335 bios_dsk->scsidev[hdcount_scsi].target_id = i; 336 bios_dsk->devices[hd_index].type = ATA_TYPE_SCSI;337 bios_dsk->devices[hd_index].device = ATA_DEVICE_HD;336 bios_dsk->devices[hd_index].type = DSK_TYPE_SCSI; 337 bios_dsk->devices[hd_index].device = DSK_DEVICE_HD; 338 338 bios_dsk->devices[hd_index].removable = 0; 339 339 bios_dsk->devices[hd_index].lock = 0; 340 340 bios_dsk->devices[hd_index].blksize = sector_size; 341 bios_dsk->devices[hd_index].translation = ATA_TRANSLATION_LBA;341 bios_dsk->devices[hd_index].translation = GEO_TRANSLATION_LBA; 342 342 343 343 /* Write LCHS values. */
Note:
See TracChangeset
for help on using the changeset viewer.