Changeset 43483 in vbox for trunk/src/VBox/Devices/PC/BIOS
- Timestamp:
- Oct 1, 2012 10:13:16 AM (12 years ago)
- Location:
- trunk/src/VBox/Devices/PC/BIOS
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/BIOS/ahci.c
r43438 r43483 608 608 } 609 609 610 staticvoid ahci_port_detect_device(ahci_t __far *ahci, uint8_t u8Port)610 void ahci_port_detect_device(ahci_t __far *ahci, uint8_t u8Port) 611 611 { 612 612 uint32_t val; … … 651 651 uint32_t sectors; 652 652 uint16_t cylinders, heads, spt; 653 uint16_t lcylinders, lheads, lspt;653 chs_t lgeo; 654 654 uint8_t idxCmosChsBase; 655 655 … … 711 711 if (idxCmosChsBase && inb_cmos(idxCmosChsBase+7)) 712 712 { 713 l cylinders = inb_cmos(idxCmosChsBase + 0) + (inb_cmos(idxCmosChsBase + 1) << 8);714 l heads = inb_cmos(idxCmosChsBase + 2);715 l spt = inb_cmos(idxCmosChsBase + 7);713 lgeo.cylinders = inb_cmos(idxCmosChsBase + 0) + (inb_cmos(idxCmosChsBase + 1) << 8); 714 lgeo.heads = inb_cmos(idxCmosChsBase + 2); 715 lgeo.spt = inb_cmos(idxCmosChsBase + 7); 716 716 } 717 717 else 718 { 719 //@todo: What should we really do if logical geometry isn't in the CMOS? 720 lcylinders = cylinders; 721 lheads = heads; 722 lspt = spt; 723 } 718 set_geom_lba(&lgeo, sectors); /* Default EDD-style translated LBA geometry. */ 719 724 720 BX_INFO("AHCI %d-P#%d: PCHS=%u/%d/%d LCHS=%u/%u/%u %ld sectors\n", devcount_ahci, 725 u8Port, cylinders, heads, spt, lcylinders, lheads, lspt, sectors); 726 727 bios_dsk->devices[hd_index].lchs.heads = lheads; 728 bios_dsk->devices[hd_index].lchs.cylinders = lcylinders; 729 bios_dsk->devices[hd_index].lchs.spt = lspt; 721 u8Port, cylinders, heads, spt, lgeo.cylinders, lgeo.heads, lgeo.spt, sectors); 722 723 bios_dsk->devices[hd_index].lchs = lgeo; 730 724 731 725 /* Store the ID of the disk in the BIOS hdidmap. */ -
trunk/src/VBox/Devices/PC/BIOS/ata.c
r43440 r43483 462 462 uint32_t sectors; 463 463 uint16_t cylinders, heads, spt, blksize; 464 uint16_t lcylinders, lheads, lspt;464 chs_t lgeo; 465 465 uint8_t chsgeo_base; 466 466 uint8_t removable, mode; … … 506 506 if (chsgeo_base) 507 507 { 508 l cylinders = inb_cmos(chsgeo_base) + (inb_cmos(chsgeo_base+1) << 8);509 l heads = inb_cmos(chsgeo_base+2);510 l spt = inb_cmos(chsgeo_base+7);508 lgeo.cylinders = inb_cmos(chsgeo_base) + (inb_cmos(chsgeo_base + 1) << 8); 509 lgeo.heads = inb_cmos(chsgeo_base + 2); 510 lgeo.spt = inb_cmos(chsgeo_base + 7); 511 511 } 512 512 else 513 { 514 lcylinders = 0; 515 lheads = 0; 516 lspt = 0; 517 } 513 set_geom_lba(&lgeo, sectors); /* Default EDD-style translated LBA geometry. */ 514 518 515 BX_INFO("ata%d-%d: PCHS=%u/%d/%d LCHS=%u/%u/%u\n", channel, slave, 519 cylinders,heads, spt, l cylinders, lheads, lspt);516 cylinders,heads, spt, lgeo.cylinders, lgeo.heads, lgeo.spt); 520 517 521 518 bios_dsk->devices[device].device = DSK_DEVICE_HD; … … 527 524 bios_dsk->devices[device].pchs.spt = spt; 528 525 bios_dsk->devices[device].sectors = sectors; 529 bios_dsk->devices[device].lchs.heads = lheads; 530 bios_dsk->devices[device].lchs.cylinders = lcylinders; 531 bios_dsk->devices[device].lchs.spt = lspt; 526 bios_dsk->devices[device].lchs = lgeo; 532 527 if (device < 2) 533 528 { … … 544 539 * isn't worth the effort of converting from AMI to Award CMOS 545 540 * format. Just do it here. */ 546 fdpt->lcyl = l cylinders;547 fdpt->lhead = l heads;541 fdpt->lcyl = lgeo.cylinders; 542 fdpt->lhead = lgeo.heads; 548 543 fdpt->sig = 0xa0; 549 544 fdpt->spt = spt; -
trunk/src/VBox/Devices/PC/BIOS/disk.c
r39651 r43483 92 92 #define ES r.es 93 93 #define FLAGS r.ra.flags.u.r16.flags 94 95 96 /* 97 * Build translated CHS geometry given a disk size in sectors. Based on 98 * Phoenix EDD 3.0. This is used as a fallback to generate sane logical 99 * geometry in case none was provided in CMOS. 100 */ 101 void set_geom_lba(chs_t __far *lgeo, uint32_t nsectors) 102 { 103 uint32_t limit = 8257536; /* 1024 * 128 * 63 */ 104 unsigned heads = 255; 105 int i; 106 107 /* Start with ~4GB limit, go down to 504MB. */ 108 for (i = 0; i < 4; ++i) { 109 if (nsectors <= limit) 110 heads = (heads + 1) / 2; 111 limit /= 2; 112 } 113 114 lgeo->cylinders = nsectors / (heads * 63UL); 115 if (lgeo->cylinders > 1024) 116 lgeo->cylinders = 1024; 117 lgeo->heads = heads; 118 lgeo->spt = 63; /* Always 63 sectors per track, the maximum. */ 119 } 120 94 121 95 122 void BIOSCALL int13_harddisk(disk_regs_t r) -
trunk/src/VBox/Devices/PC/BIOS/ebda.h
r43475 r43483 316 316 int __fastcall ahci_write_sectors(bio_dsk_t __far *bios_dsk); 317 317 318 extern void set_geom_lba(chs_t __far *lgeo, uint32_t nsectors); 319 318 320 // @todo: put this elsewhere (and change/eliminate?) 319 321 #define SET_DISK_RET_STATUS(status) write_byte(0x0040, 0x0074, status)
Note:
See TracChangeset
for help on using the changeset viewer.