hvmloader: Lay out memory a bit differently -
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 21 May 2008 10:23:03 +0000 (11:23 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 21 May 2008 10:23:03 +0000 (11:23 +0100)
 * Cleanly define a scratch area for temporary storage
 * Raise Etherboot ROM out of the way of larger VGA BIOSes

Also detect virtual VGA adaptors more cleanly.

Signed-off-by: Jean Guyader <jean.guyader@eu.citrix.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
tools/firmware/hvmloader/config.h
tools/firmware/hvmloader/hvmloader.c
tools/firmware/hvmloader/smbios.c

index cde2056f80146573310f3799450ef13d430b4b1e..296c10d76740b56984d7dbc21632ea91fcdc39f1 100644 (file)
 /* Memory map. */
 #define HYPERCALL_PHYSICAL_ADDRESS    0x00080000
 #define VGABIOS_PHYSICAL_ADDRESS      0x000C0000
-#define ETHERBOOT_PHYSICAL_ADDRESS    0x000C8000
+#define ETHERBOOT_PHYSICAL_ADDRESS    0x000D0000
 #define EXTBOOT_PHYSICAL_ADDRESS      0x000DF800
 #define SMBIOS_PHYSICAL_ADDRESS       0x000E9000
 #define SMBIOS_MAXIMUM_SIZE           0x00001000
 #define ACPI_PHYSICAL_ADDRESS         0x000EA000
 #define ROMBIOS_PHYSICAL_ADDRESS      0x000F0000
+#define SCRATCH_PHYSICAL_ADDRESS      0x00010000
 
 #endif /* __HVMLOADER_CONFIG_H__ */
index b3e075fd8a175db4b637fb5f4db862475edf98d5..74694e31d2eab820c8c3d4b2bb73f4d4e4219d0b 100644 (file)
@@ -103,12 +103,7 @@ void smp_initialise(void);
 void create_mp_tables(void);
 int hvm_write_smbios_tables(void);
 
-static int
-cirrus_check(void)
-{
-    outw(0x3C4, 0x9206);
-    return inb(0x3C5) == 0x12;
-}
+static enum { VGA_none, VGA_std, VGA_cirrus } virtual_vga = VGA_none;
 
 static void
 init_hypercalls(void)
@@ -165,7 +160,7 @@ static void pci_setup(void)
     /* Create a list of device BARs in descending order of size. */
     struct bars {
         uint32_t devfn, bar_reg, bar_sz;
-    } *bars = (struct bars *)0xc0000;
+    } *bars = (struct bars *)SCRATCH_PHYSICAL_ADDRESS;
     unsigned int i, nr_bars = 0;
 
     /* Program PCI-ISA bridge with appropriate link routes. */
@@ -196,6 +191,12 @@ static void pci_setup(void)
 
         switch ( class )
         {
+        case 0x0300:
+            if ( (vendor_id == 0x1234) && (device_id == 0x1111) )
+                virtual_vga = VGA_std;
+            if ( (vendor_id == 0x1013) && (device_id == 0xb8) )
+                virtual_vga = VGA_cirrus;
+            break;
         case 0x0680:
             ASSERT((vendor_id == 0x8086) && (device_id == 0x7113));
             /*
@@ -464,19 +465,23 @@ int main(void)
     if ( (get_vcpu_nr() > 1) || get_apic_mode() )
         create_mp_tables();
 
-    if ( cirrus_check() )
+    switch ( virtual_vga )
     {
+    case VGA_cirrus:
         printf("Loading Cirrus VGABIOS ...\n");
         memcpy((void *)VGABIOS_PHYSICAL_ADDRESS,
                vgabios_cirrusvga, sizeof(vgabios_cirrusvga));
         vgabios_sz = sizeof(vgabios_cirrusvga);
-    }
-    else
-    {
+        break;
+    case VGA_std:
         printf("Loading Standard VGABIOS ...\n");
         memcpy((void *)VGABIOS_PHYSICAL_ADDRESS,
                vgabios_stdvga, sizeof(vgabios_stdvga));
         vgabios_sz = sizeof(vgabios_stdvga);
+        break;
+    default:
+        printf("No emulated VGA adaptor ...\n");
+        break;
     }
 
     etherboot_sz = scan_etherboot_nic((void*)ETHERBOOT_PHYSICAL_ADDRESS);
index f124629925a40f590931743d1a6e80ca238cbdf0..2ef70ee53c01a05cfa14b1926b226e90c99a9987 100644 (file)
@@ -217,15 +217,16 @@ hvm_write_smbios_tables(void)
 
     xen_version_str[sizeof(xen_version_str)-1] = '\0';
 
-    /* NB. 0xC0000 is a safe large memory area for scratch. */
-    len = write_smbios_tables((void *)0xC0000,
+    /* SCRATCH_PHYSICAL_ADDRESS is a safe large memory area for scratch. */
+    len = write_smbios_tables((void *)SCRATCH_PHYSICAL_ADDRESS,
                               get_vcpu_nr(), get_memsize(),
                               uuid, xen_version_str,
                               xen_major_version, xen_minor_version);
     if ( len > SMBIOS_MAXIMUM_SIZE )
         goto error_out;
     /* Okay, not too large: copy out of scratch to final location. */
-    memcpy((void *)SMBIOS_PHYSICAL_ADDRESS, (void *)0xC0000, len);
+    memcpy((void *)SMBIOS_PHYSICAL_ADDRESS,
+           (void *)SCRATCH_PHYSICAL_ADDRESS, len);
 
     return len;