Index: trunk/src/VBox/Devices/EFI/DevEFI.cpp
===================================================================
--- trunk/src/VBox/Devices/EFI/DevEFI.cpp	(revision 26454)
+++ trunk/src/VBox/Devices/EFI/DevEFI.cpp	(revision 26464)
@@ -125,4 +125,9 @@
     /* Virtual machine CPU frequency */
     uint64_t        u64CpuFrequency;
+    /* GOP mode */
+    uint32_t        u32GopMode;
+    /* Uga mode resolutions */
+    uint32_t        u32UgaHorisontal;
+    uint32_t        u32UgaVertical;
 } DEVEFI;
 typedef DEVEFI *PDEVEFI;
@@ -152,4 +157,7 @@
         case EFI_INFO_INDEX_STACK_BASE:
         case EFI_INFO_INDEX_STACK_SIZE:
+        case EFI_INFO_INDEX_GOP_MODE:
+        case EFI_INFO_INDEX_UGA_VERTICAL_RESOLUTION:
+        case EFI_INFO_INDEX_UGA_HORISONTAL_RESOLUTION:
             return 4;
         case EFI_INFO_INDEX_BOOT_ARGS:
@@ -209,4 +217,13 @@
         case EFI_INFO_INDEX_DEVICE_PROPS:
             return pThis->pu8DeviceProps[pThis->iInfoPosition];
+        case EFI_INFO_INDEX_GOP_MODE:
+            value.u32 = pThis->u32GopMode;
+            break;
+        case EFI_INFO_INDEX_UGA_HORISONTAL_RESOLUTION:
+            value.u32 = pThis->u32UgaHorisontal;
+            break;
+        case EFI_INFO_INDEX_UGA_VERTICAL_RESOLUTION:
+            value.u32 = pThis->u32UgaVertical;
+            break;
         default:
             Assert(false);
@@ -1002,4 +1019,7 @@
                               "BootArgs\0"
                               "DeviceProps\0"
+                              "GopMode\0"
+                              "UgaHorizontalResolution\0"
+                              "UgaVerticalResolution\0"
                               ))
         return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES,
@@ -1115,5 +1135,28 @@
     pThis->u64TscFrequency = pThis->u64FsbFrequency * 3;
     pThis->u64CpuFrequency = pThis->u64TscFrequency;
-
+    /*
+     * GOP graphics
+     */
+    rc = CFGMR3QueryU32(pCfg, "GopMode", &pThis->u32GopMode);
+    AssertRC(rc);
+    if (pThis->u32GopMode == UINT32_MAX)
+    {
+        pThis->u32GopMode = 2; /* 1024x768 */
+    }
+    /*
+     * Uga graphics
+     */
+    rc = CFGMR3QueryU32(pCfg, "UgaHorizontalResolution", &pThis->u32UgaHorisontal);
+    AssertRC(rc);
+    if (pThis->u32UgaHorisontal == 0)
+    {
+        pThis->u32UgaHorisontal = 1024; /* 1024x768 */
+    }
+    rc = CFGMR3QueryU32(pCfg, "UgaVerticalResolution", &pThis->u32UgaVertical);
+    AssertRC(rc);
+    if (pThis->u32UgaVertical == 0)
+    {
+        pThis->u32UgaVertical = 768; /* 1024x768 */
+    }
 
 #ifdef DEVEFI_WITH_VBOXDBG_SCRIPT
Index: trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/Include/DevEFI.h
===================================================================
--- trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/Include/DevEFI.h	(revision 26454)
+++ trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/Include/DevEFI.h	(revision 26464)
@@ -59,4 +59,7 @@
     EFI_INFO_INDEX_CPU_FREQUENCY,
     EFI_INFO_INDEX_TSC_FREQUENCY,
+    EFI_INFO_INDEX_GOP_MODE,
+    EFI_INFO_INDEX_UGA_HORISONTAL_RESOLUTION,
+    EFI_INFO_INDEX_UGA_VERTICAL_RESOLUTION,
     EFI_INFO_INDEX_END
 } EfiInfoIndex;
Index: trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/VBoxConsoleDxe/VBoxConsole.c
===================================================================
--- trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/VBoxConsoleDxe/VBoxConsole.c	(revision 26454)
+++ trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/VBoxConsoleDxe/VBoxConsole.c	(revision 26464)
@@ -21,4 +21,7 @@
 
 #include "VBoxConsole.h"
+#include "VBoxPkg.h"
+#include "DevEFI.h"
+#include "iprt/asm.h"
 
 /* @todo understand the reasons why TextOutputProtocol.SetMode isn't enough to switch mode. */
@@ -30,4 +33,24 @@
 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
@@ -43,7 +66,17 @@
     DEBUG((DEBUG_INFO, "%a:%d - SwitchMode\n", __FILE__,  __LINE__));
     if (Gop)
-        r = Gop->SetMode(Gop, 2);
-    if (Uga)
-        r = Uga->SetMode(Uga, 1024, 768, 32, 60);
+    {
+        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_HORISONTAL_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))
     {
