diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2015-05-21 10:26:49 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2015-05-21 11:44:57 +0200 |
commit | fa9ea2e622eb105fb77f1f09e3194bfc05db7c5e (patch) | |
tree | be8d9bd2dd39fb6cd6c090f8c7bbbf1d43a39f90 /main.c | |
parent | bd363b8030716a759823d8828690e49ad4d25f96 (diff) | |
download | qboot-fa9ea2e622eb105fb77f1f09e3194bfc05db7c5e.zip qboot-fa9ea2e622eb105fb77f1f09e3194bfc05db7c5e.tar.gz qboot-fa9ea2e622eb105fb77f1f09e3194bfc05db7c5e.tar.bz2 |
add malloc
Allocate the e820 map in the E-segment.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 24 |
1 files changed, 16 insertions, 8 deletions
@@ -1,4 +1,5 @@ #include "bios.h" +#include "stdio.h" #include "e820.h" #include "pci.h" #include "string.h" @@ -83,24 +84,31 @@ static void extract_e820(void) { int id = fw_cfg_file_id("etc/e820"); uint32_t size; + int nr_map; + struct e820map *e820; if (id == -1) panic(); size = fw_cfg_file_size(id); - e820.nr_map = size / sizeof(e820.map[0]) + 4; + nr_map = size / sizeof(e820->map[0]) + 4; fw_cfg_file_select(id); - e820.map[0] = (struct e820entry) + + e820 = malloc(offsetof(struct e820map, map[nr_map])); + e820->nr_map = nr_map; + e820->map[0] = (struct e820entry) { .addr = 0, .size = 639 * 1024, .type = E820_RAM }; /* low RAM */ - e820.map[1] = (struct e820entry) + e820->map[1] = (struct e820entry) { .addr = 639 * 1024, .size = 1024, .type = E820_RESERVED }; /* EBDA */ - e820.map[2] = (struct e820entry) + e820->map[2] = (struct e820entry) { .addr = 0xe0000, .size = 64 * 1024, .type = E820_NVS }; /* ACPI tables */ - e820.map[3] = (struct e820entry) + e820->map[3] = (struct e820entry) { .addr = 0xf0000, .size = 64 * 1024, .type = E820_RESERVED }; /* firmware */ - fw_cfg_read(&e820.map[4], size); - e820.map[4].addr = 1024 * 1024; - e820.map[4].size -= 1024 * 1024; + fw_cfg_read(&e820->map[4], size); + e820->map[4].addr = 1024 * 1024; + e820->map[4].size -= 1024 * 1024; + + e820_seg = ((uintptr_t) e820) >> 4; } int main(void) |