Changeset 26221 in vbox
- Timestamp:
- Feb 3, 2010 9:42:03 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 57253
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/VBox/Devices/EFI/DevEFI.cpp ¶
r26208 r26221 114 114 RTUUID aUuid; 115 115 116 /* Device properties string */ 117 char* pszDeviceProps; 116 /* Device properties buffer */ 117 uint8_t* pu8DeviceProps; 118 /* Device properties buffer size */ 119 uint32_t u32DevicePropsLen; 118 120 119 121 /* Virtual machine front side bus frequency */ … … 152 154 return 4; 153 155 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; 155 158 case EFI_INFO_INDEX_DEVICE_PROPS: 156 return RTStrNLen(pThis->pszDeviceProps, RTSTR_MAX) + 1;159 return pThis->u32DevicePropsLen; 157 160 case EFI_INFO_INDEX_FSB_FREQUENCY: 158 161 case EFI_INFO_INDEX_CPU_FREQUENCY: … … 205 208 return pThis->szBootArgs[pThis->iInfoPosition]; 206 209 case EFI_INFO_INDEX_DEVICE_PROPS: 207 return pThis->p szDeviceProps[pThis->iInfoPosition];210 return pThis->pu8DeviceProps[pThis->iInfoPosition]; 208 211 default: 209 212 Assert(false); … … 530 533 } 531 534 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; 536 540 } 537 541 … … 898 902 } 899 903 904 905 static 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 923 static 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 } 900 957 901 958 /** … … 1032 1089 * Get device props. 1033 1090 */ 1034 rc = CFGMR3QueryStringAlloc(pCfg, "DeviceProps", &pThis->pszDeviceProps); 1091 char* pszDeviceProps; 1092 rc = CFGMR3QueryStringAlloc(pCfg, "DeviceProps", &pszDeviceProps); 1035 1093 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 1036 1094 { 1037 p This->pszDeviceProps = RTStrDup("");1095 pszDeviceProps = NULL; 1038 1096 rc = VINF_SUCCESS; 1039 1097 } … … 1041 1099 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, 1042 1100 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 } 1044 1115 1045 1116 pThis->u64FsbFrequency = 1333000000;
Note:
See TracChangeset
for help on using the changeset viewer.