Index: /trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c
===================================================================
--- /trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c	(revision 58835)
+++ /trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c	(revision 58836)
@@ -17,9 +17,5 @@
 #ifdef VBOX
 #include "VBoxPkg.h"
-#include "DevEFI.h"
-#include "iprt/asm.h"
 #include "Library/PrintLib.h"
-/* Hmmm Uga Draw wasn't pointed in BDS, so perhaps it's totally dead */
-#include <Protocol/UgaDraw.h>
 #include <Guid/EventGroup.h> /* gEfiEventReadyToBootGuid */
 #endif
@@ -35,82 +31,4 @@
 EFI_EVENT     mEmuVariableEvent;
 BOOLEAN       mDetectVgaOnly;
-
-#ifdef VBOX
-static EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOutputProtocol;
-static EFI_GRAPHICS_OUTPUT_PROTOCOL    *Gop;
-static EFI_UGA_DRAW_PROTOCOL           *Uga;
-
-/*
- *   @todo move this function to the library.
- */
-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;
-}
-
-static VOID
-EFIAPI
-VBoxConsoleSwitchMode (
-  IN EFI_EVENT                Event,
-  IN VOID                     *Context
-  )
-{
-    EFI_STATUS r = EFI_NOT_FOUND; /* Neither GOP nor UGA is found*/
-    EFI_TPL               OldTpl;
-    OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
-
-    gBS->LocateProtocol(&gEfiSimpleTextOutProtocolGuid, NULL, (VOID **)&TextOutputProtocol);
-    gBS->LocateProtocol(&gEfiUgaDrawProtocolGuid, NULL, (VOID **)&Uga);
-    gBS->LocateProtocol(&gEfiGraphicsOutputProtocolGuid, NULL, (VOID **)&Gop);
-
-    if (Gop)
-    {
-        UINT32 mode = 2;
-        GetVmVariable(EFI_INFO_INDEX_GOP_MODE, (CHAR8 *)&mode, sizeof(UINT32));
-        r = Gop->SetMode(Gop, mode);
-    }
-    else if (Uga)
-    {
-        UINT32 H = 1027;
-        UINT32 V = 768;
-        GetVmVariable(EFI_INFO_INDEX_UGA_HORIZONTAL_RESOLUTION, (CHAR8 *)&H, sizeof(UINT32));
-        GetVmVariable(EFI_INFO_INDEX_UGA_VERTICAL_RESOLUTION, (CHAR8 *)&V, sizeof(UINT32));
-        r = Uga->SetMode(Uga, H, V, 32, 60);
-    }
-
-    if(EFI_ERROR(r))
-        goto done;
-
-    r = TextOutputProtocol->SetMode(TextOutputProtocol, TextOutputProtocol->Mode->MaxMode);
-    if(EFI_ERROR(r))
-        goto done;
-    done:
-    gBS->RestoreTPL (OldTpl);
-    return;
-}
-
-EFI_STATUS
-EFIAPI
-VBoxConsoleInit()
-{
-    EFI_EVENT event;
-
-    gBS->CreateEventEx(EVT_NOTIFY_SIGNAL, TPL_NOTIFY, VBoxConsoleSwitchMode, NULL, &gEfiEventReadyToBootGuid, &event);
-    return EFI_SUCCESS;
-}
-#endif /* VBOX */
-
 
 //
@@ -1386,7 +1304,4 @@
     }
   }
-#ifdef VBOX
-  VBoxConsoleInit();
-#endif
 
   //
Index: /trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/OvmfPkgIa32.dsc
===================================================================
--- /trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/OvmfPkgIa32.dsc	(revision 58835)
+++ /trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/OvmfPkgIa32.dsc	(revision 58836)
@@ -545,5 +545,8 @@
  MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
  VBoxPkg/VBoxVgaMiniPortDxe/VBoxVgaMiniPortDxe.inf
- VBoxPkg/VBoxVgaDxe/VBoxVgaDxe.inf
+ VBoxPkg/VBoxVgaDxe/VBoxVgaDxe.inf {
+    <LibraryClasses>
+      PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
+ }
  VBoxPkg/VBoxFsDxe/VBoxIso9660.inf
  VBoxPkg/VBoxFsDxe/VBoxHfs.inf
Index: /trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/OvmfPkgX64.dsc
===================================================================
--- /trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/OvmfPkgX64.dsc	(revision 58835)
+++ /trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/OvmfPkgX64.dsc	(revision 58836)
@@ -549,5 +549,8 @@
  MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
  VBoxPkg/VBoxVgaMiniPortDxe/VBoxVgaMiniPortDxe.inf
