From: Stefan Berger Subject: [PATCH] [HVMLOADER] search for the RSDP rather than calculating its start address Date: Mon, 27 Nov 2006 16:58:47 -0500 Message-ID: <1164664727.9473.4.camel@lt2.watson.ibm.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-ctuAncnyHUgnZoSecGrQ" 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@xensource.com List-Id: xen-devel@lists.xenproject.org --=-ctuAncnyHUgnZoSecGrQ Content-Type: text/plain Content-Transfer-Encoding: 7bit This patch implements and acpi_rsdp_get() function that searches for the RSDP in memory (up to the BIOS) rather than calculating its start address. Recent changes seem to have moved the RSDP to another location in memory so that I received 'BAD RSPD signature' messages. I have also fixed some other possible issues related to return codes and alignment of ACPI entries. Signed-off-by: Stefan Berger --=-ctuAncnyHUgnZoSecGrQ Content-Disposition: attachment; filename=acpi_rsdp_find_fix.diff Content-Type: text/x-patch; name=acpi_rsdp_find_fix.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit diff -r 84c0f49de1b1 tools/firmware/hvmloader/acpi_utils.c --- a/tools/firmware/hvmloader/acpi_utils.c Mon Nov 27 10:06:41 2006 +++ b/tools/firmware/hvmloader/acpi_utils.c Mon Nov 27 16:52:22 2006 @@ -85,7 +85,8 @@ return; /* legacy systems need an RSDT entry */ - acpi_rsdt_add_entry_pointer(acpi_start, addr); + if (acpi_rsdt_add_entry_pointer(acpi_start, addr) != 1) + return; /* add ACPI TCPA table */ addr = acpi_xsdt_add_entry(acpi_start, freemem, limit, @@ -108,7 +109,8 @@ tcpa->header.length); } - acpi_rsdt_add_entry_pointer(acpi_start, addr); + if (acpi_rsdt_add_entry_pointer(acpi_start, addr) != 1) + return; } @@ -125,17 +127,47 @@ } +/* + * Search for the RSDP in memory below the BIOS + */ +struct acpi_20_rsdp *acpi_rsdp_get(unsigned char *acpi_start) +{ + int offset = 0; + int found = 0; + static int displayed = 0; + struct acpi_20_rsdp *rsdp; + + while (&acpi_start[offset] < (unsigned char *)0xf0000) { + rsdp = (struct acpi_20_rsdp *)&acpi_start[offset]; + if (rsdp->signature == ACPI_2_0_RSDP_SIGNATURE) { + found = 1; + break; + } + offset += 0x10; + } + + if (!found) + rsdp = NULL; + + if (!displayed) { + if (rsdp) + printf("Found RSDP at %lx\n",(long)rsdp); + else + printf("ERROR: RSDP was not found\n"); + displayed = 1; + } + return rsdp; +} + + struct acpi_20_rsdt *acpi_rsdt_get(unsigned char *acpi_start) { struct acpi_20_rsdp *rsdp; struct acpi_20_rsdt *rsdt; - rsdp = (struct acpi_20_rsdp *)(acpi_start + sizeof(struct acpi_20_facs)); - if ( rsdp->signature != ACPI_2_0_RSDP_SIGNATURE ) - { - printf("Bad RSDP signature\n"); + rsdp = acpi_rsdp_get(acpi_start); + if (!rsdp) return NULL; - } rsdt = (struct acpi_20_rsdt *) (acpi_start + rsdp->rsdt_address - ACPI_PHYSICAL_ADDRESS); @@ -189,12 +221,9 @@ struct acpi_20_rsdp *rsdp; struct acpi_20_xsdt *xsdt; - rsdp = (struct acpi_20_rsdp *)(acpi_start + sizeof(struct acpi_20_facs)); - if ( rsdp->signature != ACPI_2_0_RSDP_SIGNATURE ) - { - printf("Bad RSDP signature\n"); + rsdp = acpi_rsdp_get(acpi_start); + if (!rsdp) return NULL; - } xsdt = (struct acpi_20_xsdt *) (acpi_start + rsdp->xsdt_address - ACPI_PHYSICAL_ADDRESS); @@ -272,10 +301,10 @@ /* memory below hard limit ? */ if ( (*freemem + table_size) <= limit ) { - printf("Copying SSDT entry\n"); addr = *freemem; memcpy(addr, table, table_size); - *freemem += table_size; + printf("Copied dyn. ACPI entry to %lx\n",(long)addr); + *freemem += ((table_size + 0xf) & ~0xf); acpi_xsdt_add_entry_pointer(acpi_start, addr); } --=-ctuAncnyHUgnZoSecGrQ 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 --=-ctuAncnyHUgnZoSecGrQ--