From c2d55efd8a9a156fe14fd477924fadb765ac9438 Mon Sep 17 00:00:00 2001 Message-Id: From: "Michael S. Tsirkin" Date: Wed, 11 Dec 2013 15:16:27 +0100 Subject: [PATCH 1/3] biostables: support looking up RSDP RH-Author: Michael S. Tsirkin Message-id: <1386774929-25693-2-git-send-email-mst@redhat.com> Patchwork-id: 56224 O-Subject: [RHEL7.0 seabios PATCH 1/3] biostables: support looking up RSDP Bugzilla: 1034877 RH-Acked-by: Laszlo Ersek RH-Acked-by: Paolo Bonzini RH-Acked-by: Gerd Hoffmann RH-Acked-by: Marcel Apfelbaum Will be used when it's loaded from QEMU. Signed-off-by: Michael S. Tsirkin Signed-off-by: Gerd Hoffmann (cherry-picked from commit ff5f7921d904dd2ddbaded3941643da8ba5fa9aa) In rhel7 codebase we don't know the exact fseg range. Just scan all of the ROM range. Signed-off-by: Michael S. Tsirkin --- src/util.h | 1 + src/biostables.c | 41 ++++++++++++++++++++++++++++++++++------- 2 files changed, 35 insertions(+), 7 deletions(-) Signed-off-by: Michal Novotny --- src/biostables.c | 41 ++++++++++++++++++++++++++++++++++------- src/util.h | 1 + 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/biostables.c b/src/biostables.c index 81cc79b..2352ba4 100644 --- a/src/biostables.c +++ b/src/biostables.c @@ -57,22 +57,35 @@ copy_mptable(void *pos) memcpy((void*)newpos + length, (void*)p->physaddr, mpclength); } -static void -copy_acpi_rsdp(void *pos) +static int +get_acpi_rsdp_length(void *pos, unsigned size) { - if (RsdpAddr) - return; struct rsdp_descriptor *p = pos; if (p->signature != RSDP_SIGNATURE) - return; + return -1; u32 length = 20; + if (length > size) + return -1; if (checksum(pos, length) != 0) - return; + return -1; if (p->revision > 1) { length = p->length; + if (length > size) + return -1; if (checksum(pos, length) != 0) - return; + return -1; } + return length; +} + +static void +copy_acpi_rsdp(void *pos) +{ + if (RsdpAddr) + return; + int length = get_acpi_rsdp_length(pos, -1); + if (length < 0) + return; void *newpos = malloc_fseg(length); if (!newpos) { warn_noalloc(); @@ -115,3 +128,17 @@ copy_table(void *pos) copy_acpi_rsdp(pos); copy_smbios(pos); } + +void *find_acpi_rsdp(void) +{ + /* The BIOS read-only memory space is between 0E0000h and 0FFFFFh. */ + unsigned long start = 0xE0000; + unsigned long end = 0xFFFFF; + unsigned long pos; + + for (pos = ALIGN(start, 0x10); pos <= ALIGN_DOWN(end, 0x10); pos += 0x10) + if (get_acpi_rsdp_length((void *)pos, end - pos) >= 0) + return (void *)pos; + + return NULL; +} diff --git a/src/util.h b/src/util.h index 7723bb1..e46d298 100644 --- a/src/util.h +++ b/src/util.h @@ -339,6 +339,7 @@ void coreboot_cbfs_setup(void); // biostable.c void copy_table(void *pos); +void *find_acpi_rsdp(void); // vgahooks.c void handle_155f(struct bregs *regs); -- 1.7.11.7