Changeset 49098 in vbox for trunk/src/VBox
- Timestamp:
- Oct 15, 2013 1:30:53 AM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 89929
- Location:
- trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxAppleSim/VBoxAppleSim.c
r49089 r49098 33 33 #include <Library/UefiBootServicesTableLib.h> 34 34 #include <Library/UefiLib.h> 35 #include <Library/PrintLib.h> 35 36 36 37 #include <Protocol/DevicePathToText.h> … … 64 65 65 66 /* 66 * Internal Functions *67 * Internal Functions 67 68 */ 68 69 static UINT32 69 GetVmVariable(UINT32 Variable, CHAR8* Buffer, UINT32 Size ) 70 { 71 UINT32 VarLen, i; 72 70 GetVmVariable(UINT32 Variable, CHAR8 *pbBuf, UINT32 cbBuf) 71 { 72 UINT32 cbVar, offBuf; 73 73 74 74 ASMOutU32(EFI_INFO_PORT, Variable); 75 VarLen = ASMInU32(EFI_INFO_PORT); 76 77 for (i=0; i < VarLen && i < Size; i++) 78 { 79 Buffer[i] = ASMInU8(EFI_INFO_PORT); 80 } 81 82 return VarLen; 75 cbVar = ASMInU32(EFI_INFO_PORT); 76 77 for (offBuf = 0; offBuf < cbVar && offBuf < cbBuf; offBuf++) 78 pbBuf[offBuf] = ASMInU8(EFI_INFO_PORT); 79 80 return cbVar; 83 81 } 84 82 … … 86 84 * GUIDs 87 85 */ 86 /** The EFI variable GUID for the 'FirmwareFeatures' and friends. 87 * Also known as AppleFirmwareVariableGuid in other sources. */ 88 88 EFI_GUID gEfiAppleNvramGuid = { 89 89 0x4D1EDE05, 0x38C7, 0x4A6A, {0x9C, 0xC6, 0x4B, 0xCC, 0xA8, 0xB3, 0x8C, 0x14 } 90 90 }; 91 91 92 /** The EFI variable GUID for the 'boot-args' variable and others. 93 * Also known as AppleNVRAMVariableGuid in other sources. */ 92 94 EFI_GUID gEfiAppleBootGuid = { 93 95 0x7C436110, 0xAB2A, 0x4BBB, {0xA8, 0x80, 0xFE, 0x41, 0x99, 0x5C, 0x9F, 0x82} 94 96 }; 95 97 98 99 /* 100 * Device Properoty protocol implementation hack. 101 */ 102 103 /** gEfiAppleVarGuid is aka AppleDevicePropertyProtocolGuid in other sources. */ 96 104 EFI_GUID gEfiAppleVarGuid = { 97 105 0x91BD12FE, 0xF6C3, 0x44FB, {0xA5, 0xB7, 0x51, 0x22, 0xAB, 0x30, 0x3A, 0xE0} 98 106 }; 99 107 100 EFI_GUID gEfiUnknown1ProtocolGuid = { 108 /** APPLE_GETVAR_PROTOCOL is aka APPLE_DEVICE_PROPERTY_PROTOCOL in other sources. */ 109 typedef struct _APPLE_GETVAR_PROTOCOL APPLE_GETVAR_PROTOCOL; 110 111 struct _APPLE_GETVAR_PROTOCOL 112 { 113 /** Magic value or some version thingy. boot.efi doesn't check this, I think. */ 114 UINT64 u64Magic; 115 116 EFI_STATUS (EFIAPI *pfnUnknown0)(IN APPLE_GETVAR_PROTOCOL *This, IN VOID *pvArg1, IN VOID *pvArg2, 117 IN VOID *pvArg3, IN VOID *pvArg4); 118 EFI_STATUS (EFIAPI *pfnUnknown1)(IN APPLE_GETVAR_PROTOCOL *This, IN VOID *pvArg1, IN VOID *pvArg2, 119 IN VOID *pvArg3, IN VOID *pvArg4); 120 EFI_STATUS (EFIAPI *pfnUnknown2)(IN APPLE_GETVAR_PROTOCOL *This, IN VOID *pvArg1, IN VOID *pvArg2); 121 122 EFI_STATUS (EFIAPI *pfnGetDevProps)(IN APPLE_GETVAR_PROTOCOL *This, IN CHAR8 *pbBuf, IN OUT UINT32 *pcbBuf); 123 }; 124 /** The value of APPLE_GETVAR_PROTOCOL::u64Magic. */ 125 #define APPLE_GETVAR_PROTOCOL_MAGIC 0x10000 126 127 EFI_STATUS EFIAPI 128 AppleGetVar_Unknown0(IN APPLE_GETVAR_PROTOCOL *This, IN VOID *pvArg1, IN VOID *pvArg2, 129 IN VOID *pvArg3, IN VOID *pvArg4) 130 { 131 CHAR8 szMsg[128]; 132 AsciiSPrint(szMsg, sizeof(szMsg), "AppleGetVar_Unknown0: pvArg1=%p pvArg2=%p pvArg3=%p pvArg4=%p", 133 pvArg1, pvArg2, pvArg3, pvArg4); 134 DebugAssert(__FILE__, __LINE__, szMsg); 135 return EFI_UNSUPPORTED; 136 } 137 138 EFI_STATUS EFIAPI 139 AppleGetVar_Unknown1(IN APPLE_GETVAR_PROTOCOL *This, IN VOID *pvArg1, IN VOID *pvArg2, 140 IN VOID *pvArg3, IN VOID *pvArg4) 141 { 142 CHAR8 szMsg[128]; 143 AsciiSPrint(szMsg, sizeof(szMsg), "AppleGetVar_Unknown1: pvArg1=%p pvArg2=%p pvArg3=%p pvArg4=%p", 144 pvArg1, pvArg2, pvArg3, pvArg4); 145 DebugAssert(__FILE__, __LINE__, szMsg); 146 return EFI_UNSUPPORTED; 147 } 148 149 EFI_STATUS EFIAPI 150 AppleGetVar_Unknown2(IN APPLE_GETVAR_PROTOCOL *This, IN VOID *pvArg1, IN VOID *pvArg2) 151 { 152 CHAR8 szMsg[80]; 153 AsciiSPrint(szMsg, sizeof(szMsg), "AppleGetVar_Unknown2: pvArg1=%p pvArg2=%p", pvArg1, pvArg2); 154 DebugAssert(__FILE__, __LINE__, szMsg); 155 return EFI_UNSUPPORTED; 156 } 157 158 159 /** 160 * This method obtains the 'device-properties' that get exposed by 161 * AppleEFIFirmware and parsed by AppleACPIPlatform. 162 * 163 * Check out the data in the IORegisteryExplorer, the device-properties property 164 * under IODeviceTree:/efi. 165 * 166 * @retval EFI_SUCCESS, check *pcbBuf or the number of bytes actually returned. 167 * @retval EFI_BUFFER_TOO_SMALL, check *pcbBuf for the necessary buffer size. 168 * @param pThis Not used. 169 * @param pbBuf The output buffer. 170 * @param pcbBuf On input, the varible pointed to contains the size of the 171 * buffer. The size is generally 4KB from what we've observed. 172 * On output, it contains the amount of data available, this 173 * is always set. 174 */ 175 EFI_STATUS EFIAPI 176 AppleGetVar_GetDeviceProps(IN APPLE_GETVAR_PROTOCOL *pThis, OUT CHAR8 *pbBuf, IN OUT UINT32 *pcbBuf) 177 { 178 UINT32 cbBuf = *pcbBuf; 179 UINT32 cbActual; 180 181 cbActual = GetVmVariable(EFI_INFO_INDEX_DEVICE_PROPS, pbBuf, cbBuf); 182 *pcbBuf = cbActual; 183 184 if (cbActual > cbBuf) 185 return EFI_BUFFER_TOO_SMALL; 186 187 return EFI_SUCCESS; 188 } 189 190 APPLE_GETVAR_PROTOCOL gPrivateVarHandler = 191 { 192 /* Magic = */ APPLE_GETVAR_PROTOCOL_MAGIC, 193 AppleGetVar_Unknown0, 194 AppleGetVar_Unknown1, 195 AppleGetVar_Unknown2, 196 AppleGetVar_GetDeviceProps 197 }; 198 199 200 /* 201 * Unknown Protocol #1. 202 */ 203 204 /** This seems to be related to graphics/display... */ 205 EFI_GUID gEfiUnknown1ProtocolGuid = 206 { 101 207 0xDD8E06AC, 0x00E2, 0x49A9, {0x88, 0x8F, 0xFA, 0x46, 0xDE, 0xD4, 0x0A, 0x52} 102 208 }; 103 209 104 /*105 * Typedefs106 */107 typedef struct _APPLE_GETVAR_PROTOCOL APPLE_GETVAR_PROTOCOL;108 109 typedef110 EFI_STATUS111 (EFIAPI *APPLE_GETVAR_PROTOCOL_GET_DEVICE_PROPS) (112 IN APPLE_GETVAR_PROTOCOL *This,113 IN CHAR8 *Buffer,114 IN OUT UINT32 *BufferSize);115 116 117 struct _APPLE_GETVAR_PROTOCOL118 {119 UINT64 Magic;120 EFI_STATUS(EFIAPI *Unknown0)(IN VOID *);121 EFI_STATUS(EFIAPI *Unknown1)(IN VOID *);122 EFI_STATUS(EFIAPI *Unknown2)(IN VOID *);123 APPLE_GETVAR_PROTOCOL_GET_DEVICE_PROPS GetDevProps;124 };125 126 127 #define IMPL_STUB(iface, num) \128 EFI_STATUS EFIAPI \129 iface##Unknown##num(IN VOID *This) \130 { \131 Print(L"Unknown%d of %a called", num, #iface); \132 /*DebugAssert(__FILE__, __LINE__, __FUNCTION__);*/ \133 return EFI_SUCCESS; \134 }135 136 IMPL_STUB(GetVar, 0)137 IMPL_STUB(GetVar, 1)138 IMPL_STUB(GetVar, 2)139 140 141 EFI_STATUS EFIAPI142 GetDeviceProps(IN APPLE_GETVAR_PROTOCOL *This,143 IN CHAR8 *Buffer,144 IN OUT UINT32 *BufferSize)145 {146 UINT32 BufLen = *BufferSize, DataLen;147 148 DataLen = GetVmVariable(EFI_INFO_INDEX_DEVICE_PROPS, Buffer, BufLen);149 *BufferSize = DataLen;150 151 if (DataLen > BufLen)152 return EFI_BUFFER_TOO_SMALL;153 154 return EFI_SUCCESS;155 }156 157 APPLE_GETVAR_PROTOCOL gPrivateVarHandler =158 {159 /* Magic = */ 0, /** @todo figure out what's here on a real system? */160 GetVarUnknown0,161 GetVarUnknown1,162 GetVarUnknown2,163 GetDeviceProps164 };165 166 210 EFI_STATUS EFIAPI 167 211 UnknownHandlerImpl() 168 212 { 213 #ifdef DEBUG 214 ASSERT(0); 215 #endif 169 216 Print(L"Unknown called\n"); 170 217 return EFI_SUCCESS; … … 193 240 UnknownHandlerImpl 194 241 }; 195 196 EFI_STATUS EFIAPI197 SetPrivateVarProto(IN EFI_HANDLE ImageHandle, EFI_BOOT_SERVICES * bs)198 {199 EFI_STATUS rc;200 201 rc = gBS->InstallMultipleProtocolInterfaces (202 &ImageHandle,203 &gEfiAppleVarGuid,204 &gPrivateVarHandler,205 NULL206 );207 ASSERT_EFI_ERROR (rc);208 209 return EFI_SUCCESS;210 }211 242 212 243 EFI_STATUS EFIAPI … … 274 305 275 306 rc = SetProperVariables(ImageHandle, SystemTable->RuntimeServices); 276 ASSERT_EFI_ERROR 277 278 rc = SetPrivateVarProto(ImageHandle, gBS);279 ASSERT_EFI_ERROR 280 281 GetVmVariable(EFI_INFO_INDEX_FSB_FREQUENCY, (CHAR8 *)&FSBFrequency, sizeof FSBFrequency);282 GetVmVariable(EFI_INFO_INDEX_TSC_FREQUENCY, (CHAR8 *)&TSCFrequency, sizeof TSCFrequency);283 GetVmVariable(EFI_INFO_INDEX_CPU_FREQUENCY, (CHAR8 *)&CPUFrequency, sizeof CPUFrequency);307 ASSERT_EFI_ERROR(rc); 308 309 rc = gBS->InstallMultipleProtocolInterfaces(&ImageHandle, &gEfiAppleVarGuid, &gPrivateVarHandler, NULL); 310 ASSERT_EFI_ERROR(rc); 311 312 GetVmVariable(EFI_INFO_INDEX_FSB_FREQUENCY, (CHAR8 *)&FSBFrequency, sizeof(FSBFrequency)); 313 GetVmVariable(EFI_INFO_INDEX_TSC_FREQUENCY, (CHAR8 *)&TSCFrequency, sizeof(TSCFrequency)); 314 GetVmVariable(EFI_INFO_INDEX_CPU_FREQUENCY, (CHAR8 *)&CPUFrequency, sizeof(CPUFrequency)); 284 315 285 316 rc = CpuUpdateDataHub(gBS, FSBFrequency, TSCFrequency, CPUFrequency); 286 ASSERT_EFI_ERROR 317 ASSERT_EFI_ERROR(rc); 287 318 288 319 rc = InitializeConsoleSim(ImageHandle, SystemTable); 289 ASSERT_EFI_ERROR (rc); 290 291 rc = gBS->InstallMultipleProtocolInterfaces ( 292 &ImageHandle, 293 &gEfiUnknown1ProtocolGuid, 294 gUnknownProtoHandler, 295 NULL 296 ); 297 ASSERT_EFI_ERROR (rc); 320 ASSERT_EFI_ERROR(rc); 321 322 rc = gBS->InstallMultipleProtocolInterfaces(&ImageHandle, &gEfiUnknown1ProtocolGuid, gUnknownProtoHandler, NULL); 323 ASSERT_EFI_ERROR(rc); 298 324 299 325 return EFI_SUCCESS; -
trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVga.c
r48674 r49098 998 998 } 999 999 1000 /** Aka know as AppleGraphInfoProtocolGuid in other sources. */ 1000 1001 #define EFI_UNKNOWN_2_PROTOCOL_GUID \ 1001 1002 { 0xE316E100, 0x0751, 0x4C49, {0x90, 0x56, 0x48, 0x6C, 0x7E, 0x47, 0x29, 0x03} }
Note:
See TracChangeset
for help on using the changeset viewer.