VirtualBox

Changeset 42947 in vbox for trunk/src


Ignore:
Timestamp:
Aug 23, 2012 12:06:39 PM (12 years ago)
Author:
vboxsync
Message:

BIOS: Make AHCI init more similar to ATA, log discovered harddisks.

Location:
trunk/src/VBox/Devices/PC/BIOS
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/BIOS/ahci.c

    r42842 r42947  
    645645            if (val == 0x101)
    646646            {
    647                 uint32_t    cSectors;
    648                 uint16_t    cCylinders, cHeads, cSectorsPerTrack;
     647                uint32_t    sectors;
     648                uint16_t    cylinders, heads, spt;
     649                uint16_t    lcylinders, lheads, lspt;
    649650                uint8_t     idxCmosChsBase;
    650651
     
    661662                hd_index = devcount_ahci + BX_MAX_ATA_DEVICES + BX_MAX_SCSI_DEVICES;
    662663
    663                 removable        = *(abBuffer+0) & 0x80 ? 1 : 0;
    664                 cCylinders       = *(uint16_t *)(abBuffer+(1*2));   // word 1
    665                 cHeads           = *(uint16_t *)(abBuffer+(3*2));   // word 3
    666                 cSectorsPerTrack = *(uint16_t *)(abBuffer+(6*2));   // word 6
    667                 cSectors         = *(uint32_t *)(abBuffer+(60*2)); // word 60 and word 61
     664                removable = *(abBuffer+0) & 0x80 ? 1 : 0;
     665                cylinders = *(uint16_t *)(abBuffer+(1*2));  // word 1
     666                heads     = *(uint16_t *)(abBuffer+(3*2));  // word 3
     667                spt       = *(uint16_t *)(abBuffer+(6*2));  // word 6
     668                sectors   = *(uint32_t *)(abBuffer+(60*2)); // word 60 and word 61
    668669
    669670                /** @todo update sectors to be a 64 bit number (also lba...). */
    670                 if (cSectors == 268435455)
    671                     cSectors = *(uint32_t *)(abBuffer+(100*2)); // words 100 to 103 (someday)
    672 
    673                 DBG_AHCI("AHCI: %ld sectors\n", cSectors);
     671                if (sectors == 0x0FFFFFFF)  /* For disks bigger than ~128GB */
     672                    sectors = *(uint32_t *)(abBuffer+(100*2)); // words 100 to 103 (someday)
     673
     674                DBG_AHCI("AHCI: %ld sectors\n", sectors);
    674675
    675676                bios_dsk->ahcidev[devcount_ahci].port = u8Port;
     
    680681                bios_dsk->devices[hd_index].blksize     = 512;
    681682                bios_dsk->devices[hd_index].translation = GEO_TRANSLATION_LBA;
    682                 bios_dsk->devices[hd_index].sectors     = cSectors;
    683 
    684                 bios_dsk->devices[hd_index].pchs.heads     = cHeads;
    685                 bios_dsk->devices[hd_index].pchs.cylinders = cCylinders;
    686                 bios_dsk->devices[hd_index].pchs.spt       = cSectorsPerTrack;
     683                bios_dsk->devices[hd_index].sectors     = sectors;
     684
     685                bios_dsk->devices[hd_index].pchs.heads     = heads;
     686                bios_dsk->devices[hd_index].pchs.cylinders = cylinders;
     687                bios_dsk->devices[hd_index].pchs.spt       = spt;
    687688
    688689                /* Get logical CHS geometry. */
     
    706707                if (idxCmosChsBase && inb_cmos(idxCmosChsBase+7))
    707708                {
    708                     cCylinders = inb_cmos(idxCmosChsBase) + (inb_cmos(idxCmosChsBase+1) << 8);
    709                     cHeads = inb_cmos(idxCmosChsBase+2);
    710                     cSectorsPerTrack = inb_cmos(idxCmosChsBase+7);
     709                    lcylinders = inb_cmos(idxCmosChsBase + 0) + (inb_cmos(idxCmosChsBase + 1) << 8);
     710                    lheads     = inb_cmos(idxCmosChsBase + 2);
     711                    lspt       = inb_cmos(idxCmosChsBase + 7);
    711712                }
    712713                else
    713714                {
    714 #if 0   // LCHS equals PCHS?
    715                     cCylinders = 0;
    716                     cHeads = 0;
    717                     cSectorsPerTrack = 0;
    718 #endif
     715                    //@todo: What should we really do if logical geometry isn't in the CMOS?
     716                    lcylinders = cylinders;
     717                    lheads     = heads;
     718                    lspt       = spt;
    719719                }
    720                 DBG_AHCI("AHCI: Dev %d LCHS=%d/%d/%d\n",
    721                          devcount_ahci, cCylinders, cHeads, cSectorsPerTrack);
    722 
    723                 bios_dsk->devices[hd_index].lchs.heads     = cHeads;
    724                 bios_dsk->devices[hd_index].lchs.cylinders = cCylinders;
    725                 bios_dsk->devices[hd_index].lchs.spt       = cSectorsPerTrack;
     720                BX_INFO("AHCI %d-P#%d: PCHS=%u/%d/%d LCHS=%u/%u/%u %ld sectors\n", devcount_ahci,
     721                        u8Port, cylinders, heads, spt, lcylinders, lheads, lspt, sectors);
     722
     723                bios_dsk->devices[hd_index].lchs.heads     = lheads;
     724                bios_dsk->devices[hd_index].lchs.cylinders = lcylinders;
     725                bios_dsk->devices[hd_index].lchs.spt       = lspt;
    726726
    727727                /* Store the ID of the disk in the BIOS hdidmap. */
  • trunk/src/VBox/Devices/PC/BIOS/ata.c

    r39651 r42947  
    485485            sectors   = *(uint32_t *)(buffer+(60*2)); // word 60 and word 61
    486486            /** @todo update sectors to be a 64 bit number (also lba...). */
    487             if (sectors == 268435455)
     487            if (sectors == 0x0FFFFFFF)  /* For disks bigger than ~128GB */
    488488                sectors = *(uint32_t *)(buffer+(100*2)); // words 100 to 103 (someday)
    489489            switch (device)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette