ia64/xen-unstable

changeset 7916:90b9e8569dfb

Create the base set of ACPI structures necessary to satisfy the ACPI subsystem on a guest OS. This includes RSDP, XSDT, FADT, MADT, and DSDT.
The MADT contains a single LSAPIC entry for the
guest CPU. The DSDT lacks any actual AML content, which the ACPI CA
complains about, but it may be a basis to add more later. On bootup,
the guest domain now includes a comforting list of ACPI tables:
ACPI: RSDP (v002 XEN ) @ 0x0000000000000570
ACPI: XSDT (v001 XEN Xen/ia64 0x00000000 XEN 0x00030000) @ 0x0000000000000594
ACPI: FADT (v003 XEN Xen/ia64 0x00000000 XEN 0x00030000) @ 0x00000000000005c8
ACPI: MADT (v002 XEN Xen/ia64 0x00000000 XEN 0x00030000) @ 0x0000000000000720
ACPI: DSDT (v001 XEN Xen/ia64 0x00000000 XEN 0x00030000) @ 0x0000000000000000
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
author djm@kirby.fc.hp.com
date Tue Nov 22 12:19:11 2005 -0600 (2005-11-22)
parents 6ac2a06e238b
children 750b19fec820
files xen/arch/ia64/xen/dom_fw.c
line diff
     1.1 --- a/xen/arch/ia64/xen/dom_fw.c	Tue Nov 22 12:17:18 2005 -0600
     1.2 +++ b/xen/arch/ia64/xen/dom_fw.c	Tue Nov 22 12:19:11 2005 -0600
     1.3 @@ -13,6 +13,7 @@
     1.4  #include <asm/io.h>
     1.5  #include <asm/pal.h>
     1.6  #include <asm/sal.h>
     1.7 +#include <xen/compile.h>
     1.8  #include <xen/acpi.h>
     1.9  
    1.10  #include <asm/dom_fw.h>
    1.11 @@ -437,29 +438,29 @@ acpi_update_lsapic (acpi_table_entry_hea
    1.12  	return 0;
    1.13  }
    1.14  
    1.15 +static u8
    1.16 +generate_acpi_checksum(void *tbl, unsigned long len)
    1.17 +{
    1.18 +	u8 *ptr, sum = 0;
    1.19 +
    1.20 +	for (ptr = tbl; len > 0 ; len--, ptr++)
    1.21 +		sum += *ptr;
    1.22 +
    1.23 +	return 0 - sum;
    1.24 +}
    1.25 +
    1.26  static int
    1.27  acpi_update_madt_checksum (unsigned long phys_addr, unsigned long size)
    1.28  {
    1.29 -	u8 checksum=0;
    1.30 -    	u8* ptr;
    1.31 -	int len;
    1.32  	struct acpi_table_madt* acpi_madt;
    1.33  
    1.34  	if (!phys_addr || !size)
    1.35  		return -EINVAL;
    1.36  
    1.37  	acpi_madt = (struct acpi_table_madt *) __va(phys_addr);
    1.38 -	acpi_madt->header.checksum=0;
    1.39 +	acpi_madt->header.checksum = 0;
    1.40 +	acpi_madt->header.checksum = generate_acpi_checksum(acpi_madt, size);
    1.41  
    1.42 -    	/* re-calculate MADT checksum */
    1.43 -	ptr = (u8*)acpi_madt;
    1.44 -    	len = acpi_madt->header.length;
    1.45 -	while (len>0){
    1.46 -		checksum = (u8)( checksum + (*ptr++) );
    1.47 -		len--;
    1.48 -	}
    1.49 -    	acpi_madt->header.checksum = 0x0 - checksum;	
    1.50 -	
    1.51  	return 0;
    1.52  }
    1.53  
    1.54 @@ -473,6 +474,128 @@ void touch_acpi_table(void)
    1.55  	return;
    1.56  }
    1.57  
    1.58 +struct fake_acpi_tables {
    1.59 +	struct acpi20_table_rsdp rsdp;
    1.60 +	struct xsdt_descriptor_rev2 xsdt;
    1.61 +	u64 madt_ptr;
    1.62 +	struct fadt_descriptor_rev2 fadt;
    1.63 +	struct facs_descriptor_rev2 facs;
    1.64 +	struct acpi_table_header dsdt;
    1.65 +	struct acpi_table_madt madt;
    1.66 +	struct acpi_table_lsapic lsapic;
    1.67 +	u8 pm1a_evt_blk[4];
    1.68 +	u8 pm1a_cnt_blk[1];
    1.69 +	u8 pm_tmr_blk[4];
    1.70 +};
    1.71 +
    1.72 +/* Create enough of an ACPI structure to make the guest OS ACPI happy. */
    1.73 +void
    1.74 +dom_fw_fake_acpi(struct fake_acpi_tables *tables)
    1.75 +{
    1.76 +	struct acpi20_table_rsdp *rsdp = &tables->rsdp;
    1.77 +	struct xsdt_descriptor_rev2 *xsdt = &tables->xsdt;
    1.78 +	struct fadt_descriptor_rev2 *fadt = &tables->fadt;
    1.79 +	struct facs_descriptor_rev2 *facs = &tables->facs;
    1.80 +	struct acpi_table_header *dsdt = &tables->dsdt;
    1.81 +	struct acpi_table_madt *madt = &tables->madt;
    1.82 +	struct acpi_table_lsapic *lsapic = &tables->lsapic;
    1.83 +
    1.84 +	memset(tables, 0, sizeof(struct fake_acpi_tables));
    1.85 +
    1.86 +	/* setup XSDT (64bit version of RSDT) */
    1.87 +	strncpy(xsdt->signature, XSDT_SIG, 4);
    1.88 +	/* XSDT points to both the FADT and the MADT, so add one entry */
    1.89 +	xsdt->length = sizeof(struct xsdt_descriptor_rev2) + sizeof(u64);
    1.90 +	xsdt->revision = 1;
    1.91 +	strcpy(xsdt->oem_id, "XEN");
    1.92 +	strcpy(xsdt->oem_table_id, "Xen/ia64");
    1.93 +	strcpy(xsdt->asl_compiler_id, "XEN");
    1.94 +	xsdt->asl_compiler_revision = (XEN_VERSION<<16)|(XEN_SUBVERSION);
    1.95 +
    1.96 +	xsdt->table_offset_entry[0] = dom_pa(fadt);
    1.97 +	tables->madt_ptr = dom_pa(madt);
    1.98 +
    1.99 +	xsdt->checksum = generate_acpi_checksum(xsdt, xsdt->length);
   1.100 +
   1.101 +	/* setup FADT */
   1.102 +	strncpy(fadt->signature, FADT_SIG, 4);
   1.103 +	fadt->length = sizeof(struct fadt_descriptor_rev2);
   1.104 +	fadt->revision = FADT2_REVISION_ID;
   1.105 +	strcpy(fadt->oem_id, "XEN");
   1.106 +	strcpy(fadt->oem_table_id, "Xen/ia64");
   1.107 +	strcpy(fadt->asl_compiler_id, "XEN");
   1.108 +	fadt->asl_compiler_revision = (XEN_VERSION<<16)|(XEN_SUBVERSION);
   1.109 +
   1.110 +	strncpy(facs->signature, FACS_SIG, 4);
   1.111 +	facs->version = 1;
   1.112 +	facs->length = sizeof(struct facs_descriptor_rev2);
   1.113 +
   1.114 +	fadt->xfirmware_ctrl = dom_pa(facs);
   1.115 +	fadt->Xdsdt = dom_pa(dsdt);
   1.116 +
   1.117 +	/*
   1.118 +	 * All of the below FADT entries are filled it to prevent warnings
   1.119 +	 * from sanity checks in the ACPI CA.  Emulate required ACPI hardware
   1.120 +	 * registers in system memory.
   1.121 +	 */
   1.122 +	fadt->pm1_evt_len = 4;
   1.123 +	fadt->xpm1a_evt_blk.address_space_id = ACPI_ADR_SPACE_SYSTEM_MEMORY;
   1.124 +	fadt->xpm1a_evt_blk.register_bit_width = 8;
   1.125 +	fadt->xpm1a_evt_blk.address = dom_pa(&tables->pm1a_evt_blk);
   1.126 +	fadt->pm1_cnt_len = 1;
   1.127 +	fadt->xpm1a_cnt_blk.address_space_id = ACPI_ADR_SPACE_SYSTEM_MEMORY;
   1.128 +	fadt->xpm1a_cnt_blk.register_bit_width = 8;
   1.129 +	fadt->xpm1a_cnt_blk.address = dom_pa(&tables->pm1a_cnt_blk);
   1.130 +	fadt->pm_tm_len = 4;
   1.131 +	fadt->xpm_tmr_blk.address_space_id = ACPI_ADR_SPACE_SYSTEM_MEMORY;
   1.132 +	fadt->xpm_tmr_blk.register_bit_width = 8;
   1.133 +	fadt->xpm_tmr_blk.address = dom_pa(&tables->pm_tmr_blk);
   1.134 +
   1.135 +	fadt->checksum = generate_acpi_checksum(fadt, fadt->length);
   1.136 +
   1.137 +	/* setup RSDP */
   1.138 +	strncpy(rsdp->signature, RSDP_SIG, 8);
   1.139 +	strcpy(rsdp->oem_id, "XEN");
   1.140 +	rsdp->revision = 2; /* ACPI 2.0 includes XSDT */
   1.141 +	rsdp->length = sizeof(struct acpi20_table_rsdp);
   1.142 +	rsdp->xsdt_address = dom_pa(xsdt);
   1.143 +
   1.144 +	rsdp->checksum = generate_acpi_checksum(rsdp,
   1.145 +	                                        ACPI_RSDP_CHECKSUM_LENGTH);
   1.146 +	rsdp->ext_checksum = generate_acpi_checksum(rsdp, rsdp->length);
   1.147 +
   1.148 +	/*
   1.149 +	 * setup DSDT - ACPI generates a warning because there's no AML
   1.150 +	 * in the DSDT.  Revisit to add dummy AML stub.
   1.151 +	 */ 
   1.152 +	strncpy(dsdt->signature, DSDT_SIG, 4);
   1.153 +	dsdt->revision = 1;
   1.154 +	dsdt->length = sizeof(struct acpi_table_header);
   1.155 +	strcpy(dsdt->oem_id, "XEN");
   1.156 +	strcpy(dsdt->oem_table_id, "Xen/ia64");
   1.157 +	strcpy(dsdt->asl_compiler_id, "XEN");
   1.158 +	dsdt->asl_compiler_revision = (XEN_VERSION<<16)|(XEN_SUBVERSION);
   1.159 +	dsdt->checksum = generate_acpi_checksum(dsdt, dsdt->length);
   1.160 +
   1.161 +	/* setup MADT */
   1.162 +	strncpy(madt->header.signature, APIC_SIG, 4);
   1.163 +	madt->header.revision = 2;
   1.164 +	madt->header.length = sizeof(struct acpi_table_madt) +
   1.165 +	                      sizeof(struct acpi_table_lsapic);
   1.166 +	strcpy(madt->header.oem_id, "XEN");
   1.167 +	strcpy(madt->header.oem_table_id, "Xen/ia64");
   1.168 +	strcpy(madt->header.asl_compiler_id, "XEN");
   1.169 +	madt->header.asl_compiler_revision = (XEN_VERSION<<16)|(XEN_SUBVERSION);
   1.170 +
   1.171 +	/* A single LSAPIC entry describes the CPU.  Revisit for SMP guests */
   1.172 +	lsapic->header.type = ACPI_MADT_LSAPIC;
   1.173 +	lsapic->header.length = sizeof(struct acpi_table_lsapic);
   1.174 +	lsapic->flags.enabled = 1;
   1.175 +
   1.176 +	madt->header.checksum = generate_acpi_checksum(madt,
   1.177 +	                                               madt->header.length);
   1.178 +	return;
   1.179 +}
   1.180  
   1.181  struct ia64_boot_param *
   1.182  dom_fw_init (struct domain *d, char *args, int arglen, char *fw_mem, int fw_mem_size)
   1.183 @@ -620,6 +743,22 @@ dom_fw_init (struct domain *d, char *arg
   1.184  			i++;
   1.185  		}
   1.186  		printf("\n");
   1.187 +	} else {
   1.188 +		i = 1;
   1.189 +
   1.190 +		if ((unsigned long)fw_mem + fw_mem_size - (unsigned long)cp >=
   1.191 +		    sizeof(struct fake_acpi_tables)) {
   1.192 +			struct fake_acpi_tables *acpi_tables;
   1.193 +
   1.194 +			acpi_tables = (void *)cp;
   1.195 +			cp += sizeof(struct fake_acpi_tables);
   1.196 +			dom_fw_fake_acpi(acpi_tables);
   1.197 +
   1.198 +			efi_tables[i].guid = ACPI_20_TABLE_GUID;
   1.199 +			efi_tables[i].table = dom_pa(acpi_tables);
   1.200 +			printf(" ACPI 2.0=%0xlx",efi_tables[i].table);
   1.201 +			i++;
   1.202 +		}
   1.203  	}
   1.204  
   1.205  	/* fill in the SAL system table: */