- VBoxPkg/VBoxVgaDxe/VBoxVgaDxe.inf
+ VBoxPkg/VBoxVgaDxe/VBoxVgaDxe.inf {
+    <LibraryClasses>
+      PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
+ }
  VBoxPkg/VBoxFsDxe/VBoxIso9660.inf
  VBoxPkg/VBoxFsDxe/VBoxHfs.inf
Index: /trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVga.c
===================================================================
--- /trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVga.c	(revision 58835)
+++ /trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVga.c	(revision 58836)
@@ -230,4 +230,22 @@
     NULL
 };
+
+
+/*
+ *   @todo move this function to the library.
+ */
+UINT32 VBoxVgaGetVmVariable(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;
+}
+
 
 /**
Index: /trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVga.h
===================================================================
--- /trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVga.h	(revision 58835)
+++ /trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVga.h	(revision 58836)
@@ -72,4 +72,7 @@
 
 #include "VBoxPkg.h"
+#include "DevEFI.h"
+#include "iprt/asm.h"
+
 //
 // Cirrus Logic 5430 PCI Configuration Header values
@@ -447,3 +450,5 @@
   );
 
+UINT32 VBoxVgaGetVmVariable(UINT32 Variable, CHAR8* Buffer, UINT32 Size);
+
 #endif
Index: /trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVgaDxe.inf
===================================================================
--- /trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVgaDxe.inf	(revision 58835)
+++ /trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVgaDxe.inf	(revision 58836)
@@ -90,4 +90,5 @@
 [Packages]
   MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
   VBoxPkg/VBoxPkg.dec
 
@@ -119,2 +120,4 @@
 [Pcd]
   gVBoxVgaPkgTokenSpaceGuid.PcdDriverSupportedEfiVersion
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution  ## PRODUCES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution    ## PRODUCES
Index: /trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVgaGraphicsOutput.c
===================================================================
--- /trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVgaGraphicsOutput.c	(revision 58835)
+++ /trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVgaGraphicsOutput.c	(revision 58836)
@@ -444,5 +444,5 @@
   EFI_STATUS                   Status;
   EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
-
+  UINT32                        GopMode = 2;
 
   GraphicsOutput            = &Private->GraphicsOutput;
@@ -478,5 +478,6 @@
   // Initialize the hardware
   //
-  GraphicsOutput->SetMode (GraphicsOutput, 2);
+  VBoxVgaGetVmVariable(EFI_INFO_INDEX_GOP_MODE, (CHAR8 *)&GopMode, sizeof(GopMode));
+  GraphicsOutput->SetMode (GraphicsOutput, GopMode);
   DrawLogo (
     Private,
@@ -484,4 +485,6 @@
     Private->ModeData[Private->GraphicsOutput.Mode->Mode].VerticalResolution
     );
+  PcdSet32(PcdVideoHorizontalResolution, Private->ModeData[Private->GraphicsOutput.Mode->Mode].HorizontalResolution);
+  PcdSet32(PcdVideoVerticalResolution, Private->ModeData[Private->GraphicsOutput.Mode->Mode].VerticalResolution);
 
   return EFI_SUCCESS;
Index: /trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVgaUgaDraw.c
===================================================================
--- /trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVgaUgaDraw.c	(revision 58835)
+++ /trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVgaUgaDraw.c	(revision 58836)
@@ -333,4 +333,6 @@
 {
   EFI_UGA_DRAW_PROTOCOL *UgaDraw;
+  UINT32                HorizontalResolution = 1027;
+  UINT32                VerticalResolution = 768;
 
   //
@@ -353,4 +355,9 @@
   // Initialize the hardware
   //
+  VBoxVgaGetVmVariable(EFI_INFO_INDEX_UGA_HORIZONTAL_RESOLUTION, (CHAR8 *)&HorizontalResolution,
+                       sizeof(HorizontalResolution));
+  VBoxVgaGetVmVariable(EFI_INFO_INDEX_UGA_VERTICAL_RESOLUTION, (CHAR8 *)&VerticalResolution,
+                       sizeof(VerticalResolution));
+
   UgaDraw->SetMode (
             UgaDraw,
@@ -365,4 +372,6 @@
     Private->ModeData[Private->CurrentMode].VerticalResolution
     );
+  PcdSet32(PcdVideoHorizontalResolution, HorizontalResolution);
+  PcdSet32(PcdVideoVerticalResolution, VerticalResolution);
 
   return EFI_SUCCESS;
