hvmloader, rombios: Make use of new rom-lock facility in ioemu platform device.
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 11 Jul 2008 11:31:32 +0000 (12:31 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 11 Jul 2008 11:31:32 +0000 (12:31 +0100)
Signed-off-by: Trolle Selander <trolle.selander@eu.citrix.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
tools/firmware/hvmloader/acpi/build.c
tools/firmware/hvmloader/config.h
tools/firmware/hvmloader/hvmloader.c
tools/firmware/rombios/rombios.c

index 252a05572832cc7071552a8b6707ce016deb0bdf..75e1a60e5573a0c1fe08f1bbaa9fd5c234927f59 100644 (file)
@@ -70,12 +70,7 @@ static int hpet_exists(unsigned long hpet_base)
 
 static int construct_bios_info_table(uint8_t *buf)
 {
-    struct bios_info {
-        uint8_t  com1_present:1;
-        uint8_t  com2_present:1;
-        uint8_t  hpet_present:1;
-        uint32_t pci_min, pci_len;
-    } *bios_info = (struct bios_info *)buf;
+    struct bios_info *bios_info = (struct bios_info *)buf;
 
     memset(bios_info, 0, sizeof(*bios_info));
 
@@ -86,6 +81,7 @@ static int construct_bios_info_table(uint8_t *buf)
 
     bios_info->pci_min = PCI_MEMBASE;
     bios_info->pci_len = PCI_MEMSIZE;
+    bios_info->xen_pfiob = 0xdead;
 
     return align16(sizeof(*bios_info));
 }
index 296c10d76740b56984d7dbc21632ea91fcdc39f1..e66c7f38b09f687b40bce6f521bb1996b46c28b5 100644 (file)
 #define ROMBIOS_PHYSICAL_ADDRESS      0x000F0000
 #define SCRATCH_PHYSICAL_ADDRESS      0x00010000
 
+/* Xen Platform Device */
+#define PFFLAG_ROM_LOCK 1 /* Sets whether ROM memory area is RW or RO */
+
+struct bios_info {
+    uint8_t  com1_present:1;
+    uint8_t  com2_present:1;
+    uint8_t  hpet_present:1;
+    uint32_t pci_min, pci_len;
+    uint16_t xen_pfiob;
+};
+
 #endif /* __HVMLOADER_CONFIG_H__ */
index e98e31b3eaa31b4d5222c94b2e1fb72814aba11d..82e34b0e3ad0fb6114e3be70ee240c7bdbbea5f3 100644 (file)
@@ -434,6 +434,23 @@ static void cmos_write_memory_size(void)
     cmos_outb(0x35, (uint8_t)( alt_mem >> 8));
 }
 
+static void init_xen_platform_io_base(void)
+{
+    struct bios_info *bios_info = (struct bios_info *)ACPI_PHYSICAL_ADDRESS;
+    uint32_t devfn, bar_data;
+    uint16_t vendor_id, device_id;
+
+    for ( devfn = 0; devfn < 128; devfn++ )
+    {
+        vendor_id = pci_readw(devfn, PCI_VENDOR_ID);
+        device_id = pci_readw(devfn, PCI_DEVICE_ID);
+        if ( (vendor_id != 0x5853) || (device_id != 0x0001) )
+            continue;
+        bar_data = pci_readl(devfn, PCI_BASE_ADDRESS_0);
+        bios_info->xen_pfiob = bar_data & PCI_BASE_ADDRESS_IO_MASK;
+    }
+}
+
 int main(void)
 {
     int acpi_sz = 0, vgabios_sz = 0, etherboot_sz = 0, rombios_sz, smbios_sz;
@@ -527,6 +544,8 @@ int main(void)
                ROMBIOS_PHYSICAL_ADDRESS,
                ROMBIOS_PHYSICAL_ADDRESS + rombios_sz - 1);
 
+    init_xen_platform_io_base();
+
     printf("Invoking ROMBIOS ...\n");
     return 0;
 }
index 3b9b45d55ecaf6d83913deedb1d932480c564bae..c3b3828749e830bf790d5afa55145367cfc2e4ab 100644 (file)
@@ -26,6 +26,9 @@
 
 // ROM BIOS for use with Bochs/Plex x86 emulation environment
 
+#define uint8_t unsigned char
+#define uint16_t unsigned short
+#define uint32_t unsigned long
 #include "../hvmloader/config.h"
 
 #define HVMASSIST
@@ -1459,6 +1462,23 @@ copy_e820_table()
   base_mem = read_dword(0x9000, 0x2d0 + 8);
   write_word(0x40, 0x13, base_mem >> 10);
 }
+
+void
+disable_rom_write_access()
+{
+    Bit16u off = (Bit16u)&((struct bios_info *)0)->xen_pfiob;
+ASM_START
+    mov si,.disable_rom_write_access.off[bp]
+    push ds
+    mov ax,#(ACPI_PHYSICAL_ADDRESS >> 4)
+    mov ds,ax
+    mov dx,[si]
+    pop ds
+    mov ax,#PFFLAG_ROM_LOCK
+    out dx,al
+ASM_END
+}
+    
 #endif /* HVMASSIST */
 
 #if BX_DEBUG_SERIAL
@@ -10155,6 +10175,10 @@ post_default_ints:
   call tcpa_post_part2
 #endif
 
+#ifdef HVMASSIST
+  call _disable_rom_write_access
+#endif 
+
   ;; Start the boot sequence.   See the comments in int19_relocated 
   ;; for why we use INT 18h instead of INT 19h here.
   int  #0x18