VirtualBox

Changeset 1014 in vbox


Ignore:
Timestamp:
Feb 21, 2007 5:54:21 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
18870
Message:

Fixed physical CHS detection. Hopefully without breaking existing VDIs.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/DevPcBios.cpp

    r837 r1014  
    408408                }
    409409                else if (cCylinders <= 1024 && cHeads <= 16 && cSectors <= 63)
     410                {
     411                    /* Disk <= 512 MByte not needing LBA translation. */
    410412                    enmTranslation = PDMBIOSTRANSLATION_NONE;
     413                }
     414                else if (cSectors != 63 || (cHeads != 16 && cHeads != 32 && cHeads != 64 && cHeads != 128 && cHeads != 255))
     415                {
     416                    /* Disk with strange geometry. Using LBA here can
     417                     * break booting of the guest OS. Especially operating
     418                     * systems from Microsoft are sensitive to BIOS CHS not
     419                     * matching what the partition table says. */
     420                    enmTranslation = PDMBIOSTRANSLATION_NONE;
     421                }
    411422                else
    412423                    enmTranslation = PDMBIOSTRANSLATION_LBA;
     
    748759    if (VBOX_FAILURE(rc))
    749760        return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
    750                                    N_("Configuration error: Querying \"%s\" as a string failed"), 
     761                                   N_("Configuration error: Querying \"%s\" as a string failed"),
    751762                                   pszParam);
    752763    if (!strcmp(psz, "DVD") || !strcmp(psz, "CDROM"))
     
    939950    if (VBOX_FAILURE(rc))
    940951        return rc;
    941     rc = PDMDevHlpROMRegister(pDevIns, (uint32_t)-g_cbPcBiosBinary, g_cbPcBiosBinary, 
     952    rc = PDMDevHlpROMRegister(pDevIns, (uint32_t)-g_cbPcBiosBinary, g_cbPcBiosBinary,
    942953                              &g_abPcBiosBinary[0], "PC BIOS - 0xffffffff");
    943954    if (VBOX_FAILURE(rc))
     
    947958     * Register the MMIO region for the BIOS Logo: 0x000d0000 to 0x000dffff (64k)
    948959     */
    949     rc = PDMDevHlpMMIORegister(pDevIns, 0x000d0000, 0x00010000, 0, 
     960    rc = PDMDevHlpMMIORegister(pDevIns, 0x000d0000, 0x00010000, 0,
    950961                               logoMMIOWrite, logoMMIORead, NULL, "PC BIOS - Logo Buffer");
    951962    if (VBOX_FAILURE(rc))
  • trunk/src/VBox/Devices/Storage/DevATA.cpp

    r778 r1014  
    36613661            cCHSSectors = iEndSector;
    36623662            cCHSCylinders = s->cTotalSectors / (cCHSHeads * cCHSSectors);
    3663             if (cCHSCylinders >= 1 && cCHSCylinders <= 16383)
     3663            if (cCHSCylinders >= 1)
    36643664            {
     3665                cCHSCylinders = RT_MIN(cCHSCylinders, 16383);
    36653666                *pcHeads = cCHSHeads;
    36663667                *pcSectors = cCHSSectors;
     
    52205221        else if (VBOX_FAILURE(rc))
    52215222        {
    5222             rc = ataGuessDiskLCHS(pIf, &pIf->cCHSCylinders, &pIf->cCHSHeads, &pIf->cCHSSectors);
    5223             if (VBOX_SUCCESS(rc) && pIf->cCHSHeads <= 16 /* if cCHSHeads > 16, it means that a BIOS LBA translation was active, so the default hardware geometry is OK. */
    5224                 )
     5223            PDMBIOSTRANSLATION enmTranslation;
     5224            rc = pIf->pDrvBlockBios->pfnGetTranslation(pIf->pDrvBlockBios, &enmTranslation);
     5225            AssertRC(rc);
     5226
     5227            if (enmTranslation == PDMBIOSTRANSLATION_AUTO)
    52255228            {
    5226                 /* Disable any translation to be in sync with the logical geometry */
    5227                 PDMBIOSTRANSLATION enmTranslation;
    5228                 rc = pIf->pDrvBlockBios->pfnGetTranslation(pIf->pDrvBlockBios, &enmTranslation);
    5229                 if (VBOX_FAILURE(rc) || enmTranslation == PDMBIOSTRANSLATION_AUTO)
    5230                     pIf->pDrvBlockBios->pfnSetTranslation(pIf->pDrvBlockBios, PDMBIOSTRANSLATION_NONE);
     5229                /* Image contains no geometry information, detect geometry. */
     5230                rc = ataGuessDiskLCHS(pIf, &pIf->cCHSCylinders, &pIf->cCHSHeads, &pIf->cCHSSectors);
     5231                if (VBOX_SUCCESS(rc))
     5232                {
     5233                    /* Set the disk geometry information. */
     5234                    rc = pIf->pDrvBlockBios->pfnSetGeometry(pIf->pDrvBlockBios, pIf->cCHSCylinders, pIf->cCHSHeads, pIf->cCHSSectors);
     5235                }
     5236                else
     5237                {
     5238                    /* Flag geometry as invalid, will be replaced below by the
     5239                     * default geometry. */
     5240                    pIf->cCHSCylinders = 0;
     5241                }
    52315242            }
    5232             else
     5243            /* If there is no geometry, use standard physical disk geometry.
     5244             * This uses LCHS to LBA translation in the BIOS (which selects
     5245             * the logical sector count 63 and the logical head count to be
     5246             * the smallest of 16,32,64,128,255 which makes the logical
     5247             * cylinder count smaller than 1024 - if that's not possible, it
     5248             * uses 255 heads, so up to about 8 GByte maximum with the
     5249             * standard int13 interface, which supports 1024 cylinders). */
     5250            if (!pIf->cCHSCylinders)
    52335251            {
    5234                 /* If no geometry, use a standard physical disk geometry. */
    52355252                uint64_t cCHSCylinders = pIf->cTotalSectors / (16 * 63);
    5236                 pIf->cCHSCylinders = (uint32_t)RT_MIN(RT_MAX(cCHSCylinders, 2), 16383);
     5253                pIf->cCHSCylinders = (uint32_t)RT_MIN(RT_MAX(cCHSCylinders, 1), 16383);
    52375254                pIf->cCHSHeads = 16;
    52385255                pIf->cCHSSectors = 63;
     5256                /* Set the disk geometry information. */
     5257                rc = pIf->pDrvBlockBios->pfnSetGeometry(pIf->pDrvBlockBios, pIf->cCHSCylinders, pIf->cCHSHeads, pIf->cCHSSectors);
    52395258            }
    5240             pIf->pDrvBlockBios->pfnSetGeometry(pIf->pDrvBlockBios, pIf->cCHSCylinders, pIf->cCHSHeads, pIf->cCHSSectors);
    52415259        }
    52425260        LogRel(("PIIX3 ATA: LUN#%d: disk, CHS=%d/%d/%d, total number of sectors %Ld\n", pIf->iLUN, pIf->cCHSCylinders, pIf->cCHSHeads, pIf->cCHSSectors, pIf->cTotalSectors));
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