diff options
author | Ian Campbell <ian.campbell@citrix.com> | 2011-04-12 13:36:17 +0100 |
---|---|---|
committer | Ian Campbell <ian.campbell@citrix.com> | 2011-04-12 13:36:17 +0100 |
commit | ac7802b59324d3ea194ccc641fe6cca5ab317a6e (patch) | |
tree | 69a53e1378ba6525070af0ed623299a9ae1bf7a0 /tools/firmware | |
parent | ddff13d94c763321b54cfc2f6f12fc520c7b03c5 (diff) | |
download | xen-ac7802b59324d3ea194ccc641fe6cca5ab317a6e.tar.gz xen-ac7802b59324d3ea194ccc641fe6cca5ab317a6e.tar.bz2 xen-ac7802b59324d3ea194ccc641fe6cca5ab317a6e.zip |
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>
Acked-by: Keir Fraser <keir@xen.org>
Diffstat (limited to 'tools/firmware')
-rw-r--r-- | tools/firmware/hvmloader/Makefile | 1 | ||||
-rw-r--r-- | tools/firmware/hvmloader/config.h | 3 | ||||
-rw-r--r-- | tools/firmware/hvmloader/e820.c | 141 | ||||
-rw-r--r-- | tools/firmware/hvmloader/e820.h | 5 | ||||
-rw-r--r-- | tools/firmware/hvmloader/hvmloader.c | 124 | ||||
-rw-r--r-- | tools/firmware/hvmloader/smbios.c | 1 | ||||
-rw-r--r-- | tools/firmware/hvmloader/util.c | 1 | ||||
-rw-r--r-- | tools/firmware/hvmloader/util.h | 4 | ||||
-rw-r--r-- | tools/firmware/rombios/32bit/pmm.c | 2 | ||||
-rw-r--r-- | tools/firmware/rombios/config.h | 3 | ||||
-rw-r--r-- | tools/firmware/rombios/e820.h | 18 |
11 files changed, 173 insertions, 130 deletions
diff --git a/tools/firmware/hvmloader/Makefile b/tools/firmware/hvmloader/Makefile index 669bf6d653..59cfed959e 100644 --- a/tools/firmware/hvmloader/Makefile +++ b/tools/firmware/hvmloader/Makefile @@ -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 --git a/tools/firmware/hvmloader/config.h b/tools/firmware/hvmloader/config.h index 1f8124e0c6..cac9f10785 100644 --- a/tools/firmware/hvmloader/config.h +++ b/tools/firmware/hvmloader/config.h @@ -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_mem_end; #define ROMBIOS_MAXOFFSET 0x0000FFFF #define ROMBIOS_END (ROMBIOS_BEGIN + ROMBIOS_SIZE) +#include "e820.h" #include "../rombios/config.h" #define VGABIOS_PHYSICAL_ADDRESS 0x000C0000 diff --git a/tools/firmware/hvmloader/e820.c b/tools/firmware/hvmloader/e820.c new file mode 100644 index 0000000000..9ab5380a6b --- /dev/null +++ b/tools/firmware/hvmloader/e820.c @@ -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 --git a/tools/firmware/hvmloader/e820.h b/tools/firmware/hvmloader/e820.h index 940c8ed394..e9e4e33702 100644 --- a/tools/firmware/hvmloader/e820.h +++ b/tools/firmware/hvmloader/e820.h @@ -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 --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c index 5ba71f6217..01e1da2a14 100644 --- a/tools/firmware/hvmloader/hvmloader.c +++ b/tools/firmware/hvmloader/hvmloader.c @@ -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 --git a/tools/firmware/hvmloader/smbios.c b/tools/firmware/hvmloader/smbios.c index 4718e1987f..9c102a5571 100644 --- a/tools/firmware/hvmloader/smbios.c +++ b/tools/firmware/hvmloader/smbios.c @@ -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 --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c index c58ea1071a..25c5f7a040 100644 --- a/tools/firmware/hvmloader/util.c +++ b/tools/firmware/hvmloader/util.c @@ -20,7 +20,6 @@ #include "util.h" #include "config.h" -#include "e820.h" #include "hypercall.h" #include <stdint.h> #include <xen/xen.h> diff --git a/tools/firmware/hvmloader/util.h b/tools/firmware/hvmloader/util.h index e2d7e01e96..313070a298 100644 --- a/tools/firmware/hvmloader/util.h +++ b/tools/firmware/hvmloader/util.h @@ -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 --git a/tools/firmware/rombios/32bit/pmm.c b/tools/firmware/rombios/32bit/pmm.c index 3b2c5350be..de7c3ca405 100644 --- a/tools/firmware/rombios/32bit/pmm.c +++ b/tools/firmware/rombios/32bit/pmm.c @@ -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 --git a/tools/firmware/rombios/config.h b/tools/firmware/rombios/config.h index 4b501791a5..12a2f91948 100644 --- a/tools/firmware/rombios/config.h +++ b/tools/firmware/rombios/config.h @@ -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 --git a/tools/firmware/rombios/e820.h b/tools/firmware/rombios/e820.h new file mode 100644 index 0000000000..570c17e57c --- /dev/null +++ b/tools/firmware/rombios/e820.h @@ -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__ */ |