Index: root/xen-unstable.hg/tools/firmware/hvmloader/util.c =================================================================== --- root.orig/xen-unstable.hg/tools/firmware/hvmloader/util.c +++ root/xen-unstable.hg/tools/firmware/hvmloader/util.c @@ -90,6 +90,23 @@ void *memcpy(void *dest, const void *src return dest; } +void *memmove(void *dest, const void *src, unsigned n) +{ + if ((long)dest > (long)src) { + n--; + while (n > 0) { + ((char *)dest)[n] = ((char *)src)[n]; + n--; + } + } else { + memcpy(dest, src, n); + } + return dest; +} + + + + void puts(const char *s) { while (*s) @@ -229,3 +246,39 @@ uuid_to_string(char *dest, uint8_t *uuid } *p = 0; } + +#include +#define E820_MAP_NR ((unsigned char *)E820_MAP_PAGE + E820_MAP_NR_OFFSET) +#define E820_MAP ((struct e820entry *)(E820_MAP_PAGE + E820_MAP_OFFSET)) +uint64_t e820_malloc(uint64_t size, + uint32_t type, + uint64_t mask) +{ + uint64_t addr = 0; + int c = *E820_MAP_NR - 1; + struct e820entry *e820entry = (struct e820entry *)E820_MAP; + + while (c >= 0) { + if (e820entry[c].type == E820_RAM && + (e820entry[c].addr & (~mask)) == 0 && + e820entry[c].size >= size) { + addr = e820entry[c].addr; + if (e820entry[c].size != size) { + (*E820_MAP_NR)++; + memmove(&e820entry[c+1], + &e820entry[c], + (*E820_MAP_NR - c) * + sizeof(struct e820entry)); + e820entry[c].size -= size; + addr += e820entry[c].size; + c++; + } + e820entry[c].addr = addr; + e820entry[c].size = size; + e820entry[c].type = type; + break; + } + c--; + } + return addr; +} Index: root/xen-unstable.hg/tools/firmware/hvmloader/util.h =================================================================== --- root.orig/xen-unstable.hg/tools/firmware/hvmloader/util.h +++ root/xen-unstable.hg/tools/firmware/hvmloader/util.h @@ -22,6 +22,7 @@ char *strncpy(char *dest, const char *sr unsigned strlen(const char *s); int memcmp(const void *s1, const void *s2, unsigned n); void *memcpy(void *dest, const void *src, unsigned n); +void *memmove(void *dest, const void *src, unsigned n); void *memset(void *s, int c, unsigned n); char *itoa(char *a, unsigned int i); @@ -38,4 +39,10 @@ void uuid_to_string(char *dest, uint8_t /* Debug output */ void puts(const char *s); +/* allocating memory from the e820 table */ +uint64_t e820_malloc(uint64_t size, + uint32_t type, + uint64_t mask); + + #endif /* __HVMLOADER_UTIL_H__ */ Index: root/xen-unstable.hg/tools/firmware/hvmloader/acpi_utils.c =================================================================== --- root.orig/xen-unstable.hg/tools/firmware/hvmloader/acpi_utils.c +++ root/xen-unstable.hg/tools/firmware/hvmloader/acpi_utils.c @@ -23,6 +23,7 @@ #include "acpi/acpi2_0.h" #include "acpi_utils.h" #include "util.h" +#include static int acpi_rsdt_add_entry_pointer(unsigned char *acpi_start, unsigned char *entry); @@ -91,18 +92,21 @@ static int acpi_tpm_tis_probe(unsigned c /* add ACPI TCPA table */ addr = acpi_xsdt_add_entry(acpi_start, freemem, limit, (unsigned char *)&Tcpa, - sizeof(Tcpa) + - ACPI_2_0_TCPA_LAML_SIZE); + sizeof(Tcpa)); if (addr) { ACPI_2_0_TCPA_CLIENT *tcpa = (ACPI_2_0_TCPA_CLIENT *)addr; - tcpa->LASA = (uint64_t)(unsigned long)(addr + sizeof(Tcpa)); - tcpa->LAML = ACPI_2_0_TCPA_LAML_SIZE, - memset((char *)(unsigned long)tcpa->LASA, - 0x0, - tcpa->LAML); - set_checksum(tcpa, - FIELD_OFFSET(struct acpi_header, checksum), - tcpa->header.length); + tcpa->LASA = e820_malloc(ACPI_2_0_TCPA_LAML_SIZE, + E820_RESERVED, + 0xFFFFFFFF); + if (tcpa->LASA) { + tcpa->LAML = ACPI_2_0_TCPA_LAML_SIZE; + memset((char *)(unsigned long)tcpa->LASA, + 0x0, + tcpa->LAML); + set_checksum(tcpa, + FIELD_OFFSET(struct acpi_header, checksum), + tcpa->header.length); + } acpi_rsdt_add_entry_pointer(acpi_start, addr); } } Index: root/xen-unstable.hg/tools/firmware/hvmloader/acpi/acpi2_0.h =================================================================== --- root.orig/xen-unstable.hg/tools/firmware/hvmloader/acpi/acpi2_0.h +++ root/xen-unstable.hg/tools/firmware/hvmloader/acpi/acpi2_0.h @@ -146,7 +146,7 @@ typedef struct _ACPI_2_0_TCPA_CLIENT { } ACPI_2_0_TCPA_CLIENT; #define ACPI_2_0_TCPA_REVISION 0x02 -#define ACPI_2_0_TCPA_LAML_SIZE (10*1024) +#define ACPI_2_0_TCPA_LAML_SIZE (64*1024) /* * Fixed ACPI Description Table Structure (FADT).