[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] hvmloader, rombios: Make use of new rom-lock facility in ioemu platform device.



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1215775892 -3600
# Node ID b41e07aa555a73b0d48e0fc92ed11b8994aa819f
# Parent  27aaff984b3679375819075ae2bbec4e05dc9b50
hvmloader, rombios: Make use of new rom-lock facility in ioemu platform device.
Signed-off-by: Trolle Selander <trolle.selander@xxxxxxxxxxxxx>
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 tools/firmware/hvmloader/acpi/build.c |    8 ++------
 tools/firmware/hvmloader/config.h     |   11 +++++++++++
 tools/firmware/hvmloader/hvmloader.c  |   19 +++++++++++++++++++
 tools/firmware/rombios/rombios.c      |   24 ++++++++++++++++++++++++
 4 files changed, 56 insertions(+), 6 deletions(-)

diff -r 27aaff984b36 -r b41e07aa555a tools/firmware/hvmloader/acpi/build.c
--- a/tools/firmware/hvmloader/acpi/build.c     Thu Jul 10 17:33:23 2008 +0100
+++ b/tools/firmware/hvmloader/acpi/build.c     Fri Jul 11 12:31:32 2008 +0100
@@ -70,12 +70,7 @@ static int hpet_exists(unsigned long hpe
 
 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(uin
 
     bios_info->pci_min = PCI_MEMBASE;
     bios_info->pci_len = PCI_MEMSIZE;
+    bios_info->xen_pfiob = 0xdead;
 
     return align16(sizeof(*bios_info));
 }
diff -r 27aaff984b36 -r b41e07aa555a tools/firmware/hvmloader/config.h
--- a/tools/firmware/hvmloader/config.h Thu Jul 10 17:33:23 2008 +0100
+++ b/tools/firmware/hvmloader/config.h Fri Jul 11 12:31:32 2008 +0100
@@ -31,4 +31,15 @@
 #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__ */
diff -r 27aaff984b36 -r b41e07aa555a tools/firmware/hvmloader/hvmloader.c
--- a/tools/firmware/hvmloader/hvmloader.c      Thu Jul 10 17:33:23 2008 +0100
+++ b/tools/firmware/hvmloader/hvmloader.c      Fri Jul 11 12:31:32 2008 +0100
@@ -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;
 }
diff -r 27aaff984b36 -r b41e07aa555a tools/firmware/rombios/rombios.c
--- a/tools/firmware/rombios/rombios.c  Thu Jul 10 17:33:23 2008 +0100
+++ b/tools/firmware/rombios/rombios.c  Fri Jul 11 12:31:32 2008 +0100
@@ -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
@@ -10154,6 +10174,10 @@ post_default_ints:
 #if BX_TCGBIOS
   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.

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.