Ian Campbell
2011-Apr-12 11:28 UTC
[Xen-devel] [PATCH 00 of 19] tools: SeaBIOS integration
Based on the feedback to my previous patchset to multiply-compile hvmloader the following patchset enables a single hvmloader binary to be built with support for SeaBIOS as well as ROMBIOS. SeaBIOS support is optional. The SeaBIOS integration is only semi-complete and is targetted at developers and very early adopters who don''t mind some rough edges. In particular the user must clone, patch as necessary and compile SeaBIOS themselves since this patchset does not cover any of that. The bulk of the patchset is refactoring hvmloader to allow it to support multiple BIOS configurations. I''ve aimed to separate things into core hvmloader, helper routines (e.g. "create an e820 table") and BIOS specific glue to bring the two together. It''s rather function-pointer -happy at the moment and since SeaBIOS support is very much a WIP and it is not yet clear which abstractions will actually be necessary. Also many of the callbacks are not implemented for SeaBIOS yet for the same reason. I hope that this work will also simplify any future integration of tioanocore or similar as well. The series also includes changes to libxl/xl to hide the selection of specific hvmloader and device-model binaries from the user by default. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-12 11:29 UTC
[Xen-devel] [PATCH 01 of 19] tools: hvmloader: move ROMBIOS configuration into tools/firmware/rombios/
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1302597969 -3600 # Node ID d9ee229bada7659019b88ae6b75dd0a8a488714f # Parent c1d2834bdc3008e0c1f326c85a21d63279932ce5 tools: hvmloader: move ROMBIOS configuration into tools/firmware/rombios/ Currently rombios and hvmloader are rather intertwined. Separate the ROMBIOS configuration options out into a ROMBIOS provided file so that the dependency can become strictly from hvmloader to rombios. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r c1d2834bdc30 -r d9ee229bada7 tools/firmware/hvmloader/config.h --- a/tools/firmware/hvmloader/config.h Tue Apr 12 09:46:09 2011 +0100 +++ b/tools/firmware/hvmloader/config.h Tue Apr 12 09:46:09 2011 +0100 @@ -23,44 +23,13 @@ extern unsigned long pci_mem_start, pci_ #define RESERVED_MEMBASE 0xfc000000 #define RESERVED_MEMSIZE 0x01000000 -#define ROMBIOS_SEG 0xF000 #define ROMBIOS_BEGIN 0x000F0000 #define ROMBIOS_SIZE 0x00010000 #define ROMBIOS_MAXOFFSET 0x0000FFFF #define ROMBIOS_END (ROMBIOS_BEGIN + ROMBIOS_SIZE) -/* Memory map. */ -#define SCRATCH_PHYSICAL_ADDRESS 0x00010000 -#define HYPERCALL_PHYSICAL_ADDRESS 0x00080000 +#include "../rombios/config.h" + #define VGABIOS_PHYSICAL_ADDRESS 0x000C0000 -#define OPTIONROM_PHYSICAL_ADDRESS 0x000C8000 -#define OPTIONROM_PHYSICAL_END 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 -#define ROMBIOS_PHYSICAL_ADDRESS 0x000F0000 - -/* Offsets from E820_PHYSICAL_ADDRESS. */ -#define E820_NR_OFFSET 0x0 -#define E820_OFFSET 0x8 - -/* Xen Platform Device */ -#define XEN_PF_IOBASE 0x10 -#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; /* 0[0] - System has COM1? */ - uint8_t com2_present:1; /* 0[1] - System has COM2? */ - uint8_t lpt1_present:1; /* 0[2] - System has LPT1? */ - uint8_t hpet_present:1; /* 0[3] - System has HPET? */ - uint32_t pci_min, pci_len; /* 4, 8 - PCI I/O hole boundaries */ - uint32_t madt_csum_addr; /* 12 - Address of MADT checksum */ - uint32_t madt_lapic0_addr; /* 16 - Address of first MADT LAPIC struct */ - uint32_t bios32_entry; /* 20 - Entry point for 32-bit BIOS */ -}; -#define BIOSINFO_OFF_bios32_entry 20 #endif /* __HVMLOADER_CONFIG_H__ */ diff -r c1d2834bdc30 -r d9ee229bada7 tools/firmware/rombios/32bit/pmm.c --- a/tools/firmware/rombios/32bit/pmm.c Tue Apr 12 09:46:09 2011 +0100 +++ b/tools/firmware/rombios/32bit/pmm.c Tue Apr 12 09:46:09 2011 +0100 @@ -65,7 +65,7 @@ #include <stdint.h> #include <stddef.h> -#include <../hvmloader/config.h> +#include "config.h" #include <../hvmloader/e820.h> #include "util.h" diff -r c1d2834bdc30 -r d9ee229bada7 tools/firmware/rombios/config.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/firmware/rombios/config.h Tue Apr 12 09:46:09 2011 +0100 @@ -0,0 +1,39 @@ +#ifndef _ROMBIOS_CONFIG_H +#define _ROMBIOS_CONFIG_H + +/* Memory map. */ +#define SCRATCH_PHYSICAL_ADDRESS 0x00010000 +#define HYPERCALL_PHYSICAL_ADDRESS 0x00080000 + +#define OPTIONROM_PHYSICAL_ADDRESS 0x000C8000 +#define OPTIONROM_PHYSICAL_END 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 +#define ROMBIOS_PHYSICAL_ADDRESS 0x000F0000 + +/* Offsets from E820_PHYSICAL_ADDRESS. */ +#define E820_NR_OFFSET 0x0 +#define E820_OFFSET 0x8 + +/* Xen Platform Device */ +#define XEN_PF_IOBASE 0x10 +#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; /* 0[0] - System has COM1? */ + uint8_t com2_present:1; /* 0[1] - System has COM2? */ + uint8_t lpt1_present:1; /* 0[2] - System has LPT1? */ + uint8_t hpet_present:1; /* 0[3] - System has HPET? */ + uint32_t pci_min, pci_len; /* 4, 8 - PCI I/O hole boundaries */ + uint32_t madt_csum_addr; /* 12 - Address of MADT checksum */ + uint32_t madt_lapic0_addr; /* 16 - Address of first MADT LAPIC struct */ + uint32_t bios32_entry; /* 20 - Entry point for 32-bit BIOS */ +}; +#define BIOSINFO_OFF_bios32_entry 20 + +#endif + diff -r c1d2834bdc30 -r d9ee229bada7 tools/firmware/rombios/rombios.c --- a/tools/firmware/rombios/rombios.c Tue Apr 12 09:46:09 2011 +0100 +++ b/tools/firmware/rombios/rombios.c Tue Apr 12 09:46:09 2011 +0100 @@ -29,7 +29,7 @@ #define uint8_t unsigned char #define uint16_t unsigned short #define uint32_t unsigned long -#include "../hvmloader/config.h" +#include "config.h" #define HVMASSIST #undef HVMTEST _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-12 11:29 UTC
[Xen-devel] [PATCH 02 of 19] tools: hvmloader: split e820 support into its own code module
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1302598647 -3600 # Node ID 17184d148ff5b507710561cd62cb2987fb531c47 # Parent d9ee229bada7659019b88ae6b75dd0a8a488714f tools: hvmloader: split e820 support into its own code module. Pass the table address as a paramter to the build function and cause it to return the number of entries. Pass both base and offset as parameters to the dump function. This adds a duplicated e820.h header to ROMBIOS. Since the e820 data structure is well defined by existing BIOS implementations I think this is OK and simplifies the cross talk between hvmloader and ROMBIOS. Reduces the cross talk between ROMBIOS and hvmloader. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r d9ee229bada7 -r 17184d148ff5 tools/firmware/hvmloader/Makefile --- a/tools/firmware/hvmloader/Makefile Tue Apr 12 09:46:09 2011 +0100 +++ b/tools/firmware/hvmloader/Makefile Tue Apr 12 09:57:27 2011 +0100 @@ -30,6 +30,7 @@ CFLAGS += $(CFLAGS_xeninclude) SRCS = hvmloader.c mp_tables.c util.c smbios.c SRCS += 32bitbios_support.c smp.c cacheattr.c xenbus.c +SRCS += e820.c ifeq ($(debug),y) SRCS += tests.c endif diff -r d9ee229bada7 -r 17184d148ff5 tools/firmware/hvmloader/config.h --- a/tools/firmware/hvmloader/config.h Tue Apr 12 09:46:09 2011 +0100 +++ b/tools/firmware/hvmloader/config.h Tue Apr 12 09:57:27 2011 +0100 @@ -1,6 +1,8 @@ #ifndef __HVMLOADER_CONFIG_H__ #define __HVMLOADER_CONFIG_H__ +#include <stdint.h> + #define PAGE_SHIFT 12 #define PAGE_SIZE (1ul << PAGE_SHIFT) @@ -28,6 +30,7 @@ extern unsigned long pci_mem_start, pci_ #define ROMBIOS_MAXOFFSET 0x0000FFFF #define ROMBIOS_END (ROMBIOS_BEGIN + ROMBIOS_SIZE) +#include "e820.h" #include "../rombios/config.h" #define VGABIOS_PHYSICAL_ADDRESS 0x000C0000 diff -r d9ee229bada7 -r 17184d148ff5 tools/firmware/hvmloader/e820.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/firmware/hvmloader/e820.c Tue Apr 12 09:57:27 2011 +0100 @@ -0,0 +1,141 @@ +/* + * HVM e820 support. + * + * Leendert van Doorn, leendert@watson.ibm.com + * Copyright (c) 2005, International Business Machines Corporation. + * Copyright (c) 2006, Keir Fraser, XenSource Inc. + * Copyright (c) 2011, Citrix Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place - Suite 330, Boston, MA 02111-1307 USA. + */ + +#include "config.h" +#include "util.h" + +void dump_e820_table(struct e820entry *e820, unsigned int nr) +{ + uint64_t last_end = 0, start, end; + int i; + + printf("E820 table:\n"); + + for ( i = 0; i < nr; i++ ) + { + start = e820[i].addr; + end = e820[i].addr + e820[i].size; + + if ( start < last_end ) + printf(" OVERLAP!!\n"); + else if ( start > last_end ) + printf(" HOLE: %08x:%08x - %08x:%08x\n", + (uint32_t)(last_end >> 32), (uint32_t)last_end, + (uint32_t)(start >> 32), (uint32_t)start); + + printf(" [%02d]: %08x:%08x - %08x:%08x: ", i, + (uint32_t)(start >> 32), (uint32_t)start, + (uint32_t)(end >> 32), (uint32_t)end); + switch ( e820[i].type ) + { + case E820_RAM: + printf("RAM\n"); + break; + case E820_RESERVED: + printf("RESERVED\n"); + break; + case E820_ACPI: + printf("ACPI\n"); + break; + case E820_NVS: + printf("NVS\n"); + break; + default: + printf("UNKNOWN (%08x)\n", e820[i].type); + break; + } + + last_end = end; + } +} + +/* Create an E820 table based on memory parameters provided in hvm_info. */ +int build_e820_table(struct e820entry *e820) +{ + unsigned int nr = 0; + + /* 0x0-0x9E000: Ordinary RAM. */ + /* (Must be at least 512K to keep Windows happy) */ + e820[nr].addr = 0x00000; + e820[nr].size = 0x9E000; + e820[nr].type = E820_RAM; + nr++; + + /* 0x9E000-0x9FC00: Reserved for internal use. */ + e820[nr].addr = 0x9E000; + e820[nr].size = 0x01C00; + e820[nr].type = E820_RESERVED; + nr++; + + /* 0x9FC00-0xA0000: Extended BIOS Data Area (EBDA). */ + e820[nr].addr = 0x9FC00; + e820[nr].size = 0x400; + e820[nr].type = E820_RESERVED; + nr++; + + /* + * Following regions are standard regions of the PC memory map. + * They are not covered by e820 regions. OSes will not use as RAM. + * 0xA0000-0xC0000: VGA memory-mapped I/O. Not covered by E820. + * 0xC0000-0xE0000: 16-bit devices, expansion ROMs (inc. vgabios). + * TODO: free pages which turn out to be unused. + */ + + /* + * 0xE0000-0x0F0000: PC-specific area. We place various tables here. + * 0xF0000-0x100000: System BIOS. + * TODO: free pages which turn out to be unused. + */ + e820[nr].addr = 0xE0000; + e820[nr].size = 0x20000; + e820[nr].type = E820_RESERVED; + nr++; + + /* Low RAM goes here. Reserve space for special pages. */ + BUG_ON((hvm_info->low_mem_pgend << PAGE_SHIFT) < (2u << 20)); + e820[nr].addr = 0x100000; + e820[nr].size = (hvm_info->low_mem_pgend << PAGE_SHIFT) - e820[nr].addr; + e820[nr].type = E820_RAM; + nr++; + + /* + * Explicitly reserve space for special pages. + * This space starts at RESERVED_MEMBASE an extends to cover various + * fixed hardware mappings (e.g., LAPIC, IOAPIC, default SVGA framebuffer). + */ + e820[nr].addr = RESERVED_MEMBASE; + e820[nr].size = (uint32_t)-e820[nr].addr; + e820[nr].type = E820_RESERVED; + nr++; + + if ( hvm_info->high_mem_pgend ) + { + e820[nr].addr = ((uint64_t)1 << 32); + e820[nr].size + ((uint64_t)hvm_info->high_mem_pgend << PAGE_SHIFT) - e820[nr].addr; + e820[nr].type = E820_RAM; + nr++; + } + + return nr; +} + diff -r d9ee229bada7 -r 17184d148ff5 tools/firmware/hvmloader/e820.h --- a/tools/firmware/hvmloader/e820.h Tue Apr 12 09:46:09 2011 +0100 +++ b/tools/firmware/hvmloader/e820.h Tue Apr 12 09:57:27 2011 +0100 @@ -1,8 +1,6 @@ #ifndef __HVMLOADER_E820_H__ #define __HVMLOADER_E820_H__ -#include <xen/hvm/e820.h> - /* * PC BIOS standard E820 types and structure. */ @@ -17,7 +15,4 @@ struct e820entry { uint32_t type; } __attribute__((packed)); -#define E820_NR ((uint16_t *)(E820_PHYSICAL_ADDRESS + E820_NR_OFFSET)) -#define E820 ((struct e820entry *)(E820_PHYSICAL_ADDRESS + E820_OFFSET)) - #endif /* __HVMLOADER_E820_H__ */ diff -r d9ee229bada7 -r 17184d148ff5 tools/firmware/hvmloader/hvmloader.c --- a/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 09:46:09 2011 +0100 +++ b/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 09:57:27 2011 +0100 @@ -27,7 +27,6 @@ #include "config.h" #include "apic_regs.h" #include "pci_regs.h" -#include "e820.h" #include "option_rom.h" #include <xen/version.h> #include <xen/hvm/params.h> @@ -578,125 +577,6 @@ static void init_vm86_tss(void) printf("vm86 TSS at %08lx\n", virt_to_phys(tss)); } -static void dump_e820_table(void) -{ - struct e820entry *e820 = E820; - unsigned int nr = *E820_NR; - uint64_t last_end = 0, start, end; - int i; - - printf("E820 table:\n"); - - for ( i = 0; i < nr; i++ ) - { - start = e820[i].addr; - end = e820[i].addr + e820[i].size; - - if ( start < last_end ) - printf(" OVERLAP!!\n"); - else if ( start > last_end ) - printf(" HOLE: %08x:%08x - %08x:%08x\n", - (uint32_t)(last_end >> 32), (uint32_t)last_end, - (uint32_t)(start >> 32), (uint32_t)start); - - printf(" [%02d]: %08x:%08x - %08x:%08x: ", i, - (uint32_t)(start >> 32), (uint32_t)start, - (uint32_t)(end >> 32), (uint32_t)end); - switch ( e820[i].type ) - { - case E820_RAM: - printf("RAM\n"); - break; - case E820_RESERVED: - printf("RESERVED\n"); - break; - case E820_ACPI: - printf("ACPI\n"); - break; - case E820_NVS: - printf("NVS\n"); - break; - default: - printf("UNKNOWN (%08x)\n", e820[i].type); - break; - } - - last_end = end; - } -} - -/* Create an E820 table based on memory parameters provided in hvm_info. */ -static void build_e820_table(void) -{ - struct e820entry *e820 = E820; - unsigned int nr = 0; - - /* 0x0-0x9E000: Ordinary RAM. */ - /* (Must be at least 512K to keep Windows happy) */ - e820[nr].addr = 0x00000; - e820[nr].size = 0x9E000; - e820[nr].type = E820_RAM; - nr++; - - /* 0x9E000-0x9FC00: Reserved for internal use. */ - e820[nr].addr = 0x9E000; - e820[nr].size = 0x01C00; - e820[nr].type = E820_RESERVED; - nr++; - - /* 0x9FC00-0xA0000: Extended BIOS Data Area (EBDA). */ - e820[nr].addr = 0x9FC00; - e820[nr].size = 0x400; - e820[nr].type = E820_RESERVED; - nr++; - - /* - * Following regions are standard regions of the PC memory map. - * They are not covered by e820 regions. OSes will not use as RAM. - * 0xA0000-0xC0000: VGA memory-mapped I/O. Not covered by E820. - * 0xC0000-0xE0000: 16-bit devices, expansion ROMs (inc. vgabios). - * TODO: free pages which turn out to be unused. - */ - - /* - * 0xE0000-0x0F0000: PC-specific area. We place various tables here. - * 0xF0000-0x100000: System BIOS. - * TODO: free pages which turn out to be unused. - */ - e820[nr].addr = 0xE0000; - e820[nr].size = 0x20000; - e820[nr].type = E820_RESERVED; - nr++; - - /* Low RAM goes here. Reserve space for special pages. */ - BUG_ON((hvm_info->low_mem_pgend << PAGE_SHIFT) < (2u << 20)); - e820[nr].addr = 0x100000; - e820[nr].size = (hvm_info->low_mem_pgend << PAGE_SHIFT) - e820[nr].addr; - e820[nr].type = E820_RAM; - nr++; - - /* - * Explicitly reserve space for special pages. - * This space starts at RESERVED_MEMBASE an extends to cover various - * fixed hardware mappings (e.g., LAPIC, IOAPIC, default SVGA framebuffer). - */ - e820[nr].addr = RESERVED_MEMBASE; - e820[nr].size = (uint32_t)-e820[nr].addr; - e820[nr].type = E820_RESERVED; - nr++; - - if ( hvm_info->high_mem_pgend ) - { - e820[nr].addr = ((uint64_t)1 << 32); - e820[nr].size - ((uint64_t)hvm_info->high_mem_pgend << PAGE_SHIFT) - e820[nr].addr; - e820[nr].type = E820_RAM; - nr++; - } - - *E820_NR = nr; -} - int main(void) { int option_rom_sz = 0, vgabios_sz = 0, etherboot_sz = 0; @@ -802,8 +682,8 @@ int main(void) ROMBIOS_PHYSICAL_ADDRESS, ROMBIOS_PHYSICAL_ADDRESS + rombios_sz - 1); - build_e820_table(); - dump_e820_table(); + *E820_NR = build_e820_table(E820); + dump_e820_table(E820, *E820_NR); bios_info = (struct bios_info *)BIOS_INFO_PHYSICAL_ADDRESS; memset(bios_info, 0, sizeof(*bios_info)); diff -r d9ee229bada7 -r 17184d148ff5 tools/firmware/hvmloader/smbios.c --- a/tools/firmware/hvmloader/smbios.c Tue Apr 12 09:46:09 2011 +0100 +++ b/tools/firmware/hvmloader/smbios.c Tue Apr 12 09:57:27 2011 +0100 @@ -26,7 +26,6 @@ #include "smbios_types.h" #include "util.h" #include "hypercall.h" -#include "e820.h" static int write_smbios_tables(void *start, diff -r d9ee229bada7 -r 17184d148ff5 tools/firmware/hvmloader/util.c --- a/tools/firmware/hvmloader/util.c Tue Apr 12 09:46:09 2011 +0100 +++ b/tools/firmware/hvmloader/util.c Tue Apr 12 09:57:27 2011 +0100 @@ -20,7 +20,6 @@ #include "util.h" #include "config.h" -#include "e820.h" #include "hypercall.h" #include <stdint.h> #include <xen/xen.h> diff -r d9ee229bada7 -r 17184d148ff5 tools/firmware/hvmloader/util.h --- a/tools/firmware/hvmloader/util.h Tue Apr 12 09:46:09 2011 +0100 +++ b/tools/firmware/hvmloader/util.h Tue Apr 12 09:57:27 2011 +0100 @@ -189,6 +189,10 @@ void create_mp_tables(void); int hvm_write_smbios_tables(void); void smp_initialise(void); +#include "e820.h" +int build_e820_table(struct e820entry *e820); +void dump_e820_table(struct e820entry *e820, unsigned int nr); + #ifndef NDEBUG void perform_tests(void); #else diff -r d9ee229bada7 -r 17184d148ff5 tools/firmware/rombios/32bit/pmm.c --- a/tools/firmware/rombios/32bit/pmm.c Tue Apr 12 09:46:09 2011 +0100 +++ b/tools/firmware/rombios/32bit/pmm.c Tue Apr 12 09:57:27 2011 +0100 @@ -66,7 +66,7 @@ #include <stdint.h> #include <stddef.h> #include "config.h" -#include <../hvmloader/e820.h> +#include "e820.h" #include "util.h" #define DEBUG_PMM 0 diff -r d9ee229bada7 -r 17184d148ff5 tools/firmware/rombios/config.h --- a/tools/firmware/rombios/config.h Tue Apr 12 09:46:09 2011 +0100 +++ b/tools/firmware/rombios/config.h Tue Apr 12 09:57:27 2011 +0100 @@ -18,6 +18,9 @@ #define E820_NR_OFFSET 0x0 #define E820_OFFSET 0x8 +#define E820_NR ((uint16_t *)(E820_PHYSICAL_ADDRESS + E820_NR_OFFSET)) +#define E820 ((struct e820entry *)(E820_PHYSICAL_ADDRESS + E820_OFFSET)) + /* Xen Platform Device */ #define XEN_PF_IOBASE 0x10 #define PFFLAG_ROM_LOCK 1 /* Sets whether ROM memory area is RW or RO */ diff -r d9ee229bada7 -r 17184d148ff5 tools/firmware/rombios/e820.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/firmware/rombios/e820.h Tue Apr 12 09:57:27 2011 +0100 @@ -0,0 +1,18 @@ +#ifndef __ROMBIOS_E820_H__ +#define __ROMBIOS_E820_H__ + +/* + * PC BIOS standard E820 types and structure. + */ +#define E820_RAM 1 +#define E820_RESERVED 2 +#define E820_ACPI 3 +#define E820_NVS 4 + +struct e820entry { + uint64_t addr; + uint64_t size; + uint32_t type; +} __attribute__((packed)); + +#endif /* __ROMBIOS_E820_H__ */ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-12 11:29 UTC
[Xen-devel] [PATCH 03 of 19] tools: hvmloader: pass ACPI_PHYSICAL_ADDRESS as a runtime parameter
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1302598830 -3600 # Node ID b29f772657190d609c4f5df250f1ec1c9e87a972 # Parent 17184d148ff5b507710561cd62cb2987fb531c47 tools: hvmloader: pass ACPI_PHYSICAL_ADDRESS as a runtime parameter. Instead of hardcoding in a header. Reduces the cross talk between ROMBIOS and hvmloader. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 17184d148ff5 -r b29f77265719 tools/firmware/hvmloader/acpi/acpi2_0.h --- a/tools/firmware/hvmloader/acpi/acpi2_0.h Tue Apr 12 09:57:27 2011 +0100 +++ b/tools/firmware/hvmloader/acpi/acpi2_0.h Tue Apr 12 10:00:30 2011 +0100 @@ -382,7 +382,7 @@ struct acpi_20_madt_intsrcovr { #pragma pack () -void acpi_build_tables(void); +void acpi_build_tables(unsigned int physical); extern uint32_t madt_csum_addr, madt_lapic0_addr; #endif /* _ACPI_2_0_H_ */ diff -r 17184d148ff5 -r b29f77265719 tools/firmware/hvmloader/acpi/build.c --- a/tools/firmware/hvmloader/acpi/build.c Tue Apr 12 09:57:27 2011 +0100 +++ b/tools/firmware/hvmloader/acpi/build.c Tue Apr 12 10:00:30 2011 +0100 @@ -242,7 +242,9 @@ static int construct_secondary_tables(ui return align16(offset); } -static void __acpi_build_tables(uint8_t *buf, int *low_sz, int *high_sz) +static void __acpi_build_tables(unsigned int physical, + uint8_t *buf, + int *low_sz, int *high_sz) { struct acpi_20_rsdp *rsdp; struct acpi_20_rsdt *rsdt; @@ -335,11 +337,11 @@ static void __acpi_build_tables(uint8_t /* * Fill in low-memory data structures: bios_info_table and RSDP. */ - - buf = (uint8_t *)ACPI_PHYSICAL_ADDRESS; + buf = (uint8_t *)physical; offset = 0; 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; @@ -354,24 +356,23 @@ static void __acpi_build_tables(uint8_t *low_sz = offset; } -void acpi_build_tables(void) +void acpi_build_tables(unsigned int physical) { int high_sz, low_sz; uint8_t *buf; /* Find out size of high-memory ACPI data area. */ buf = (uint8_t *)&_end; - __acpi_build_tables(buf, &low_sz, &high_sz); + __acpi_build_tables(physical, buf, &low_sz, &high_sz); memset(buf, 0, high_sz); /* Allocate data area and set up ACPI tables there. */ buf = mem_alloc(high_sz, 0); - __acpi_build_tables(buf, &low_sz, &high_sz); + __acpi_build_tables(physical, buf, &low_sz, &high_sz); - printf(" - Lo data: %08lx-%08lx\n" + printf(" - Lo data: %08x-%08x\n" " - Hi data: %08lx-%08lx\n", - (unsigned long)ACPI_PHYSICAL_ADDRESS, - (unsigned long)ACPI_PHYSICAL_ADDRESS + low_sz - 1, + physical, physical + low_sz - 1, (unsigned long)buf, (unsigned long)buf + high_sz - 1); } diff -r 17184d148ff5 -r b29f77265719 tools/firmware/hvmloader/hvmloader.c --- a/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 09:57:27 2011 +0100 +++ b/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 10:00:30 2011 +0100 @@ -652,7 +652,7 @@ int main(void) }; printf("Loading ACPI ...\n"); - acpi_build_tables(); + acpi_build_tables(ACPI_PHYSICAL_ADDRESS); hypercall_hvm_op(HVMOP_set_param, &p); } _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-12 11:29 UTC
[Xen-devel] [PATCH 04 of 19] tools: hvmloader: pass SMBIOS location as a runtime parameter
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1302599695 -3600 # Node ID 73653e949dbef093ddd72fa527e00aa3fea854c4 # Parent b29f772657190d609c4f5df250f1ec1c9e87a972 tools: hvmloader: pass SMBIOS location as a runtime parameter. Instead of hardcoding in a header. Reduces the cross talk between ROMBIOS and hvmloader. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r b29f77265719 -r 73653e949dbe tools/firmware/hvmloader/hvmloader.c --- a/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 10:00:30 2011 +0100 +++ b/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 10:14:55 2011 +0100 @@ -599,7 +599,9 @@ int main(void) perform_tests(); printf("Writing SMBIOS tables ...\n"); - smbios_sz = hvm_write_smbios_tables(); + smbios_sz = hvm_write_smbios_tables(SCRATCH_PHYSICAL_ADDRESS, + SMBIOS_PHYSICAL_ADDRESS, + SMBIOS_PHYSICAL_END); printf("Loading ROMBIOS ...\n"); rombios_sz = sizeof(rombios); diff -r b29f77265719 -r 73653e949dbe tools/firmware/hvmloader/smbios.c --- a/tools/firmware/hvmloader/smbios.c Tue Apr 12 10:00:30 2011 +0100 +++ b/tools/firmware/hvmloader/smbios.c Tue Apr 12 10:14:55 2011 +0100 @@ -28,7 +28,7 @@ #include "hypercall.h" static int -write_smbios_tables(void *start, +write_smbios_tables(void *start, unsigned long phys, uint32_t vcpus, uint64_t memsize, uint8_t uuid[16], char *xen_version, uint32_t xen_major_version, uint32_t xen_minor_version); @@ -85,7 +85,7 @@ get_cpu_manufacturer(char *buf, int len) } static int -write_smbios_tables(void *start, +write_smbios_tables(void *start, unsigned long phys, uint32_t vcpus, uint64_t memsize, uint8_t uuid[16], char *xen_version, uint32_t xen_major_version, uint32_t xen_minor_version) @@ -136,7 +136,7 @@ write_smbios_tables(void *start, smbios_entry_point_init( start, max_struct_size, (p - (char *)start) - sizeof(struct smbios_entry_point), - SMBIOS_PHYSICAL_ADDRESS + sizeof(struct smbios_entry_point), + phys + sizeof(struct smbios_entry_point), nr_structs); return ((char *)p - (char *)start); @@ -162,7 +162,7 @@ get_memsize(void) } int -hvm_write_smbios_tables(void) +hvm_write_smbios_tables(unsigned long scratch, unsigned long smbios_start, unsigned long smbios_end) { xen_domain_handle_t uuid; uint16_t xen_major_version, xen_minor_version; @@ -222,15 +222,14 @@ hvm_write_smbios_tables(void) xen_version_str[sizeof(xen_version_str)-1] = ''\0''; /* SCRATCH_PHYSICAL_ADDRESS is a safe large memory area for scratch. */ - len = write_smbios_tables((void *)SCRATCH_PHYSICAL_ADDRESS, + len = write_smbios_tables((void *)scratch, smbios_start, hvm_info->nr_vcpus, get_memsize(), uuid, xen_version_str, xen_major_version, xen_minor_version); - if ( len > SMBIOS_MAXIMUM_SIZE ) + if ( smbios_start + len > smbios_end ) goto error_out; /* Okay, not too large: copy out of scratch to final location. */ - memcpy((void *)SMBIOS_PHYSICAL_ADDRESS, - (void *)SCRATCH_PHYSICAL_ADDRESS, len); + memcpy((void *)smbios_start, (void *)scratch, len); return len; diff -r b29f77265719 -r 73653e949dbe tools/firmware/hvmloader/util.h --- a/tools/firmware/hvmloader/util.h Tue Apr 12 10:00:30 2011 +0100 +++ b/tools/firmware/hvmloader/util.h Tue Apr 12 10:14:55 2011 +0100 @@ -186,7 +186,9 @@ uint32_t highbios_setup(void); /* Miscellaneous. */ void cacheattr_init(void); void create_mp_tables(void); -int hvm_write_smbios_tables(void); +int hvm_write_smbios_tables(unsigned long scratch, + unsigned long smbios_start, + unsigned long smbios_end); void smp_initialise(void); #include "e820.h" diff -r b29f77265719 -r 73653e949dbe tools/firmware/rombios/config.h --- a/tools/firmware/rombios/config.h Tue Apr 12 10:00:30 2011 +0100 +++ b/tools/firmware/rombios/config.h Tue Apr 12 10:14:55 2011 +0100 @@ -11,7 +11,8 @@ #define ACPI_PHYSICAL_ADDRESS 0x000EA020 #define E820_PHYSICAL_ADDRESS 0x000EA100 #define SMBIOS_PHYSICAL_ADDRESS 0x000EB000 -#define SMBIOS_MAXIMUM_SIZE 0x00005000 +#define SMBIOS_PHYSICAL_END 0x000F0000 + #define ROMBIOS_PHYSICAL_ADDRESS 0x000F0000 /* Offsets from E820_PHYSICAL_ADDRESS. */ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-12 11:29 UTC
[Xen-devel] [PATCH 05 of 19] tools: hvmloader: pass option ROM end address around as a parameter
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1302599957 -3600 # Node ID f3596ba54b29dec182f995e052f31ada0efd5f83 # Parent 73653e949dbef093ddd72fa527e00aa3fea854c4 tools: hvmloader: pass option ROM end address around as a parameter. Reduces the cross talk between ROMBIOS and hvmloader. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 73653e949dbe -r f3596ba54b29 tools/firmware/hvmloader/hvmloader.c --- a/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 10:14:55 2011 +0100 +++ b/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 10:19:17 2011 +0100 @@ -378,10 +378,11 @@ static void pci_setup(void) * Scan the list of Option ROMs at @roms for one which supports * PCI (@vendor_id, @device_id) found at slot @devfn. If one is found, * copy it to @dest and return its size rounded up to a multiple 2kB. This - * function will not copy ROMs beyond address OPTIONROM_PHYSICAL_END. + * function will not copy ROMs beyond address option_rom_end. */ #define round_option_rom(x) (((x) + 2047) & ~2047) static int scan_option_rom( + unsigned int option_rom_end, uint8_t devfn, uint16_t vendor_id, uint16_t device_id, void *roms, uint32_t dest) { @@ -449,7 +450,7 @@ static int scan_option_rom( printf(" - Product name: %s\n", (char *)rom + pnph->product_name_offset); - if ( (dest + rom->rom_size * 512 + 1) > OPTIONROM_PHYSICAL_END ) + if ( (dest + rom->rom_size * 512 + 1) > option_rom_end ) { printf("Option ROM size %x exceeds available space\n", rom->rom_size * 512); @@ -467,7 +468,8 @@ static int scan_option_rom( * the corresponding rom data to *copy_rom_dest. Returns the length of the * selected rom, or 0 if no NIC found. */ -static int scan_etherboot_nic(uint32_t copy_rom_dest) +static int scan_etherboot_nic(unsigned int option_rom_end, + uint32_t copy_rom_dest) { uint16_t class, vendor_id, device_id, devfn; int rom_size = 0; @@ -483,6 +485,7 @@ static int scan_etherboot_nic(uint32_t c (device_id != 0xffff) && (class == 0x0200) ) rom_size = scan_option_rom( + option_rom_end, devfn, vendor_id, device_id, etherboot, copy_rom_dest); } @@ -493,7 +496,8 @@ static int scan_etherboot_nic(uint32_t c * Scan the PCI bus for the devices that have an option ROM, and copy * the corresponding rom data to rom_phys_addr. */ -static int pci_load_option_roms(uint32_t rom_base_addr) +static int pci_load_option_roms(unsigned int option_rom_end, + uint32_t rom_base_addr) { uint32_t option_rom_addr, rom_phys_addr = rom_base_addr; uint16_t vendor_id, device_id, devfn, class; @@ -522,6 +526,7 @@ static int pci_load_option_roms(uint32_t pci_writel(devfn, PCI_ROM_ADDRESS, option_rom_addr | 0x1); rom_phys_addr += scan_option_rom( + option_rom_end, devfn, vendor_id, device_id, (void *)(option_rom_addr & ~2047), rom_phys_addr); @@ -640,10 +645,12 @@ int main(void) etherboot_phys_addr = VGABIOS_PHYSICAL_ADDRESS + vgabios_sz; if ( etherboot_phys_addr < OPTIONROM_PHYSICAL_ADDRESS ) etherboot_phys_addr = OPTIONROM_PHYSICAL_ADDRESS; - etherboot_sz = scan_etherboot_nic(etherboot_phys_addr); + etherboot_sz = scan_etherboot_nic(OPTIONROM_PHYSICAL_END, + etherboot_phys_addr); option_rom_phys_addr = etherboot_phys_addr + etherboot_sz; - option_rom_sz = pci_load_option_roms(option_rom_phys_addr); + option_rom_sz = pci_load_option_roms(OPTIONROM_PHYSICAL_END, + option_rom_phys_addr); if ( hvm_info->acpi_enabled ) { _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-12 11:29 UTC
[Xen-devel] [PATCH 06 of 19] tools: hvmloader: split scratch and hypercall addressing from ROMBIOS low heap
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1302600167 -3600 # Node ID 170ca1c6603ce0cc1893125103c4666dfa303364 # Parent f3596ba54b29dec182f995e052f31ada0efd5f83 tools: hvmloader: split scratch and hypercall addressing from ROMBIOS low heap. Although happen to live at the same physical address their lifespans do not overlap. The scratch and hypercall spaces are used only within hvmloader and the same area is reused as a heap within ROMBIOS. But each is free to make its own decisions about where to place things. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r f3596ba54b29 -r 170ca1c6603c tools/firmware/hvmloader/config.h --- a/tools/firmware/hvmloader/config.h Tue Apr 12 10:19:17 2011 +0100 +++ b/tools/firmware/hvmloader/config.h Tue Apr 12 10:22:47 2011 +0100 @@ -33,6 +33,9 @@ extern unsigned long pci_mem_start, pci_ #include "e820.h" #include "../rombios/config.h" +#define SCRATCH_PHYSICAL_ADDRESS 0x00010000 +#define HYPERCALL_PHYSICAL_ADDRESS 0x00080000 + #define VGABIOS_PHYSICAL_ADDRESS 0x000C0000 #endif /* __HVMLOADER_CONFIG_H__ */ diff -r f3596ba54b29 -r 170ca1c6603c tools/firmware/rombios/32bit/pmm.c --- a/tools/firmware/rombios/32bit/pmm.c Tue Apr 12 10:19:17 2011 +0100 +++ b/tools/firmware/rombios/32bit/pmm.c Tue Apr 12 10:22:47 2011 +0100 @@ -147,7 +147,7 @@ typedef struct heap { * * - conventional memroy (below 1MB) * In HVM, the area is fixed. 0x00010000-0x0007FFFF - * (from SCRATCH_PHYSICAL_ADDRESS to HYPERCALL_PHYSICAL_ADDRESS) + * (LOWHEAP_SIZE bytes from LOWHEAP_PHYSICAL_ADDRESS) * * - extended memory (start at 1MB, below 4GB) * In HVM, the area starts at memory address 0x00100000. @@ -283,8 +283,9 @@ pmm_initalize(void) } /* convectional memory: RAM below 1MB, 0x10000-0x7FFFF */ - pmm_init_heap(&pmm_data.heap, SCRATCH_PHYSICAL_ADDRESS, - HYPERCALL_PHYSICAL_ADDRESS); + pmm_init_heap(&pmm_data.heap, + LOWHEAP_PHYSICAL_ADDRESS, + LOWHEAP_PHYSICAL_ADDRESS+LOWHEAP_SIZE); } static uint32_t diff -r f3596ba54b29 -r 170ca1c6603c tools/firmware/rombios/config.h --- a/tools/firmware/rombios/config.h Tue Apr 12 10:19:17 2011 +0100 +++ b/tools/firmware/rombios/config.h Tue Apr 12 10:22:47 2011 +0100 @@ -2,8 +2,8 @@ #define _ROMBIOS_CONFIG_H /* Memory map. */ -#define SCRATCH_PHYSICAL_ADDRESS 0x00010000 -#define HYPERCALL_PHYSICAL_ADDRESS 0x00080000 +#define LOWHEAP_PHYSICAL_ADDRESS 0x00010000 +#define LOWHEAP_SIZE 0x00070000 #define OPTIONROM_PHYSICAL_ADDRESS 0x000C8000 #define OPTIONROM_PHYSICAL_END 0x000EA000 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-12 11:29 UTC
[Xen-devel] [PATCH 07 of 19] tools: hvmloader: refactor Makefile to move ROM filenames into variables
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1302600838 -3600 # Node ID 70bf20a0b5462f3a1fa4213592bae076ec1a81ba # Parent 170ca1c6603ce0cc1893125103c4666dfa303364 tools: hvmloader: refactor Makefile to move ROM filenames into variables. Add an option to use debug Cirrus video BIOS, simply as a convenience. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 170ca1c6603c -r 70bf20a0b546 tools/firmware/hvmloader/Makefile --- a/tools/firmware/hvmloader/Makefile Tue Apr 12 10:22:47 2011 +0100 +++ b/tools/firmware/hvmloader/Makefile Tue Apr 12 10:33:58 2011 +0100 @@ -36,6 +36,17 @@ SRCS += tests.c endif OBJS = $(patsubst %.c,%.o,$(SRCS)) +CIRRUSVGA_DEBUG ?= n + +ROMBIOS_ROM := ../rombios/BIOS-bochs-latest + +STDVGA_ROM := ../vgabios/VGABIOS-lgpl-latest.bin +ifeq ($(CIRRUSVGA_DEBUG),y) +CIRRUSVGA_ROM := ../vgabios/VGABIOS-lgpl-latest.cirrus.debug.bin +else +CIRRUSVGA_ROM := ../vgabios/VGABIOS-lgpl-latest.cirrus.bin +endif + .PHONY: all all: subdirs-all $(MAKE) hvmloader @@ -48,12 +59,17 @@ hvmloader: $(OBJS) acpi/acpi.a $(OBJCOPY) hvmloader.tmp hvmloader rm -f hvmloader.tmp -roms.h: ../rombios/BIOS-bochs-latest ../vgabios/VGABIOS-lgpl-latest.bin \ - ../vgabios/VGABIOS-lgpl-latest.cirrus.bin ../etherboot/eb-roms.h - sh ./mkhex rombios ../rombios/BIOS-bochs-latest > roms.h - sh ./mkhex vgabios_stdvga ../vgabios/VGABIOS-lgpl-latest.bin >> roms.h - sh ./mkhex vgabios_cirrusvga \ - ../vgabios/VGABIOS-lgpl-latest.cirrus.bin >> roms.h +roms.h: $(ROMBIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) ../etherboot/eb-roms.h +ifneq ($(ROMBIOS_ROM),) + sh ./mkhex rombios $(ROMBIOS_ROM) > roms.h +endif +ifneq ($(STDVGA_ROM),) + sh ./mkhex vgabios_stdvga $(STDVGA_ROM) >> roms.h +endif +ifneq ($(CIRRUSVGA_ROM),) + sh ./mkhex vgabios_cirrusvga $(CIRRUSVGA_ROM) >> roms.h +endif + cat ../etherboot/eb-roms.h >> roms.h .PHONY: clean _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-12 11:29 UTC
[Xen-devel] [PATCH 08 of 19] tools: hvmloader: remove rombios_sz, just use sizeof(rombios)
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1302601381 -3600 # Node ID bb3e40b2c856db6b0f3500625ff45a9d07377d1f # Parent 70bf20a0b5462f3a1fa4213592bae076ec1a81ba tools: hvmloader: remove rombios_sz, just use sizeof(rombios) Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 70bf20a0b546 -r bb3e40b2c856 tools/firmware/hvmloader/hvmloader.c --- a/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 10:33:58 2011 +0100 +++ b/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 10:43:01 2011 +0100 @@ -585,7 +585,7 @@ static void init_vm86_tss(void) int main(void) { int option_rom_sz = 0, vgabios_sz = 0, etherboot_sz = 0; - int rombios_sz, smbios_sz; + int smbios_sz; uint32_t etherboot_phys_addr, option_rom_phys_addr, bios32_addr; struct bios_info *bios_info; @@ -609,10 +609,7 @@ int main(void) SMBIOS_PHYSICAL_END); printf("Loading ROMBIOS ...\n"); - rombios_sz = sizeof(rombios); - if ( rombios_sz > 0x10000 ) - rombios_sz = 0x10000; - memcpy((void *)ROMBIOS_PHYSICAL_ADDRESS, rombios, rombios_sz); + memcpy((void *)ROMBIOS_PHYSICAL_ADDRESS, rombios, sizeof(rombios)); bios32_addr = highbios_setup(); if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode ) @@ -686,10 +683,9 @@ int main(void) printf(" %05x-%05x: SMBIOS tables\n", SMBIOS_PHYSICAL_ADDRESS, SMBIOS_PHYSICAL_ADDRESS + smbios_sz - 1); - if ( rombios_sz ) - printf(" %05x-%05x: Main BIOS\n", - ROMBIOS_PHYSICAL_ADDRESS, - ROMBIOS_PHYSICAL_ADDRESS + rombios_sz - 1); + printf(" %05x-%05x: Main BIOS\n", + ROMBIOS_PHYSICAL_ADDRESS, + ROMBIOS_PHYSICAL_ADDRESS + sizeof(rombios) - 1); *E820_NR = build_e820_table(E820); dump_e820_table(E820, *E820_NR); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-12 11:29 UTC
[Xen-devel] [PATCH 09 of 19] tools: hvmloader: rename roms.h to roms.inc
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1302601656 -3600 # Node ID 35d6dd63d96ee37c3fcf7690bac933c44a40b23c # Parent bb3e40b2c856db6b0f3500625ff45a9d07377d1f tools: hvmloader: rename roms.h to roms.inc It''s not really a header, it''s an autogenerated data file. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r bb3e40b2c856 -r 35d6dd63d96e .hgignore --- a/.hgignore Tue Apr 12 10:43:01 2011 +0100 +++ b/.hgignore Tue Apr 12 10:47:36 2011 +0100 @@ -143,7 +143,7 @@ ^tools/firmware/hvmloader/acpi/dsdt.*\.c$ ^tools/firmware/hvmloader/acpi/ssdt_.*\.h$ ^tools/firmware/hvmloader/hvmloader$ -^tools/firmware/hvmloader/roms\.h$ +^tools/firmware/hvmloader/roms\.inc$ ^tools/firmware/rombios/BIOS-bochs-[^/]*$ ^tools/firmware/rombios/_rombios[^/]*_\.c$ ^tools/firmware/rombios/rombios[^/]*\.s$ diff -r bb3e40b2c856 -r 35d6dd63d96e tools/firmware/hvmloader/Makefile --- a/tools/firmware/hvmloader/Makefile Tue Apr 12 10:43:01 2011 +0100 +++ b/tools/firmware/hvmloader/Makefile Tue Apr 12 10:47:36 2011 +0100 @@ -51,7 +51,7 @@ endif all: subdirs-all $(MAKE) hvmloader -hvmloader.o: roms.h +hvmloader.o: roms.inc smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(shell date +%m/%d/%Y)\"" hvmloader: $(OBJS) acpi/acpi.a @@ -59,22 +59,25 @@ hvmloader: $(OBJS) acpi/acpi.a $(OBJCOPY) hvmloader.tmp hvmloader rm -f hvmloader.tmp -roms.h: $(ROMBIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) ../etherboot/eb-roms.h +roms.inc: $(ROMBIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) ../etherboot/eb-roms.h + echo "/* Autogenerated file. DO NOT EDIT */" > roms.inc + ifneq ($(ROMBIOS_ROM),) - sh ./mkhex rombios $(ROMBIOS_ROM) > roms.h + sh ./mkhex rombios $(ROMBIOS_ROM) >> roms.inc endif + ifneq ($(STDVGA_ROM),) - sh ./mkhex vgabios_stdvga $(STDVGA_ROM) >> roms.h + sh ./mkhex vgabios_stdvga $(STDVGA_ROM) >> roms.inc endif ifneq ($(CIRRUSVGA_ROM),) - sh ./mkhex vgabios_cirrusvga $(CIRRUSVGA_ROM) >> roms.h + sh ./mkhex vgabios_cirrusvga $(CIRRUSVGA_ROM) >> roms.inc endif - cat ../etherboot/eb-roms.h >> roms.h + cat ../etherboot/eb-roms.h >> roms.inc .PHONY: clean clean: subdirs-clean - rm -f roms.h acpi.h + rm -f roms.inc acpi.h rm -f hvmloader hvmloader.tmp *.o $(DEPS) -include $(DEPS) diff -r bb3e40b2c856 -r 35d6dd63d96e tools/firmware/hvmloader/hvmloader.c --- a/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 10:43:01 2011 +0100 +++ b/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 10:47:36 2011 +0100 @@ -20,7 +20,6 @@ * Place - Suite 330, Boston, MA 02111-1307 USA. */ -#include "roms.h" #include "acpi/acpi2_0.h" #include "util.h" #include "hypercall.h" @@ -33,6 +32,8 @@ #include <xen/hvm/ioreq.h> #include <xen/memory.h> +#include "roms.inc" + asm ( " .text \n" " .globl _start \n" _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-12 11:29 UTC
[Xen-devel] [PATCH 10 of 19] tools: hvmloader: Define $(OBJS) directly instead of via $(SRCS)
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1302601741 -3600 # Node ID a25b909fed618dc7e8b95921a59a0db552d60612 # Parent 35d6dd63d96ee37c3fcf7690bac933c44a40b23c tools: hvmloader: Define $(OBJS) directly instead of via $(SRCS) $(SRCS) isn''t used for anything else. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 35d6dd63d96e -r a25b909fed61 tools/firmware/hvmloader/Makefile --- a/tools/firmware/hvmloader/Makefile Tue Apr 12 10:47:36 2011 +0100 +++ b/tools/firmware/hvmloader/Makefile Tue Apr 12 10:49:01 2011 +0100 @@ -28,13 +28,12 @@ LOADADDR = 0x100000 CFLAGS += $(CFLAGS_xeninclude) -SRCS = hvmloader.c mp_tables.c util.c smbios.c -SRCS += 32bitbios_support.c smp.c cacheattr.c xenbus.c -SRCS += e820.c +OBJS = hvmloader.o mp_tables.o util.o smbios.o +OBJS += 32bitbios_support.o smp.o cacheattr.o xenbus.o +OBJS += e820.o ifeq ($(debug),y) -SRCS += tests.c +OBJS += tests.o endif -OBJS = $(patsubst %.c,%.o,$(SRCS)) CIRRUSVGA_DEBUG ?= n _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-12 11:29 UTC
[Xen-devel] [PATCH 11 of 19] tools: hvmloader: add bios_config data structure
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1302601994 -3600 # Node ID 700f2fd3d5fd5733a33aa038d090ffb8a6561294 # Parent a25b909fed618dc7e8b95921a59a0db552d60612 tools: hvmloader: add bios_config data structure For now abstract away the actual ROM bits themselves and the various load addresses. Create a rombios.c to contain the ROMBIOS specific parts. ROMBIOS is still statically selected for the time being. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r a25b909fed61 -r 700f2fd3d5fd tools/firmware/hvmloader/Makefile --- a/tools/firmware/hvmloader/Makefile Tue Apr 12 10:49:01 2011 +0100 +++ b/tools/firmware/hvmloader/Makefile Tue Apr 12 10:53:14 2011 +0100 @@ -37,7 +37,11 @@ endif CIRRUSVGA_DEBUG ?= n -ROMBIOS_ROM := ../rombios/BIOS-bochs-latest +ROMBIOS_DIR := ../rombios +ifneq ($(ROMBIOS_DIR),) +OBJS += rombios.o +ROMBIOS_ROM := $(ROMBIOS_DIR)/BIOS-bochs-latest +endif STDVGA_ROM := ../vgabios/VGABIOS-lgpl-latest.bin ifeq ($(CIRRUSVGA_DEBUG),y) @@ -62,17 +66,25 @@ roms.inc: $(ROMBIOS_ROM) $(STDVGA_ROM) $ echo "/* Autogenerated file. DO NOT EDIT */" > roms.inc ifneq ($(ROMBIOS_ROM),) + echo "#ifdef ROM_INCLUDE_ROMBIOS" >> roms.inc sh ./mkhex rombios $(ROMBIOS_ROM) >> roms.inc + echo "#endif" >> roms.inc endif ifneq ($(STDVGA_ROM),) + echo "#ifdef ROM_INCLUDE_VGABIOS" >> roms.inc sh ./mkhex vgabios_stdvga $(STDVGA_ROM) >> roms.inc + echo "#endif" >> roms.inc endif ifneq ($(CIRRUSVGA_ROM),) + echo "#ifdef ROM_INCLUDE_VGABIOS" >> roms.inc sh ./mkhex vgabios_cirrusvga $(CIRRUSVGA_ROM) >> roms.inc + echo "#endif" >> roms.inc endif + echo "#ifdef ROM_INCLUDE_ETHERBOOT" >> roms.inc cat ../etherboot/eb-roms.h >> roms.inc + echo "#endif" >> roms.inc .PHONY: clean clean: subdirs-clean diff -r a25b909fed61 -r 700f2fd3d5fd tools/firmware/hvmloader/config.h --- a/tools/firmware/hvmloader/config.h Tue Apr 12 10:49:01 2011 +0100 +++ b/tools/firmware/hvmloader/config.h Tue Apr 12 10:53:14 2011 +0100 @@ -3,6 +3,28 @@ #include <stdint.h> +struct bios_config { + const char *name; + + /* BIOS ROM image bits */ + void *image; + unsigned int image_size; + + /* Physical address to load at */ + unsigned int bios_address; + + /* SMBIOS */ + unsigned int smbios_start, smbios_end; + + /* Option ROMs */ + unsigned int optionrom_start, optionrom_end; + + /* ACPI tables */ + unsigned int acpi_start; +}; + +extern struct bios_config rombios_config; + #define PAGE_SHIFT 12 #define PAGE_SIZE (1ul << PAGE_SHIFT) @@ -39,3 +61,13 @@ extern unsigned long pci_mem_start, pci_ #define VGABIOS_PHYSICAL_ADDRESS 0x000C0000 #endif /* __HVMLOADER_CONFIG_H__ */ + +/* + * Local variables: + * mode: C + * c-set-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff -r a25b909fed61 -r 700f2fd3d5fd tools/firmware/hvmloader/hvmloader.c --- a/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 10:49:01 2011 +0100 +++ b/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 10:53:14 2011 +0100 @@ -32,6 +32,8 @@ #include <xen/hvm/ioreq.h> #include <xen/memory.h> +#define ROM_INCLUDE_VGABIOS +#define ROM_INCLUDE_ETHERBOOT #include "roms.inc" asm ( @@ -583,10 +585,15 @@ static void init_vm86_tss(void) printf("vm86 TSS at %08lx\n", virt_to_phys(tss)); } +static const struct bios_config *detect_bios(void) +{ + return &rombios_config; +} + int main(void) { - int option_rom_sz = 0, vgabios_sz = 0, etherboot_sz = 0; - int smbios_sz; + const struct bios_config *bios; + int option_rom_sz = 0, vgabios_sz = 0, etherboot_sz = 0, smbios_sz = 0; uint32_t etherboot_phys_addr, option_rom_phys_addr, bios32_addr; struct bios_info *bios_info; @@ -594,9 +601,13 @@ int main(void) init_hypercalls(); + xenbus_setup(); + + bios = detect_bios(); + printf("System requested %s\n", bios->name); + printf("CPU speed is %u MHz\n", get_cpu_mhz()); - xenbus_setup(); apic_setup(); pci_setup(); @@ -604,13 +615,16 @@ int main(void) perform_tests(); - printf("Writing SMBIOS tables ...\n"); - smbios_sz = hvm_write_smbios_tables(SCRATCH_PHYSICAL_ADDRESS, - SMBIOS_PHYSICAL_ADDRESS, - SMBIOS_PHYSICAL_END); + if (bios->smbios_start) { + printf("Writing SMBIOS tables ...\n"); + smbios_sz = hvm_write_smbios_tables(SCRATCH_PHYSICAL_ADDRESS, + bios->smbios_start, + bios->smbios_end); + } - printf("Loading ROMBIOS ...\n"); - memcpy((void *)ROMBIOS_PHYSICAL_ADDRESS, rombios, sizeof(rombios)); + printf("Loading %s ...\n", bios->name); + memcpy((void *)bios->bios_address, bios->image, + bios->image_size); bios32_addr = highbios_setup(); if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode ) @@ -641,13 +655,13 @@ int main(void) } etherboot_phys_addr = VGABIOS_PHYSICAL_ADDRESS + vgabios_sz; - if ( etherboot_phys_addr < OPTIONROM_PHYSICAL_ADDRESS ) - etherboot_phys_addr = OPTIONROM_PHYSICAL_ADDRESS; - etherboot_sz = scan_etherboot_nic(OPTIONROM_PHYSICAL_END, + if ( etherboot_phys_addr < bios->optionrom_start ) + etherboot_phys_addr = bios->optionrom_start; + etherboot_sz = scan_etherboot_nic(bios->optionrom_end, etherboot_phys_addr); option_rom_phys_addr = etherboot_phys_addr + etherboot_sz; - option_rom_sz = pci_load_option_roms(OPTIONROM_PHYSICAL_END, + option_rom_sz = pci_load_option_roms(bios->optionrom_end, option_rom_phys_addr); if ( hvm_info->acpi_enabled ) @@ -659,7 +673,7 @@ int main(void) }; printf("Loading ACPI ...\n"); - acpi_build_tables(ACPI_PHYSICAL_ADDRESS); + acpi_build_tables(bios->acpi_start); hypercall_hvm_op(HVMOP_set_param, &p); } @@ -682,11 +696,11 @@ int main(void) option_rom_phys_addr + option_rom_sz - 1); if ( smbios_sz ) printf(" %05x-%05x: SMBIOS tables\n", - SMBIOS_PHYSICAL_ADDRESS, - SMBIOS_PHYSICAL_ADDRESS + smbios_sz - 1); + bios->smbios_start, + bios->smbios_start + smbios_sz - 1); printf(" %05x-%05x: Main BIOS\n", - ROMBIOS_PHYSICAL_ADDRESS, - ROMBIOS_PHYSICAL_ADDRESS + sizeof(rombios) - 1); + bios->bios_address, + bios->bios_address + bios->image_size - 1); *E820_NR = build_e820_table(E820); dump_e820_table(E820, *E820_NR); @@ -705,7 +719,7 @@ int main(void) xenbus_shutdown(); - printf("Invoking ROMBIOS ...\n"); + printf("Invoking %s ...\n", bios->name); return 0; } diff -r a25b909fed61 -r 700f2fd3d5fd tools/firmware/hvmloader/rombios.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/firmware/hvmloader/rombios.c Tue Apr 12 10:53:14 2011 +0100 @@ -0,0 +1,58 @@ +/* + * HVM ROMBIOS support. + * + * Leendert van Doorn, leendert@watson.ibm.com + * Copyright (c) 2005, International Business Machines Corporation. + * Copyright (c) 2006, Keir Fraser, XenSource Inc. + * Copyright (c) 2011, Citrix Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place - Suite 330, Boston, MA 02111-1307 USA. + */ + +#include "config.h" + +#include "../rombios/config.h" + +#define ROM_INCLUDE_ROMBIOS +#include "roms.inc" + +//BUILD_BUG_ON(sizeof(rombios) > (0x00100000U - ROMBIOS_PHYSICAL_ADDRESS)); + +struct bios_config rombios_config = { + .name = "ROMBIOS", + + .image = rombios, + .image_size = sizeof(rombios), + + .bios_address = ROMBIOS_PHYSICAL_ADDRESS, + + .smbios_start = SMBIOS_PHYSICAL_ADDRESS, + .smbios_end = SMBIOS_PHYSICAL_END, + + .optionrom_start = OPTIONROM_PHYSICAL_ADDRESS, + .optionrom_end = OPTIONROM_PHYSICAL_END, + + .acpi_start = ACPI_PHYSICAL_ADDRESS, + +}; + +/* + * Local variables: + * mode: C + * c-set-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-12 11:29 UTC
[Xen-devel] [PATCH 12 of 19] tools: hvmloader: Refactor APIC, PCI and SMP setup into struct bios_config
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1302602061 -3600 # Node ID f153a0d91b9f7cc9fe9d84bf7d97ac6371793b03 # Parent 700f2fd3d5fd5733a33aa038d090ffb8a6561294 tools: hvmloader: Refactor APIC, PCI and SMP setup into struct bios_config Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 700f2fd3d5fd -r f153a0d91b9f tools/firmware/hvmloader/config.h --- a/tools/firmware/hvmloader/config.h Tue Apr 12 10:53:14 2011 +0100 +++ b/tools/firmware/hvmloader/config.h Tue Apr 12 10:54:21 2011 +0100 @@ -3,6 +3,9 @@ #include <stdint.h> +enum virtual_vga { VGA_none, VGA_std, VGA_cirrus, VGA_pt } virtual_vga; +extern enum virtual_vga virtual_vga; + struct bios_config { const char *name; @@ -21,6 +24,10 @@ struct bios_config { /* ACPI tables */ unsigned int acpi_start; + + void (*apic_setup)(void); + void (*pci_setup)(void); + void (*smp_setup)(void); }; extern struct bios_config rombios_config; diff -r 700f2fd3d5fd -r f153a0d91b9f tools/firmware/hvmloader/hvmloader.c --- a/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 10:53:14 2011 +0100 +++ b/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 10:54:21 2011 +0100 @@ -24,13 +24,10 @@ #include "util.h" #include "hypercall.h" #include "config.h" -#include "apic_regs.h" #include "pci_regs.h" #include "option_rom.h" #include <xen/version.h> #include <xen/hvm/params.h> -#include <xen/hvm/ioreq.h> -#include <xen/memory.h> #define ROM_INCLUDE_VGABIOS #define ROM_INCLUDE_ETHERBOOT @@ -116,7 +113,7 @@ asm ( unsigned long pci_mem_start = PCI_MEM_START; unsigned long pci_mem_end = PCI_MEM_END; -static enum { VGA_none, VGA_std, VGA_cirrus, VGA_pt } virtual_vga = VGA_none; +enum virtual_vga virtual_vga = VGA_none; static void init_hypercalls(void) { @@ -152,231 +149,6 @@ static void init_hypercalls(void) printf("Detected Xen v%u.%u%s\n", eax >> 16, eax & 0xffff, extraversion); } -static void apic_setup(void) -{ - /* Set the IOAPIC ID to the static value used in the MP/ACPI tables. */ - ioapic_write(0x00, IOAPIC_ID); - - /* NMIs are delivered direct to the BSP. */ - lapic_write(APIC_SPIV, APIC_SPIV_APIC_ENABLED | 0xFF); - lapic_write(APIC_LVT0, (APIC_MODE_EXTINT << 8) | APIC_LVT_MASKED); - lapic_write(APIC_LVT1, APIC_MODE_NMI << 8); - - /* 8259A ExtInts are delivered through IOAPIC pin 0 (Virtual Wire Mode). */ - ioapic_write(0x10, APIC_DM_EXTINT); - ioapic_write(0x11, SET_APIC_ID(LAPIC_ID(0))); -} - -static void pci_setup(void) -{ - uint32_t base, devfn, bar_reg, bar_data, bar_sz, cmd, mmio_total = 0; - uint16_t class, vendor_id, device_id; - unsigned int bar, pin, link, isa_irq; - - /* Resources assignable to PCI devices via BARs. */ - struct resource { - uint32_t base, max; - } *resource, mem_resource, io_resource; - - /* Create a list of device BARs in descending order of size. */ - struct bars { - uint32_t devfn, bar_reg, bar_sz; - } *bars = (struct bars *)SCRATCH_PHYSICAL_ADDRESS; - unsigned int i, nr_bars = 0; - - /* Program PCI-ISA bridge with appropriate link routes. */ - isa_irq = 0; - for ( link = 0; link < 4; link++ ) - { - do { isa_irq = (isa_irq + 1) & 15; - } while ( !(PCI_ISA_IRQ_MASK & (1U << isa_irq)) ); - pci_writeb(PCI_ISA_DEVFN, 0x60 + link, isa_irq); - printf("PCI-ISA link %u routed to IRQ%u\n", link, isa_irq); - } - - /* Program ELCR to match PCI-wired IRQs. */ - outb(0x4d0, (uint8_t)(PCI_ISA_IRQ_MASK >> 0)); - outb(0x4d1, (uint8_t)(PCI_ISA_IRQ_MASK >> 8)); - - /* Scan the PCI bus and map resources. */ - for ( devfn = 0; devfn < 256; devfn++ ) - { - class = pci_readw(devfn, PCI_CLASS_DEVICE); - vendor_id = pci_readw(devfn, PCI_VENDOR_ID); - device_id = pci_readw(devfn, PCI_DEVICE_ID); - if ( (vendor_id == 0xffff) && (device_id == 0xffff) ) - continue; - - ASSERT((devfn != PCI_ISA_DEVFN) || - ((vendor_id == 0x8086) && (device_id == 0x7000))); - - switch ( class ) - { - case 0x0300: - /* If emulated VGA is found, preserve it as primary VGA. */ - if ( (vendor_id == 0x1234) && (device_id == 0x1111) ) - virtual_vga = VGA_std; - else if ( (vendor_id == 0x1013) && (device_id == 0xb8) ) - virtual_vga = VGA_cirrus; - else if ( virtual_vga == VGA_none ) - virtual_vga = VGA_pt; - break; - case 0x0680: - /* PIIX4 ACPI PM. Special device with special PCI config space. */ - ASSERT((vendor_id == 0x8086) && (device_id == 0x7113)); - pci_writew(devfn, 0x20, 0x0000); /* No smb bus IO enable */ - pci_writew(devfn, 0xd2, 0x0000); /* No smb bus IO enable */ - pci_writew(devfn, 0x22, 0x0000); - pci_writew(devfn, 0x3c, 0x0009); /* Hardcoded IRQ9 */ - pci_writew(devfn, 0x3d, 0x0001); - pci_writel(devfn, 0x40, ACPI_PM1A_EVT_BLK_ADDRESS_V1 | 1); - pci_writeb(devfn, 0x80, 0x01); /* enable PM io space */ - break; - case 0x0101: - if ( vendor_id == 0x8086 ) - { - /* Intel ICHs since PIIX3: enable IDE legacy mode. */ - pci_writew(devfn, 0x40, 0x8000); /* enable IDE0 */ - pci_writew(devfn, 0x42, 0x8000); /* enable IDE1 */ - } - break; - } - - /* Map the I/O memory and port resources. */ - for ( bar = 0; bar < 7; bar++ ) - { - bar_reg = PCI_BASE_ADDRESS_0 + 4*bar; - if ( bar == 6 ) - bar_reg = PCI_ROM_ADDRESS; - - bar_data = pci_readl(devfn, bar_reg); - pci_writel(devfn, bar_reg, ~0); - bar_sz = pci_readl(devfn, bar_reg); - pci_writel(devfn, bar_reg, bar_data); - if ( bar_sz == 0 ) - continue; - - bar_sz &= (((bar_data & PCI_BASE_ADDRESS_SPACE) =- PCI_BASE_ADDRESS_SPACE_MEMORY) ? - PCI_BASE_ADDRESS_MEM_MASK : - (PCI_BASE_ADDRESS_IO_MASK & 0xffff)); - bar_sz &= ~(bar_sz - 1); - - for ( i = 0; i < nr_bars; i++ ) - if ( bars[i].bar_sz < bar_sz ) - break; - - if ( i != nr_bars ) - memmove(&bars[i+1], &bars[i], (nr_bars-i) * sizeof(*bars)); - - bars[i].devfn = devfn; - bars[i].bar_reg = bar_reg; - bars[i].bar_sz = bar_sz; - - if ( (bar_data & PCI_BASE_ADDRESS_SPACE) =- PCI_BASE_ADDRESS_SPACE_MEMORY ) - mmio_total += bar_sz; - - nr_bars++; - - /* Skip the upper-half of the address for a 64-bit BAR. */ - if ( (bar_data & (PCI_BASE_ADDRESS_SPACE | - PCI_BASE_ADDRESS_MEM_TYPE_MASK)) == - (PCI_BASE_ADDRESS_SPACE_MEMORY | - PCI_BASE_ADDRESS_MEM_TYPE_64) ) - bar++; - } - - /* Map the interrupt. */ - pin = pci_readb(devfn, PCI_INTERRUPT_PIN); - if ( pin != 0 ) - { - /* This is the barber''s pole mapping used by Xen. */ - link = ((pin - 1) + (devfn >> 3)) & 3; - isa_irq = pci_readb(PCI_ISA_DEVFN, 0x60 + link); - pci_writeb(devfn, PCI_INTERRUPT_LINE, isa_irq); - printf("pci dev %02x:%x INT%c->IRQ%u\n", - devfn>>3, devfn&7, ''A''+pin-1, isa_irq); - } - - /* Enable bus mastering. */ - cmd = pci_readw(devfn, PCI_COMMAND); - cmd |= PCI_COMMAND_MASTER; - pci_writew(devfn, PCI_COMMAND, cmd); - } - - while ( (mmio_total > (pci_mem_end - pci_mem_start)) && - ((pci_mem_start << 1) != 0) ) - pci_mem_start <<= 1; - - while ( (pci_mem_start >> PAGE_SHIFT) < hvm_info->low_mem_pgend ) - { - struct xen_add_to_physmap xatp; - if ( hvm_info->high_mem_pgend == 0 ) - hvm_info->high_mem_pgend = 1ull << (32 - PAGE_SHIFT); - xatp.domid = DOMID_SELF; - xatp.space = XENMAPSPACE_gmfn; - xatp.idx = --hvm_info->low_mem_pgend; - xatp.gpfn = hvm_info->high_mem_pgend++; - if ( hypercall_memory_op(XENMEM_add_to_physmap, &xatp) != 0 ) - BUG(); - } - - mem_resource.base = pci_mem_start; - mem_resource.max = pci_mem_end; - io_resource.base = 0xc000; - io_resource.max = 0x10000; - - /* Assign iomem and ioport resources in descending order of size. */ - for ( i = 0; i < nr_bars; i++ ) - { - devfn = bars[i].devfn; - bar_reg = bars[i].bar_reg; - bar_sz = bars[i].bar_sz; - - bar_data = pci_readl(devfn, bar_reg); - - if ( (bar_data & PCI_BASE_ADDRESS_SPACE) =- PCI_BASE_ADDRESS_SPACE_MEMORY ) - { - resource = &mem_resource; - bar_data &= ~PCI_BASE_ADDRESS_MEM_MASK; - } - else - { - resource = &io_resource; - bar_data &= ~PCI_BASE_ADDRESS_IO_MASK; - } - - base = (resource->base + bar_sz - 1) & ~(bar_sz - 1); - bar_data |= base; - base += bar_sz; - - if ( (base < resource->base) || (base > resource->max) ) - { - printf("pci dev %02x:%x bar %02x size %08x: no space for " - "resource!\n", devfn>>3, devfn&7, bar_reg, bar_sz); - continue; - } - - resource->base = base; - - pci_writel(devfn, bar_reg, bar_data); - printf("pci dev %02x:%x bar %02x size %08x: %08x\n", - devfn>>3, devfn&7, bar_reg, bar_sz, bar_data); - - /* Now enable the memory or I/O mapping. */ - cmd = pci_readw(devfn, PCI_COMMAND); - if ( (bar_reg == PCI_ROM_ADDRESS) || - ((bar_data & PCI_BASE_ADDRESS_SPACE) =- PCI_BASE_ADDRESS_SPACE_MEMORY) ) - cmd |= PCI_COMMAND_MEMORY; - else - cmd |= PCI_COMMAND_IO; - pci_writew(devfn, PCI_COMMAND, cmd); - } -} - /* * Scan the list of Option ROMs at @roms for one which supports * PCI (@vendor_id, @device_id) found at slot @devfn. If one is found, @@ -608,10 +380,13 @@ int main(void) printf("CPU speed is %u MHz\n", get_cpu_mhz()); - apic_setup(); - pci_setup(); + if (bios->apic_setup) + bios->apic_setup(); + if (bios->pci_setup) + bios->pci_setup(); - smp_initialise(); + if (bios->smp_setup) + bios->smp_setup(); perform_tests(); diff -r 700f2fd3d5fd -r f153a0d91b9f tools/firmware/hvmloader/rombios.c --- a/tools/firmware/hvmloader/rombios.c Tue Apr 12 10:53:14 2011 +0100 +++ b/tools/firmware/hvmloader/rombios.c Tue Apr 12 10:54:21 2011 +0100 @@ -24,9 +24,241 @@ #include "../rombios/config.h" +#include "apic_regs.h" +#include "pci_regs.h" +#include "util.h" +#include "hypercall.h" + +#include <xen/hvm/ioreq.h> +#include <xen/memory.h> + #define ROM_INCLUDE_ROMBIOS #include "roms.inc" +static void rombios_apic_setup(void) +{ + /* Set the IOAPIC ID to the static value used in the MP/ACPI tables. */ + ioapic_write(0x00, IOAPIC_ID); + + /* NMIs are delivered direct to the BSP. */ + lapic_write(APIC_SPIV, APIC_SPIV_APIC_ENABLED | 0xFF); + lapic_write(APIC_LVT0, (APIC_MODE_EXTINT << 8) | APIC_LVT_MASKED); + lapic_write(APIC_LVT1, APIC_MODE_NMI << 8); + + /* 8259A ExtInts are delivered through IOAPIC pin 0 (Virtual Wire Mode). */ + ioapic_write(0x10, APIC_DM_EXTINT); + ioapic_write(0x11, SET_APIC_ID(LAPIC_ID(0))); +} + +static void rombios_pci_setup(void) +{ + uint32_t base, devfn, bar_reg, bar_data, bar_sz, cmd, mmio_total = 0; + uint16_t class, vendor_id, device_id; + unsigned int bar, pin, link, isa_irq; + + /* Resources assignable to PCI devices via BARs. */ + struct resource { + uint32_t base, max; + } *resource, mem_resource, io_resource; + + /* Create a list of device BARs in descending order of size. */ + struct bars { + uint32_t devfn, bar_reg, bar_sz; + } *bars = (struct bars *)SCRATCH_PHYSICAL_ADDRESS; + unsigned int i, nr_bars = 0; + + /* Program PCI-ISA bridge with appropriate link routes. */ + isa_irq = 0; + for ( link = 0; link < 4; link++ ) + { + do { isa_irq = (isa_irq + 1) & 15; + } while ( !(PCI_ISA_IRQ_MASK & (1U << isa_irq)) ); + pci_writeb(PCI_ISA_DEVFN, 0x60 + link, isa_irq); + printf("PCI-ISA link %u routed to IRQ%u\n", link, isa_irq); + } + + /* Program ELCR to match PCI-wired IRQs. */ + outb(0x4d0, (uint8_t)(PCI_ISA_IRQ_MASK >> 0)); + outb(0x4d1, (uint8_t)(PCI_ISA_IRQ_MASK >> 8)); + + /* Scan the PCI bus and map resources. */ + for ( devfn = 0; devfn < 256; devfn++ ) + { + class = pci_readw(devfn, PCI_CLASS_DEVICE); + vendor_id = pci_readw(devfn, PCI_VENDOR_ID); + device_id = pci_readw(devfn, PCI_DEVICE_ID); + if ( (vendor_id == 0xffff) && (device_id == 0xffff) ) + continue; + + ASSERT((devfn != PCI_ISA_DEVFN) || + ((vendor_id == 0x8086) && (device_id == 0x7000))); + + switch ( class ) + { + case 0x0300: + /* If emulated VGA is found, preserve it as primary VGA. */ + if ( (vendor_id == 0x1234) && (device_id == 0x1111) ) + virtual_vga = VGA_std; + else if ( (vendor_id == 0x1013) && (device_id == 0xb8) ) + virtual_vga = VGA_cirrus; + else if ( virtual_vga == VGA_none ) + virtual_vga = VGA_pt; + break; + case 0x0680: + /* PIIX4 ACPI PM. Special device with special PCI config space. */ + ASSERT((vendor_id == 0x8086) && (device_id == 0x7113)); + pci_writew(devfn, 0x20, 0x0000); /* No smb bus IO enable */ + pci_writew(devfn, 0xd2, 0x0000); /* No smb bus IO enable */ + pci_writew(devfn, 0x22, 0x0000); + pci_writew(devfn, 0x3c, 0x0009); /* Hardcoded IRQ9 */ + pci_writew(devfn, 0x3d, 0x0001); + pci_writel(devfn, 0x40, ACPI_PM1A_EVT_BLK_ADDRESS_V1 | 1); + pci_writeb(devfn, 0x80, 0x01); /* enable PM io space */ + break; + case 0x0101: + if ( vendor_id == 0x8086 ) + { + /* Intel ICHs since PIIX3: enable IDE legacy mode. */ + pci_writew(devfn, 0x40, 0x8000); /* enable IDE0 */ + pci_writew(devfn, 0x42, 0x8000); /* enable IDE1 */ + } + break; + } + + /* Map the I/O memory and port resources. */ + for ( bar = 0; bar < 7; bar++ ) + { + bar_reg = PCI_BASE_ADDRESS_0 + 4*bar; + if ( bar == 6 ) + bar_reg = PCI_ROM_ADDRESS; + + bar_data = pci_readl(devfn, bar_reg); + pci_writel(devfn, bar_reg, ~0); + bar_sz = pci_readl(devfn, bar_reg); + pci_writel(devfn, bar_reg, bar_data); + if ( bar_sz == 0 ) + continue; + + bar_sz &= (((bar_data & PCI_BASE_ADDRESS_SPACE) =+ PCI_BASE_ADDRESS_SPACE_MEMORY) ? + PCI_BASE_ADDRESS_MEM_MASK : + (PCI_BASE_ADDRESS_IO_MASK & 0xffff)); + bar_sz &= ~(bar_sz - 1); + + for ( i = 0; i < nr_bars; i++ ) + if ( bars[i].bar_sz < bar_sz ) + break; + + if ( i != nr_bars ) + memmove(&bars[i+1], &bars[i], (nr_bars-i) * sizeof(*bars)); + + bars[i].devfn = devfn; + bars[i].bar_reg = bar_reg; + bars[i].bar_sz = bar_sz; + + if ( (bar_data & PCI_BASE_ADDRESS_SPACE) =+ PCI_BASE_ADDRESS_SPACE_MEMORY ) + mmio_total += bar_sz; + + nr_bars++; + + /* Skip the upper-half of the address for a 64-bit BAR. */ + if ( (bar_data & (PCI_BASE_ADDRESS_SPACE | + PCI_BASE_ADDRESS_MEM_TYPE_MASK)) == + (PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_TYPE_64) ) + bar++; + } + + /* Map the interrupt. */ + pin = pci_readb(devfn, PCI_INTERRUPT_PIN); + if ( pin != 0 ) + { + /* This is the barber''s pole mapping used by Xen. */ + link = ((pin - 1) + (devfn >> 3)) & 3; + isa_irq = pci_readb(PCI_ISA_DEVFN, 0x60 + link); + pci_writeb(devfn, PCI_INTERRUPT_LINE, isa_irq); + printf("pci dev %02x:%x INT%c->IRQ%u\n", + devfn>>3, devfn&7, ''A''+pin-1, isa_irq); + } + + /* Enable bus mastering. */ + cmd = pci_readw(devfn, PCI_COMMAND); + cmd |= PCI_COMMAND_MASTER; + pci_writew(devfn, PCI_COMMAND, cmd); + } + + while ( (mmio_total > (pci_mem_end - pci_mem_start)) && + ((pci_mem_start << 1) != 0) ) + pci_mem_start <<= 1; + + while ( (pci_mem_start >> PAGE_SHIFT) < hvm_info->low_mem_pgend ) + { + struct xen_add_to_physmap xatp; + if ( hvm_info->high_mem_pgend == 0 ) + hvm_info->high_mem_pgend = 1ull << (32 - PAGE_SHIFT); + xatp.domid = DOMID_SELF; + xatp.space = XENMAPSPACE_gmfn; + xatp.idx = --hvm_info->low_mem_pgend; + xatp.gpfn = hvm_info->high_mem_pgend++; + if ( hypercall_memory_op(XENMEM_add_to_physmap, &xatp) != 0 ) + BUG(); + } + + mem_resource.base = pci_mem_start; + mem_resource.max = pci_mem_end; + io_resource.base = 0xc000; + io_resource.max = 0x10000; + + /* Assign iomem and ioport resources in descending order of size. */ + for ( i = 0; i < nr_bars; i++ ) + { + devfn = bars[i].devfn; + bar_reg = bars[i].bar_reg; + bar_sz = bars[i].bar_sz; + + bar_data = pci_readl(devfn, bar_reg); + + if ( (bar_data & PCI_BASE_ADDRESS_SPACE) =+ PCI_BASE_ADDRESS_SPACE_MEMORY ) + { + resource = &mem_resource; + bar_data &= ~PCI_BASE_ADDRESS_MEM_MASK; + } + else + { + resource = &io_resource; + bar_data &= ~PCI_BASE_ADDRESS_IO_MASK; + } + + base = (resource->base + bar_sz - 1) & ~(bar_sz - 1); + bar_data |= base; + base += bar_sz; + + if ( (base < resource->base) || (base > resource->max) ) + { + printf("pci dev %02x:%x bar %02x size %08x: no space for " + "resource!\n", devfn>>3, devfn&7, bar_reg, bar_sz); + continue; + } + + resource->base = base; + + pci_writel(devfn, bar_reg, bar_data); + printf("pci dev %02x:%x bar %02x size %08x: %08x\n", + devfn>>3, devfn&7, bar_reg, bar_sz, bar_data); + + /* Now enable the memory or I/O mapping. */ + cmd = pci_readw(devfn, PCI_COMMAND); + if ( (bar_reg == PCI_ROM_ADDRESS) || + ((bar_data & PCI_BASE_ADDRESS_SPACE) =+ PCI_BASE_ADDRESS_SPACE_MEMORY) ) + cmd |= PCI_COMMAND_MEMORY; + else + cmd |= PCI_COMMAND_IO; + pci_writew(devfn, PCI_COMMAND, cmd); + } +} //BUILD_BUG_ON(sizeof(rombios) > (0x00100000U - ROMBIOS_PHYSICAL_ADDRESS)); struct bios_config rombios_config = { @@ -45,6 +277,9 @@ struct bios_config rombios_config = { .acpi_start = ACPI_PHYSICAL_ADDRESS, + .apic_setup = rombios_apic_setup, + .pci_setup = rombios_pci_setup, + .smp_setup = smp_initialise, }; /* _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-12 11:29 UTC
[Xen-devel] [PATCH 13 of 19] tools: hvmloader: refactor highbios and bios_info setup into struct bios_config
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1302602206 -3600 # Node ID 99d1e52175a3d7770ab0cfe286133cf84954cf8d # Parent f153a0d91b9f7cc9fe9d84bf7d97ac6371793b03 tools: hvmloader: refactor highbios and bios_info setup into struct bios_config Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r f153a0d91b9f -r 99d1e52175a3 tools/firmware/hvmloader/32bitbios_support.c --- a/tools/firmware/hvmloader/32bitbios_support.c Tue Apr 12 10:54:21 2011 +0100 +++ b/tools/firmware/hvmloader/32bitbios_support.c Tue Apr 12 10:56:46 2011 +0100 @@ -144,7 +144,7 @@ static uint32_t relocate_32bitbios(char return (uint32_t)highbiosarea; } -uint32_t highbios_setup(void) +uint32_t rombios_highbios_setup(void) { return relocate_32bitbios((char *)highbios_array, sizeof(highbios_array)); } diff -r f153a0d91b9f -r 99d1e52175a3 tools/firmware/hvmloader/config.h --- a/tools/firmware/hvmloader/config.h Tue Apr 12 10:54:21 2011 +0100 +++ b/tools/firmware/hvmloader/config.h Tue Apr 12 10:56:46 2011 +0100 @@ -28,6 +28,9 @@ struct bios_config { void (*apic_setup)(void); void (*pci_setup)(void); void (*smp_setup)(void); + + uint32_t (*bios_high_setup)(void); + void (*bios_info_setup)(uint32_t); }; extern struct bios_config rombios_config; diff -r f153a0d91b9f -r 99d1e52175a3 tools/firmware/hvmloader/hvmloader.c --- a/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 10:54:21 2011 +0100 +++ b/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 10:56:46 2011 +0100 @@ -364,10 +364,10 @@ static const struct bios_config *detect_ int main(void) { + uint32_t highbios = 0; const struct bios_config *bios; int option_rom_sz = 0, vgabios_sz = 0, etherboot_sz = 0, smbios_sz = 0; - uint32_t etherboot_phys_addr, option_rom_phys_addr, bios32_addr; - struct bios_info *bios_info; + uint32_t etherboot_phys_addr, option_rom_phys_addr; printf("HVM Loader\n"); @@ -400,7 +400,9 @@ int main(void) printf("Loading %s ...\n", bios->name); memcpy((void *)bios->bios_address, bios->image, bios->image_size); - bios32_addr = highbios_setup(); + + if (bios->bios_high_setup) + highbios = bios->bios_high_setup(); if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode ) create_mp_tables(); @@ -480,17 +482,8 @@ int main(void) *E820_NR = build_e820_table(E820); dump_e820_table(E820, *E820_NR); - 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->lpt1_present = lpt_exists(0x378); - 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->madt_csum_addr = madt_csum_addr; - bios_info->madt_lapic0_addr = madt_lapic0_addr; - bios_info->bios32_entry = bios32_addr; + if (bios->bios_info_setup) + bios->bios_info_setup(highbios); xenbus_shutdown(); diff -r f153a0d91b9f -r 99d1e52175a3 tools/firmware/hvmloader/rombios.c --- a/tools/firmware/hvmloader/rombios.c Tue Apr 12 10:54:21 2011 +0100 +++ b/tools/firmware/hvmloader/rombios.c Tue Apr 12 10:56:46 2011 +0100 @@ -24,6 +24,7 @@ #include "../rombios/config.h" +#include "acpi/acpi2_0.h" #include "apic_regs.h" #include "pci_regs.h" #include "util.h" @@ -35,6 +36,23 @@ #define ROM_INCLUDE_ROMBIOS #include "roms.inc" +static void rombios_setup_bios_info(uint32_t bioshigh) +{ + struct bios_info *bios_info; + + 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->lpt1_present = lpt_exists(0x378); + 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->madt_csum_addr = madt_csum_addr; + bios_info->madt_lapic0_addr = madt_lapic0_addr; + bios_info->bios32_entry = bioshigh; +} + static void rombios_apic_setup(void) { /* Set the IOAPIC ID to the static value used in the MP/ACPI tables. */ @@ -280,6 +298,9 @@ struct bios_config rombios_config = { .apic_setup = rombios_apic_setup, .pci_setup = rombios_pci_setup, .smp_setup = smp_initialise, + + .bios_high_setup = rombios_highbios_setup, + .bios_info_setup = rombios_setup_bios_info, }; /* diff -r f153a0d91b9f -r 99d1e52175a3 tools/firmware/hvmloader/util.h --- a/tools/firmware/hvmloader/util.h Tue Apr 12 10:54:21 2011 +0100 +++ b/tools/firmware/hvmloader/util.h Tue Apr 12 10:56:46 2011 +0100 @@ -181,7 +181,7 @@ void xenbus_shutdown(void); char *xenstore_read(char *path); /* Prepare the 32bit BIOS */ -uint32_t highbios_setup(void); +uint32_t rombios_highbios_setup(void); /* Miscellaneous. */ void cacheattr_init(void); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-12 11:29 UTC
[Xen-devel] [PATCH 14 of 19] tools: hvmloader: Refactor VM86 and E820 setup into struct bios_config
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1302602711 -3600 # Node ID 31e9da762b1ebd22b5ed68d3a15ea56f4a41d63c # Parent 99d1e52175a3d7770ab0cfe286133cf84954cf8d tools: hvmloader: Refactor VM86 and E820 setup into struct bios_config Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 99d1e52175a3 -r 31e9da762b1e tools/firmware/hvmloader/config.h --- a/tools/firmware/hvmloader/config.h Tue Apr 12 10:56:46 2011 +0100 +++ b/tools/firmware/hvmloader/config.h Tue Apr 12 11:05:11 2011 +0100 @@ -31,6 +31,9 @@ struct bios_config { uint32_t (*bios_high_setup)(void); void (*bios_info_setup)(uint32_t); + + void (*vm86_setup)(void); + void (*e820_setup)(void); }; extern struct bios_config rombios_config; @@ -62,9 +65,6 @@ extern unsigned long pci_mem_start, pci_ #define ROMBIOS_MAXOFFSET 0x0000FFFF #define ROMBIOS_END (ROMBIOS_BEGIN + ROMBIOS_SIZE) -#include "e820.h" -#include "../rombios/config.h" - #define SCRATCH_PHYSICAL_ADDRESS 0x00010000 #define HYPERCALL_PHYSICAL_ADDRESS 0x00080000 diff -r 99d1e52175a3 -r 31e9da762b1e tools/firmware/hvmloader/hvmloader.c --- a/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 10:56:46 2011 +0100 +++ b/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 11:05:11 2011 +0100 @@ -338,24 +338,6 @@ static void cmos_write_memory_size(void) cmos_outb(0x35, (uint8_t)( alt_mem >> 8)); } -/* - * Set up an empty TSS area for virtual 8086 mode to use. - * The only important thing is that it musn''t have any bits set - * in the interrupt redirection bitmap, so all zeros will do. - */ -static void init_vm86_tss(void) -{ - void *tss; - struct xen_hvm_param p; - - tss = mem_alloc(128, 128); - memset(tss, 0, 128); - p.domid = DOMID_SELF; - p.index = HVM_PARAM_VM86_TSS; - p.value = virt_to_phys(tss); - hypercall_hvm_op(HVMOP_set_param, &p); - printf("vm86 TSS at %08lx\n", virt_to_phys(tss)); -} static const struct bios_config *detect_bios(void) { @@ -454,7 +436,8 @@ int main(void) hypercall_hvm_op(HVMOP_set_param, &p); } - init_vm86_tss(); + if (bios->vm86_setup) + bios->vm86_setup(); cmos_write_memory_size(); @@ -479,8 +462,8 @@ int main(void) bios->bios_address, bios->bios_address + bios->image_size - 1); - *E820_NR = build_e820_table(E820); - dump_e820_table(E820, *E820_NR); + if (bios->e820_setup) + bios->e820_setup(); if (bios->bios_info_setup) bios->bios_info_setup(highbios); diff -r 99d1e52175a3 -r 31e9da762b1e tools/firmware/hvmloader/rombios.c --- a/tools/firmware/hvmloader/rombios.c Tue Apr 12 10:56:46 2011 +0100 +++ b/tools/firmware/hvmloader/rombios.c Tue Apr 12 11:05:11 2011 +0100 @@ -30,12 +30,38 @@ #include "util.h" #include "hypercall.h" +#include <xen/hvm/params.h> #include <xen/hvm/ioreq.h> #include <xen/memory.h> #define ROM_INCLUDE_ROMBIOS #include "roms.inc" +/* + * Set up an empty TSS area for virtual 8086 mode to use. + * The only important thing is that it musn''t have any bits set + * in the interrupt redirection bitmap, so all zeros will do. + */ +static void rombios_init_vm86_tss(void) +{ + void *tss; + struct xen_hvm_param p; + + tss = mem_alloc(128, 128); + memset(tss, 0, 128); + p.domid = DOMID_SELF; + p.index = HVM_PARAM_VM86_TSS; + p.value = virt_to_phys(tss); + hypercall_hvm_op(HVMOP_set_param, &p); + printf("vm86 TSS at %08lx\n", virt_to_phys(tss)); +} + +static void rombios_setup_e820(void) +{ + *E820_NR = build_e820_table(E820); + dump_e820_table(E820, *E820_NR); +} + static void rombios_setup_bios_info(uint32_t bioshigh) { struct bios_info *bios_info; @@ -301,6 +327,9 @@ struct bios_config rombios_config = { .bios_high_setup = rombios_highbios_setup, .bios_info_setup = rombios_setup_bios_info, + + .vm86_setup = rombios_init_vm86_tss, + .e820_setup = rombios_setup_e820, }; /* _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-12 11:29 UTC
[Xen-devel] [PATCH 15 of 19] tools: hvmloader: Refactor ACPI table setup into struct bios_config
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1302603558 -3600 # Node ID 63da98f210b0f708a6bd2f85bc03de8826655784 # Parent 31e9da762b1ebd22b5ed68d3a15ea56f4a41d63c tools: hvmloader: Refactor ACPI table setup into struct bios_config Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 31e9da762b1e -r 63da98f210b0 tools/firmware/hvmloader/config.h --- a/tools/firmware/hvmloader/config.h Tue Apr 12 11:05:11 2011 +0100 +++ b/tools/firmware/hvmloader/config.h Tue Apr 12 11:19:18 2011 +0100 @@ -34,6 +34,8 @@ struct bios_config { void (*vm86_setup)(void); void (*e820_setup)(void); + + void (*acpi_build_tables)(unsigned int physical); }; extern struct bios_config rombios_config; diff -r 31e9da762b1e -r 63da98f210b0 tools/firmware/hvmloader/hvmloader.c --- a/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 11:05:11 2011 +0100 +++ b/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 11:19:18 2011 +0100 @@ -20,7 +20,6 @@ * Place - Suite 330, Boston, MA 02111-1307 USA. */ -#include "acpi/acpi2_0.h" #include "util.h" #include "hypercall.h" #include "config.h" @@ -431,8 +430,10 @@ int main(void) .value = 1, }; - printf("Loading ACPI ...\n"); - acpi_build_tables(bios->acpi_start); + if ( bios->acpi_build_tables ) { + printf("Loading ACPI ...\n"); + bios->acpi_build_tables(bios->acpi_start); + } hypercall_hvm_op(HVMOP_set_param, &p); } diff -r 31e9da762b1e -r 63da98f210b0 tools/firmware/hvmloader/rombios.c --- a/tools/firmware/hvmloader/rombios.c Tue Apr 12 11:05:11 2011 +0100 +++ b/tools/firmware/hvmloader/rombios.c Tue Apr 12 11:19:18 2011 +0100 @@ -330,6 +330,8 @@ struct bios_config rombios_config = { .vm86_setup = rombios_init_vm86_tss, .e820_setup = rombios_setup_e820, + + .acpi_build_tables = acpi_build_tables, }; /* _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-12 11:29 UTC
[Xen-devel] [PATCH 16 of 19] tools: hvmloader: Refactor MP table setup into struct bios_config
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1302603807 -3600 # Node ID 7bddcc4cfc8789cffe511b0b38645479d8d3490d # Parent 63da98f210b0f708a6bd2f85bc03de8826655784 tools: hvmloader: Refactor MP table setup into struct bios_config Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 63da98f210b0 -r 7bddcc4cfc87 tools/firmware/hvmloader/config.h --- a/tools/firmware/hvmloader/config.h Tue Apr 12 11:19:18 2011 +0100 +++ b/tools/firmware/hvmloader/config.h Tue Apr 12 11:23:27 2011 +0100 @@ -36,6 +36,7 @@ struct bios_config { void (*e820_setup)(void); void (*acpi_build_tables)(unsigned int physical); + void (*create_mp_tables)(void); }; extern struct bios_config rombios_config; @@ -62,11 +63,6 @@ extern unsigned long pci_mem_start, pci_ #define RESERVED_MEMBASE 0xfc000000 #define RESERVED_MEMSIZE 0x01000000 -#define ROMBIOS_BEGIN 0x000F0000 -#define ROMBIOS_SIZE 0x00010000 -#define ROMBIOS_MAXOFFSET 0x0000FFFF -#define ROMBIOS_END (ROMBIOS_BEGIN + ROMBIOS_SIZE) - #define SCRATCH_PHYSICAL_ADDRESS 0x00010000 #define HYPERCALL_PHYSICAL_ADDRESS 0x00080000 diff -r 63da98f210b0 -r 7bddcc4cfc87 tools/firmware/hvmloader/hvmloader.c --- a/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 11:19:18 2011 +0100 +++ b/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 11:23:27 2011 +0100 @@ -385,8 +385,9 @@ int main(void) if (bios->bios_high_setup) highbios = bios->bios_high_setup(); - if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode ) - create_mp_tables(); + if ( bios->create_mp_tables && + ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode ) ) + bios->create_mp_tables(); switch ( virtual_vga ) { diff -r 63da98f210b0 -r 7bddcc4cfc87 tools/firmware/hvmloader/mp_tables.c --- a/tools/firmware/hvmloader/mp_tables.c Tue Apr 12 11:19:18 2011 +0100 +++ b/tools/firmware/hvmloader/mp_tables.c Tue Apr 12 11:23:27 2011 +0100 @@ -259,46 +259,9 @@ static void fill_mpfps(struct mp_floatin mpfps->checksum = -checksum; } - -/* - * find_mp_table_start - searchs through BIOS memory for ''___HVMMP'' signature - * - * The ''___HVMMP'' signature is created by the ROMBIOS and designates a chunk - * of space inside the ROMBIOS that is safe for us to write our MP table info - */ -static void *get_mp_table_start(void) +/* create_mp_tables - creates MP tables for the guest based upon config data */ +void create_mp_tables(void *mp_table_base) { - char *bios_mem; - - for ( bios_mem = (char *)ROMBIOS_BEGIN; - bios_mem != (char *)ROMBIOS_END; - bios_mem++ ) - { - if ( strncmp(bios_mem, "___HVMMP", 8) == 0) - return bios_mem; - } - - return NULL; -} - - -/* recalculate the new ROMBIOS checksum after adding MP tables */ -static void reset_bios_checksum(void) -{ - uint32_t i; - uint8_t checksum; - - checksum = 0; - for (i = 0; i < ROMBIOS_MAXOFFSET; ++i) - checksum += ((uint8_t *)(ROMBIOS_BEGIN))[i]; - - *((uint8_t *)(ROMBIOS_BEGIN + ROMBIOS_MAXOFFSET)) = -checksum; -} - -/* create_mp_tables - creates MP tables for the guest based upon config data */ -void create_mp_tables(void) -{ - void *mp_table_base; char *p; int vcpu_nr, i, length; struct mp_io_intr_entry *mpiie; @@ -307,14 +270,6 @@ void create_mp_tables(void) printf("Creating MP tables ...\n"); - /* Find the ''safe'' place in ROMBIOS for the MP tables. */ - mp_table_base = get_mp_table_start(); - if ( mp_table_base == NULL ) - { - printf("Couldn''t find start point for MP tables\n"); - return; - } - p = mp_table_base + sizeof(struct mp_config_table); for ( i = 0; i < vcpu_nr; i++ ) @@ -363,5 +318,4 @@ void create_mp_tables(void) (uint32_t)mp_table_base); fill_mp_config_table((struct mp_config_table *)mp_table_base, length); - reset_bios_checksum(); } diff -r 63da98f210b0 -r 7bddcc4cfc87 tools/firmware/hvmloader/rombios.c --- a/tools/firmware/hvmloader/rombios.c Tue Apr 12 11:19:18 2011 +0100 +++ b/tools/firmware/hvmloader/rombios.c Tue Apr 12 11:23:27 2011 +0100 @@ -37,6 +37,11 @@ #define ROM_INCLUDE_ROMBIOS #include "roms.inc" +#define ROMBIOS_BEGIN 0x000F0000 +#define ROMBIOS_SIZE 0x00010000 +#define ROMBIOS_MAXOFFSET 0x0000FFFF +#define ROMBIOS_END (ROMBIOS_BEGIN + ROMBIOS_SIZE) + /* * Set up an empty TSS area for virtual 8086 mode to use. * The only important thing is that it musn''t have any bits set @@ -303,6 +308,57 @@ static void rombios_pci_setup(void) pci_writew(devfn, PCI_COMMAND, cmd); } } + +/* + * find_mp_table_start - searchs through BIOS memory for ''___HVMMP'' signature + * + * The ''___HVMMP'' signature is created by the ROMBIOS and designates a chunk + * of space inside the ROMBIOS that is safe for us to write our MP table info + */ +static void *get_mp_table_start(void) +{ + char *bios_mem; + + for ( bios_mem = (char *)ROMBIOS_BEGIN; + bios_mem != (char *)ROMBIOS_END; + bios_mem++ ) + { + if ( strncmp(bios_mem, "___HVMMP", 8) == 0) + return bios_mem; + } + + return NULL; +} + +/* recalculate the new ROMBIOS checksum after adding MP tables */ +static void reset_bios_checksum(void) +{ + uint32_t i; + uint8_t checksum; + + checksum = 0; + for (i = 0; i < ROMBIOS_MAXOFFSET; ++i) + checksum += ((uint8_t *)(ROMBIOS_BEGIN))[i]; + + *((uint8_t *)(ROMBIOS_BEGIN + ROMBIOS_MAXOFFSET)) = -checksum; +} + +static void rombios_create_mp_tables(void) +{ + /* Find the ''safe'' place in ROMBIOS for the MP tables. */ + void *table = get_mp_table_start(); + + if ( table == NULL ) + { + printf("Couldn''t find start point for MP tables\n"); + return; + } + + create_mp_tables(table); + + reset_bios_checksum(); +} + //BUILD_BUG_ON(sizeof(rombios) > (0x00100000U - ROMBIOS_PHYSICAL_ADDRESS)); struct bios_config rombios_config = { @@ -332,6 +388,7 @@ struct bios_config rombios_config = { .e820_setup = rombios_setup_e820, .acpi_build_tables = acpi_build_tables, + .create_mp_tables = rombios_create_mp_tables, }; /* diff -r 63da98f210b0 -r 7bddcc4cfc87 tools/firmware/hvmloader/util.h --- a/tools/firmware/hvmloader/util.h Tue Apr 12 11:19:18 2011 +0100 +++ b/tools/firmware/hvmloader/util.h Tue Apr 12 11:23:27 2011 +0100 @@ -185,7 +185,7 @@ uint32_t rombios_highbios_setup(void); /* Miscellaneous. */ void cacheattr_init(void); -void create_mp_tables(void); +void create_mp_tables(void *table); int hvm_write_smbios_tables(unsigned long scratch, unsigned long smbios_start, unsigned long smbios_end); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-12 11:29 UTC
[Xen-devel] [PATCH 17 of 19] tools: libxl: hide selection of device-model, hvmloader and BIOS by default
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1302607225 -3600 # Node ID 20dcc3b31fd416636a69dc7c528ef486adc9dacc # Parent 7bddcc4cfc8789cffe511b0b38645479d8d3490d tools: libxl: hide selection of device-model, hvmloader and BIOS by default. These should never have been exposed to users as something they are required to think about, unless they want to. At the libxl API level: * Move libxl_domain_build_info.kernel into the PV side of the tagged union (using this field to specify both PV kernel and hvmloader is confusing) * Add hvmloader (a string) to the HVM side of the tagged union. * Add libxl_device_model_info.device_model_version allowing the user to say which qemu version (e.g. old qemu-xen or qemu upstream) they want for a domain. * Default both the hvmloader and device_model fields to NULL and DTRT when building a domain with that value in those fields, but still allow libxl users to specify something explicit if they want. * Note that libxl_device_model_info.device_model, if specified, must now be a complete path. At the xl level: * WARN if an HVM guest cfg uses the "kernel" config option, and direct users to the "hvmloader_override" option if they really do not want the default hvmloader. * WARN if an HVM guest cfg uses the "device_model" config option, and again direct users to the "device_model_override" option if they really do not want the default. * Support a new "device_model_version" option which sets the new libxl_device_model_info.device_model_version field. This option is mandatory if device_model_override is used (other toolstacks would do something similar presumably) The default qemu remains the existing qemu-xen based qemu-dm. I suspect that the vast majority of users only have these config options because they''ve copied them from somewhere and they normally have no interest in which specific hvmloader or device model is used. Renaming the fields and warning when they are used makes these decisions internal. This will allow us to make decisions at a platform level regarding the preferred hvmloader, device model, stub domain etc without requiring everyone to change their configuration files. Adding a device model version to the API is intended to make it easy for users to select what they need without having to know about the paths to specific binaries etc. Most importantly it gets rid of the parsing of the output of qemu -h... It''s not clear where upstream qemu will eventually be installed, I went with /usr/bin/qemu for now. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 7bddcc4cfc87 -r 20dcc3b31fd4 tools/libxl/libxl.c --- a/tools/libxl/libxl.c Tue Apr 12 11:23:27 2011 +0100 +++ b/tools/libxl/libxl.c Tue Apr 12 12:20:25 2011 +0100 @@ -2276,15 +2276,17 @@ out: int libxl_domain_need_memory(libxl_ctx *ctx, libxl_domain_build_info *b_info, libxl_device_model_info *dm_info, uint32_t *need_memkb) { + libxl__gc gc = LIBXL_INIT_GC(ctx); *need_memkb = b_info->target_memkb; if (b_info->hvm) { *need_memkb += b_info->shadow_memkb + LIBXL_HVM_EXTRA_MEMORY; - if (strstr(dm_info->device_model, "stubdom-dm")) + if (strstr(libxl__domain_device_model(&gc, dm_info), "stubdom-dm")) *need_memkb += 32 * 1024; } else *need_memkb += b_info->shadow_memkb + LIBXL_PV_EXTRA_MEMORY; if (*need_memkb % (2 * 1024)) *need_memkb += (2 * 1024) - (*need_memkb % (2 * 1024)); + libxl__free_all(&gc); return 0; } diff -r 7bddcc4cfc87 -r 20dcc3b31fd4 tools/libxl/libxl.h --- a/tools/libxl/libxl.h Tue Apr 12 11:23:27 2011 +0100 +++ b/tools/libxl/libxl.h Tue Apr 12 12:20:25 2011 +0100 @@ -257,6 +257,12 @@ typedef enum libxl_action_on_shutdown { LIBXL_ACTION_COREDUMP_RESTART, } libxl_action_on_shutdown; +/* + * 1 - Historical qemu-xen device model (qemu-dm) + * 2 - Upstream qemu + */ +#define LIBXL_DEVICE_MODEL_VERSION_DEFAULT 1 + typedef struct { libxl_domain_create_info c_info; libxl_domain_build_info b_info; diff -r 7bddcc4cfc87 -r 20dcc3b31fd4 tools/libxl/libxl.idl --- a/tools/libxl/libxl.idl Tue Apr 12 11:23:27 2011 +0100 +++ b/tools/libxl/libxl.idl Tue Apr 12 12:20:25 2011 +0100 @@ -95,12 +95,12 @@ libxl_domain_build_info = Struct("domain ("video_memkb", uint32), ("shadow_memkb", uint32), ("disable_migrate", bool), - ("kernel", libxl_file_reference), ("cpuid", libxl_cpuid_policy_list), ("hvm", integer), ("u", KeyedUnion(None, "hvm", [("hvm", "%s", Struct(None, - [("pae", bool), + [("hvmloader", string), + ("pae", bool), ("apic", bool), ("acpi", bool), ("nx", bool), @@ -112,7 +112,8 @@ libxl_domain_build_info = Struct("domain ("nested_hvm", bool), ])), ("pv", "!%s", Struct(None, - [("slack_memkb", uint32), + [("kernel", libxl_file_reference), + ("slack_memkb", uint32), ("bootloader", string), ("bootloader_args", string), ("cmdline", string), @@ -139,7 +140,8 @@ libxl_device_model_info = Struct("device ("domid", integer), ("uuid", libxl_uuid, False, "this is use only with stubdom, and must be different from the domain uuid"), ("dom_name", string), - ("device_model", string), + ("device_model_version", integer), + ("device_model", string, False, "if you set this you must set device_model_version too"), ("saved_state", string), ("type", libxl_qemu_machine_type), ("target_ram", uint32), diff -r 7bddcc4cfc87 -r 20dcc3b31fd4 tools/libxl/libxl_bootloader.c --- a/tools/libxl/libxl_bootloader.c Tue Apr 12 11:23:27 2011 +0100 +++ b/tools/libxl/libxl_bootloader.c Tue Apr 12 12:20:25 2011 +0100 @@ -44,8 +44,9 @@ static char **make_bootloader_args(libxl flexarray_set(args, nr++, (char *)info->u.pv.bootloader); - if (info->kernel.path) - flexarray_set(args, nr++, libxl__sprintf(gc, "--kernel=%s", info->kernel.path)); + if (info->u.pv.kernel.path) + flexarray_set(args, nr++, libxl__sprintf(gc, "--kernel=%s", + info->u.pv.kernel.path)); if (info->u.pv.ramdisk.path) flexarray_set(args, nr++, libxl__sprintf(gc, "--ramdisk=%s", info->u.pv.ramdisk.path)); if (info->u.pv.cmdline && *info->u.pv.cmdline != ''\0'') @@ -277,10 +278,10 @@ static void parse_bootloader_result(libx { while (*o != ''\0'') { if (strncmp("kernel ", o, strlen("kernel ")) == 0) { - free(info->kernel.path); - info->kernel.path = strdup(o + strlen("kernel ")); - libxl__file_reference_map(&info->kernel); - unlink(info->kernel.path); + free(info->u.pv.kernel.path); + info->u.pv.kernel.path = strdup(o + strlen("kernel ")); + libxl__file_reference_map(&info->u.pv.kernel); + unlink(info->u.pv.kernel.path); } else if (strncmp("ramdisk ", o, strlen("ramdisk ")) == 0) { free(info->u.pv.ramdisk.path); info->u.pv.ramdisk.path = strdup(o + strlen("ramdisk ")); diff -r 7bddcc4cfc87 -r 20dcc3b31fd4 tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Tue Apr 12 11:23:27 2011 +0100 +++ b/tools/libxl/libxl_create.c Tue Apr 12 12:20:25 2011 +0100 @@ -88,8 +88,8 @@ void libxl_init_build_info(libxl_domain_ b_info->shadow_memkb = 0; if (c_info->hvm) { b_info->video_memkb = 8 * 1024; - b_info->kernel.path = strdup("hvmloader"); b_info->hvm = 1; + b_info->u.hvm.hvmloader = NULL; b_info->u.hvm.pae = 1; b_info->u.hvm.apic = 1; b_info->u.hvm.acpi = 1; @@ -112,7 +112,8 @@ void libxl_init_dm_info(libxl_device_mod libxl_uuid_generate(&dm_info->uuid); dm_info->dom_name = strdup(c_info->name); - dm_info->device_model = strdup("qemu-dm"); + dm_info->device_model_version = LIBXL_DEVICE_MODEL_VERSION_DEFAULT; + dm_info->device_model = NULL; dm_info->target_ram = libxl__sizekb_to_mb(b_info->target_memkb); dm_info->videoram = libxl__sizekb_to_mb(b_info->video_memkb); dm_info->apic = b_info->u.hvm.apic; @@ -182,7 +183,7 @@ int libxl__domain_build(libxl__gc *gc, l vments[i++] = "image/ostype"; vments[i++] = "linux"; vments[i++] = "image/kernel"; - vments[i++] = (char*) info->kernel.path; + vments[i++] = (char*) info->u.pv.kernel.path; vments[i++] = "start_time"; vments[i++] = libxl__sprintf(gc, "%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000); if (info->u.pv.ramdisk.path) { @@ -232,7 +233,7 @@ static int domain_restore(libxl__gc *gc, vments[i++] = "image/ostype"; vments[i++] = "linux"; vments[i++] = "image/kernel"; - vments[i++] = (char*) info->kernel.path; + vments[i++] = (char*) info->u.pv.kernel.path; vments[i++] = "start_time"; vments[i++] = libxl__sprintf(gc, "%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000); if (info->u.pv.ramdisk.path) { @@ -256,9 +257,10 @@ static int domain_restore(libxl__gc *gc, } out: - libxl__file_reference_unmap(&info->kernel); - if (!info->hvm) - libxl__file_reference_unmap(&info->u.pv.ramdisk); + if (!info->hvm) { + libxl__file_reference_unmap(&info->u.pv.kernel); + libxl__file_reference_unmap(&info->u.pv.ramdisk); + } esave = errno; diff -r 7bddcc4cfc87 -r 20dcc3b31fd4 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Tue Apr 12 11:23:27 2011 +0100 +++ b/tools/libxl/libxl_dm.c Tue Apr 12 12:20:25 2011 +0100 @@ -38,7 +38,36 @@ static const char *libxl_tapif_script(li #endif } +const char *libxl__domain_device_model(libxl__gc *gc, + libxl_device_model_info *info) +{ + libxl_ctx *ctx = libxl__gc_owner(gc); + const char *dm; + + if (info->device_model) { + dm = libxl__strdup(gc, info->device_model); + } else { + switch (info->device_model_version) { + case 1: + dm = libxl__abs_path(gc, "qemu-dm", libxl_libexec_path()); + break; + case 2: + dm = libxl__strdup(gc, "/usr/bin/qemu"); + break; + default: + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, + "invalid device model version %d\n", + info->device_model_version); + dm = NULL; + break; + } + } + + return dm; +} + static char ** libxl__build_device_model_args_old(libxl__gc *gc, + const char *dm, libxl_device_model_info *info, libxl_device_disk *disks, int num_disks, libxl_device_nic *vifs, int num_vifs) @@ -50,7 +79,8 @@ static char ** libxl__build_device_model if (!dm_args) return NULL; - flexarray_vappend(dm_args, "qemu-dm", "-d", libxl__sprintf(gc, "%d", info->domid), NULL); + flexarray_vappend(dm_args, dm, + "-d", libxl__sprintf(gc, "%d", info->domid), NULL); if (info->dom_name) flexarray_vappend(dm_args, "-domain-name", info->dom_name, NULL); @@ -183,6 +213,7 @@ static const char *qemu_disk_format_stri } static char ** libxl__build_device_model_args_new(libxl__gc *gc, + const char *dm, libxl_device_model_info *info, libxl_device_disk *disks, int num_disks, libxl_device_nic *vifs, int num_vifs) @@ -195,8 +226,8 @@ static char ** libxl__build_device_model if (!dm_args) return NULL; - flexarray_vappend(dm_args, libxl__strdup(gc, info->device_model), - "-xen-domid", libxl__sprintf(gc, "%d", info->domid), NULL); + flexarray_vappend(dm_args, dm, + "-xen-domid", libxl__sprintf(gc, "%d", info->domid), NULL); if (info->type == XENPV) { flexarray_append(dm_args, "-xen-attach"); @@ -385,19 +416,26 @@ static char ** libxl__build_device_model } static char ** libxl__build_device_model_args(libxl__gc *gc, + const char *dm, libxl_device_model_info *info, libxl_device_disk *disks, int num_disks, libxl_device_nic *vifs, int num_vifs) { libxl_ctx *ctx = libxl__gc_owner(gc); - int new_qemu; - new_qemu = libxl_check_device_model_version(ctx, info->device_model); - - if (new_qemu == 1) { - return libxl__build_device_model_args_new(gc, info, disks, num_disks, vifs, num_vifs); - } else { - return libxl__build_device_model_args_old(gc, info, disks, num_disks, vifs, num_vifs); + switch (info->device_model_version) { + case 1: + return libxl__build_device_model_args_old(gc, dm, info, + disks, num_disks, + vifs, num_vifs); + case 2: + return libxl__build_device_model_args_new(gc, dm, info, + disks, num_disks, + vifs, num_vifs); + default: + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unknown device model version %d", + info->device_model_version); + return NULL; } } @@ -499,6 +537,7 @@ retry_transaction: } static int libxl__create_stubdom(libxl__gc *gc, + const char *dm, libxl_device_model_info *info, libxl_device_disk *disks, int num_disks, libxl_device_nic *vifs, int num_vifs, @@ -518,7 +557,8 @@ static int libxl__create_stubdom(libxl__ xs_transaction_t t; libxl__device_model_starting *dm_starting = 0; - args = libxl__build_device_model_args(gc, info, disks, num_disks, + args = libxl__build_device_model_args(gc, dm, info, + disks, num_disks, vifs, num_vifs); if (!args) { ret = ERROR_FAIL; @@ -535,7 +575,8 @@ static int libxl__create_stubdom(libxl__ b_info.max_vcpus = 1; b_info.max_memkb = 32 * 1024; b_info.target_memkb = b_info.max_memkb; - b_info.kernel.path = libxl__abs_path(gc, "ioemu-stubdom.gz", libxl_xenfirmwaredir_path()); + b_info.u.pv.kernel.path = libxl__abs_path(gc, "ioemu-stubdom.gz", + libxl_xenfirmwaredir_path()); b_info.u.pv.cmdline = libxl__sprintf(gc, " -d %d", info->domid); b_info.u.pv.ramdisk.path = ""; b_info.u.pv.features = ""; @@ -683,17 +724,27 @@ int libxl__create_device_model(libxl__gc xs_transaction_t t; char *vm_path; char **pass_stuff; + const char *dm; - if (strstr(info->device_model, "stubdom-dm")) { + dm = libxl__domain_device_model(gc, info); + if (!dm) { + rc = ERROR_FAIL; + goto out; + } + + if (strstr(dm, "stubdom-dm")) { libxl_device_vfb vfb; libxl_device_vkb vkb; libxl__vfb_and_vkb_from_device_model_info(gc, info, &vfb, &vkb); - rc = libxl__create_stubdom(gc, info, disks, num_disks, vifs, num_vifs, &vfb, &vkb, starting_r); + rc = libxl__create_stubdom(gc, dm, info, + disks, num_disks, + vifs, num_vifs, + &vfb, &vkb, starting_r); goto out; } - args = libxl__build_device_model_args(gc, info, disks, num_disks, + args = libxl__build_device_model_args(gc, dm, info, disks, num_disks, vifs, num_vifs); if (!args) { rc = ERROR_FAIL; @@ -751,8 +802,8 @@ retry_transaction: if (!rc) { /* inner child */ setsid(); libxl__exec(null, logfile_w, logfile_w, - libxl__abs_path(gc, info->device_model, libxl_libexec_path()), - args); + libxl__domain_device_model(gc, info), + args); } rc = 0; @@ -851,7 +902,8 @@ static int libxl__build_xenpv_qemu_args( info->nographic = 1; info->domid = domid; info->dom_name = libxl_domid_to_name(ctx, domid); - info->device_model = libxl__abs_path(gc, "qemu-dm", libxl_libexec_path()); + info->device_model_version = LIBXL_DEVICE_MODEL_VERSION_DEFAULT; + info->device_model = NULL; info->type = XENPV; return 0; } diff -r 7bddcc4cfc87 -r 20dcc3b31fd4 tools/libxl/libxl_dom.c --- a/tools/libxl/libxl_dom.c Tue Apr 12 11:23:27 2011 +0100 +++ b/tools/libxl/libxl_dom.c Tue Apr 12 12:20:25 2011 +0100 @@ -160,13 +160,17 @@ int libxl__build_pv(libxl__gc *gc, uint3 return ERROR_FAIL; } - if (info->kernel.mapped) { - if ( (ret = xc_dom_kernel_mem(dom, info->kernel.data, info->kernel.size)) != 0) { + if (info->u.pv.kernel.mapped) { + ret = xc_dom_kernel_mem(dom, + info->u.pv.kernel.data, + info->u.pv.kernel.size); + if ( ret != 0) { LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_kernel_mem failed"); goto out; } } else { - if ( (ret = xc_dom_kernel_file(dom, info->kernel.path)) != 0) { + ret = xc_dom_kernel_file(dom, info->u.pv.kernel.path); + if ( ret != 0) { LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_kernel_file failed"); goto out; } @@ -264,25 +268,27 @@ static int hvm_build_set_params(xc_inter return 0; } +static const char *libxl__domain_hvmloader(libxl__gc *gc, + libxl_domain_build_info *info) +{ + return libxl__abs_path(gc, + info->u.hvm.hvmloader ? : "hvmloader", + libxl_xenfirmwaredir_path()); +} + int libxl__build_hvm(libxl__gc *gc, uint32_t domid, libxl_domain_build_info *info, libxl_domain_build_state *state) { libxl_ctx *ctx = libxl__gc_owner(gc); int ret, rc = ERROR_INVAL; - if (info->kernel.mapped) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "libxl__build_hvm kernel cannot be mmapped"); - goto out; - } - rc = ERROR_FAIL; ret = xc_hvm_build_target_mem( ctx->xch, domid, (info->max_memkb - info->video_memkb) / 1024, (info->target_memkb - info->video_memkb) / 1024, - libxl__abs_path(gc, (char *)info->kernel.path, - libxl_xenfirmwaredir_path())); + libxl__domain_hvmloader(gc, info)); if (ret) { LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, ret, "hvm building failed"); goto out; diff -r 7bddcc4cfc87 -r 20dcc3b31fd4 tools/libxl/libxl_internal.c --- a/tools/libxl/libxl_internal.c Tue Apr 12 11:23:27 2011 +0100 +++ b/tools/libxl/libxl_internal.c Tue Apr 12 12:20:25 2011 +0100 @@ -184,10 +184,10 @@ void libxl__log(libxl_ctx *ctx, xentooll va_end(ap); } -char *libxl__abs_path(libxl__gc *gc, char *s, const char *path) +char *libxl__abs_path(libxl__gc *gc, const char *s, const char *path) { if (!s || s[0] == ''/'') - return s; + return libxl__strdup(gc, s); return libxl__sprintf(gc, "%s/%s", path, s); } diff -r 7bddcc4cfc87 -r 20dcc3b31fd4 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Tue Apr 12 11:23:27 2011 +0100 +++ b/tools/libxl/libxl_internal.h Tue Apr 12 12:20:25 2011 +0100 @@ -235,6 +235,8 @@ _hidden int libxl__domain_make(libxl__gc _hidden int libxl__domain_build(libxl__gc *gc, libxl_domain_build_info *info, uint32_t domid, /* out */ libxl_domain_build_state *state); /* for device model creation */ +_hidden const char *libxl__domain_device_model(libxl__gc *gc, + libxl_device_model_info *info); _hidden int libxl__create_device_model(libxl__gc *gc, libxl_device_model_info *info, libxl_device_disk *disk, int num_disks, @@ -290,7 +292,7 @@ _hidden void libxl__exec(int stdinfd, in _hidden void libxl__log_child_exitstatus(libxl__gc *gc, const char *what, pid_t pid, int status); -_hidden char *libxl__abs_path(libxl__gc *gc, char *s, const char *path); +_hidden char *libxl__abs_path(libxl__gc *gc, const char *s, const char *path); #define LIBXL__LOG_DEBUG XTL_DEBUG #define LIBXL__LOG_INFO XTL_INFO diff -r 7bddcc4cfc87 -r 20dcc3b31fd4 tools/libxl/libxl_utils.c --- a/tools/libxl/libxl_utils.c Tue Apr 12 11:23:27 2011 +0100 +++ b/tools/libxl/libxl_utils.c Tue Apr 12 12:20:25 2011 +0100 @@ -639,89 +639,6 @@ int libxl_strtomac(const char *mac_s, ui return 0; } -#define QEMU_VERSION_STR "QEMU emulator version " - - -int libxl_check_device_model_version(libxl_ctx *ctx, char *path) -{ - libxl__gc gc = LIBXL_INIT_GC(ctx); - pid_t pid = -1; - int pipefd[2]; - char buf[100]; - ssize_t i, count = 0; - int status; - char *abs_path = NULL; - int rc = -1; - - abs_path = libxl__abs_path(&gc, path, libxl_private_bindir_path()); - - if (pipe(pipefd)) - goto out; - - pid = fork(); - if (pid == -1) { - goto out; - } - - if (!pid) { - close(pipefd[0]); - if (dup2(pipefd[1], STDOUT_FILENO) == -1) - exit(1); - execlp(abs_path, abs_path, "-h", NULL); - - close(pipefd[1]); - exit(127); - } - - close(pipefd[1]); - - /* attempt to get the first line of `qemu -h` */ - while ((i = read(pipefd[0], buf + count, 99 - count)) > 0) { - if (i + count > 90) - break; - for (int j = 0; j < i; j++) { - if (buf[j + count] == ''\n'') - break; - } - count += i; - } - count += i; - close(pipefd[0]); - waitpid(pid, &status, 0); - if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { - goto out; - } - - /* Check if we have the forked qemu-xen. */ - /* QEMU-DM emulator version 0.10.2, ... */ - if (strncmp("QEMU-DM ", buf, 7) == 0) { - rc = 0; - goto out; - } - - /* Check if the version is above 12.0 */ - /* The first line is : QEMU emulator version 0.12.50, ... */ - if (strncmp(QEMU_VERSION_STR, buf, strlen(QEMU_VERSION_STR)) == 0) { - int major, minor; - char *endptr = NULL; - char *v = buf + strlen(QEMU_VERSION_STR); - - major = strtol(v, &endptr, 10); - if (major == 0 && endptr && *endptr == ''.'') { - v = endptr + 1; - minor = strtol(v, &endptr, 10); - if (minor >= 12) { - rc = 1; - goto out; - } - } - } - rc = 0; -out: - libxl__free_all(&gc); - return rc; -} - int libxl_cpumap_alloc(libxl_ctx *ctx, libxl_cpumap *cpumap) { int max_cpus; diff -r 7bddcc4cfc87 -r 20dcc3b31fd4 tools/libxl/libxl_utils.h --- a/tools/libxl/libxl_utils.h Tue Apr 12 11:23:27 2011 +0100 +++ b/tools/libxl/libxl_utils.h Tue Apr 12 12:20:25 2011 +0100 @@ -71,12 +71,6 @@ int libxl_strtomac(const char *mac_s, ui int libxl_devid_to_device_net2(libxl_ctx *ctx, uint32_t domid, const char *devid, libxl_device_net2 *net2); -/* check the version of qemu - * return 1 if is the new one - * return 0 if is the old one - * return -1 if there are an error */ -int libxl_check_device_model_version(libxl_ctx *ctx, char *path); - int libxl_cpumap_alloc(libxl_ctx *ctx, libxl_cpumap *cpumap); int libxl_cpumap_test(libxl_cpumap *cpumap, int cpu); void libxl_cpumap_set(libxl_cpumap *cpumap, int cpu); diff -r 7bddcc4cfc87 -r 20dcc3b31fd4 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Tue Apr 12 11:23:27 2011 +0100 +++ b/tools/libxl/xl_cmdimpl.c Tue Apr 12 12:20:25 2011 +0100 @@ -337,7 +337,7 @@ static void printf_info(int domid, printf("\t(image\n"); if (c_info->hvm) { printf("\t\t(hvm\n"); - printf("\t\t\t(loader %s)\n", b_info->kernel.path); + printf("\t\t\t(loader %s)\n", b_info->u.hvm.hvmloader); printf("\t\t\t(video_memkb %d)\n", b_info->video_memkb); printf("\t\t\t(shadow_memkb %d)\n", b_info->shadow_memkb); printf("\t\t\t(pae %d)\n", b_info->u.hvm.pae); @@ -350,7 +350,7 @@ static void printf_info(int domid, printf("\t\t\t(timer_mode %d)\n", b_info->u.hvm.timer_mode); printf("\t\t\t(nestedhvm %d)\n", b_info->u.hvm.nested_hvm); - printf("\t\t\t(device_model %s)\n", dm_info->device_model); + printf("\t\t\t(device_model %s)\n", dm_info->device_model ? : "default"); printf("\t\t\t(videoram %d)\n", dm_info->videoram); printf("\t\t\t(stdvga %d)\n", dm_info->stdvga); printf("\t\t\t(vnc %d)\n", dm_info->vnc); @@ -370,7 +370,7 @@ static void printf_info(int domid, printf("\t\t)\n"); } else { printf("\t\t(linux %d)\n", b_info->hvm); - printf("\t\t\t(kernel %s)\n", b_info->kernel.path); + printf("\t\t\t(kernel %s)\n", b_info->u.pv.kernel.path); printf("\t\t\t(cmdline %s)\n", b_info->u.pv.cmdline); printf("\t\t\t(ramdisk %s)\n", b_info->u.pv.ramdisk.path); printf("\t\t)\n"); @@ -740,12 +740,16 @@ static void parse_config_data(const char if (!xlu_cfg_get_long (config, "videoram", &l)) b_info->video_memkb = l * 1024; - xlu_cfg_replace_string (config, "kernel", &b_info->kernel.path); - if (!xlu_cfg_get_long (config, "gfx_passthru", &l)) dm_info->gfx_passthru = l; if (c_info->hvm == 1) { + if (!xlu_cfg_get_string (config, "kernel", &buf)) + fprintf(stderr, "WARNING: ignoring \"kernel\" directive for HVM guest. " + "Use \"hvmloader_override\" instead if you really want a non-default hvmloader\n"); + + xlu_cfg_replace_string (config, "hvmloader_override", + &b_info->u.hvm.hvmloader); if (!xlu_cfg_get_long (config, "pae", &l)) b_info->u.hvm.pae = l; if (!xlu_cfg_get_long (config, "apic", &l)) @@ -768,6 +772,8 @@ static void parse_config_data(const char char *cmdline = NULL; const char *root = NULL, *extra = ""; + xlu_cfg_replace_string (config, "kernel", &b_info->u.pv.kernel.path); + xlu_cfg_get_string (config, "root", &root); xlu_cfg_get_string (config, "extra", &extra); @@ -786,7 +792,7 @@ static void parse_config_data(const char xlu_cfg_replace_string (config, "bootloader", &b_info->u.pv.bootloader); xlu_cfg_replace_string (config, "bootloader_args", &b_info->u.pv.bootloader_args); - if (!b_info->u.pv.bootloader && !b_info->kernel.path) { + if (!b_info->u.pv.bootloader && !b_info->u.pv.kernel.path) { fprintf(stderr, "Neither kernel nor bootloader specified\n"); exit(1); } @@ -1118,7 +1124,17 @@ skip_vfb: libxl_init_dm_info(dm_info, c_info, b_info); /* then process config related to dm */ - xlu_cfg_replace_string (config, "device_model", &dm_info->device_model); + if (!xlu_cfg_get_string (config, "device_model", &buf)) + fprintf(stderr, "WARNING: ignoring device_model directive. " + "Use \"device_model_override\" instead if you really want a non-default device_model\n"); + + xlu_cfg_replace_string (config, "device_model_override", + &dm_info->device_model); + if (!xlu_cfg_get_long (config, "device_model_version", &l)) + dm_info->device_model_version = l; + else if (dm_info->device_model) + fprintf(stderr, "WARNING: device model override given without specific DM version, assuming latest\n"); + if (!xlu_cfg_get_long (config, "stdvga", &l)) dm_info->stdvga = l; if (!xlu_cfg_get_long (config, "vnc", &l)) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-12 11:29 UTC
[Xen-devel] [PATCH 18 of 19] tools: hvmloader: select BIOS through xenstore
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1302607403 -3600 # Node ID deeb1b89d8fd0dbdd3929ed203ce8dd9c2cf50db # Parent 20dcc3b31fd416636a69dc7c528ef486adc9dacc tools: hvmloader: select BIOS through xenstore. Allow the toolstack to select the BIOS to use via a xenstore key. Defaults to "rombios" for compatibility with toolstacks which do not write the key (e.g. xend). Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 20dcc3b31fd4 -r deeb1b89d8fd tools/firmware/hvmloader/hvmloader.c --- a/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 12:20:25 2011 +0100 +++ b/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 12:23:23 2011 +0100 @@ -337,10 +337,34 @@ static void cmos_write_memory_size(void) cmos_outb(0x35, (uint8_t)( alt_mem >> 8)); } +struct bios_info { + const char *key; + const struct bios_config *bios; +} bios_configs[] = { + { "rombios", &rombios_config, }, + { NULL, NULL } +}; static const struct bios_config *detect_bios(void) { - return &rombios_config; + const struct bios_info *b = &bios_configs[0]; + const char *bios = xenstore_read("hvmloader/bios"); + + if (!bios) + bios = "rombios"; + + while(b->key != NULL) { + if (!strcmp(bios, b->key)) + return b->bios; + b++; + } + + /* oh dear */ + printf("Unknown BIOS %s, no ROM image found\n", bios); + asm volatile (".text \n" + "1: hlt \n" + " jmp 1b \n"); + return NULL; } int main(void) diff -r 20dcc3b31fd4 -r deeb1b89d8fd tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Tue Apr 12 12:20:25 2011 +0100 +++ b/tools/libxl/libxl_dm.c Tue Apr 12 12:23:23 2011 +0100 @@ -66,6 +66,16 @@ const char *libxl__domain_device_model(l return dm; } +static char *libxl__domain_bios(libxl__gc *gc, + libxl_device_model_info *info) +{ + switch (info->device_model_version) { + case 1: return libxl__strdup(gc, "rombios"); + case 2: return libxl__strdup(gc, "rombios"); + default:return NULL; + } +} + static char ** libxl__build_device_model_args_old(libxl__gc *gc, const char *dm, libxl_device_model_info *info, @@ -751,6 +761,11 @@ int libxl__create_device_model(libxl__gc goto out; } + path = libxl__sprintf(gc, "/local/domain/%d/hvmloader", info->domid); + xs_mkdir(ctx->xsh, XBT_NULL, path); + libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/bios", path), + libxl__domain_bios(gc, info)); + path = libxl__sprintf(gc, "/local/domain/0/device-model/%d", info->domid); xs_mkdir(ctx->xsh, XBT_NULL, path); libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/disable_pf", path), "%d", !info->xen_platform_pci); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-12 11:29 UTC
[Xen-devel] [PATCH 19 of 19] tools: support SeaBIOS. Use by default when upstream qemu is configured
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1302607447 -3600 # Node ID 5caa03e080fc311891df6516caf4747f6557a749 # Parent deeb1b89d8fd0dbdd3929ed203ce8dd9c2cf50db tools: support SeaBIOS. Use by default when upstream qemu is configured. The SeaBIOS integration here is only semi-complete and is targetted at developers and very early adopters who can be expected to cope with some rough edges. In particular the user must clone, patch as necessary and compile SeaBIOS themselves since this patchset does not cover any of that (in the same way we currently do not integrate upstream qemu clone+build). Include a big comment to that effect next to the Config.mk option. Many of the bios_config callback functions are not yet used by SeaBIOS. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r deeb1b89d8fd -r 5caa03e080fc Config.mk --- a/Config.mk Tue Apr 12 12:23:23 2011 +0100 +++ b/Config.mk Tue Apr 12 12:24:07 2011 +0100 @@ -184,6 +184,18 @@ QEMU_TAG := xen-4.1.0-rc6 # Fri Feb 11 17:54:51 2011 +0000 # qemu-xen: fix segfault with empty cdroms +# Short answer -- do not enable this unless you know what you are +# doing and are prepared for some pain. + +# SeaBIOS integration is a work in progress. Before enabling this +# option you must clone git://git.qemu.org/seabios.git/, possibly add +# some development patches and then build it yourself before pointing +# this variable to it (using an absolute path). +# +# Note that using SeaBIOS requires the use the upstream qemu as the +# device model. +SEABIOS_DIR ?= + # Optional components XENSTAT_XENTOP ?= y VTPM_TOOLS ?= n diff -r deeb1b89d8fd -r 5caa03e080fc tools/firmware/hvmloader/Makefile --- a/tools/firmware/hvmloader/Makefile Tue Apr 12 12:23:23 2011 +0100 +++ b/tools/firmware/hvmloader/Makefile Tue Apr 12 12:24:07 2011 +0100 @@ -40,9 +40,16 @@ CIRRUSVGA_DEBUG ?= n ROMBIOS_DIR := ../rombios ifneq ($(ROMBIOS_DIR),) OBJS += rombios.o +CFLAGS += -DENABLE_ROMBIOS ROMBIOS_ROM := $(ROMBIOS_DIR)/BIOS-bochs-latest endif +ifneq ($(SEABIOS_DIR),) +OBJS += seabios.o +CFLAGS += -DENABLE_SEABIOS +SEABIOS_ROM := $(SEABIOS_DIR)/out/bios.bin +endif + STDVGA_ROM := ../vgabios/VGABIOS-lgpl-latest.bin ifeq ($(CIRRUSVGA_DEBUG),y) CIRRUSVGA_ROM := ../vgabios/VGABIOS-lgpl-latest.cirrus.debug.bin @@ -62,7 +69,7 @@ hvmloader: $(OBJS) acpi/acpi.a $(OBJCOPY) hvmloader.tmp hvmloader rm -f hvmloader.tmp -roms.inc: $(ROMBIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) ../etherboot/eb-roms.h +roms.inc: $(ROMBIOS_ROM) $(SEABIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) ../etherboot/eb-roms.h echo "/* Autogenerated file. DO NOT EDIT */" > roms.inc ifneq ($(ROMBIOS_ROM),) @@ -71,6 +78,12 @@ ifneq ($(ROMBIOS_ROM),) echo "#endif" >> roms.inc endif +ifneq ($(SEABIOS_ROM),) + echo "#ifdef ROM_INCLUDE_SEABIOS" >> roms.inc + sh ./mkhex seabios $(SEABIOS_ROM) >> roms.inc + echo "#endif" >> roms.inc +endif + ifneq ($(STDVGA_ROM),) echo "#ifdef ROM_INCLUDE_VGABIOS" >> roms.inc sh ./mkhex vgabios_stdvga $(STDVGA_ROM) >> roms.inc diff -r deeb1b89d8fd -r 5caa03e080fc tools/firmware/hvmloader/config-seabios.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/firmware/hvmloader/config-seabios.h Tue Apr 12 12:24:07 2011 +0100 @@ -0,0 +1,9 @@ +#ifndef __HVMLOADER_CONFIG_SEABIOS_H__ +#define __HVMLOADER_CONFIG_SEABIOS_H__ + +#define OPTIONROM_PHYSICAL_ADDRESS 0x000C8000 +#define OPTIONROM_PHYSICAL_END 0x000E0000 + +#define SEABIOS_PHYSICAL_ADDRESS 0x000E0000 + +#endif /* __HVMLOADER_CONFIG_SEABIOS_H__ */ diff -r deeb1b89d8fd -r 5caa03e080fc tools/firmware/hvmloader/config.h --- a/tools/firmware/hvmloader/config.h Tue Apr 12 12:23:23 2011 +0100 +++ b/tools/firmware/hvmloader/config.h Tue Apr 12 12:24:07 2011 +0100 @@ -40,6 +40,7 @@ struct bios_config { }; extern struct bios_config rombios_config; +extern struct bios_config seabios_config; #define PAGE_SHIFT 12 #define PAGE_SIZE (1ul << PAGE_SHIFT) diff -r deeb1b89d8fd -r 5caa03e080fc tools/firmware/hvmloader/hvmloader.c --- a/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 12:23:23 2011 +0100 +++ b/tools/firmware/hvmloader/hvmloader.c Tue Apr 12 12:24:07 2011 +0100 @@ -341,7 +341,12 @@ struct bios_info { const char *key; const struct bios_config *bios; } bios_configs[] = { +#ifdef ENABLE_ROMBIOS { "rombios", &rombios_config, }, +#endif +#ifdef ENABLE_SEABIOS + { "seabios", &seabios_config, }, +#endif { NULL, NULL } }; diff -r deeb1b89d8fd -r 5caa03e080fc tools/firmware/hvmloader/seabios.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/firmware/hvmloader/seabios.c Tue Apr 12 12:24:07 2011 +0100 @@ -0,0 +1,75 @@ +/* + * HVM SeaBIOS support. + * + * Leendert van Doorn, leendert@watson.ibm.com + * Copyright (c) 2005, International Business Machines Corporation. + * Copyright (c) 2006, Keir Fraser, XenSource Inc. + * Copyright (c) 2011, Citrix Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place - Suite 330, Boston, MA 02111-1307 USA. + */ + +#include "config.h" +#include "config-seabios.h" + +#include "util.h" + +#define ROM_INCLUDE_SEABIOS +#include "roms.inc" + +static void seabios_pci_setup(void) +{ + virtual_vga = VGA_cirrus; +} + +//BUILD_BUG_ON(sizeof(seabios) > (0x00100000U - SEABIOS_PHYSICAL_ADDRESS)); + +struct bios_config seabios_config = { + .name = "SeaBIOS", + + .image = seabios, + .image_size = sizeof(seabios), + + .bios_address = SEABIOS_PHYSICAL_ADDRESS, + + .smbios_start = 0, + .smbios_end = 0, + + .optionrom_start = OPTIONROM_PHYSICAL_ADDRESS, + .optionrom_end = OPTIONROM_PHYSICAL_END, + + .acpi_start = 0, + + .bios_info_setup = NULL, + + .apic_setup = NULL, + .pci_setup = seabios_pci_setup, + .smp_setup = NULL, + + .vm86_setup = NULL, + .e820_setup = NULL, + + .acpi_build_tables = NULL, + .create_mp_tables = NULL, +}; + +/* + * Local variables: + * mode: C + * c-set-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff -r deeb1b89d8fd -r 5caa03e080fc tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Tue Apr 12 12:23:23 2011 +0100 +++ b/tools/libxl/libxl_dm.c Tue Apr 12 12:24:07 2011 +0100 @@ -62,7 +62,6 @@ const char *libxl__domain_device_model(l break; } } - return dm; } @@ -71,7 +70,7 @@ static char *libxl__domain_bios(libxl__g { switch (info->device_model_version) { case 1: return libxl__strdup(gc, "rombios"); - case 2: return libxl__strdup(gc, "rombios"); + case 2: return libxl__strdup(gc, "seabios"); default:return NULL; } } _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2011-Apr-14 18:09 UTC
Re: [Xen-devel] [PATCH 17 of 19] tools: libxl: hide selection of device-model, hvmloader and BIOS by default
Ian Campbell writes ("[Xen-devel] [PATCH 17 of 19] tools: libxl: hide selection of device-model, hvmloader and BIOS by default"):> At the libxl API level:...> * Add libxl_device_model_info.device_model_version allowing the > user to say which qemu version (e.g. old qemu-xen or qemu > upstream) they want for a domain.Perhaps this ought to be a series of #defines, rather than an integer ? Integers have the virtue of sortability but it''s not clear that that''s important; a series of #defines and corresponding strings would be easier in the config file I think.> - if (strstr(dm_info->device_model, "stubdom-dm")) > + if (strstr(libxl__domain_device_model(&gc, dm_info), "stubdom-dm")) > *need_memkb += 32 * 1024;Surely this strstr(,"stubdom-dm",) can be got rid of too, in favour of "stubdom=1" or something ? Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-15 07:53 UTC
Re: [Xen-devel] [PATCH 17 of 19] tools: libxl: hide selection of device-model, hvmloader and BIOS by default
On Thu, 2011-04-14 at 19:09 +0100, Ian Jackson wrote:> Ian Campbell writes ("[Xen-devel] [PATCH 17 of 19] tools: libxl: hide selection of device-model, hvmloader and BIOS by default"): > > At the libxl API level: > ... > > * Add libxl_device_model_info.device_model_version allowing the > > user to say which qemu version (e.g. old qemu-xen or qemu > > upstream) they want for a domain. > > Perhaps this ought to be a series of #defines, rather than an > integer ? Integers have the virtue of sortability but it''s not clear > that that''s important; a series of #defines and corresponding strings > would be easier in the config file I think.I agree but I had trouble figuring out what the strings/#define names should be. The current libxl code uses "old" and "new" which clearly falls apart if we need to support e.g. a new upstream command line syntax. I didn''t like the "qemu-dm" vs. "upstream" distinction either. So I''m open to suggestions... (also, enum not #define, I think, maybe a #define for the default)> > - if (strstr(dm_info->device_model, "stubdom-dm")) > > + if (strstr(libxl__domain_device_model(&gc, dm_info), "stubdom-dm")) > > *need_memkb += 32 * 1024; > > Surely this strstr(,"stubdom-dm",) can be got rid of too, in favour of > "stubdom=1" or something ?I don''t want to expose the choice of stub or non-stub too directly so I think it would be better as a blahblah_override in the cfg file. I''m undecided if this should be part of the set of values associated with device_model_version or if it is orthogonal enough to be a separate variable. At the moment the only way the "stubdom-dm" string can arise is if the user used the device_model_override, since we are changing the field name anyway I guess we could also give a further warning if the device model given is "stubdom-dm" and point to the new syntax. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel