From: Stefan Berger Subject: [PATCH] [BIOS] Improve the way the RSDP is found in the BIOS extension Date: Tue, 25 Sep 2007 16:22:24 -0400 Message-ID: <1190751744.14363.14.camel@gsal-3.watson.ibm.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-KGbMV6Dugj3Ly/L4S3FV" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel Cc: Keir Fraser List-Id: xen-devel@lists.xenproject.org --=-KGbMV6Dugj3Ly/L4S3FV Content-Type: text/plain Content-Transfer-Encoding: 7bit Following the ACPI spec. I improved the way the RSDP is found in the BIOS extension so that it will still be found if it ever moves. Also makes the code look better. Signed-off-by: Stefan Berger --=-KGbMV6Dugj3Ly/L4S3FV Content-Disposition: attachment; filename=tcgbios_rsdp_find.diff Content-Type: text/x-patch; name=tcgbios_rsdp_find.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit --- xen-unstable.hg/tools/firmware/rombios/32bit/tcgbios/tcgbios.c | 40 ++++++---- 1 file changed, 26 insertions(+), 14 deletions(-) Index: latest/xen-unstable.hg/tools/firmware/rombios/32bit/tcgbios/tcgbios.c =================================================================== --- latest.orig/xen-unstable.hg/tools/firmware/rombios/32bit/tcgbios/tcgbios.c +++ latest/xen-unstable.hg/tools/firmware/rombios/32bit/tcgbios/tcgbios.c @@ -260,31 +260,44 @@ uint8_t acpi_validate_entry(struct acpi_ } +/* + * Search for the RSDP ACPI table in the memory starting at addr and + * ending at addr + len - 1. + */ +static struct acpi_20_rsdp *find_rsdp(const void *start, unsigned int len) +{ + char *rsdp = (char *)start; + char *end = rsdp + len; + /* scan memory in steps of 16 bytes */ + while (rsdp < end) { + /* check for expected string */ + if (!strncmp( rsdp, "RSD PTR ", 8)) + return (struct acpi_20_rsdp *)rsdp; + rsdp += 0x10; + } + return 0; +} + void tcpa_acpi_init(void) { struct acpi_20_rsdt *rsdt; - uint32_t length; struct acpi_20_tcpa *tcpa = (void *)0; - uint16_t found = 0; - uint16_t rsdp_off; + struct acpi_20_rsdp *rsdp; + uint32_t length; uint16_t off; - struct acpi_20_rsdp *rsdp = (void *)0; + int found = 0; + uint16_t ebda_seg; if (MA_IsTPMPresent() == 0) { return; } - /* scan memory in steps of 16 bytes in the ACPI_SEGMENT segment */ - found = 0; - for (rsdp_off = 0; rsdp_off < 0xfff0; rsdp_off += 0x10) { - char *_rsdp = (char *)(ACPI_SEGMENT << 4); - /* check for expected string */ - if (!strncmp( &_rsdp[rsdp_off], "RSD PTR ", 8)) { - found = 1; - rsdp = (struct acpi_20_rsdp *)&_rsdp[rsdp_off]; - break; - } - } + /* RSDP in EBDA? */ + ebda_seg = *(uint16_t *)ADDR_FROM_SEG_OFF(0x40, 0xe); + rsdp = find_rsdp((void *)(ebda_seg << 16), 1024); + + if (!rsdp) + rsdp = find_rsdp((void *)(ACPI_SEGMENT << 4), 0x20000); if (rsdp) { uint32_t ctr = 0; --=-KGbMV6Dugj3Ly/L4S3FV Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=-KGbMV6Dugj3Ly/L4S3FV--