Changeset 44547 in vbox
- Timestamp:
- Feb 5, 2013 3:27:45 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/DevEFI.cpp
r44528 r44547 5 5 6 6 /* 7 * Copyright (C) 2006-201 2Oracle Corporation7 * Copyright (C) 2006-2013 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 78 78 /** Thunk page pointer. */ 79 79 uint8_t *pu8EfiThunk; 80 /** First entry point of the EFI firmware */80 /** First entry point of the EFI firmware. */ 81 81 RTGCPHYS GCEntryPoint0; 82 /* Second Entry Point (PeiCore)*/82 /** Second Entry Point (PeiCore)*/ 83 83 RTGCPHYS GCEntryPoint1; 84 /** EFI firmware physical load address */84 /** EFI firmware physical load address. */ 85 85 RTGCPHYS GCLoadAddress; 86 /** Current info selector */86 /** Current info selector. */ 87 87 uint32_t iInfoSelector; 88 /** Current info position */89 int32_t iInfoPosition;88 /** Current info position. */ 89 int32_t offInfo; 90 90 91 91 /** Number of virtual CPUs. (Config) */ … … 95 95 /** RAM above 4GB (in bytes). (Config) */ 96 96 uint64_t cbAbove4GB; 97 97 /** The total amount of memory. */ 98 98 uint64_t cbRam; 99 99 /** The size of the RAM hole below 4GB. */ 100 100 uint64_t cbRamHole; 101 101 102 /** The size of the DMI tables */102 /** The size of the DMI tables. */ 103 103 uint16_t cbDmiTables; 104 104 /** The DMI tables. */ … … 108 108 uint8_t u8IOAPIC; 109 109 110 /* Boot parameters passed to the firmware*/110 /** Boot parameters passed to the firmware. */ 111 111 char szBootArgs[256]; 112 112 113 /* Host UUID (for DMI)*/113 /** Host UUID (for DMI). */ 114 114 RTUUID aUuid; 115 115 116 /* Device properties buffer*/117 uint8_t* pu8DeviceProps;118 /* Device properties buffer size*/119 uint32_t u32DevicePropsLen;120 121 /* Virtual machine front side bus frequency*/116 /** Device properties buffer. */ 117 R3PTRTYPE(uint8_t *) pbDeviceProps; 118 /** Device properties buffer size. */ 119 uint32_t cbDeviceProps; 120 121 /** Virtual machine front side bus frequency. */ 122 122 uint64_t u64FsbFrequency; 123 /* Virtual machine time stamp counter frequency*/123 /** Virtual machine time stamp counter frequency. */ 124 124 uint64_t u64TscFrequency; 125 /* Virtual machine CPU frequency*/125 /** Virtual machine CPU frequency. */ 126 126 uint64_t u64CpuFrequency; 127 /* GOP mode*/127 /** GOP mode. */ 128 128 uint32_t u32GopMode; 129 /* Uga mode resolutions */ 130 uint32_t u32UgaHorisontal; 131 uint32_t u32UgaVertical; 129 /** Uga mode horisontal resolution. */ 130 uint32_t cxUgaResolution; 131 /** Uga mode vertical resolution. */ 132 uint32_t cyUgaResolution; 132 133 } DEVEFI; 133 134 typedef DEVEFI *PDEVEFI; … … 147 148 148 149 150 151 /** 152 * Gets the info item size. 153 * 154 * @returns Size in bytes, UINT32_MAX on error. 155 * @param pThis . 156 */ 149 157 static uint32_t efiInfoSize(PDEVEFI pThis) 150 158 { … … 162 170 return 4; 163 171 case EFI_INFO_INDEX_BOOT_ARGS: 164 return (uint32_t)RTStrNLen(pThis->szBootArgs, 165 sizeof pThis->szBootArgs) + 1; 172 return (uint32_t)RTStrNLen(pThis->szBootArgs, sizeof(pThis->szBootArgs)) + 1; 166 173 case EFI_INFO_INDEX_DEVICE_PROPS: 167 return pThis-> u32DevicePropsLen;174 return pThis->cbDeviceProps; 168 175 case EFI_INFO_INDEX_FSB_FREQUENCY: 169 176 case EFI_INFO_INDEX_CPU_FREQUENCY: … … 171 178 return 8; 172 179 } 173 Assert(false); 174 return 0; 175 } 176 180 return UINT32_MAX; 181 } 182 183 184 /** 185 * efiInfoNextByte for a uint64_t value. 186 * 187 * @returns Next (current) byte. 188 * @param pThis The EFI instance data. 189 * @param u64 The value. 190 */ 191 static uint8_t efiInfoNextByteU64(PDEVEFI pThis, uint64_t u64) 192 { 193 uint64_t off = pThis->offInfo; 194 if (off >= 4) 195 return 0; 196 return (uint8_t)(off >> (off * 8)); 197 } 198 199 /** 200 * efiInfoNextByte for a uint32_t value. 201 * 202 * @returns Next (current) byte. 203 * @param pThis The EFI instance data. 204 * @param u32 The value. 205 */ 206 static uint8_t efiInfoNextByteU32(PDEVEFI pThis, uint32_t u32) 207 { 208 uint32_t off = pThis->offInfo; 209 if (off >= 4) 210 return 0; 211 return (uint8_t)(off >> (off * 8)); 212 } 213 214 /** 215 * efiInfoNextByte for a buffer. 216 * 217 * @returns Next (current) byte. 218 * @param pThis The EFI instance data. 219 * @param pvBuf The buffer. 220 * @param cbBuf The buffer size. 221 */ 222 static uint8_t efiInfoNextByteBuf(PDEVEFI pThis, void const *pvBuf, size_t cbBuf) 223 { 224 uint32_t off = pThis->offInfo; 225 if (off >= cbBuf) 226 return 0; 227 return ((uint8_t const *)pvBuf)[off]; 228 } 229 230 /** 231 * Gets the next info byte. 232 * 233 * @returns Next (current) byte. 234 * @param pThis The EFI instance data. 235 */ 177 236 static uint8_t efiInfoNextByte(PDEVEFI pThis) 178 237 { 179 union180 {181 uint32_t u32;182 uint64_t u64;183 } value;184 185 238 switch (pThis->iInfoSelector) 186 239 { 187 case EFI_INFO_INDEX_VOLUME_BASE: 188 value.u32 = pThis->GCLoadAddress; 189 break; 190 case EFI_INFO_INDEX_VOLUME_SIZE: 191 value.u32 = pThis->cbEfiRom; 192 break; 193 case EFI_INFO_INDEX_TEMPMEM_BASE: 194 value.u32 = VBOX_EFI_TOP_OF_STACK; /* just after stack */ 195 break; 196 case EFI_INFO_INDEX_TEMPMEM_SIZE: 197 value.u32 = 512 * 1024; /* 512 K */ 198 break; 199 case EFI_INFO_INDEX_STACK_BASE: 200 /* Keep in sync with value in EfiThunk.asm */ 201 value.u32 = VBOX_EFI_TOP_OF_STACK - 128*1024; /* 2M - 128 K */ 202 break; 203 case EFI_INFO_INDEX_STACK_SIZE: 204 value.u32 = 128*1024; /* 128 K */ 205 break; 206 case EFI_INFO_INDEX_FSB_FREQUENCY: 207 value.u64 = pThis->u64FsbFrequency; 208 break; 209 case EFI_INFO_INDEX_TSC_FREQUENCY: 210 value.u64 = pThis->u64TscFrequency; 211 break; 212 case EFI_INFO_INDEX_CPU_FREQUENCY: 213 value.u64 = pThis->u64CpuFrequency; 214 break; 215 case EFI_INFO_INDEX_BOOT_ARGS: 216 return pThis->szBootArgs[pThis->iInfoPosition]; 217 case EFI_INFO_INDEX_DEVICE_PROPS: 218 return pThis->pu8DeviceProps[pThis->iInfoPosition]; 219 case EFI_INFO_INDEX_GOP_MODE: 220 value.u32 = pThis->u32GopMode; 221 break; 222 case EFI_INFO_INDEX_UGA_HORISONTAL_RESOLUTION: 223 value.u32 = pThis->u32UgaHorisontal; 224 break; 225 case EFI_INFO_INDEX_UGA_VERTICAL_RESOLUTION: 226 value.u32 = pThis->u32UgaVertical; 227 break; 240 241 case EFI_INFO_INDEX_VOLUME_BASE: return efiInfoNextByteU64(pThis, pThis->GCLoadAddress); 242 case EFI_INFO_INDEX_VOLUME_SIZE: return efiInfoNextByteU64(pThis, pThis->cbEfiRom); 243 case EFI_INFO_INDEX_TEMPMEM_BASE: return efiInfoNextByteU32(pThis, VBOX_EFI_TOP_OF_STACK); /* just after stack */ 244 case EFI_INFO_INDEX_TEMPMEM_SIZE: return efiInfoNextByteU32(pThis, _512K); 245 case EFI_INFO_INDEX_FSB_FREQUENCY: return efiInfoNextByteU64(pThis, pThis->u64FsbFrequency); 246 case EFI_INFO_INDEX_TSC_FREQUENCY: return efiInfoNextByteU64(pThis, pThis->u64TscFrequency); 247 case EFI_INFO_INDEX_CPU_FREQUENCY: return efiInfoNextByteU64(pThis, pThis->u64CpuFrequency); 248 case EFI_INFO_INDEX_BOOT_ARGS: return efiInfoNextByteBuf(pThis, pThis->szBootArgs, sizeof(pThis->szBootArgs)); 249 case EFI_INFO_INDEX_DEVICE_PROPS: return efiInfoNextByteBuf(pThis, pThis->pbDeviceProps, pThis->cbDeviceProps); 250 case EFI_INFO_INDEX_GOP_MODE: return efiInfoNextByteU32(pThis, pThis->u32GopMode); 251 case EFI_INFO_INDEX_UGA_HORISONTAL_RESOLUTION: return efiInfoNextByteU32(pThis, pThis->cxUgaResolution); 252 case EFI_INFO_INDEX_UGA_VERTICAL_RESOLUTION: return efiInfoNextByteU32(pThis, pThis->cyUgaResolution); 253 254 /* Keep in sync with value in EfiThunk.asm */ 255 case EFI_INFO_INDEX_STACK_BASE: return efiInfoNextByteU32(pThis, VBOX_EFI_TOP_OF_STACK - _128K); /* 2M - 128 K */ 256 case EFI_INFO_INDEX_STACK_SIZE: return efiInfoNextByteU32(pThis, _128K); 257 228 258 default: 229 Assert(false); 230 value.u64 = 0; 231 break; 232 } 233 234 return *((uint8_t*)&value+pThis->iInfoPosition); 259 PDMDevHlpDBGFStop(pThis->pDevIns, RT_SRC_POS, "%#x", pThis->iInfoSelector); 260 return 0; 261 } 235 262 } 236 263 … … 254 281 { 255 282 case EFI_INFO_PORT: 256 if (pThis-> iInfoPosition== -1 && cb == 4)283 if (pThis->offInfo == -1 && cb == 4) 257 284 { 258 *pu32 = efiInfoSize(pThis); 259 pThis->iInfoPosition = 0; 285 pThis->offInfo = 0; 286 uint32_t cbInfo = *pu32 = efiInfoSize(pThis); 287 if (cbInfo == UINT32_MAX) 288 return PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "iInfoSelector=%#x (%d)\n", 289 pThis->iInfoSelector, pThis->iInfoSelector); 260 290 } 261 291 else 262 292 { 263 /* So far */264 293 if (cb != 1) 265 294 return VERR_IOM_IOPORT_UNUSED; 266 295 *pu32 = efiInfoNextByte(pThis); 267 pThis-> iInfoPosition++;296 pThis->offInfo++; 268 297 } 269 298 return VINF_SUCCESS; … … 271 300 case EFI_PANIC_PORT: 272 301 #ifdef IN_RING3 273 LogRel((" Panic port read!\n"));302 LogRel(("EFI panic port read!\n")); 274 303 /* Insert special code here on panic reads */ 275 304 return PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "EFI Panic: panic port read!\n"); … … 304 333 case EFI_INFO_PORT: 305 334 pThis->iInfoSelector = u32; 306 pThis-> iInfoPosition= -1;335 pThis->offInfo = -1; 307 336 break; 308 337 case EFI_DEBUG_PORT: … … 466 495 467 496 pThis->iInfoSelector = 0; 468 pThis-> iInfoPosition= -1;497 pThis->offInfo = -1; 469 498 470 499 pThis->iMsg = 0; … … 544 573 } 545 574 546 if (pThis->p u8DeviceProps)547 { 548 MMR3HeapFree(pThis->p u8DeviceProps);549 pThis->p u8DeviceProps = NULL;550 pThis-> u32DevicePropsLen= 0;575 if (pThis->pbDeviceProps) 576 { 577 MMR3HeapFree(pThis->pbDeviceProps); 578 pThis->pbDeviceProps = NULL; 579 pThis->cbDeviceProps = 0; 551 580 } 552 581 … … 963 992 964 993 965 static int efiParseDeviceString(PDEVEFI pThis, char *pszDeviceProps)994 static int efiParseDeviceString(PDEVEFI pThis, char *pszDeviceProps) 966 995 { 967 996 int rc = 0; … … 972 1001 u32OutLen = (uint32_t)RTStrNLen(pszDeviceProps, RTSTR_MAX) / 2 + 1; 973 1002 974 pThis->pu8DeviceProps = 975 (uint8_t*)PDMDevHlpMMHeapAlloc(pThis->pDevIns, u32OutLen); 976 if (!pThis->pu8DeviceProps) 1003 pThis->pbDeviceProps = (uint8_t *)PDMDevHlpMMHeapAlloc(pThis->pDevIns, u32OutLen); 1004 if (!pThis->pbDeviceProps) 977 1005 return VERR_NO_MEMORY; 978 1006 … … 986 1014 u8Value = u8Hb << 4; 987 1015 else 988 pThis->p u8DeviceProps[iHex++] = u8Hb | u8Value;1016 pThis->pbDeviceProps[iHex++] = u8Hb | u8Value; 989 1017 990 1018 Assert(iHex < u32OutLen); … … 993 1021 994 1022 Assert(iHex == 0 || fUpper); 995 pThis-> u32DevicePropsLen= iHex;1023 pThis->cbDeviceProps = iHex; 996 1024 997 1025 return rc; … … 1164 1192 else 1165 1193 { 1166 pThis->p u8DeviceProps= NULL;1167 pThis-> u32DevicePropsLen= 0;1194 pThis->pbDeviceProps = NULL; 1195 pThis->cbDeviceProps = 0; 1168 1196 } 1169 1197 … … 1192 1220 * Uga graphics 1193 1221 */ 1194 rc = CFGMR3QueryU32(pCfg, "UgaHorizontalResolution", &pThis->u32UgaHorisontal); 1195 AssertRC(rc); 1196 if (pThis->u32UgaHorisontal == 0) 1197 { 1198 pThis->u32UgaHorisontal = 1024; /* 1024x768 */ 1199 } 1200 rc = CFGMR3QueryU32(pCfg, "UgaVerticalResolution", &pThis->u32UgaVertical); 1201 AssertRC(rc); 1202 if (pThis->u32UgaVertical == 0) 1203 { 1204 pThis->u32UgaVertical = 768; /* 1024x768 */ 1205 } 1222 rc = CFGMR3QueryU32Def(pCfg, "UgaHorizontalResolution", &pThis->cxUgaResolution, 0); AssertRC(rc); 1223 if (pThis->cxUgaResolution == 0) 1224 pThis->cxUgaResolution = 1024; /* 1024x768 */ 1225 rc = CFGMR3QueryU32Def(pCfg, "UgaVerticalResolution", &pThis->cyUgaResolution, 0); AssertRC(rc); 1226 if (pThis->cyUgaResolution == 0) 1227 pThis->cyUgaResolution = 768; /* 1024x768 */ 1206 1228 1207 1229 #ifdef DEVEFI_WITH_VBOXDBG_SCRIPT
Note:
See TracChangeset
for help on using the changeset viewer.