VirtualBox

Changeset 17077 in vbox for trunk/src/VBox/Devices/Storage


Ignore:
Timestamp:
Feb 24, 2009 4:58:15 PM (16 years ago)
Author:
vboxsync
Message:

pass IDE controller type as string in config

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DevATA.cpp

    r17075 r17077  
    60866086}
    60876087
     6088/**
     6089 * Convert config value to DEVPCBIOSBOOT.
     6090 *
     6091 * @returns VBox status code.
     6092 * @param   pDevIns     The device instance data.
     6093 * @param   pCfgHandle  Configuration handle.
     6094 * @param   penmChipset Where to store the chipset type.
     6095 */
     6096static int ataControllerFromCfg(PPDMDEVINS pDevIns, PCFGMNODE pCfgHandle, CHIPSET *penmChipset)
     6097{
     6098    char szType[20];
     6099
     6100    int rc = CFGMR3QueryString(pCfgHandle, "Type", &szType[0], sizeof(szType));
     6101    if (RT_FAILURE(rc))
     6102        return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
     6103                                   N_("Configuration error: Querying \"Type\" as a string failed"));
     6104    if (!strcmp(szType, "PIIX3"))
     6105        *penmChipset = CHIPSET_PIIX3;
     6106    else if (!strcmp(szType, "PIIX4"))
     6107        *penmChipset = CHIPSET_PIIX4;
     6108    else if (!strcmp(szType, "ICH6"))
     6109        *penmChipset = CHIPSET_ICH6;
     6110    else
     6111    {
     6112        PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
     6113                            N_("Configuration error: The \"Type\" value \"%s\" is unknown"),
     6114                            szType);
     6115        rc = VERR_INTERNAL_ERROR;
     6116    }
     6117    return rc;
     6118}
     6119
    60886120
    60896121/**
     
    61476179    Assert(DelayIRQMillies < 50);
    61486180
    6149     pThis->u8Type = CHIPSET_PIIX3;
    6150     uint32_t type;
    6151     rc = CFGMR3QueryU32Def(pCfgHandle, "Type", &type, 0);
     6181    CHIPSET enmChipset = CHIPSET_PIIX3;
     6182    rc = ataControllerFromCfg(pDevIns, pCfgHandle, &enmChipset);
    61526183    if (RT_FAILURE(rc))
    6153         return PDMDEV_SET_ERROR(pDevIns, rc,
    6154                                 N_("PIIX3 configuration error: failed to read Type as integer"));
    6155     Log(("%s: type=%d\n", __FUNCTION__, type));
    6156     /** See IDEControllerType in VirtualBox.xidl */
    6157     switch (type)
    6158     {
    6159         case 0:
    6160             /** @todo: what is right here? */
    6161             AssertMsgFailed(("What do we do here: type Null\n"));
    6162             break;
    6163         case 1:
    6164             pThis->u8Type = CHIPSET_PIIX3;
    6165             break;
    6166         case 2:
    6167             pThis->u8Type = CHIPSET_PIIX4;
    6168             break;
    6169         case 3:
    6170             pThis->u8Type = CHIPSET_ICH6;
    6171             break;
    6172         default:
    6173             AssertMsgFailed(("Unknown IDE type: %d\n", type));
    6174     }
    6175 
     6184        return rc;
     6185    pThis->u8Type = (uint8_t)enmChipset;
     6186   
    61766187    /*
    61776188     * Initialize data (most of it anyway).
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