ia64/xen-unstable

changeset 15985:e54226c3b796

hvm: Improve tcgbios code for finding ACPI RSDP.
Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author Keir Fraser <keir@xensource.com>
date Wed Sep 26 09:14:33 2007 +0100 (2007-09-26)
parents 6ae1f8af06a7
children 3c1e76dda38b
files tools/firmware/rombios/32bit/tcgbios/tcgbios.c
line diff
     1.1 --- a/tools/firmware/rombios/32bit/tcgbios/tcgbios.c	Wed Sep 26 09:11:46 2007 +0100
     1.2 +++ b/tools/firmware/rombios/32bit/tcgbios/tcgbios.c	Wed Sep 26 09:14:33 2007 +0100
     1.3 @@ -260,31 +260,44 @@ uint8_t acpi_validate_entry(struct acpi_
     1.4  }
     1.5  
     1.6  
     1.7 +/*
     1.8 + * Search for the RSDP ACPI table in the memory starting at addr and
     1.9 + * ending at addr + len - 1.
    1.10 + */
    1.11 +static struct acpi_20_rsdp *find_rsdp(const void *start, unsigned int len)
    1.12 +{
    1.13 +	char *rsdp = (char *)start;
    1.14 +	char *end = rsdp + len;
    1.15 +	/* scan memory in steps of 16 bytes */
    1.16 +	while (rsdp < end) {
    1.17 +		/* check for expected string */
    1.18 +		if (!strncmp( rsdp, "RSD PTR ", 8))
    1.19 +			return (struct acpi_20_rsdp *)rsdp;
    1.20 +		rsdp += 0x10;
    1.21 +	}
    1.22 +	return 0;
    1.23 +}
    1.24 +
    1.25  void tcpa_acpi_init(void)
    1.26  {
    1.27  	struct acpi_20_rsdt *rsdt;
    1.28 +	struct acpi_20_tcpa *tcpa = (void *)0;
    1.29 +	struct acpi_20_rsdp *rsdp;
    1.30  	uint32_t length;
    1.31 -	struct acpi_20_tcpa *tcpa = (void *)0;
    1.32 -	uint16_t found = 0;
    1.33 -	uint16_t rsdp_off;
    1.34  	uint16_t off;
    1.35 -	struct acpi_20_rsdp *rsdp = (void *)0;
    1.36 +	int found = 0;
    1.37 +	uint16_t ebda_seg;
    1.38  
    1.39  	if (MA_IsTPMPresent() == 0) {
    1.40  		return;
    1.41  	}
    1.42  
    1.43 -	/* scan memory in steps of  16 bytes in the ACPI_SEGMENT segment */
    1.44 -	found = 0;
    1.45 -	for (rsdp_off = 0; rsdp_off < 0xfff0; rsdp_off += 0x10) {
    1.46 -		char *_rsdp = (char *)(ACPI_SEGMENT << 4);
    1.47 -		/* check for expected string */
    1.48 -		if (!strncmp( &_rsdp[rsdp_off], "RSD PTR ", 8)) {
    1.49 -			found = 1;
    1.50 -			rsdp = (struct acpi_20_rsdp *)&_rsdp[rsdp_off];
    1.51 -			break;
    1.52 -		}
    1.53 -	}
    1.54 +	/* RSDP in EBDA? */
    1.55 +	ebda_seg = *(uint16_t *)ADDR_FROM_SEG_OFF(0x40, 0xe);
    1.56 +	rsdp = find_rsdp((void *)(ebda_seg << 16), 1024);
    1.57 +
    1.58 +	if (!rsdp)
    1.59 +		rsdp = find_rsdp((void *)(ACPI_SEGMENT << 4), 0x20000);
    1.60  
    1.61  	if (rsdp) {
    1.62  		uint32_t ctr = 0;