Index: trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/VBoxAppleSim/Console.c
===================================================================
--- trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/VBoxAppleSim/Console.c	(revision 29070)
+++ trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/VBoxAppleSim/Console.c	(revision 29070)
@@ -0,0 +1,87 @@
+/* $Id$ */
+/** @file
+ * Console.c - VirtualBox Console control emulation
+ */
+
+/*
+ * Copyright (C) 2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+#include <Uefi.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/DebugLib.h>
+
+#include "VBoxPkg.h"
+#include "ConsoleControl.h"
+
+EFI_STATUS EFIAPI
+GetModeImpl(
+  IN  EFI_CONSOLE_CONTROL_PROTOCOL      *This,
+  OUT EFI_CONSOLE_CONTROL_SCREEN_MODE   *Mode,
+  OUT BOOLEAN                           *GopUgaExists,  OPTIONAL
+  OUT BOOLEAN                           *StdInLocked    OPTIONAL
+  )
+{
+    *Mode =   EfiConsoleControlScreenGraphics;
+
+    if (GopUgaExists)
+        *GopUgaExists = TRUE;
+    if (StdInLocked)
+        *StdInLocked = FALSE;
+    return EFI_SUCCESS;
+}
+
+EFI_STATUS EFIAPI
+SetModeImpl(
+  IN  EFI_CONSOLE_CONTROL_PROTOCOL      *This,
+  IN  EFI_CONSOLE_CONTROL_SCREEN_MODE   Mode
+  )
+{
+    return EFI_SUCCESS;
+}
+
+EFI_STATUS EFIAPI
+LockStdInImpl(
+  IN  EFI_CONSOLE_CONTROL_PROTOCOL      *This,
+  IN CHAR16                             *Password
+  )
+{
+    return EFI_SUCCESS;
+}
+
+
+EFI_CONSOLE_CONTROL_PROTOCOL gConsoleController =
+{
+    GetModeImpl,
+    SetModeImpl,
+    LockStdInImpl
+};
+
+EFI_GUID gEfiConsoleControlProtocolGuid = EFI_CONSOLE_CONTROL_PROTOCOL_GUID;
+
+EFI_STATUS
+EFIAPI
+InitializeConsoleSim (
+  IN EFI_HANDLE           ImageHandle,
+  IN EFI_SYSTEM_TABLE     *SystemTable
+  )
+{
+  EFI_STATUS              Status;
+
+  Status = gBS->InstallMultipleProtocolInterfaces (
+      &ImageHandle,
+      &gEfiConsoleControlProtocolGuid,
+      &gConsoleController,
+      NULL
+                                                   );
+  ASSERT_EFI_ERROR (Status);
+
+  return Status;
+}
Index: trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/VBoxAppleSim/ConsoleControl.h
===================================================================
--- trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/VBoxAppleSim/ConsoleControl.h	(revision 29070)
+++ trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/VBoxAppleSim/ConsoleControl.h	(revision 29070)
@@ -0,0 +1,137 @@
+/* $Id$ */
+/** @file
+ * ConsonleControl.h
+ */
+
+/*
+ * Copyright (C) 2009-2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * This code is based on:
+ *
+ * Copyright (c) 2004 - 2006, Intel Corporation
+ * All rights reserved. This program and the accompanying materials
+ * are licensed and made available under the terms and conditions of the BSD License
+ * which accompanies this distribution.  The full text of the license may be found at
+ * http://opensource.org/licenses/bsd-license.php
+ *
+ * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ * 
+ * Module Name:
+ *
+ * ConsoleControl.h
+ *
+ * Abstract:
+ *
+ * Abstraction of a Text mode or GOP/UGA screen
+ */
+
+#ifndef __CONSOLE_CONTROL_H__
+#define __CONSOLE_CONTROL_H__
+
+#define EFI_CONSOLE_CONTROL_PROTOCOL_GUID \
+  { 0xf42f7782, 0x12e, 0x4c12, {0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21} }
+
+typedef struct _EFI_CONSOLE_CONTROL_PROTOCOL   EFI_CONSOLE_CONTROL_PROTOCOL;
+
+
+typedef enum {
+  EfiConsoleControlScreenText,
+  EfiConsoleControlScreenGraphics,
+  EfiConsoleControlScreenMaxValue
+} EFI_CONSOLE_CONTROL_SCREEN_MODE;
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_GET_MODE) (
+  IN  EFI_CONSOLE_CONTROL_PROTOCOL      *This,
+  OUT EFI_CONSOLE_CONTROL_SCREEN_MODE   *Mode,
+  OUT BOOLEAN                           *GopUgaExists,  OPTIONAL
+  OUT BOOLEAN                           *StdInLocked    OPTIONAL
+  )
+/*++
+
+  Routine Description:
+    Return the current video mode information. Also returns info about existence
+    of Graphics Output devices or UGA Draw devices in system, and if the Std In
+    device is locked. All the arguments are optional and only returned if a non
+    NULL pointer is passed in.
+
+  Arguments:
+    This         - Protocol instance pointer.
+    Mode         - Are we in text of grahics mode.
+    GopUgaExists - TRUE if Console Spliter has found a GOP or UGA device
+    StdInLocked  - TRUE if StdIn device is keyboard locked
+
+  Returns:
+    EFI_SUCCESS     - Mode information returned.
+
+--*/
+;
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_SET_MODE) (
+  IN  EFI_CONSOLE_CONTROL_PROTOCOL      *This,
+  OUT EFI_CONSOLE_CONTROL_SCREEN_MODE   Mode
+  )
+/*++
+
+  Routine Description:
+    Set the current mode to either text or graphics. Graphics is
+    for Quiet Boot.
+
+  Arguments:
+    This  - Protocol instance pointer.
+    Mode  - Mode to set the
+
+  Returns:
+    EFI_SUCCESS     - Mode information returned.
+
+--*/
+;
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_LOCK_STD_IN) (
+  IN  EFI_CONSOLE_CONTROL_PROTOCOL      *This,
+  IN CHAR16                             *Password
+  )
+/*++
+
+  Routine Description:
+    Lock Std In devices until Password is typed.
+
+  Arguments:
+    This     - Protocol instance pointer.
+    Password - Password needed to unlock screen. NULL means unlock keyboard
+
+  Returns:
+    EFI_SUCCESS      - Mode information returned.
+    EFI_DEVICE_ERROR - Std In not locked
+
+--*/
+;
+
+
+
+struct _EFI_CONSOLE_CONTROL_PROTOCOL {
+  EFI_CONSOLE_CONTROL_PROTOCOL_GET_MODE           GetMode;
+  EFI_CONSOLE_CONTROL_PROTOCOL_SET_MODE           SetMode;
+  EFI_CONSOLE_CONTROL_PROTOCOL_LOCK_STD_IN        LockStdIn;
+};
+
+extern EFI_GUID gEfiConsoleControlProtocolGuid;
+
+#endif
Index: trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/VBoxAppleSim/Cpu.c
===================================================================
--- trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/VBoxAppleSim/Cpu.c	(revision 29070)
+++ trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/VBoxAppleSim/Cpu.c	(revision 29070)
@@ -0,0 +1,135 @@
+/* $Id$ */
+/** @file
+ * Cpu.c - VirtualBox CPU descriptors
+ */
+
+/*
+ * Copyright (C) 2009-2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+
+/*******************************************************************************
+ *   Header Files                                                               *
+ *******************************************************************************/
+#include <Framework/FrameworkInternalFormRepresentation.h>
+
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiLib.h>
+#include <Library/HiiLib.h>
+#include <Library/BaseLib.h>
+
+#include <Guid/DataHubRecords.h>
+
+#include <Protocol/Cpu.h>
+#include <Protocol/DataHub.h>
+#include <Protocol/FrameworkHii.h>
+#include <Protocol/CpuIo.h>
+
+#define EFI_CPU_DATA_MAXIMUM_LENGTH 0x100
+
+typedef union {
+    EFI_CPU_DATA_RECORD *DataRecord;
+    UINT8               *Raw;
+} EFI_CPU_DATA_RECORD_BUFFER;
+
+EFI_SUBCLASS_TYPE1_HEADER mCpuDataRecordHeader = {
+    EFI_PROCESSOR_SUBCLASS_VERSION,       // Version
+    sizeof (EFI_SUBCLASS_TYPE1_HEADER),   // Header Size
+    0,                                    // Instance, Initialize later
+    EFI_SUBCLASS_INSTANCE_NON_APPLICABLE, // SubInstance
+    0                                     // RecordType, Initialize later
+};
+
+EFI_GUID gEfiAppleMagicHubGuid = {
+    0x64517cc8, 0x6561, 0x4051, {0xb0, 0x3c, 0x59, 0x64, 0xb6, 0x0f, 0x4c, 0x7a }
+};
+
+#pragma pack(1)
+typedef struct {
+    UINT8          Pad0[0x10];      /* 0x48 */
+    UINT32         NameLen;         /* 0x58 , in bytes */
+    UINT32         ValLen;          /* 0x5c */
+    UINT8          Data[1];         /* 0x60 Name Value */
+} MAGIC_HUB_DATA;
+#pragma pack()
+
+UINT32
+CopyRecord(MAGIC_HUB_DATA* Rec, const CHAR16* Name, VOID* Val, UINT32 ValLen)
+{
+    Rec->NameLen = StrLen(Name) * sizeof(CHAR16);
+    Rec->ValLen = ValLen;
+    CopyMem(Rec->Data, Name, Rec->NameLen);
+    CopyMem(Rec->Data + Rec->NameLen, Val, ValLen);
+
+    return 0x10 + 4 + 4 + Rec->NameLen + Rec->ValLen;
+}
+
+EFI_STATUS EFIAPI
+LogData(EFI_DATA_HUB_PROTOCOL       *DataHub,
+        MAGIC_HUB_DATA              *MagicData,
+        CHAR16                      *Name,
+        VOID                        *Data,
+        UINT32                       DataSize)
+{
+    UINT32                      RecordSize;
+    EFI_STATUS                  Status;
+
+    RecordSize = CopyRecord(MagicData, Name, Data, DataSize);
+    Status = DataHub->LogData (
+        DataHub,
+        &gEfiProcessorSubClassGuid, /* DataRecordGuid */
+        &gEfiAppleMagicHubGuid,     /* ProducerName */
+        EFI_DATA_RECORD_CLASS_DATA,
+        MagicData,
+        RecordSize
+                               );
+    ASSERT_EFI_ERROR (Status);
+
+    return Status;
+}
+
+EFI_STATUS EFIAPI
+CpuUpdateDataHub(EFI_BOOT_SERVICES * bs,
+                 UINT64              FSBFrequency,
+                 UINT64              TSCFrequency,
+                 UINT64              CPUFrequency)
+{
+    EFI_STATUS                  Status;
+    EFI_DATA_HUB_PROTOCOL       *DataHub;
+    MAGIC_HUB_DATA              *MagicData;
+    //
+    // Locate DataHub protocol.
+    //
+    Status = bs->LocateProtocol (&gEfiDataHubProtocolGuid, NULL, (VOID**)&DataHub);
+    if (EFI_ERROR (Status)) {
+        return Status;
+    }
+
+    MagicData = (MAGIC_HUB_DATA*)AllocatePool (0x200);
+    if (MagicData == NULL) {
+        return EFI_OUT_OF_RESOURCES;
+    }
+
+    // Log data in format some OSes like
+    LogData(DataHub, MagicData, L"FSBFrequency", &FSBFrequency, sizeof(FSBFrequency));
+    // do that twice, as last variable read not really accounted for
+    LogData(DataHub, MagicData, L"FSBFrequency", &FSBFrequency, sizeof(FSBFrequency));
+    LogData(DataHub, MagicData, L"TSCFrequency", &TSCFrequency, sizeof(TSCFrequency));
+    LogData(DataHub, MagicData, L"CPUFrequency", &CPUFrequency, sizeof(CPUFrequency));
+
+    FreePool (MagicData);
+
+    return EFI_SUCCESS;
+}
Index: trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/VBoxAppleSim/VBoxAppleSim.c
===================================================================
--- trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/VBoxAppleSim/VBoxAppleSim.c	(revision 29070)
+++ trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/VBoxAppleSim/VBoxAppleSim.c	(revision 29070)
@@ -0,0 +1,297 @@
+/* $Id$ */
+/** @file
+ * VBoxAppleSim.c - VirtualBox Apple Firmware simulation support
+ */
+
+/*
+ * Copyright (C) 2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+
+#include <Protocol/DevicePathToText.h>
+
+#include <IndustryStandard/Acpi10.h>
+#include <IndustryStandard/Acpi20.h>
+#include <IndustryStandard/SmBios.h>
+
+#include <Guid/SmBios.h>
+#include <Guid/Acpi.h>
+#include <Guid/Mps.h>
+
+#include "VBoxPkg.h"
+#include "DevEFI.h"
+#include "iprt/asm.h"
+
+
+/*
+ * External functions
+ */
+EFI_STATUS EFIAPI
+CpuUpdateDataHub(EFI_BOOT_SERVICES * bs,
+                 UINT64              FSBFrequency,
+                 UINT64              TSCFrequency,
+                 UINT64              CPUFrequency);
+
+EFI_STATUS EFIAPI
+InitializeConsoleSim (IN EFI_HANDLE           ImageHandle,
+                      IN EFI_SYSTEM_TABLE     *SystemTable);
+
+
+/*
+ *   Internal Functions                                                        *
+ */
+static UINT32
+GetVmVariable(UINT32 Variable, CHAR8* Buffer, UINT32 Size )
+{
+    UINT32 VarLen, i;
+
+
+    ASMOutU32(EFI_INFO_PORT, Variable);
+    VarLen = ASMInU32(EFI_INFO_PORT);
+
+    for (i=0; i < VarLen && i < Size; i++)
+    {
+        Buffer[i] = ASMInU8(EFI_INFO_PORT);
+    }
+
+    return VarLen;
+}
+
+/*
+ * GUIDs
+ */
+EFI_GUID gEfiAppleNvramGuid = {
+    0x4D1EDE05, 0x38C7, 0x4A6A, {0x9C, 0xC6, 0x4B, 0xCC, 0xA8, 0xB3, 0x8C, 0x14 }
+};
+
+EFI_GUID gEfiAppleBootGuid = {
+    0x7C436110, 0xAB2A, 0x4BBB, {0xA8, 0x80, 0xFE, 0x41, 0x99, 0x5C, 0x9F, 0x82}
+};
+
+EFI_GUID gEfiAppleVarGuid = {
+    0x91BD12FE, 0xF6C3, 0x44FB, {0xA5, 0xB7, 0x51, 0x22, 0xAB, 0x30, 0x3A, 0xE0}
+};
+
+EFI_GUID gEfiUnknown1ProtocolGuid = {
+    0xDD8E06AC, 0x00E2, 0x49A9, {0x88, 0x8F, 0xFA, 0x46, 0xDE, 0xD4, 0x0A, 0x52}
+};
+
+/*
+ * Typedefs
+ */
+typedef struct _APPLE_GETVAR_PROTOCOL APPLE_GETVAR_PROTOCOL;
+
+typedef
+EFI_STATUS
+(EFIAPI *APPLE_GETVAR_PROTOCOL_GET_DEVICE_PROPS) (
+    IN     APPLE_GETVAR_PROTOCOL   *This,
+    IN     CHAR8                   *Buffer,
+    IN OUT UINT32                  *BufferSize);
+
+
+struct _APPLE_GETVAR_PROTOCOL {
+    EFI_STATUS(EFIAPI *Unknown0)(IN VOID *);
+    EFI_STATUS(EFIAPI *Unknown1)(IN VOID *);
+    EFI_STATUS(EFIAPI *Unknown2)(IN VOID *);
+    EFI_STATUS(EFIAPI *Unknown3)(IN VOID *);
+    EFI_STATUS(EFIAPI *Unknown4)(IN VOID *);
+    APPLE_GETVAR_PROTOCOL_GET_DEVICE_PROPS  GetDevProps;
+};
+
+
+#define IMPL_STUB(iface, num)                                   \
+    EFI_STATUS EFIAPI                                           \
+    iface##Unknown##num(IN  VOID   *This)                       \
+    {                                                           \
+        Print(L"Unknown%d of %a called", num, #iface);          \
+        return EFI_SUCCESS;                                     \
+    }
+
+IMPL_STUB(GetVar, 0)
+IMPL_STUB(GetVar, 1)
+IMPL_STUB(GetVar, 2)
+IMPL_STUB(GetVar, 3)
+IMPL_STUB(GetVar, 4)
+
+EFI_STATUS EFIAPI
+GetDeviceProps(IN     APPLE_GETVAR_PROTOCOL   *This,
+               IN     CHAR8                   *Buffer,
+               IN OUT UINT32                  *BufferSize)
+{
+    UINT32 BufLen = *BufferSize, DataLen;
+
+    DataLen = GetVmVariable(EFI_INFO_INDEX_DEVICE_PROPS, Buffer, BufLen);
+    *BufferSize = DataLen;
+
+    if (DataLen > BufLen)
+        return EFI_BUFFER_TOO_SMALL;
+
+    return EFI_SUCCESS;
+}
+
+APPLE_GETVAR_PROTOCOL gPrivateVarHandler =
+{
+    GetVarUnknown0,
+    GetVarUnknown1,
+    GetVarUnknown2,
+    GetVarUnknown3,
+    GetVarUnknown4,
+    GetDeviceProps
+};
+
+EFI_STATUS EFIAPI
+UnknownHandlerImpl()
+{
+    Print(L"Unknown called\n");
+    return EFI_SUCCESS;
+}
+
+/* array of pointers to function */
+EFI_STATUS (EFIAPI *gUnknownProtoHandler[])() =
+{
+    UnknownHandlerImpl,
+    UnknownHandlerImpl,
+    UnknownHandlerImpl,
+    UnknownHandlerImpl,
+    UnknownHandlerImpl,
+    UnknownHandlerImpl,
+    UnknownHandlerImpl,
+    UnknownHandlerImpl,
+    UnknownHandlerImpl,
+    UnknownHandlerImpl,
+    UnknownHandlerImpl,
+    UnknownHandlerImpl,
+    UnknownHandlerImpl,
+    UnknownHandlerImpl,
+    UnknownHandlerImpl,
+    UnknownHandlerImpl,
+    UnknownHandlerImpl,
+    UnknownHandlerImpl
+};
+
+EFI_STATUS EFIAPI
+SetPrivateVarProto(IN EFI_HANDLE ImageHandle, EFI_BOOT_SERVICES * bs)
+{
+    EFI_STATUS  rc;
+
+    rc = gBS->InstallMultipleProtocolInterfaces (
+        &ImageHandle,
+        &gEfiAppleVarGuid,
+        &gPrivateVarHandler,
+        NULL
+                                                 );
+    ASSERT_EFI_ERROR (rc);
+
+    return EFI_SUCCESS;
+}
+
+EFI_STATUS EFIAPI
+SetProperVariables(IN EFI_HANDLE ImageHandle, EFI_RUNTIME_SERVICES * rs)
+{
+     EFI_STATUS          rc;
+     UINT32              vBackgroundClear = 0x00000000;
+     UINT32              vFwFeatures      = 0x80000015;
+     UINT32              vFwFeaturesMask  = 0x800003ff;
+
+     // -legacy acpi=0xffffffff acpi_debug=0xfffffff panic_io_port=0xef11 io=0xfffffffe trace=4096  io=0xffffffef -v serial=2 serialbaud=9600
+     // 0x10 makes kdb default, thus 0x15e for kdb, 0x14e for gdb
+
+     //static const CHAR8  vBootArgs[]      = "debug=0x15e keepsyms=1 acpi=0xffffffff acpi_debug=0xff acpi_level=7 -v -x32 -s"; // or just "debug=0x8 -legacy"
+     // 0x14e for serial output
+     static const CHAR8  vDefBootArgs[]      = "debug=0x146 keepsyms=1 -v -serial=0x1";
+     CHAR8  vBootArgs[256];
+     UINT32 BootArgsLen;
+
+     BootArgsLen = GetVmVariable(EFI_INFO_INDEX_BOOT_ARGS, vBootArgs, sizeof vBootArgs);
+     if (BootArgsLen <= 1)
+     {
+         BootArgsLen = sizeof vDefBootArgs;
+         CopyMem(vBootArgs, vDefBootArgs, BootArgsLen);
+     }
+     rc = rs->SetVariable(L"BackgroundClear",
+                          &gEfiAppleNvramGuid,
+                          /* EFI_VARIABLE_NON_VOLATILE | */ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+                          sizeof(vBackgroundClear), &vBackgroundClear);
+
+     rc = rs->SetVariable(L"FirmwareFeatures",
+                          &gEfiAppleNvramGuid,
+                          EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+                          sizeof(vFwFeatures), &vFwFeatures);
+
+     rc = rs->SetVariable(L"FirmwareFeaturesMask",
+                          &gEfiAppleNvramGuid,
+                          EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+                          sizeof(vFwFeaturesMask), &vFwFeaturesMask);
+
+     rc = rs->SetVariable(L"boot-args",
+                          &gEfiAppleBootGuid,
+                          EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+                          BootArgsLen, &vBootArgs);
+
+     return EFI_SUCCESS;
+}
+
+/**
+ * VBoxInitAppleSim entry point.
+ *
+ * @returns EFI status code.
+ *
+ * @param   ImageHandle     The image handle.
+ * @param   SystemTable     The system table pointer.
+ */
+EFI_STATUS EFIAPI
+VBoxInitAppleSim(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
+{
+    EFI_STATUS          rc;
+    UINT64              FSBFrequency;
+    UINT64              TSCFrequency;
+    UINT64              CPUFrequency;
+
+    rc = SetProperVariables(ImageHandle, SystemTable->RuntimeServices);
+    ASSERT_EFI_ERROR (rc);
+
+    rc = SetPrivateVarProto(ImageHandle, gBS);
+    ASSERT_EFI_ERROR (rc);
+
+    GetVmVariable(EFI_INFO_INDEX_FSB_FREQUENCY, (CHAR8*)&FSBFrequency, sizeof FSBFrequency);
+    GetVmVariable(EFI_INFO_INDEX_TSC_FREQUENCY, (CHAR8*)&TSCFrequency, sizeof TSCFrequency);
+    GetVmVariable(EFI_INFO_INDEX_CPU_FREQUENCY, (CHAR8*)&CPUFrequency, sizeof CPUFrequency);
+
+    rc = CpuUpdateDataHub(gBS, FSBFrequency, TSCFrequency, CPUFrequency);
+    ASSERT_EFI_ERROR (rc);
+
+    rc = InitializeConsoleSim(ImageHandle, SystemTable);
+    ASSERT_EFI_ERROR (rc);
+
+    rc = gBS->InstallMultipleProtocolInterfaces (
+                                                 &ImageHandle,
+                                                 &gEfiUnknown1ProtocolGuid,
+                                                 gUnknownProtoHandler,
+                                                 NULL
+                                                 );
+    ASSERT_EFI_ERROR (rc);
+
+    return EFI_SUCCESS;
+}
+
+EFI_STATUS EFIAPI
+VBoxDeinitAppleSim(IN EFI_HANDLE         ImageHandle)
+{
+    return EFI_SUCCESS;
+}
Index: trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/VBoxAppleSim/VBoxAppleSim.inf
===================================================================
--- trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/VBoxAppleSim/VBoxAppleSim.inf	(revision 29070)
+++ trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/VBoxAppleSim/VBoxAppleSim.inf	(revision 29070)
@@ -0,0 +1,64 @@
+# $Id$
+## @file
+# VBoxAppleSim - VBox Apple intrefaces simulation support.
+#
+
+#
+# Copyright (C) 2010 Oracle Corporation
+#
+# This file is part of VirtualBox Open Source Edition (OSE), as
+# available from http://www.virtualbox.org. This file is free software;
+# you can redistribute it and/or modify it under the terms of the GNU
+# General Public License (GPL) as published by the Free Software
+# Foundation, in version 2 as it comes in the "COPYING" file of the
+# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+#
+
+[Defines]
+        INF_VERSION                = 0x00010005
+        BASE_NAME                  = VBoxAppleSim
+        FILE_GUID                  = 17795471-FD9A-46BE-8806-AE787BA73CD4
+        MODULE_TYPE                = UEFI_DRIVER
+        VERSION_STRING             = 1.0
+        EDK_RELEASE_VERSION        = 0x00020000
+        EFI_SPECIFICATION_VERSION  = 0x00020000
+        ENTRY_POINT                = VBoxInitAppleSim
+        UNLOAD_IMAGE               = VBoxDeinitAppleSim
+
+[Sources.common]
+        VBoxAppleSim.c
+        Cpu.c
+        Console.c
+ 
+[Packages]
+        MdePkg/MdePkg.dec
+        MdeModulePkg/MdeModulePkg.dec
+        IntelFrameworkPkg/IntelFrameworkPkg.dec
+        IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
+        VBoxPkg/VBoxPkg.dec
+
+[LibraryClasses]
+   UefiRuntimeServicesTableLib
+   UefiBootServicesTableLib
+   MemoryAllocationLib
+   BaseMemoryLib
+   BaseLib
+   UefiLib
+   UefiDriverEntryPoint
+   DebugLib
+   PcdLib
+   DevicePathLib
+
+[Guids]
+   gEfiProcessorSubClassGuid
+   
+[Protocols]
+   gEfiDevicePathToTextProtocolGuid
+   gEfiDataHubProtocolGuid
+
+[BuildOptions.common]
+
+  GCC:*_*_*_CC_FLAGS = 
+  INTEL:*_*_*_CC_FLAGS =
+  MSFT:*_*_*_CC_FLAGS =
