VirtualBox

Changeset 26221 in vbox


Ignore:
Timestamp:
Feb 3, 2010 9:42:03 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
57253
Message:

EFI: device props

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/VBox/Devices/EFI/DevEFI.cpp

    r26208 r26221  
    114114    RTUUID          aUuid;
    115115
    116     /* Device properties string */
    117     char*           pszDeviceProps;
     116    /* Device properties buffer */
     117    uint8_t*           pu8DeviceProps;
     118    /* Device properties buffer size */
     119    uint32_t           u32DevicePropsLen;
    118120
    119121    /* Virtual machine front side bus frequency */
     
    152154            return 4;
    153155        case EFI_INFO_INDEX_BOOT_ARGS:
    154             return RTStrNLen(pThis->szBootArgs, sizeof pThis->szBootArgs) + 1;
     156            return (uint32_t)RTStrNLen(pThis->szBootArgs,
     157                                       sizeof pThis->szBootArgs) + 1;
    155158        case EFI_INFO_INDEX_DEVICE_PROPS:
    156             return RTStrNLen(pThis->pszDeviceProps, RTSTR_MAX) + 1;
     159            return pThis->u32DevicePropsLen;
    157160        case EFI_INFO_INDEX_FSB_FREQUENCY:
    158161        case EFI_INFO_INDEX_CPU_FREQUENCY:
     
    205208            return pThis->szBootArgs[pThis->iInfoPosition];
    206209        case EFI_INFO_INDEX_DEVICE_PROPS:
    207             return pThis->pszDeviceProps[pThis->iInfoPosition];
     210            return pThis->pu8DeviceProps[pThis->iInfoPosition];
    208211        default:
    209212            Assert(false);
     
    530533    }
    531534
    532     if (pThis->pszDeviceProps)
    533     {
    534         MMR3HeapFree(pThis->pszDeviceProps);
    535         pThis->pszDeviceProps = NULL;
     535    if (pThis->pu8DeviceProps)
     536    {
     537        MMR3HeapFree(pThis->pu8DeviceProps);
     538        pThis->pu8DeviceProps = NULL;
     539        pThis->u32DevicePropsLen = 0;
    536540    }
    537541
     
    898902}
    899903
     904
     905static uint8_t efiGetHalfByte(char ch)
     906{
     907    uint8_t val;
     908
     909    if (ch >= '0' && ch <= '9')
     910        val = ch - '0';
     911    else if (ch >= 'A' && ch <= 'F')
     912        val = ch - 'A' + 10;
     913    else if(ch >= 'a' && ch <= 'f')
     914        val = ch - 'a' + 10;
     915    else
     916        val = 0xff;
     917
     918    return val;
     919
     920}
     921
     922
     923static int efiParseDeviceString(PDEVEFI  pThis, char* pszDeviceProps)
     924{
     925    int         rc = 0;
     926    uint32_t    iStr, iHex, u32OutLen;
     927    uint8_t     u8Value;
     928    bool        fUpper = true;
     929
     930    u32OutLen = (uint32_t)RTStrNLen(pszDeviceProps, RTSTR_MAX) / 2 + 1;
     931
     932    pThis->pu8DeviceProps =
     933            (uint8_t*)PDMDevHlpMMHeapAlloc(pThis->pDevIns, u32OutLen);
     934    if (!pThis->pu8DeviceProps)
     935        return VERR_NO_MEMORY;
     936
     937    for (iStr=0, iHex = 0; pszDeviceProps[iStr]; iStr++)
     938    {
     939        uint8_t u8Hb = efiGetHalfByte(pszDeviceProps[iStr]);
     940        if (u8Hb > 0xf)
     941            continue;
     942
     943        if (fUpper)
     944            u8Value = u8Hb << 4;
     945        else
     946            pThis->pu8DeviceProps[iHex++] = u8Hb | u8Value;
     947
     948        Assert(iHex < u32OutLen);
     949        fUpper = !fUpper;
     950    }
     951
     952    Assert(iHex == 0 || fUpper);
     953    pThis->u32DevicePropsLen = iHex;
     954
     955    return rc;
     956}
    900957
    901958/**
     
    10321089     * Get device props.
    10331090     */
    1034     rc = CFGMR3QueryStringAlloc(pCfg, "DeviceProps", &pThis->pszDeviceProps);
     1091    char* pszDeviceProps;
     1092    rc = CFGMR3QueryStringAlloc(pCfg, "DeviceProps", &pszDeviceProps);
    10351093    if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    10361094    {
    1037         pThis->pszDeviceProps = RTStrDup("");
     1095        pszDeviceProps = NULL;
    10381096        rc = VINF_SUCCESS;
    10391097    }
     
    10411099        return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
    10421100                                   N_("Configuration error: Querying \"DeviceProps\" as a string failed"));
    1043     LogRel(("EFI device props: %s\n", pThis->pszDeviceProps));
     1101    if (pszDeviceProps)
     1102    {
     1103        LogRel(("EFI device props: %s\n", pszDeviceProps));
     1104        rc = efiParseDeviceString(pThis, pszDeviceProps);
     1105        MMR3HeapFree(pszDeviceProps);
     1106        if (RT_FAILURE(rc))
     1107            return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
     1108                                       N_("Configuration error: Cannot parse device properties"));
     1109    }
     1110    else
     1111    {
     1112        pThis->pu8DeviceProps    = NULL;
     1113        pThis->u32DevicePropsLen = 0;
     1114    }
    10441115
    10451116    pThis->u64FsbFrequency = 1333000000;
Note: See TracChangeset for help on using the changeset viewer.

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