[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] rombios: Indirect through 32-bit jump table from within the 32-bit bios.
# HG changeset patch # User Keir Fraser <keir.fraser@xxxxxxxxxx> # Date 1232721161 0 # Node ID f3240cd3cd2b9d48acf3d82caa2ca1cab1f66325 # Parent 8de0aae803e04d54fd565c4dcd20cc69db536f45 rombios: Indirect through 32-bit jump table from within the 32-bit bios. This gets rid of shenanigans with relocating the jump table around the place. Also clean up bios_info table while we are updating it. Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx> --- tools/firmware/hvmloader/32bitbios_support.c | 30 +++---------------- tools/firmware/hvmloader/acpi/build.c | 41 -------------------------- tools/firmware/hvmloader/acpi/dsdt.asl | 2 - tools/firmware/hvmloader/acpi/dsdt.c | 8 ++--- tools/firmware/hvmloader/config.h | 17 ++++++---- tools/firmware/hvmloader/hvmloader.c | 40 ++++++++++++++----------- tools/firmware/hvmloader/util.c | 21 +++++++++++++ tools/firmware/hvmloader/util.h | 6 +++ tools/firmware/rombios/32bit/32bitbios.c | 17 +++++----- tools/firmware/rombios/32bit/Makefile | 11 +++--- tools/firmware/rombios/32bit/tcgbios/Makefile | 11 ++---- tools/firmware/rombios/32bitgateway.c | 11 ------ tools/firmware/rombios/rombios.c | 28 +++-------------- 13 files changed, 95 insertions(+), 148 deletions(-) diff -r 8de0aae803e0 -r f3240cd3cd2b tools/firmware/hvmloader/32bitbios_support.c --- a/tools/firmware/hvmloader/32bitbios_support.c Fri Jan 23 12:50:14 2009 +0000 +++ b/tools/firmware/hvmloader/32bitbios_support.c Fri Jan 23 14:32:41 2009 +0000 @@ -32,15 +32,13 @@ #include "../rombios/32bit/32bitbios_flat.h" -static void relocate_32bitbios(char *elfarray, uint32_t elfarraysize) +static uint32_t relocate_32bitbios(char *elfarray, uint32_t elfarraysize) { Elf32_Ehdr *ehdr = (Elf32_Ehdr *)elfarray; Elf32_Shdr *shdr = (Elf32_Shdr *)&elfarray[ehdr->e_shoff]; - char *secstrings = &elfarray[shdr[ehdr->e_shstrndx].sh_offset]; - char *jump_table; uint32_t reloc_off, reloc_size; char *highbiosarea; - int i, jump_sec_idx = 0; + int i; /* * Step 1. General elf cleanup, and compute total relocation size. @@ -50,13 +48,6 @@ static void relocate_32bitbios(char *elf { /* By default all section data points into elf image data array. */ shdr[i].sh_addr = (Elf32_Addr)&elfarray[shdr[i].sh_offset]; - - if ( !strcmp(".biosjumptable", secstrings + shdr[i].sh_name) ) - { - /* We do not relocate the BIOS jump table to high memory. */ - shdr[i].sh_flags &= ~SHF_ALLOC; - jump_sec_idx = i; - } /* Fix up a corner case of address alignment. */ if ( shdr[i].sh_addralign == 0 ) @@ -148,21 +139,12 @@ static void relocate_32bitbios(char *elf } } - /* Step 5. Find the ROMBIOS jump-table stub and copy in the real table. */ - for ( jump_table = (char *)ROMBIOS_BEGIN; - jump_table != (char *)ROMBIOS_END; - jump_table++ ) - if ( !strncmp(jump_table, "___JMPT", 7) ) - break; - BUG_ON(jump_table == NULL); - BUG_ON(jump_sec_idx == 0); - memcpy(jump_table, (char *)shdr[jump_sec_idx].sh_addr, - shdr[jump_sec_idx].sh_size); + printf("done\n"); - printf("done\n"); + return (uint32_t)highbiosarea; } -void highbios_setup(void) +uint32_t highbios_setup(void) { - relocate_32bitbios((char *)highbios_array, sizeof(highbios_array)); + return relocate_32bitbios((char *)highbios_array, sizeof(highbios_array)); } diff -r 8de0aae803e0 -r f3240cd3cd2b tools/firmware/hvmloader/acpi/build.c --- a/tools/firmware/hvmloader/acpi/build.c Fri Jan 23 12:50:14 2009 +0000 +++ b/tools/firmware/hvmloader/acpi/build.c Fri Jan 23 14:32:41 2009 +0000 @@ -48,48 +48,9 @@ static void set_checksum( p[checksum_offset] = -sum; } -static int uart_exists(uint16_t uart_base) -{ - uint16_t ier = uart_base + 1; - uint8_t a, b, c; - - a = inb(ier); - outb(ier, 0); - b = inb(ier); - outb(ier, 0xf); - c = inb(ier); - outb(ier, a); - - return ((b == 0) && (c == 0xf)); -} - -static int hpet_exists(unsigned long hpet_base) -{ - uint32_t hpet_id = *(uint32_t *)hpet_base; - return ((hpet_id >> 16) == 0x8086); -} - static uint8_t battery_port_exists(void) { return (inb(0x88) == 0x1F); -} - -static int construct_bios_info_table(uint8_t *buf) -{ - struct bios_info *bios_info = (struct bios_info *)buf; - - memset(bios_info, 0, sizeof(*bios_info)); - - bios_info->com1_present = uart_exists(0x3f8); - bios_info->com2_present = uart_exists(0x2f8); - - bios_info->hpet_present = hpet_exists(ACPI_HPET_ADDRESS); - - bios_info->pci_min = pci_mem_start; - bios_info->pci_len = pci_mem_end - pci_mem_start; - bios_info->xen_pfiob = 0xdead; - - return align16(sizeof(*bios_info)); } static int construct_madt(struct acpi_20_madt *madt) @@ -349,9 +310,7 @@ static void __acpi_build_tables(uint8_t buf = (uint8_t *)ACPI_PHYSICAL_ADDRESS; offset = 0; - offset += construct_bios_info_table(&buf[offset]); rsdp = (struct acpi_20_rsdp *)&buf[offset]; - memcpy(rsdp, &Rsdp, sizeof(struct acpi_20_rsdp)); offset += align16(sizeof(struct acpi_20_rsdp)); rsdp->rsdt_address = (unsigned long)rsdt; diff -r 8de0aae803e0 -r f3240cd3cd2b tools/firmware/hvmloader/acpi/dsdt.asl --- a/tools/firmware/hvmloader/acpi/dsdt.asl Fri Jan 23 12:50:14 2009 +0000 +++ b/tools/firmware/hvmloader/acpi/dsdt.asl Fri Jan 23 14:32:41 2009 +0000 @@ -86,7 +86,7 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, Scope (\_SB) { - /* ACPI_PHYSICAL_ADDRESS == 0xEA000 */ + /* BIOS_INFO_PHYSICAL_ADDRESS == 0xEA000 */ OperationRegion(BIOS, SystemMemory, 0xEA000, 16) Field(BIOS, ByteAcc, NoLock, Preserve) { UAR1, 1, diff -r 8de0aae803e0 -r f3240cd3cd2b tools/firmware/hvmloader/acpi/dsdt.c --- a/tools/firmware/hvmloader/acpi/dsdt.c Fri Jan 23 12:50:14 2009 +0000 +++ b/tools/firmware/hvmloader/acpi/dsdt.c Fri Jan 23 14:32:41 2009 +0000 @@ -1,11 +1,11 @@ /* * * Intel ACPI Component Architecture - * ASL Optimizing Compiler version 20080729 [Dec 25 2008] + * ASL Optimizing Compiler version 20081204 [Jan 23 2009] * Copyright (C) 2000 - 2008 Intel Corporation * Supports ACPI Specification Revision 3.0a * - * Compilation of "dsdt.asl" - Thu Dec 25 17:00:32 2008 + * Compilation of "dsdt.asl" - Fri Jan 23 14:30:29 2009 * * C source code output * @@ -13,10 +13,10 @@ unsigned char AmlCode[] = unsigned char AmlCode[] = { 0x44,0x53,0x44,0x54,0x5E,0x11,0x00,0x00, /* 00000000 "DSDT^..." */ - 0x02,0xD1,0x58,0x65,0x6E,0x00,0x00,0x00, /* 00000008 "..Xen..." */ + 0x02,0xEB,0x58,0x65,0x6E,0x00,0x00,0x00, /* 00000008 "..Xen..." */ 0x48,0x56,0x4D,0x00,0x00,0x00,0x00,0x00, /* 00000010 "HVM....." */ 0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x29,0x07,0x08,0x20,0x08,0x50,0x4D,0x42, /* 00000020 ").. .PMB" */ + 0x04,0x12,0x08,0x20,0x08,0x50,0x4D,0x42, /* 00000020 "... .PMB" */ 0x53,0x0B,0x00,0x0C,0x08,0x50,0x4D,0x4C, /* 00000028 "S....PML" */ 0x4E,0x0A,0x08,0x08,0x49,0x4F,0x42,0x31, /* 00000030 "N...IOB1" */ 0x00,0x08,0x49,0x4F,0x4C,0x31,0x00,0x08, /* 00000038 "..IOL1.." */ diff -r 8de0aae803e0 -r f3240cd3cd2b tools/firmware/hvmloader/config.h --- a/tools/firmware/hvmloader/config.h Fri Jan 23 12:50:14 2009 +0000 +++ b/tools/firmware/hvmloader/config.h Fri Jan 23 14:32:41 2009 +0000 @@ -35,7 +35,8 @@ extern unsigned long pci_mem_start, pci_ #define VGABIOS_PHYSICAL_ADDRESS 0x000C0000 #define OPTIONROM_PHYSICAL_ADDRESS 0x000C8000 #define OPTIONROM_PHYSICAL_END 0x000EA000 -#define ACPI_PHYSICAL_ADDRESS 0x000EA000 +#define BIOS_INFO_PHYSICAL_ADDRESS 0x000EA000 +#define ACPI_PHYSICAL_ADDRESS 0x000EA020 #define E820_PHYSICAL_ADDRESS 0x000EA100 #define SMBIOS_PHYSICAL_ADDRESS 0x000EB000 #define SMBIOS_MAXIMUM_SIZE 0x00005000 @@ -48,12 +49,16 @@ extern unsigned long pci_mem_start, pci_ /* Xen Platform Device */ #define PFFLAG_ROM_LOCK 1 /* Sets whether ROM memory area is RW or RO */ +/* Located at BIOS_INFO_PHYSICAL_ADDRESS. */ 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; + uint8_t com1_present:1; /* 0[0] - System has COM1? */ + uint8_t com2_present:1; /* 0[1] - System has COM2? */ + uint8_t hpet_present:1; /* 0[2] - System has HPET? */ + uint32_t pci_min, pci_len; /* 4, 8 - PCI I/O hole boundaries */ + uint32_t bios32_entry; /* 12 - Entry point for 32-bit BIOS */ + uint16_t xen_pfiob; /* 16 - Xen platform device I/O ports */ }; +#define BIOSINFO_OFF_bios32_entry 12 +#define BIOSINFO_OFF_xen_pfiob 16 #endif /* __HVMLOADER_CONFIG_H__ */ diff -r 8de0aae803e0 -r f3240cd3cd2b tools/firmware/hvmloader/hvmloader.c --- a/tools/firmware/hvmloader/hvmloader.c Fri Jan 23 12:50:14 2009 +0000 +++ b/tools/firmware/hvmloader/hvmloader.c Fri Jan 23 14:32:41 2009 +0000 @@ -539,25 +539,23 @@ static void cmos_write_memory_size(void) cmos_outb(0x35, (uint8_t)( alt_mem >> 8)); } -static uint16_t init_xen_platform_io_base(void) -{ - struct bios_info *bios_info = (struct bios_info *)ACPI_PHYSICAL_ADDRESS; +static uint16_t xen_platform_io_base(void) +{ uint32_t devfn, bar_data; uint16_t vendor_id, device_id; - bios_info->xen_pfiob = 0; - 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; - } - - return bios_info->xen_pfiob; + if ( (vendor_id == 0x5853) && (device_id == 0x0001) ) + { + bar_data = pci_readl(devfn, PCI_BASE_ADDRESS_0); + return bar_data & PCI_BASE_ADDRESS_IO_MASK; + } + } + + return 0; } /* @@ -648,8 +646,8 @@ int main(void) { int option_rom_sz = 0, vgabios_sz = 0, etherboot_sz = 0; int rombios_sz, smbios_sz; - uint32_t etherboot_phys_addr, option_rom_phys_addr; - uint16_t xen_pfiob; + uint32_t etherboot_phys_addr, option_rom_phys_addr, bios32_addr; + struct bios_info *bios_info; printf("HVM Loader\n"); @@ -672,7 +670,7 @@ int main(void) if ( rombios_sz > 0x10000 ) rombios_sz = 0x10000; memcpy((void *)ROMBIOS_PHYSICAL_ADDRESS, rombios, rombios_sz); - highbios_setup(); + bios32_addr = highbios_setup(); if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode ) create_mp_tables(); @@ -736,9 +734,17 @@ int main(void) ROMBIOS_PHYSICAL_ADDRESS, ROMBIOS_PHYSICAL_ADDRESS + rombios_sz - 1); - xen_pfiob = init_xen_platform_io_base(); - build_e820_table(); + + bios_info = (struct bios_info *)BIOS_INFO_PHYSICAL_ADDRESS; + memset(bios_info, 0, sizeof(*bios_info)); + bios_info->com1_present = uart_exists(0x3f8); + bios_info->com2_present = uart_exists(0x2f8); + bios_info->hpet_present = hpet_exists(ACPI_HPET_ADDRESS); + bios_info->pci_min = pci_mem_start; + bios_info->pci_len = pci_mem_end - pci_mem_start; + bios_info->bios32_entry = bios32_addr; + bios_info->xen_pfiob = xen_platform_io_base(); printf("Invoking ROMBIOS ...\n"); return 0; diff -r 8de0aae803e0 -r f3240cd3cd2b tools/firmware/hvmloader/util.c --- a/tools/firmware/hvmloader/util.c Fri Jan 23 12:50:14 2009 +0000 +++ b/tools/firmware/hvmloader/util.c Fri Jan 23 14:32:41 2009 +0000 @@ -629,6 +629,27 @@ uint16_t get_cpu_mhz(void) return cpu_mhz; } +int uart_exists(uint16_t uart_base) +{ + uint16_t ier = uart_base + 1; + uint8_t a, b, c; + + a = inb(ier); + outb(ier, 0); + b = inb(ier); + outb(ier, 0xf); + c = inb(ier); + outb(ier, a); + + return ((b == 0) && (c == 0xf)); +} + +int hpet_exists(unsigned long hpet_base) +{ + uint32_t hpet_id = *(uint32_t *)hpet_base; + return ((hpet_id >> 16) == 0x8086); +} + /* * Local variables: * mode: C diff -r 8de0aae803e0 -r f3240cd3cd2b tools/firmware/hvmloader/util.h --- a/tools/firmware/hvmloader/util.h Fri Jan 23 12:50:14 2009 +0000 +++ b/tools/firmware/hvmloader/util.h Fri Jan 23 14:32:41 2009 +0000 @@ -56,6 +56,10 @@ void pci_write(uint32_t devfn, uint32_t /* Get CPU speed in MHz. */ uint16_t get_cpu_mhz(void); + +/* Hardware detection. */ +int uart_exists(uint16_t uart_base); +int hpet_exists(unsigned long hpet_base); /* Do cpuid instruction, with operation 'idx' */ void cpuid(uint32_t idx, uint32_t *eax, uint32_t *ebx, @@ -136,7 +140,7 @@ void *mem_alloc(uint32_t size, uint32_t #define virt_to_phys(v) ((unsigned long)(v)) /* Prepare the 32bit BIOS */ -void highbios_setup(void); +uint32_t highbios_setup(void); /* Miscellaneous. */ void cacheattr_init(void); diff -r 8de0aae803e0 -r f3240cd3cd2b tools/firmware/rombios/32bit/32bitbios.c --- a/tools/firmware/rombios/32bit/32bitbios.c Fri Jan 23 12:50:14 2009 +0000 +++ b/tools/firmware/rombios/32bit/32bitbios.c Fri Jan 23 14:32:41 2009 +0000 @@ -22,14 +22,13 @@ #include "rombios_compat.h" -/* - the jumptable that will be copied into the rombios in the 0xf000 segment - for every function that is to be called from the lower BIOS, make an entry - here. - */ -uint32_t jumptable[] __attribute__((section (".biosjumptable"))) = -{ -#define X(idx, ret, fn, args...) [idx] = (uint32_t)fn, +asm ( + " .text \n" + " movzwl %bx,%eax \n" + " jmp *jumptable(,%eax,4) \n" + " .data \n" + "jumptable: \n" +#define X(idx, ret, fn, args...) " .long "#fn"\n" #include "32bitprotos.h" #undef X -}; + ); diff -r 8de0aae803e0 -r f3240cd3cd2b tools/firmware/rombios/32bit/Makefile --- a/tools/firmware/rombios/32bit/Makefile Fri Jan 23 12:50:14 2009 +0000 +++ b/tools/firmware/rombios/32bit/Makefile Fri Jan 23 14:32:41 2009 +0000 @@ -1,14 +1,11 @@ XEN_ROOT = ../../../.. XEN_ROOT = ../../../.. include $(XEN_ROOT)/tools/firmware/Rules.mk -SOURCES = util.c TARGET = 32bitbios_flat.h -CFLAGS += $(CFLAGS_include) -I.. -DGCC_PROTOS +CFLAGS += $(CFLAGS_include) -I.. SUBDIRS = tcgbios - -MODULES = tcgbios/tcgbiosext.o .PHONY: all all: subdirs-all @@ -18,7 +15,10 @@ clean: subdirs-clean clean: subdirs-clean rm -rf *.o $(TARGET) $(DEPS) -$(TARGET): 32bitbios.o $(MODULES) util.o pmm.o +$(TARGET): 32bitbios_all.o + sh mkhex highbios_array 32bitbios_all.o > $@ + +32bitbios_all.o: 32bitbios.o tcgbios/tcgbiosext.o util.o pmm.o $(LD) $(LDFLAGS_DIRECT) -s -r $^ -o 32bitbios_all.o @nm 32bitbios_all.o | \ egrep '^ +U ' >/dev/null && { \ @@ -26,6 +26,5 @@ clean: subdirs-clean nm -u 32bitbios_all.o; \ exit 11; \ } || : - sh mkhex highbios_array 32bitbios_all.o > $@ -include $(DEPS) diff -r 8de0aae803e0 -r f3240cd3cd2b tools/firmware/rombios/32bit/tcgbios/Makefile --- a/tools/firmware/rombios/32bit/tcgbios/Makefile Fri Jan 23 12:50:14 2009 +0000 +++ b/tools/firmware/rombios/32bit/tcgbios/Makefile Fri Jan 23 14:32:41 2009 +0000 @@ -2,20 +2,17 @@ include $(XEN_ROOT)/tools/firmware/Rules include $(XEN_ROOT)/tools/firmware/Rules.mk TARGET = tcgbiosext.o -FILES = tcgbios tpm_drivers -OBJECTS = $(foreach f,$(FILES),$(f).o) -CFLAGS += $(CFLAGS_include) -I.. -I../.. -DGCC_PROTOS +CFLAGS += $(CFLAGS_include) -I.. -I../.. -.PHONY: all clean - +.PHONY: all all: $(TARGET) +.PHONY: clean clean: rm -rf *.o $(TARGET) $(DEPS) -$(TARGET): $(OBJECTS) +$(TARGET): tcgbios.o tpm_drivers.o $(LD) $(LDFLAGS_DIRECT) -r $^ -o $@ -include $(DEPS) - diff -r 8de0aae803e0 -r f3240cd3cd2b tools/firmware/rombios/32bitgateway.c --- a/tools/firmware/rombios/32bitgateway.c Fri Jan 23 12:50:14 2009 +0000 +++ b/tools/firmware/rombios/32bitgateway.c Fri Jan 23 14:32:41 2009 +0000 @@ -96,15 +96,6 @@ Upcall: push ss push esp - ; Find the 32-bit function address via a table lookup - push si - rol bx, #2 - mov si, #jmptable - seg cs - mov eax, dword ptr [si+bx] - pop si - push eax - ; Calculate protected-mode esp from ss:sp and esp, #0xffff xor eax, eax @@ -127,11 +118,11 @@ upcall1: mov ss, ax ; Marshal arguments and call 32-bit function - pop eax mov ecx, #MAX_ARG_BYTES/4 upcall2: push MAX_ARG_BYTES-4+args_off[esp] loop upcall2 + mov eax, [BIOS_INFO_PHYSICAL_ADDRESS + BIOSINFO_OFF_bios32_entry] call eax add esp, #MAX_ARG_BYTES mov ecx, eax ; Result in ecx diff -r 8de0aae803e0 -r f3240cd3cd2b tools/firmware/rombios/rombios.c --- a/tools/firmware/rombios/rombios.c Fri Jan 23 12:50:14 2009 +0000 +++ b/tools/firmware/rombios/rombios.c Fri Jan 23 14:32:41 2009 +0000 @@ -1418,31 +1418,24 @@ fixup_base_mem_in_k() write_word(0x40, 0x13, base_mem >> 10); } -void -set_rom_write_access(action) - Bit16u action; -{ - Bit16u off = (Bit16u)&((struct bios_info *)0)->xen_pfiob; ASM_START - mov si,.set_rom_write_access.off[bp] +_rom_write_access_control: push ds - mov ax,#(ACPI_PHYSICAL_ADDRESS >> 4) + mov ax,#(BIOS_INFO_PHYSICAL_ADDRESS >> 4) mov ds,ax - mov dx,[si] + mov ax,[BIOSINFO_OFF_xen_pfiob] pop ds - mov ax,.set_rom_write_access.action[bp] - out dx,al + ret ASM_END -} void enable_rom_write_access() { - set_rom_write_access(0); + outb(rom_write_access_control(), 0); } void disable_rom_write_access() { - set_rom_write_access(PFFLAG_ROM_LOCK); + outb(rom_write_access_control(), PFFLAG_ROM_LOCK); } #endif /* HVMASSIST */ @@ -11824,15 +11817,6 @@ static Bit8u vgafont8[128*8]= #ifdef HVMASSIST ASM_START -// space for addresses in 32bit BIOS area; currently 256/4 entries -// are allocated -.org 0xcb00 -jmptable: -db 0x5F, 0x5F, 0x5F, 0x4A, 0x4D, 0x50, 0x54 ;; ___JMPT -dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;; 64 bytes -dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;; 128 bytes -dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;; 192 bytes - // // MP Tables // just carve out some blank space for HVMLOADER to write the MP tables to _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |