VirtualBox

Changeset 49098 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Oct 15, 2013 1:30:53 AM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
89929
Message:

EFI: Found a likely value for APPLE_GETVAR_PROTOCOL::u64Magic as well as number of parameters for the unknown methods. Some cleanups.

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  
    3333#include <Library/UefiBootServicesTableLib.h>
    3434#include <Library/UefiLib.h>
     35#include <Library/PrintLib.h>
    3536
    3637#include <Protocol/DevicePathToText.h>
     
    6465
    6566/*
    66  *   Internal Functions                                                        *
     67 * Internal Functions
    6768 */
    6869static UINT32
    69 GetVmVariable(UINT32 Variable, CHAR8* Buffer, UINT32 Size )
    70 {
    71     UINT32 VarLen, i;
    72 
     70GetVmVariable(UINT32 Variable, CHAR8 *pbBuf, UINT32 cbBuf)
     71{
     72    UINT32 cbVar, offBuf;
    7373
    7474    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;
    8381}
    8482
     
    8684 * GUIDs
    8785 */
     86/** The EFI variable GUID for the 'FirmwareFeatures' and friends.
     87 * Also known as AppleFirmwareVariableGuid in other sources. */
    8888EFI_GUID gEfiAppleNvramGuid = {
    8989    0x4D1EDE05, 0x38C7, 0x4A6A, {0x9C, 0xC6, 0x4B, 0xCC, 0xA8, 0xB3, 0x8C, 0x14 }
    9090};
    9191
     92/** The EFI variable GUID for the 'boot-args' variable and others.
     93 * Also known as AppleNVRAMVariableGuid in other sources. */
    9294EFI_GUID gEfiAppleBootGuid = {
    9395    0x7C436110, 0xAB2A, 0x4BBB, {0xA8, 0x80, 0xFE, 0x41, 0x99, 0x5C, 0x9F, 0x82}
    9496};
    9597
     98
     99/*
     100 * Device Properoty protocol implementation hack.
     101 */
     102
     103/** gEfiAppleVarGuid is aka AppleDevicePropertyProtocolGuid in other sources. */
    96104EFI_GUID gEfiAppleVarGuid = {
    97105    0x91BD12FE, 0xF6C3, 0x44FB, {0xA5, 0xB7, 0x51, 0x22, 0xAB, 0x30, 0x3A, 0xE0}
    98106};
    99107
    100 EFI_GUID gEfiUnknown1ProtocolGuid = {
     108/** APPLE_GETVAR_PROTOCOL is aka APPLE_DEVICE_PROPERTY_PROTOCOL in other sources. */
     109typedef struct _APPLE_GETVAR_PROTOCOL APPLE_GETVAR_PROTOCOL;
     110
     111struct _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
     127EFI_STATUS EFIAPI
     128AppleGetVar_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
     138EFI_STATUS EFIAPI
     139AppleGetVar_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
     149EFI_STATUS EFIAPI
     150AppleGetVar_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 */
     175EFI_STATUS EFIAPI
     176AppleGetVar_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
     190APPLE_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... */
     205EFI_GUID gEfiUnknown1ProtocolGuid =
     206{
    101207    0xDD8E06AC, 0x00E2, 0x49A9, {0x88, 0x8F, 0xFA, 0x46, 0xDE, 0xD4, 0x0A, 0x52}
    102208};
    103209
    104 /*
    105  * Typedefs
    106  */
    107 typedef struct _APPLE_GETVAR_PROTOCOL APPLE_GETVAR_PROTOCOL;
    108 
    109 typedef
    110 EFI_STATUS
    111 (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_PROTOCOL
    118 {
    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 EFIAPI
    142 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     GetDeviceProps
    164 };
    165 
    166210EFI_STATUS EFIAPI
    167211UnknownHandlerImpl()
    168212{
     213#ifdef DEBUG
     214    ASSERT(0);
     215#endif
    169216    Print(L"Unknown called\n");
    170217    return EFI_SUCCESS;
     
    193240    UnknownHandlerImpl
    194241};
    195 
    196 EFI_STATUS EFIAPI
    197 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         NULL
    206                                                  );
    207     ASSERT_EFI_ERROR (rc);
    208 
    209     return EFI_SUCCESS;
    210 }
    211242
    212243EFI_STATUS EFIAPI
     
    274305
    275306    rc = SetProperVariables(ImageHandle, SystemTable->RuntimeServices);
    276     ASSERT_EFI_ERROR (rc);
    277 
    278     rc = SetPrivateVarProto(ImageHandle, gBS);
    279     ASSERT_EFI_ERROR (rc);
    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));
    284315
    285316    rc = CpuUpdateDataHub(gBS, FSBFrequency, TSCFrequency, CPUFrequency);
    286     ASSERT_EFI_ERROR (rc);
     317    ASSERT_EFI_ERROR(rc);
    287318
    288319    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);
    298324
    299325    return EFI_SUCCESS;
  • trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVga.c

    r48674 r49098  
    998998}
    999999
     1000/** Aka know as AppleGraphInfoProtocolGuid in other sources. */
    10001001#define EFI_UNKNOWN_2_PROTOCOL_GUID \
    10011002  { 0xE316E100, 0x0751, 0x4C49, {0x90, 0x56, 0x48, 0x6C, 0x7E, 0x47, 0x29, 0x03} }
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