diff -uNr firmware-orig/hvmloader/acpi/build.c firmware/hvmloader/acpi/build.c --- firmware-orig/hvmloader/acpi/build.c 2008-07-10 17:42:53.984872925 +0100 +++ firmware/hvmloader/acpi/build.c 2008-07-10 17:44:52.936306925 +0100 @@ -70,12 +70,7 @@ 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 @@ bios_info->pci_min = PCI_MEMBASE; bios_info->pci_len = PCI_MEMSIZE; + bios_info->xen_pfiob = 0xdead; return align16(sizeof(*bios_info)); } diff -uNr firmware-orig/hvmloader/config.h firmware/hvmloader/config.h --- firmware-orig/hvmloader/config.h 2008-07-10 17:42:53.988873175 +0100 +++ firmware/hvmloader/config.h 2008-07-10 15:10:54.480290200 +0100 @@ -31,4 +31,7 @@ #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 */ + #endif /* __HVMLOADER_CONFIG_H__ */ diff -uNr firmware-orig/hvmloader/hvmloader.c firmware/hvmloader/hvmloader.c --- firmware-orig/hvmloader/hvmloader.c 2008-07-10 17:42:53.988873175 +0100 +++ firmware/hvmloader/hvmloader.c 2008-07-10 17:44:09.333581925 +0100 @@ -105,6 +105,8 @@ static enum { VGA_none, VGA_std, VGA_cirrus } virtual_vga = VGA_none; +static uint16_t xen_platform_io_base; + static void init_hypercalls(void) { @@ -149,6 +151,7 @@ uint32_t base, devfn, bar_reg, bar_data, bar_sz, cmd; uint16_t class, vendor_id, device_id; unsigned int bar, pin, link, isa_irq; + uint32_t xen_pf_devfn = 0xff; /* Resources assignable to PCI devices via BARs. */ struct resource { @@ -213,6 +216,10 @@ pci_writew(devfn, 0x42, 0x8000); /* enable IDE1 */ } break; + case 0xff80: + if ( (vendor_id == 0x5853) && (device_id == 0x0001) ) + xen_pf_devfn = devfn; + break; } /* Map the I/O memory and port resources. */ @@ -284,6 +291,10 @@ } base = (resource->base + bar_sz - 1) & ~(bar_sz - 1); + + if ( devfn == xen_pf_devfn && resource == &io_resource ) + xen_platform_io_base = (uint16_t) base; + bar_data |= base; base += bar_sz; @@ -527,6 +538,9 @@ ROMBIOS_PHYSICAL_ADDRESS, ROMBIOS_PHYSICAL_ADDRESS + rombios_sz - 1); + /* Tell rombios the platform device base io port so it can write-protect ROM once its done self-modifying */ + ((struct bios_info *)ACPI_PHYSICAL_ADDRESS)->xen_pfiob = xen_platform_io_base; + printf("Invoking ROMBIOS ...\n"); return 0; } diff -uNr firmware-orig/hvmloader/util.h firmware/hvmloader/util.h --- firmware-orig/hvmloader/util.h 2008-07-10 17:42:54.004874175 +0100 +++ firmware/hvmloader/util.h 2008-07-10 16:18:05.742877675 +0100 @@ -137,6 +137,14 @@ /* Prepare the 32bit BIOS */ void highbios_setup(void); +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; +}; + #define isdigit(c) ((c) >= '0' && (c) <= '9') #endif /* __HVMLOADER_UTIL_H__ */ diff -uNr firmware-orig/rombios/rombios.c firmware/rombios/rombios.c --- firmware-orig/rombios/rombios.c 2008-07-10 17:42:54.064877925 +0100 +++ firmware/rombios/rombios.c 2008-07-10 17:35:28.549034925 +0100 @@ -275,6 +275,31 @@ mov ?1*4+2, ax MEND +/* bios_info is the first structure at ACPI_PHYSICAL_ADDRESS(0xEA000) + and the offset of .xen_pfiob is 0x0C */ + +#define ACPI_PFIOB_OFFSET 0xA00C + +MACRO ROM_WRITE_ENABLE + push ds + mov ax,#((ACPI_PHYSICAL_ADDRESS >> 4) & $F000) + mov ds,ax + mov ax,#0 + mov dx,ACPI_PFIOB_OFFSET + out dx,al + pop ds +MEND + +MACRO ROM_WRITE_DISABLE + push ds + mov ax,#((ACPI_PHYSICAL_ADDRESS >> 4) & $F000) + mov ds,ax + mov ax,#1 + mov dx,ACPI_PFIOB_OFFSET + out dx,al + pop ds +MEND + ASM_END typedef unsigned char Bit8u; @@ -10155,6 +10180,10 @@ call tcpa_post_part2 #endif +#ifdef HVMASSIST + ROM_WRITE_DISABLE +#endif + ;; Start the boot sequence. See the comments in int19_relocated ;; for why we use INT 18h instead of INT 19h here. int #0x18