Xen: Use VGA Hooks to make VGA passthrough work on certain devices

The Intel gfx VGA option ROM on certain platforms requires the 155f50 BIOS
function to be implemented (even if it does nothing), to work properly.

v2: Ignore the case where Option ROMs are pre-deployed.
    Make vgahook_setup independent of wether the CB* variables are set.
    VGA hooks can be enabled on non-coreboot and non-Xen configurations.

Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com>
diff --git a/src/Kconfig b/src/Kconfig
index cf0bff0..250663a 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -283,7 +283,6 @@
             Support S3 resume handler.
 
     config VGAHOOKS
-        depends on COREBOOT
         bool "Hardware specific VGA helpers"
         default y
         help
diff --git a/src/coreboot.c b/src/coreboot.c
index ee9dd8b..e328c15 100644
--- a/src/coreboot.c
+++ b/src/coreboot.c
@@ -117,7 +117,7 @@
 }
 
 static struct cb_memory *CBMemTable;
-const char *CBvendor, *CBpart;
+const char *CBvendor = "", *CBpart = "";
 
 // Populate max ram and e820 map info by scanning for a coreboot table.
 static void
diff --git a/src/vgahooks.c b/src/vgahooks.c
index a8f667c..20a2e2e 100644
--- a/src/vgahooks.c
+++ b/src/vgahooks.c
@@ -186,11 +186,20 @@
 }
 
 static void
+intel_155f50(struct bregs *regs)
+{
+    /* Mandatory hook on some Dell laptops */
+    regs->ax = 0x005f;
+    set_success(regs);
+}
+
+static void
 intel_155f(struct bregs *regs)
 {
     switch (regs->al) {
     case 0x35: intel_155f35(regs); break;
     case 0x40: intel_155f40(regs); break;
+    case 0x50: intel_155f50(regs); break;
     default:   handle_155fXX(regs); break;
     }
 }
@@ -206,6 +215,15 @@
 #define BOOT_DISPLAY_LCD2       (1 << 7)
 
 static void
+intel_setup(struct pci_device *pci)
+{
+    VGAHookHandlerType = VH_INTEL;
+
+    IntelDisplayType = BOOT_DISPLAY_DEFAULT;
+    IntelDisplayId = 3;
+}
+
+static void
 roda_setup(struct pci_device *pci)
 {
     VGAHookHandlerType = VH_INTEL;
@@ -254,7 +272,7 @@
 void
 vgahook_setup(struct pci_device *pci)
 {
-    if (!CONFIG_VGAHOOKS || !CBvendor || !CBpart)
+    if (!CONFIG_VGAHOOKS)
         return;
 
     if (strcmp(CBvendor, "KONTRON") == 0 && strcmp(CBpart, "986LCD-M") == 0)
@@ -265,4 +283,6 @@
         roda_setup(pci);
     else if (pci->vendor == PCI_VENDOR_ID_VIA)
         via_setup(pci);
+    else if (pci->vendor == PCI_VENDOR_ID_INTEL)
+        intel_setup(pci);
 }