ia64/xen-unstable

changeset 17820:9af7a535225f

Pull in ACPI table parsing code from Linux 2.6.26-rc4.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jun 10 13:45:29 2008 +0100 (2008-06-10)
parents 7a0f1bf86516
children 8a36f7f70859
files xen/arch/ia64/xen/acpi.c xen/arch/ia64/xen/dom_fw_dom0.c xen/arch/x86/acpi/boot.c xen/drivers/acpi/Makefile xen/drivers/acpi/numa.c xen/drivers/acpi/osl.c xen/drivers/acpi/tables.c xen/drivers/acpi/tables/Makefile xen/drivers/acpi/tables/tbfadt.c xen/drivers/acpi/tables/tbinstal.c xen/drivers/acpi/tables/tbutils.c xen/drivers/acpi/tables/tbxface.c xen/drivers/acpi/tables/tbxfroot.c xen/drivers/acpi/utglobal.c xen/drivers/acpi/utilities/Makefile xen/drivers/acpi/utilities/utglobal.c xen/drivers/acpi/utilities/utmisc.c xen/drivers/passthrough/amd/iommu_acpi.c xen/drivers/passthrough/amd/pci_amd_iommu.c xen/drivers/passthrough/vtd/dmar.c xen/include/acpi/acnamesp.h xen/include/acpi/actables.h xen/include/acpi/platform/aclinux.h xen/include/asm-x86/hvm/svm/amd-iommu-proto.h xen/include/xen/acpi.h xen/include/xen/compiler.h
line diff
     1.1 --- a/xen/arch/ia64/xen/acpi.c	Tue Jun 10 09:27:01 2008 +0100
     1.2 +++ b/xen/arch/ia64/xen/acpi.c	Tue Jun 10 13:45:29 2008 +0100
     1.3 @@ -58,7 +58,7 @@
     1.4  
     1.5  #define BAD_MADT_ENTRY(entry, end) (                                        \
     1.6  		(!entry) || (unsigned long)entry + sizeof(*entry) > end ||  \
     1.7 -		((acpi_table_entry_header *)entry)->length != sizeof(*entry))
     1.8 +		((struct acpi_subtable_header *)entry)->length != sizeof(*entry))
     1.9  
    1.10  #define PREFIX			"ACPI: "
    1.11  
    1.12 @@ -167,7 +167,7 @@ static u8			has_8259;
    1.13  
    1.14  static int __init
    1.15  acpi_parse_lapic_addr_ovr (
    1.16 -	acpi_table_entry_header *header, const unsigned long end)
    1.17 +	struct acpi_subtable_header *header, const unsigned long end)
    1.18  {
    1.19  	struct acpi_table_lapic_addr_ovr *lapic;
    1.20  
    1.21 @@ -187,7 +187,7 @@ acpi_parse_lapic_addr_ovr (
    1.22  
    1.23  
    1.24  static int __init
    1.25 -acpi_parse_lsapic (acpi_table_entry_header *header, const unsigned long end)
    1.26 +acpi_parse_lsapic (struct acpi_subtable_header *header, const unsigned long end)
    1.27  {
    1.28  	struct acpi_table_lsapic *lsapic;
    1.29  
    1.30 @@ -227,7 +227,7 @@ acpi_parse_lsapic (acpi_table_entry_head
    1.31  
    1.32  
    1.33  static int __init
    1.34 -acpi_parse_lapic_nmi (acpi_table_entry_header *header, const unsigned long end)
    1.35 +acpi_parse_lapic_nmi (struct acpi_subtable_header *header, const unsigned long end)
    1.36  {
    1.37  	struct acpi_table_lapic_nmi *lacpi_nmi;
    1.38  
    1.39 @@ -244,7 +244,7 @@ acpi_parse_lapic_nmi (acpi_table_entry_h
    1.40  
    1.41  
    1.42  static int __init
    1.43 -acpi_parse_iosapic (acpi_table_entry_header *header, const unsigned long end)
    1.44 +acpi_parse_iosapic (struct acpi_subtable_header *header, const unsigned long end)
    1.45  {
    1.46  	struct acpi_table_iosapic *iosapic;
    1.47  
    1.48 @@ -262,7 +262,7 @@ acpi_parse_iosapic (acpi_table_entry_hea
    1.49  
    1.50  static int __init
    1.51  acpi_parse_plat_int_src (
    1.52 -	acpi_table_entry_header *header, const unsigned long end)
    1.53 +	struct acpi_subtable_header *header, const unsigned long end)
    1.54  {
    1.55  	struct acpi_table_plat_int_src *plintsrc;
    1.56  	int vector;
    1.57 @@ -293,7 +293,7 @@ acpi_parse_plat_int_src (
    1.58  
    1.59  static int __init
    1.60  acpi_parse_int_src_ovr (
    1.61 -	acpi_table_entry_header *header, const unsigned long end)
    1.62 +	struct acpi_subtable_header *header, const unsigned long end)
    1.63  {
    1.64  	struct acpi_table_int_src_ovr *p;
    1.65  
    1.66 @@ -311,7 +311,7 @@ acpi_parse_int_src_ovr (
    1.67  }
    1.68  
    1.69  static int __init
    1.70 -acpi_parse_nmi_src (acpi_table_entry_header *header, const unsigned long end)
    1.71 +acpi_parse_nmi_src (struct acpi_subtable_header *header, const unsigned long end)
    1.72  {
    1.73  	struct acpi_table_nmi_src *nmi_src;
    1.74  
    1.75 @@ -345,12 +345,9 @@ void __init acpi_madt_oem_check(char *oe
    1.76  }
    1.77  
    1.78  static int __init
    1.79 -acpi_parse_madt (unsigned long phys_addr, unsigned long size)
    1.80 +acpi_parse_madt (struct acpi_table_header *table)
    1.81  {
    1.82 -	if (!phys_addr || !size)
    1.83 -		return -EINVAL;
    1.84 -
    1.85 -	acpi_madt = (struct acpi_table_madt *) __va(phys_addr);
    1.86 +	acpi_madt = (struct acpi_table_madt *)table;
    1.87  
    1.88  	/* remember the value for reference after free_initmem() */
    1.89  #ifdef CONFIG_ITANIUM
    1.90 @@ -560,15 +557,12 @@ acpi_register_gsi (u32 gsi, int polarity
    1.91  EXPORT_SYMBOL(acpi_register_gsi);
    1.92  #endif
    1.93  static int __init
    1.94 -acpi_parse_fadt (unsigned long phys_addr, unsigned long size)
    1.95 +acpi_parse_fadt (struct acpi_table_header *table)
    1.96  {
    1.97  	struct acpi_table_header *fadt_header;
    1.98  	struct acpi_table_fadt *fadt;
    1.99  
   1.100 -	if (!phys_addr || !size)
   1.101 -		return -EINVAL;
   1.102 -
   1.103 -	fadt_header = (struct acpi_table_header *) __va(phys_addr);
   1.104 +	fadt_header = (struct acpi_table_header *)table;
   1.105  	if (fadt_header->revision != 3)
   1.106  		return -ENODEV;		/* Only deal with ACPI 2.0 FADT */
   1.107  
   1.108 @@ -610,7 +604,7 @@ acpi_boot_init (void)
   1.109  	 * information -- the successor to MPS tables.
   1.110  	 */
   1.111  
   1.112 -	if (acpi_table_parse(ACPI_APIC, acpi_parse_madt) < 1) {
   1.113 +	if (acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
   1.114  		printk(KERN_ERR PREFIX "Can't find MADT\n");
   1.115  		goto skip_madt;
   1.116  	}
   1.117 @@ -649,7 +643,7 @@ acpi_boot_init (void)
   1.118  	 * gets interrupts such as power and sleep buttons.  If it's not
   1.119  	 * on a Legacy interrupt, it needs to be setup.
   1.120  	 */
   1.121 -	if (acpi_table_parse(ACPI_FADT, acpi_parse_fadt) < 1)
   1.122 +	if (acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt))
   1.123  		printk(KERN_ERR PREFIX "Can't find FADT\n");
   1.124  
   1.125  #ifdef CONFIG_SMP
     2.1 --- a/xen/arch/ia64/xen/dom_fw_dom0.c	Tue Jun 10 09:27:01 2008 +0100
     2.2 +++ b/xen/arch/ia64/xen/dom_fw_dom0.c	Tue Jun 10 13:45:29 2008 +0100
     2.3 @@ -50,7 +50,7 @@ static u32 lsapic_nbr;
     2.4  
     2.5  /* Modify lsapic table.  Provides LPs.  */
     2.6  static int __init
     2.7 -acpi_update_lsapic(acpi_table_entry_header * header, const unsigned long end)
     2.8 +acpi_update_lsapic(struct acpi_subtable_header * header, const unsigned long end)
     2.9  {
    2.10  	struct acpi_table_lsapic *lsapic;
    2.11  	int enable;
    2.12 @@ -79,7 +79,7 @@ acpi_update_lsapic(acpi_table_entry_head
    2.13  }
    2.14  
    2.15  static int __init
    2.16 -acpi_patch_plat_int_src(acpi_table_entry_header * header,
    2.17 +acpi_patch_plat_int_src(struct acpi_subtable_header * header,
    2.18  			const unsigned long end)
    2.19  {
    2.20  	struct acpi_table_plat_int_src *plintsrc;
    2.21 @@ -96,14 +96,11 @@ acpi_patch_plat_int_src(acpi_table_entry
    2.22  }
    2.23  
    2.24  static int __init
    2.25 -acpi_update_madt_checksum(unsigned long phys_addr, unsigned long size)
    2.26 +acpi_update_madt_checksum(struct acpi_table_header *table)
    2.27  {
    2.28  	struct acpi_table_madt *acpi_madt;
    2.29  
    2.30 -	if (!phys_addr || !size)
    2.31 -		return -EINVAL;
    2.32 -
    2.33 -	acpi_madt = (struct acpi_table_madt *)__va(phys_addr);
    2.34 +	acpi_madt = (struct acpi_table_madt *)table;
    2.35  	acpi_madt->header.checksum = 0;
    2.36  	acpi_madt->header.checksum = generate_acpi_checksum(acpi_madt, size);
    2.37  
    2.38 @@ -111,32 +108,26 @@ acpi_update_madt_checksum(unsigned long 
    2.39  }
    2.40  
    2.41  static int __init
    2.42 -acpi_backup_table(unsigned long phys_addr, unsigned long size)
    2.43 +acpi_backup_table(struct acpi_table_header *table)
    2.44  {
    2.45  	struct acpi_backup_table_entry *entry;
    2.46 -	void *vaddr = __va(phys_addr);
    2.47  
    2.48 -	if (!phys_addr || !size)
    2.49 -		return -EINVAL;
    2.50 -
    2.51 -	entry = xmalloc_bytes(sizeof(*entry) + size);
    2.52 +	entry = xmalloc_bytes(sizeof(*entry) + table->length);
    2.53  	if (!entry) {
    2.54  		dprintk(XENLOG_WARNING, "Failed to allocate memory for "
    2.55 -		        "%.4s table backup\n",
    2.56 -			((struct acpi_table_header *)vaddr)->signature);
    2.57 +		        "%.4s table backup\n", table->signature);
    2.58  		return -ENOMEM;
    2.59  	}
    2.60  
    2.61 -	entry->pa = phys_addr;
    2.62 -	entry->size = size;
    2.63 +	entry->pa = __pa(table);
    2.64 +	entry->size = table->length;
    2.65  
    2.66 -	memcpy(entry->data, vaddr, size);
    2.67 +	memcpy(entry->data, table, table->length);
    2.68  
    2.69  	list_add(&entry->list, &acpi_backup_table_list);
    2.70  
    2.71  	printk(XENLOG_INFO "Backup %.4s table stored @0x%p\n",
    2.72 -	       ((struct acpi_table_header *)entry->data)->signature,
    2.73 -	       entry->data);
    2.74 +	       table->signature, entry->data);
    2.75  
    2.76  	return 0;
    2.77  }
    2.78 @@ -156,6 +147,22 @@ acpi_restore_tables()
    2.79  	}
    2.80  }
    2.81  
    2.82 +static int __init __acpi_table_disable(struct acpi_table_header *header)
    2.83 +{
    2.84 +	memcpy(header->oem_id, "xxxxxx", 6);
    2.85 +	memcpy(header->oem_id+1, header->signature, 4);
    2.86 +	memcpy(header->oem_table_id, "Xen     ", 8);
    2.87 +	memcpy(header->signature, "OEMx", 4);
    2.88 +	header->checksum = 0;
    2.89 +	header->checksum = generate_acpi_checksum(header, header->length);
    2.90 +	return 0;
    2.91 +}
    2.92 +
    2.93 +static void __init acpi_table_disable(char *id)
    2.94 +{
    2.95 +	acpi_table_parse(id, __acpi_table_disable);
    2.96 +}
    2.97 +
    2.98  /* base is physical address of acpi table */
    2.99  static void __init touch_acpi_table(void)
   2.100  {
   2.101 @@ -170,7 +177,7 @@ static void __init touch_acpi_table(void
   2.102  	 *
   2.103  	 * ACPI tables must be backed-up before modification!
   2.104  	 */
   2.105 -	acpi_table_parse(ACPI_APIC, acpi_backup_table);
   2.106 +	acpi_table_parse(ACPI_SIG_MADT, acpi_backup_table);
   2.107  
   2.108  	if (acpi_table_parse_madt(ACPI_MADT_LSAPIC, acpi_update_lsapic, 0) < 0)
   2.109  		printk("Error parsing MADT - no LAPIC entries\n");
   2.110 @@ -178,7 +185,7 @@ static void __init touch_acpi_table(void
   2.111  				  acpi_patch_plat_int_src, 0) < 0)
   2.112  		printk("Error parsing MADT - no PLAT_INT_SRC entries\n");
   2.113  
   2.114 -	acpi_table_parse(ACPI_APIC, acpi_update_madt_checksum);
   2.115 +	acpi_table_parse(ACPI_SIG_MADT, acpi_update_madt_checksum);
   2.116  
   2.117  	/*
   2.118  	 * SRAT & SLIT tables aren't useful for Dom0 until
   2.119 @@ -186,16 +193,16 @@ static void __init touch_acpi_table(void
   2.120  	 *
   2.121  	 * NB - backup ACPI tables first.
   2.122  	 */
   2.123 -	acpi_table_parse(ACPI_SRAT, acpi_backup_table);
   2.124 -	acpi_table_parse(ACPI_SLIT, acpi_backup_table);
   2.125 +	acpi_table_parse(ACPI_SIG_SRAT, acpi_backup_table);
   2.126 +	acpi_table_parse(ACPI_SIG_SLIT, acpi_backup_table);
   2.127  
   2.128 -	result = acpi_table_disable(ACPI_SRAT);
   2.129 +	result = acpi_table_disable(ACPI_SIG_SRAT);
   2.130  	if ( result == 0 )
   2.131  		printk("Success Disabling SRAT\n");
   2.132  	else if ( result != -ENOENT )
   2.133  		printk("ERROR: Failed Disabling SRAT\n");
   2.134  
   2.135 -	result = acpi_table_disable(ACPI_SLIT);
   2.136 +	result = acpi_table_disable(ACPI_SIG_SLIT);
   2.137  	if ( result == 0 )
   2.138  		printk("Success Disabling SLIT\n");
   2.139  	else if ( result != -ENOENT )
     3.1 --- a/xen/arch/x86/acpi/boot.c	Tue Jun 10 09:27:01 2008 +0100
     3.2 +++ b/xen/arch/x86/acpi/boot.c	Tue Jun 10 13:45:29 2008 +0100
     3.3 @@ -45,7 +45,7 @@ int sbf_port;
     3.4  
     3.5  #define BAD_MADT_ENTRY(entry, end) (					    \
     3.6  		(!entry) || (unsigned long)entry + sizeof(*entry) > end ||  \
     3.7 -		((acpi_table_entry_header *)entry)->length != sizeof(*entry))
     3.8 +		((struct acpi_subtable_header *)entry)->length != sizeof(*entry))
     3.9  
    3.10  #define PREFIX			"ACPI: "
    3.11  
    3.12 @@ -111,7 +111,7 @@ char *__acpi_map_table(unsigned long phy
    3.13  	int idx;
    3.14  
    3.15  	/* XEN: RAM holes above 1MB are not permanently mapped. */
    3.16 -	if (phys + size < 1 * 1024 * 1024)
    3.17 +	if ((phys + size) <= (1 * 1024 * 1024))
    3.18  		return __va(phys);
    3.19  
    3.20  	offset = phys & (PAGE_SIZE - 1);
    3.21 @@ -135,18 +135,11 @@ char *__acpi_map_table(unsigned long phy
    3.22  }
    3.23  
    3.24  #ifdef CONFIG_X86_LOCAL_APIC
    3.25 -static int __init acpi_parse_madt(unsigned long phys_addr, unsigned long size)
    3.26 +static int __init acpi_parse_madt(struct acpi_table_header *table)
    3.27  {
    3.28 -	struct acpi_table_madt *madt = NULL;
    3.29 +	struct acpi_table_madt *madt;
    3.30  
    3.31 -	if (!phys_addr || !size)
    3.32 -		return -EINVAL;
    3.33 -
    3.34 -	madt = (struct acpi_table_madt *)__acpi_map_table(phys_addr, size);
    3.35 -	if (!madt) {
    3.36 -		printk(KERN_WARNING PREFIX "Unable to map MADT\n");
    3.37 -		return -ENODEV;
    3.38 -	}
    3.39 +	madt = (struct acpi_table_madt *)table;
    3.40  
    3.41  	if (madt->address) {
    3.42  		acpi_lapic_addr = (u64) madt->address;
    3.43 @@ -161,7 +154,7 @@ static int __init acpi_parse_madt(unsign
    3.44  }
    3.45  
    3.46  static int __init
    3.47 -acpi_parse_lapic(acpi_table_entry_header * header, const unsigned long end)
    3.48 +acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end)
    3.49  {
    3.50  	struct acpi_table_lapic *processor = NULL;
    3.51  
    3.52 @@ -190,7 +183,7 @@ acpi_parse_lapic(acpi_table_entry_header
    3.53  }
    3.54  
    3.55  static int __init
    3.56 -acpi_parse_lapic_addr_ovr(acpi_table_entry_header * header,
    3.57 +acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header,
    3.58  			  const unsigned long end)
    3.59  {
    3.60  	struct acpi_table_lapic_addr_ovr *lapic_addr_ovr = NULL;
    3.61 @@ -206,7 +199,7 @@ acpi_parse_lapic_addr_ovr(acpi_table_ent
    3.62  }
    3.63  
    3.64  static int __init
    3.65 -acpi_parse_lapic_nmi(acpi_table_entry_header * header, const unsigned long end)
    3.66 +acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long end)
    3.67  {
    3.68  	struct acpi_table_lapic_nmi *lapic_nmi = NULL;
    3.69  
    3.70 @@ -228,7 +221,7 @@ acpi_parse_lapic_nmi(acpi_table_entry_he
    3.71  #if defined(CONFIG_X86_IO_APIC) /*&& defined(CONFIG_ACPI_INTERPRETER)*/
    3.72  
    3.73  static int __init
    3.74 -acpi_parse_ioapic(acpi_table_entry_header * header, const unsigned long end)
    3.75 +acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end)
    3.76  {
    3.77  	struct acpi_table_ioapic *ioapic = NULL;
    3.78  
    3.79 @@ -246,7 +239,7 @@ acpi_parse_ioapic(acpi_table_entry_heade
    3.80  }
    3.81  
    3.82  static int __init
    3.83 -acpi_parse_int_src_ovr(acpi_table_entry_header * header,
    3.84 +acpi_parse_int_src_ovr(struct acpi_subtable_header * header,
    3.85  		       const unsigned long end)
    3.86  {
    3.87  	struct acpi_table_int_src_ovr *intsrc = NULL;
    3.88 @@ -272,7 +265,7 @@ acpi_parse_int_src_ovr(acpi_table_entry_
    3.89  }
    3.90  
    3.91  static int __init
    3.92 -acpi_parse_nmi_src(acpi_table_entry_header * header, const unsigned long end)
    3.93 +acpi_parse_nmi_src(struct acpi_subtable_header * header, const unsigned long end)
    3.94  {
    3.95  	struct acpi_table_nmi_src *nmi_src = NULL;
    3.96  
    3.97 @@ -309,38 +302,26 @@ acpi_scan_rsdp(unsigned long start, unsi
    3.98  	return 0;
    3.99  }
   3.100  
   3.101 -static int __init acpi_parse_sbf(unsigned long phys_addr, unsigned long size)
   3.102 +static int __init acpi_parse_sbf(struct acpi_table_header *table)
   3.103  {
   3.104 -	struct acpi_table_sbf *sb;
   3.105 +	struct acpi_table_boot *sb;
   3.106  
   3.107 -	if (!phys_addr || !size)
   3.108 -		return -EINVAL;
   3.109 -
   3.110 -	sb = (struct acpi_table_sbf *)__acpi_map_table(phys_addr, size);
   3.111 +	sb = (struct acpi_table_boot *)table;
   3.112  	if (!sb) {
   3.113  		printk(KERN_WARNING PREFIX "Unable to map SBF\n");
   3.114  		return -ENODEV;
   3.115  	}
   3.116  
   3.117 -	sbf_port = sb->sbf_cmos;	/* Save CMOS port */
   3.118 +	sbf_port = sb->cmos_index;	/* Save CMOS port */
   3.119  
   3.120  	return 0;
   3.121  }
   3.122  
   3.123  #ifdef CONFIG_HPET_TIMER
   3.124  
   3.125 -static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
   3.126 +static int __init acpi_parse_hpet(struct acpi_table_header *table)
   3.127  {
   3.128 -	struct acpi_table_hpet *hpet_tbl;
   3.129 -
   3.130 -	if (!phys || !size)
   3.131 -		return -EINVAL;
   3.132 -
   3.133 -	hpet_tbl = (struct acpi_table_hpet *)__acpi_map_table(phys, size);
   3.134 -	if (!hpet_tbl) {
   3.135 -		printk(KERN_WARNING PREFIX "Unable to map HPET\n");
   3.136 -		return -ENODEV;
   3.137 -	}
   3.138 +	struct acpi_table_hpet *hpet_tbl = (struct acpi_table_hpet *)table;
   3.139  
   3.140  	if (hpet_tbl->address.space_id != ACPI_SPACE_MEM) {
   3.141  		printk(KERN_WARNING PREFIX "HPET timers must be located in "
   3.142 @@ -454,37 +435,9 @@ bad:
   3.143  }
   3.144  #endif
   3.145  
   3.146 -static void __init
   3.147 -acpi_fadt_parse_reg(struct acpi_table_fadt *fadt)
   3.148 +static int __init acpi_parse_fadt(struct acpi_table_header *table)
   3.149  {
   3.150 -	unsigned int len;
   3.151 -
   3.152 -	len = min_t(unsigned int, fadt->header.length, sizeof(*fadt));
   3.153 -	memcpy(&acpi_gbl_FADT, fadt, len);
   3.154 -
   3.155 -	if (len > offsetof(struct acpi_table_fadt, xpm1b_event_block)) {
   3.156 -		memcpy(&acpi_gbl_xpm1a_enable, &fadt->xpm1a_event_block,
   3.157 -		       sizeof(acpi_gbl_xpm1a_enable));
   3.158 -		memcpy(&acpi_gbl_xpm1b_enable, &fadt->xpm1b_event_block,
   3.159 -		       sizeof(acpi_gbl_xpm1b_enable));
   3.160 -
   3.161 -		acpi_gbl_xpm1a_enable.address +=
   3.162 -			acpi_gbl_FADT.pm1_event_length / 2;
   3.163 -		if ( acpi_gbl_xpm1b_enable.address )
   3.164 -			acpi_gbl_xpm1b_enable.address +=
   3.165 -				acpi_gbl_FADT.pm1_event_length / 2;
   3.166 -	}
   3.167 -}
   3.168 -
   3.169 -static int __init acpi_parse_fadt(unsigned long phys, unsigned long size)
   3.170 -{
   3.171 -	struct acpi_table_fadt *fadt = NULL;
   3.172 -
   3.173 -	fadt = (struct acpi_table_fadt *)__acpi_map_table(phys, size);
   3.174 -	if (!fadt) {
   3.175 -		printk(KERN_WARNING PREFIX "Unable to map FADT\n");
   3.176 -		return 0;
   3.177 -	}
   3.178 +	struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table;
   3.179  
   3.180  #ifdef	CONFIG_ACPI_INTERPRETER
   3.181  	/* initialize sci_int early for INT_SRC_OVR MADT parsing */
   3.182 @@ -523,8 +476,6 @@ static int __init acpi_parse_fadt(unsign
   3.183  	acpi_enable_value  = fadt->acpi_enable;
   3.184  	acpi_disable_value = fadt->acpi_disable;
   3.185  
   3.186 -	acpi_fadt_parse_reg(fadt);
   3.187 -
   3.188  #ifdef CONFIG_ACPI_SLEEP
   3.189  	acpi_fadt_parse_sleep_info(fadt);
   3.190  #endif
   3.191 @@ -692,10 +643,9 @@ static inline int acpi_parse_madt_ioapic
   3.192  static void __init acpi_process_madt(void)
   3.193  {
   3.194  #ifdef CONFIG_X86_LOCAL_APIC
   3.195 -	int count, error;
   3.196 +	int error;
   3.197  
   3.198 -	count = acpi_table_parse(ACPI_APIC, acpi_parse_madt);
   3.199 -	if (count >= 1) {
   3.200 +	if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
   3.201  
   3.202  		/*
   3.203  		 * Parse MADT LAPIC entries
   3.204 @@ -990,7 +940,7 @@ int __init acpi_boot_table_init(void)
   3.205  		return error;
   3.206  	}
   3.207  
   3.208 -	acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
   3.209 +	acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
   3.210  
   3.211  	/*
   3.212  	 * blacklist may disable ACPI entirely
   3.213 @@ -1020,19 +970,19 @@ int __init acpi_boot_init(void)
   3.214  	if (acpi_disabled && !acpi_ht)
   3.215  		return 1;
   3.216  
   3.217 -	acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
   3.218 +	acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
   3.219  
   3.220  	/*
   3.221  	 * set sci_int and PM timer address
   3.222  	 */
   3.223 -	acpi_table_parse(ACPI_FADT, acpi_parse_fadt);
   3.224 +	acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt);
   3.225  
   3.226  	/*
   3.227  	 * Process the Multiple APIC Description Table (MADT), if present
   3.228  	 */
   3.229  	acpi_process_madt();
   3.230  
   3.231 -	acpi_table_parse(ACPI_HPET, acpi_parse_hpet);
   3.232 +	acpi_table_parse(ACPI_SIG_HPET, acpi_parse_hpet);
   3.233  
   3.234  	acpi_dmar_init();
   3.235  
     4.1 --- a/xen/drivers/acpi/Makefile	Tue Jun 10 09:27:01 2008 +0100
     4.2 +++ b/xen/drivers/acpi/Makefile	Tue Jun 10 13:45:29 2008 +0100
     4.3 @@ -1,6 +1,8 @@
     4.4 +subdir-y += tables
     4.5 +subdir-y += utilities
     4.6 +
     4.7  obj-y += tables.o
     4.8  obj-y += numa.o
     4.9  obj-y += osl.o
    4.10  
    4.11  obj-$(x86) += hwregs.o
    4.12 -obj-$(x86) += utglobal.o
     5.1 --- a/xen/drivers/acpi/numa.c	Tue Jun 10 09:27:01 2008 +0100
     5.2 +++ b/xen/drivers/acpi/numa.c	Tue Jun 10 13:45:29 2008 +0100
     5.3 @@ -35,13 +35,7 @@
     5.4  #define _COMPONENT	ACPI_NUMA
     5.5  ACPI_MODULE_NAME("numa")
     5.6  
     5.7 -extern int __init acpi_table_parse_madt_family(enum acpi_table_id id,
     5.8 -					       unsigned long madt_size,
     5.9 -					       int entry_id,
    5.10 -					       acpi_madt_entry_handler handler,
    5.11 -					       unsigned int max_entries);
    5.12 -
    5.13 -void __init acpi_table_print_srat_entry(acpi_table_entry_header * header)
    5.14 +void __init acpi_table_print_srat_entry(struct acpi_subtable_header * header)
    5.15  {
    5.16  
    5.17  	ACPI_FUNCTION_NAME("acpi_table_print_srat_entry");
    5.18 @@ -93,26 +87,15 @@ void __init acpi_table_print_srat_entry(
    5.19  	}
    5.20  }
    5.21  
    5.22 -static int __init acpi_parse_slit(unsigned long phys_addr, unsigned long size)
    5.23 +static int __init acpi_parse_slit(struct acpi_table_header *table)
    5.24  {
    5.25 -	struct acpi_table_slit *slit;
    5.26 -	u32 localities;
    5.27 -
    5.28 -	if (!phys_addr || !size)
    5.29 -		return -EINVAL;
    5.30 -
    5.31 -	slit = (struct acpi_table_slit *)__acpi_map_table(phys_addr, size);
    5.32 -
    5.33 -	/* downcast just for %llu vs %lu for i386/ia64  */
    5.34 -	localities = (u32) slit->locality_count;
    5.35 -
    5.36 -	acpi_numa_slit_init(slit);
    5.37 +	acpi_numa_slit_init((struct acpi_table_slit *)table);
    5.38  
    5.39  	return 0;
    5.40  }
    5.41  
    5.42  static int __init
    5.43 -acpi_parse_processor_affinity(acpi_table_entry_header * header,
    5.44 +acpi_parse_processor_affinity(struct acpi_subtable_header * header,
    5.45  			      const unsigned long end)
    5.46  {
    5.47  	struct acpi_table_processor_affinity *processor_affinity;
    5.48 @@ -130,7 +113,7 @@ acpi_parse_processor_affinity(acpi_table
    5.49  }
    5.50  
    5.51  static int __init
    5.52 -acpi_parse_memory_affinity(acpi_table_entry_header * header,
    5.53 +acpi_parse_memory_affinity(struct acpi_subtable_header * header,
    5.54  			   const unsigned long end)
    5.55  {
    5.56  	struct acpi_table_memory_affinity *memory_affinity;
    5.57 @@ -147,15 +130,8 @@ acpi_parse_memory_affinity(acpi_table_en
    5.58  	return 0;
    5.59  }
    5.60  
    5.61 -static int __init acpi_parse_srat(unsigned long phys_addr, unsigned long size)
    5.62 +static int __init acpi_parse_srat(struct acpi_table_header *table)
    5.63  {
    5.64 -	struct acpi_table_srat *srat;
    5.65 -
    5.66 -	if (!phys_addr || !size)
    5.67 -		return -EINVAL;
    5.68 -
    5.69 -	srat = (struct acpi_table_srat *)__acpi_map_table(phys_addr, size);
    5.70 -
    5.71  	return 0;
    5.72  }
    5.73  
    5.74 @@ -163,27 +139,23 @@ int __init
    5.75  acpi_table_parse_srat(enum acpi_srat_entry_id id,
    5.76  		      acpi_madt_entry_handler handler, unsigned int max_entries)
    5.77  {
    5.78 -	return acpi_table_parse_madt_family(ACPI_SRAT,
    5.79 -					    sizeof(struct acpi_table_srat), id,
    5.80 -					    handler, max_entries);
    5.81 +	return acpi_table_parse_entries(ACPI_SIG_SRAT,
    5.82 +					sizeof(struct acpi_table_srat), id,
    5.83 +					handler, max_entries);
    5.84  }
    5.85  
    5.86  int __init acpi_numa_init(void)
    5.87  {
    5.88 -	int result;
    5.89 -
    5.90  	/* SRAT: Static Resource Affinity Table */
    5.91 -	result = acpi_table_parse(ACPI_SRAT, acpi_parse_srat);
    5.92 -
    5.93 -	if (result > 0) {
    5.94 -		result = acpi_table_parse_srat(ACPI_SRAT_PROCESSOR_AFFINITY,
    5.95 +	if (!acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat)) {
    5.96 +		acpi_table_parse_srat(ACPI_SRAT_PROCESSOR_AFFINITY,
    5.97  					       acpi_parse_processor_affinity,
    5.98  					       NR_CPUS);
    5.99 -		result = acpi_table_parse_srat(ACPI_SRAT_MEMORY_AFFINITY, acpi_parse_memory_affinity, NR_NODE_MEMBLKS);	// IA64 specific
   5.100 +		acpi_table_parse_srat(ACPI_SRAT_MEMORY_AFFINITY, acpi_parse_memory_affinity, NR_NODE_MEMBLKS);	// IA64 specific
   5.101  	}
   5.102  
   5.103  	/* SLIT: System Locality Information Table */
   5.104 -	result = acpi_table_parse(ACPI_SLIT, acpi_parse_slit);
   5.105 +	acpi_table_parse(ACPI_SIG_SLIT, acpi_parse_slit);
   5.106  
   5.107  	acpi_numa_arch_fixup();
   5.108  	return 0;
     6.1 --- a/xen/drivers/acpi/osl.c	Tue Jun 10 09:27:01 2008 +0100
     6.2 +++ b/xen/drivers/acpi/osl.c	Tue Jun 10 13:45:29 2008 +0100
     6.3 @@ -63,6 +63,41 @@ extern char line_buf[80];
     6.4  int acpi_specific_hotkey_enabled = TRUE;
     6.5  EXPORT_SYMBOL(acpi_specific_hotkey_enabled);
     6.6  
     6.7 +void acpi_os_printf(const char *fmt, ...)
     6.8 +{
     6.9 +	va_list args;
    6.10 +	va_start(args, fmt);
    6.11 +	acpi_os_vprintf(fmt, args);
    6.12 +	va_end(args);
    6.13 +}
    6.14 +
    6.15 +void acpi_os_vprintf(const char *fmt, va_list args)
    6.16 +{
    6.17 +	static char buffer[512];
    6.18 +
    6.19 +	vsnprintf(buffer, sizeof(buffer), fmt, args);
    6.20 +
    6.21 +	printk("%s", buffer);
    6.22 +}
    6.23 +
    6.24 +acpi_physical_address __init acpi_os_get_root_pointer(void)
    6.25 +{
    6.26 +	acpi_physical_address pa = 0;
    6.27 +	acpi_find_root_pointer(&pa);
    6.28 +	return pa;
    6.29 +}
    6.30 +
    6.31 +void __iomem *
    6.32 +acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
    6.33 +{
    6.34 +	return __acpi_map_table((unsigned long)phys, size);
    6.35 +}
    6.36 +EXPORT_SYMBOL_GPL(acpi_os_map_memory);
    6.37 +
    6.38 +void acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
    6.39 +{
    6.40 +}
    6.41 +EXPORT_SYMBOL_GPL(acpi_os_unmap_memory);
    6.42  
    6.43  acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width)
    6.44  {
     7.1 --- a/xen/drivers/acpi/tables.c	Tue Jun 10 09:27:01 2008 +0100
     7.2 +++ b/xen/drivers/acpi/tables.c	Tue Jun 10 13:45:29 2008 +0100
     7.3 @@ -23,172 +23,112 @@
     7.4   *
     7.5   */
     7.6  
     7.7 -#include <xen/config.h>
     7.8  #include <xen/init.h>
     7.9  #include <xen/kernel.h>
    7.10 -#include <xen/sched.h>
    7.11  #include <xen/smp.h>
    7.12  #include <xen/string.h>
    7.13  #include <xen/types.h>
    7.14  #include <xen/irq.h>
    7.15  #include <xen/errno.h>
    7.16  #include <xen/acpi.h>
    7.17 -/*#include <xen/bootmem.h>*/
    7.18  
    7.19  #define PREFIX			"ACPI: "
    7.20  
    7.21  #define ACPI_MAX_TABLES		128
    7.22  
    7.23 -static char *acpi_table_signatures[ACPI_TABLE_COUNT] = {
    7.24 -	[ACPI_TABLE_UNKNOWN] = "????",
    7.25 -	[ACPI_APIC] = "APIC",
    7.26 -	[ACPI_BOOT] = "BOOT",
    7.27 -	[ACPI_DBGP] = "DBGP",
    7.28 -	[ACPI_DSDT] = "DSDT",
    7.29 -	[ACPI_ECDT] = "ECDT",
    7.30 -	[ACPI_ETDT] = "ETDT",
    7.31 -	[ACPI_FADT] = "FACP",
    7.32 -	[ACPI_FACS] = "FACS",
    7.33 -	[ACPI_OEMX] = "OEM",
    7.34 -	[ACPI_PSDT] = "PSDT",
    7.35 -	[ACPI_SBST] = "SBST",
    7.36 -	[ACPI_SLIT] = "SLIT",
    7.37 -	[ACPI_SPCR] = "SPCR",
    7.38 -	[ACPI_SRAT] = "SRAT",
    7.39 -	[ACPI_SSDT] = "SSDT",
    7.40 -	[ACPI_SPMI] = "SPMI",
    7.41 -	[ACPI_HPET] = "HPET",
    7.42 -	[ACPI_MCFG] = "MCFG",
    7.43 -	[ACPI_DMAR] = "DMAR",
    7.44 -	[ACPI_IVRS] = "IVRS",
    7.45 -};
    7.46 -
    7.47  static char *mps_inti_flags_polarity[] = { "dfl", "high", "res", "low" };
    7.48  static char *mps_inti_flags_trigger[] = { "dfl", "edge", "res", "level" };
    7.49  
    7.50 -/* System Description Table (RSDT/XSDT) */
    7.51 -struct acpi_table_sdt {
    7.52 -	unsigned long pa;
    7.53 -	enum acpi_table_id id;
    7.54 -	unsigned long size;
    7.55 -} __attribute__ ((packed));
    7.56 -
    7.57 -static unsigned long sdt_pa;	/* Physical Address */
    7.58 -static unsigned long sdt_count;	/* Table count */
    7.59 -
    7.60 -static struct acpi_table_sdt sdt_entry[ACPI_MAX_TABLES] __initdata;
    7.61 -
    7.62 -void acpi_table_print(struct acpi_table_header *header, unsigned long phys_addr)
    7.63 -{
    7.64 -	char *name = NULL;
    7.65 -
    7.66 -	if (!header)
    7.67 -		return;
    7.68 +static struct acpi_table_desc initial_tables[ACPI_MAX_TABLES] __initdata;
    7.69  
    7.70 -	/* Some table signatures aren't good table names */
    7.71 +static int acpi_apic_instance __initdata;
    7.72  
    7.73 -	if (!strncmp((char *)&header->signature,
    7.74 -		     acpi_table_signatures[ACPI_APIC],
    7.75 -		     sizeof(header->signature))) {
    7.76 -		name = "MADT";
    7.77 -	} else if (!strncmp((char *)&header->signature,
    7.78 -			    acpi_table_signatures[ACPI_FADT],
    7.79 -			    sizeof(header->signature))) {
    7.80 -		name = "FADT";
    7.81 -	} else
    7.82 -		name = header->signature;
    7.83 -
    7.84 -	printk(KERN_DEBUG PREFIX
    7.85 -	       "%.4s (v%3.3d %6.6s %8.8s 0x%08x %.4s 0x%08x) @ 0x%p\n", name,
    7.86 -	       header->revision, header->oem_id, header->oem_table_id,
    7.87 -	       header->oem_revision, header->asl_compiler_id,
    7.88 -	       header->asl_compiler_revision, (void *)phys_addr);
    7.89 -}
    7.90 -
    7.91 -void acpi_table_print_madt_entry(acpi_table_entry_header * header)
    7.92 +void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
    7.93  {
    7.94  	if (!header)
    7.95  		return;
    7.96  
    7.97  	switch (header->type) {
    7.98  
    7.99 -	case ACPI_MADT_LAPIC:
   7.100 +	case ACPI_MADT_TYPE_LOCAL_APIC:
   7.101  		{
   7.102 -			struct acpi_table_lapic *p =
   7.103 -			    (struct acpi_table_lapic *)header;
   7.104 +			struct acpi_madt_local_apic *p =
   7.105 +			    (struct acpi_madt_local_apic *)header;
   7.106  			printk(KERN_INFO PREFIX
   7.107  			       "LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n",
   7.108 -			       p->acpi_id, p->id,
   7.109 -			       p->flags.enabled ? "enabled" : "disabled");
   7.110 +			       p->processor_id, p->id,
   7.111 +			       (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
   7.112  		}
   7.113  		break;
   7.114  
   7.115 -	case ACPI_MADT_IOAPIC:
   7.116 +	case ACPI_MADT_TYPE_IO_APIC:
   7.117  		{
   7.118 -			struct acpi_table_ioapic *p =
   7.119 -			    (struct acpi_table_ioapic *)header;
   7.120 +			struct acpi_madt_io_apic *p =
   7.121 +			    (struct acpi_madt_io_apic *)header;
   7.122  			printk(KERN_INFO PREFIX
   7.123  			       "IOAPIC (id[0x%02x] address[0x%08x] gsi_base[%d])\n",
   7.124  			       p->id, p->address, p->global_irq_base);
   7.125  		}
   7.126  		break;
   7.127  
   7.128 -	case ACPI_MADT_INT_SRC_OVR:
   7.129 +	case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE:
   7.130  		{
   7.131 -			struct acpi_table_int_src_ovr *p =
   7.132 -			    (struct acpi_table_int_src_ovr *)header;
   7.133 +			struct acpi_madt_interrupt_override *p =
   7.134 +			    (struct acpi_madt_interrupt_override *)header;
   7.135  			printk(KERN_INFO PREFIX
   7.136  			       "INT_SRC_OVR (bus %d bus_irq %d global_irq %d %s %s)\n",
   7.137 -			       p->bus, p->bus_irq, p->global_irq,
   7.138 -			       mps_inti_flags_polarity[p->flags.polarity],
   7.139 -			       mps_inti_flags_trigger[p->flags.trigger]);
   7.140 -			if (p->flags.reserved)
   7.141 +			       p->bus, p->source_irq, p->global_irq,
   7.142 +			       mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK],
   7.143 +			       mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2]);
   7.144 +			if (p->inti_flags  &
   7.145 +			    ~(ACPI_MADT_POLARITY_MASK | ACPI_MADT_TRIGGER_MASK))
   7.146  				printk(KERN_INFO PREFIX
   7.147  				       "INT_SRC_OVR unexpected reserved flags: 0x%x\n",
   7.148 -				       p->flags.reserved);
   7.149 +				       p->inti_flags  &
   7.150 +					~(ACPI_MADT_POLARITY_MASK | ACPI_MADT_TRIGGER_MASK));
   7.151  
   7.152  		}
   7.153  		break;
   7.154  
   7.155 -	case ACPI_MADT_NMI_SRC:
   7.156 +	case ACPI_MADT_TYPE_NMI_SOURCE:
   7.157  		{
   7.158 -			struct acpi_table_nmi_src *p =
   7.159 -			    (struct acpi_table_nmi_src *)header;
   7.160 +			struct acpi_madt_nmi_source *p =
   7.161 +			    (struct acpi_madt_nmi_source *)header;
   7.162  			printk(KERN_INFO PREFIX
   7.163  			       "NMI_SRC (%s %s global_irq %d)\n",
   7.164 -			       mps_inti_flags_polarity[p->flags.polarity],
   7.165 -			       mps_inti_flags_trigger[p->flags.trigger],
   7.166 +			       mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK],
   7.167 +			       mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2],
   7.168  			       p->global_irq);
   7.169  		}
   7.170  		break;
   7.171  
   7.172 -	case ACPI_MADT_LAPIC_NMI:
   7.173 +	case ACPI_MADT_TYPE_LOCAL_APIC_NMI:
   7.174  		{
   7.175 -			struct acpi_table_lapic_nmi *p =
   7.176 -			    (struct acpi_table_lapic_nmi *)header;
   7.177 +			struct acpi_madt_local_apic_nmi *p =
   7.178 +			    (struct acpi_madt_local_apic_nmi *)header;
   7.179  			printk(KERN_INFO PREFIX
   7.180  			       "LAPIC_NMI (acpi_id[0x%02x] %s %s lint[0x%x])\n",
   7.181 -			       p->acpi_id,
   7.182 -			       mps_inti_flags_polarity[p->flags.polarity],
   7.183 -			       mps_inti_flags_trigger[p->flags.trigger],
   7.184 +			       p->processor_id,
   7.185 +			       mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK	],
   7.186 +			       mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2],
   7.187  			       p->lint);
   7.188  		}
   7.189  		break;
   7.190  
   7.191 -	case ACPI_MADT_LAPIC_ADDR_OVR:
   7.192 +	case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE:
   7.193  		{
   7.194 -			struct acpi_table_lapic_addr_ovr *p =
   7.195 -			    (struct acpi_table_lapic_addr_ovr *)header;
   7.196 +			struct acpi_madt_local_apic_override *p =
   7.197 +			    (struct acpi_madt_local_apic_override *)header;
   7.198  			printk(KERN_INFO PREFIX
   7.199  			       "LAPIC_ADDR_OVR (address[%p])\n",
   7.200  			       (void *)(unsigned long)p->address);
   7.201  		}
   7.202  		break;
   7.203  
   7.204 -	case ACPI_MADT_IOSAPIC:
   7.205 +	case ACPI_MADT_TYPE_IO_SAPIC:
   7.206  		{
   7.207 -			struct acpi_table_iosapic *p =
   7.208 -			    (struct acpi_table_iosapic *)header;
   7.209 +			struct acpi_madt_io_sapic *p =
   7.210 +			    (struct acpi_madt_io_sapic *)header;
   7.211  			printk(KERN_INFO PREFIX
   7.212  			       "IOSAPIC (id[0x%x] address[%p] gsi_base[%d])\n",
   7.213  			       p->id, (void *)(unsigned long)p->address,
   7.214 @@ -196,26 +136,26 @@ void acpi_table_print_madt_entry(acpi_ta
   7.215  		}
   7.216  		break;
   7.217  
   7.218 -	case ACPI_MADT_LSAPIC:
   7.219 +	case ACPI_MADT_TYPE_LOCAL_SAPIC:
   7.220  		{
   7.221 -			struct acpi_table_lsapic *p =
   7.222 -			    (struct acpi_table_lsapic *)header;
   7.223 +			struct acpi_madt_local_sapic *p =
   7.224 +			    (struct acpi_madt_local_sapic *)header;
   7.225  			printk(KERN_INFO PREFIX
   7.226  			       "LSAPIC (acpi_id[0x%02x] lsapic_id[0x%02x] lsapic_eid[0x%02x] %s)\n",
   7.227 -			       p->acpi_id, p->id, p->eid,
   7.228 -			       p->flags.enabled ? "enabled" : "disabled");
   7.229 +			       p->processor_id, p->id, p->eid,
   7.230 +			       (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
   7.231  		}
   7.232  		break;
   7.233  
   7.234 -	case ACPI_MADT_PLAT_INT_SRC:
   7.235 +	case ACPI_MADT_TYPE_INTERRUPT_SOURCE:
   7.236  		{
   7.237 -			struct acpi_table_plat_int_src *p =
   7.238 -			    (struct acpi_table_plat_int_src *)header;
   7.239 +			struct acpi_madt_interrupt_source *p =
   7.240 +			    (struct acpi_madt_interrupt_source *)header;
   7.241  			printk(KERN_INFO PREFIX
   7.242  			       "PLAT_INT_SRC (%s %s type[0x%x] id[0x%04x] eid[0x%x] iosapic_vector[0x%x] global_irq[0x%x]\n",
   7.243 -			       mps_inti_flags_polarity[p->flags.polarity],
   7.244 -			       mps_inti_flags_trigger[p->flags.trigger],
   7.245 -			       p->type, p->id, p->eid, p->iosapic_vector,
   7.246 +			       mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK],
   7.247 +			       mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2],
   7.248 +			       p->type, p->id, p->eid, p->io_sapic_vector,
   7.249  			       p->global_irq);
   7.250  		}
   7.251  		break;
   7.252 @@ -228,352 +168,117 @@ void acpi_table_print_madt_entry(acpi_ta
   7.253  	}
   7.254  }
   7.255  
   7.256 -uint8_t
   7.257 -generate_acpi_checksum(void *tbl, unsigned long len)
   7.258 -{
   7.259 -	uint8_t *ptr, sum = 0;
   7.260 -
   7.261 -	for (ptr = tbl; len > 0 ; len--, ptr++)
   7.262 -		sum += *ptr;
   7.263 -
   7.264 -	return 0 - sum;
   7.265 -}
   7.266 -
   7.267 -static int
   7.268 -acpi_table_compute_checksum(void *table_pointer, unsigned long length)
   7.269 -{
   7.270 -	u8 *p = (u8 *) table_pointer;
   7.271 -	unsigned long remains = length;
   7.272 -	unsigned long sum = 0;
   7.273 -
   7.274 -	if (!p || !length)
   7.275 -		return -EINVAL;
   7.276 -
   7.277 -	while (remains--)
   7.278 -		sum += *p++;
   7.279 -
   7.280 -	return (sum & 0xFF);
   7.281 -}
   7.282 -
   7.283 -/*
   7.284 - * acpi_get_table_header_early()
   7.285 - * for acpi_blacklisted(), acpi_table_get_sdt()
   7.286 - */
   7.287 -int __init
   7.288 -acpi_get_table_header_early(enum acpi_table_id id,
   7.289 -			    struct acpi_table_header **header)
   7.290 -{
   7.291 -	unsigned int i;
   7.292 -	enum acpi_table_id temp_id;
   7.293 -
   7.294 -	/* DSDT is different from the rest */
   7.295 -	if (id == ACPI_DSDT)
   7.296 -		temp_id = ACPI_FADT;
   7.297 -	else
   7.298 -		temp_id = id;
   7.299 -
   7.300 -	/* Locate the table. */
   7.301 -
   7.302 -	for (i = 0; i < sdt_count; i++) {
   7.303 -		if (sdt_entry[i].id != temp_id)
   7.304 -			continue;
   7.305 -		*header = (void *)
   7.306 -		    __acpi_map_table(sdt_entry[i].pa, sdt_entry[i].size);
   7.307 -		if (!*header) {
   7.308 -			printk(KERN_WARNING PREFIX "Unable to map %s\n",
   7.309 -			       acpi_table_signatures[temp_id]);
   7.310 -			return -ENODEV;
   7.311 -		}
   7.312 -		break;
   7.313 -	}
   7.314 -
   7.315 -	if (!*header) {
   7.316 -		printk(KERN_WARNING PREFIX "%s not present\n",
   7.317 -		       acpi_table_signatures[id]);
   7.318 -		return -ENODEV;
   7.319 -	}
   7.320 -
   7.321 -	/* Map the DSDT header via the pointer in the FADT */
   7.322 -	if (id == ACPI_DSDT) {
   7.323 -		struct acpi_table_fadt *fadt =
   7.324 -			(struct acpi_table_fadt *)*header;
   7.325 -
   7.326 -		if (fadt->header.revision == 3 && fadt->Xdsdt) {
   7.327 -			*header = (void *)__acpi_map_table(fadt->Xdsdt,
   7.328 -							   sizeof(struct
   7.329 -								  acpi_table_header));
   7.330 -		} else if (fadt->dsdt) {
   7.331 -			*header = (void *)__acpi_map_table(fadt->dsdt,
   7.332 -							   sizeof(struct
   7.333 -								  acpi_table_header));
   7.334 -		} else
   7.335 -			*header = NULL;
   7.336 -
   7.337 -		if (!*header) {
   7.338 -			printk(KERN_WARNING PREFIX "Unable to map DSDT\n");
   7.339 -			return -ENODEV;
   7.340 -		}
   7.341 -	}
   7.342 -
   7.343 -	return 0;
   7.344 -}
   7.345  
   7.346  int __init
   7.347 -acpi_table_parse_madt_family(enum acpi_table_id id,
   7.348 -			     unsigned long madt_size,
   7.349 +acpi_table_parse_entries(char *id,
   7.350 +			     unsigned long table_size,
   7.351  			     int entry_id,
   7.352 -			     acpi_madt_entry_handler handler,
   7.353 +			     acpi_table_entry_handler handler,
   7.354  			     unsigned int max_entries)
   7.355  {
   7.356 -	void *madt = NULL;
   7.357 -	acpi_table_entry_header *entry;
   7.358 +	struct acpi_table_header *table_header = NULL;
   7.359 +	struct acpi_subtable_header *entry;
   7.360  	unsigned int count = 0;
   7.361 -	unsigned long madt_end;
   7.362 -	unsigned int i;
   7.363 +	unsigned long table_end;
   7.364  
   7.365  	if (!handler)
   7.366  		return -EINVAL;
   7.367  
   7.368 -	/* Locate the MADT (if exists). There should only be one. */
   7.369 +	if (strncmp(id, ACPI_SIG_MADT, 4) == 0)
   7.370 +		acpi_get_table(id, acpi_apic_instance, &table_header);
   7.371 +	else
   7.372 +		acpi_get_table(id, 0, &table_header);
   7.373  
   7.374 -	for (i = 0; i < sdt_count; i++) {
   7.375 -		if (sdt_entry[i].id != id)
   7.376 -			continue;
   7.377 -		madt = (void *)
   7.378 -		    __acpi_map_table(sdt_entry[i].pa, sdt_entry[i].size);
   7.379 -		if (!madt) {
   7.380 -			printk(KERN_WARNING PREFIX "Unable to map %s\n",
   7.381 -			       acpi_table_signatures[id]);
   7.382 -			return -ENODEV;
   7.383 -		}
   7.384 -		break;
   7.385 -	}
   7.386 -
   7.387 -	if (!madt) {
   7.388 -		printk(KERN_WARNING PREFIX "%s not present\n",
   7.389 -		       acpi_table_signatures[id]);
   7.390 +	if (!table_header) {
   7.391 +		printk(KERN_WARNING PREFIX "%4.4s not present\n", id);
   7.392  		return -ENODEV;
   7.393  	}
   7.394  
   7.395 -	madt_end = (unsigned long)madt + sdt_entry[i].size;
   7.396 +	table_end = (unsigned long)table_header + table_header->length;
   7.397  
   7.398  	/* Parse all entries looking for a match. */
   7.399  
   7.400 -	entry = (acpi_table_entry_header *)
   7.401 -	    ((unsigned long)madt + madt_size);
   7.402 +	entry = (struct acpi_subtable_header *)
   7.403 +	    ((unsigned long)table_header + table_size);
   7.404  
   7.405 -	while (((unsigned long)entry) + sizeof(acpi_table_entry_header) <
   7.406 -	       madt_end) {
   7.407 +	while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) <
   7.408 +	       table_end) {
   7.409  		if (entry->type == entry_id
   7.410  		    && (!max_entries || count++ < max_entries))
   7.411 -			if (handler(entry, madt_end))
   7.412 +			if (handler(entry, table_end))
   7.413  				return -EINVAL;
   7.414  
   7.415 -		entry = (acpi_table_entry_header *)
   7.416 +		entry = (struct acpi_subtable_header *)
   7.417  		    ((unsigned long)entry + entry->length);
   7.418  	}
   7.419  	if (max_entries && count > max_entries) {
   7.420 -		printk(KERN_WARNING PREFIX "[%s:0x%02x] ignored %i entries of "
   7.421 -		       "%i found\n", acpi_table_signatures[id], entry_id,
   7.422 -		       count - max_entries, count);
   7.423 +		printk(KERN_WARNING PREFIX "[%4.4s:0x%02x] ignored %i entries of "
   7.424 +		       "%i found\n", id, entry_id, count - max_entries, count);
   7.425  	}
   7.426  
   7.427  	return count;
   7.428  }
   7.429  
   7.430  int __init
   7.431 -acpi_table_parse_madt(enum acpi_madt_entry_id id,
   7.432 -		      acpi_madt_entry_handler handler, unsigned int max_entries)
   7.433 +acpi_table_parse_madt(enum acpi_madt_type id,
   7.434 +		      acpi_table_entry_handler handler, unsigned int max_entries)
   7.435  {
   7.436 -	return acpi_table_parse_madt_family(ACPI_APIC,
   7.437 +	return acpi_table_parse_entries(ACPI_SIG_MADT,
   7.438  					    sizeof(struct acpi_table_madt), id,
   7.439  					    handler, max_entries);
   7.440  }
   7.441  
   7.442 -int __init acpi_table_parse(enum acpi_table_id id, acpi_table_handler handler)
   7.443 +/**
   7.444 + * acpi_table_parse - find table with @id, run @handler on it
   7.445 + *
   7.446 + * @id: table id to find
   7.447 + * @handler: handler to run
   7.448 + *
   7.449 + * Scan the ACPI System Descriptor Table (STD) for a table matching @id,
   7.450 + * run @handler on it.  Return 0 if table found, return on if not.
   7.451 + */
   7.452 +int __init acpi_table_parse(char *id, acpi_table_handler handler)
   7.453  {
   7.454 -	int count = 0;
   7.455 -	unsigned int i = 0;
   7.456 +	struct acpi_table_header *table = NULL;
   7.457  
   7.458  	if (!handler)
   7.459  		return -EINVAL;
   7.460  
   7.461 -	for (i = 0; i < sdt_count; i++) {
   7.462 -		if (sdt_entry[i].id != id)
   7.463 -			continue;
   7.464 -		count++;
   7.465 -		if (count == 1)
   7.466 -			handler(sdt_entry[i].pa, sdt_entry[i].size);
   7.467 +	if (strncmp(id, ACPI_SIG_MADT, 4) == 0)
   7.468 +		acpi_get_table(id, acpi_apic_instance, &table);
   7.469 +	else
   7.470 +		acpi_get_table(id, 0, &table);
   7.471  
   7.472 -		else
   7.473 -			printk(KERN_WARNING PREFIX
   7.474 -			       "%d duplicate %s table ignored.\n", count,
   7.475 -			       acpi_table_signatures[id]);
   7.476 -	}
   7.477 -
   7.478 -	return count;
   7.479 +	if (table) {
   7.480 +		handler(table);
   7.481 +		return 0;
   7.482 +	} else
   7.483 +		return 1;
   7.484  }
   7.485  
   7.486 -static int __init acpi_table_get_sdt(struct acpi_table_rsdp *rsdp)
   7.487 +/* 
   7.488 + * The BIOS is supposed to supply a single APIC/MADT,
   7.489 + * but some report two.  Provide a knob to use either.
   7.490 + * (don't you wish instance 0 and 1 were not the same?)
   7.491 + */
   7.492 +static void __init check_multiple_madt(void)
   7.493  {
   7.494 -	struct acpi_table_header *header = NULL;
   7.495 -	unsigned int i, id = 0;
   7.496 -
   7.497 -	if (!rsdp)
   7.498 -		return -EINVAL;
   7.499 -
   7.500 -	/* First check XSDT (but only on ACPI 2.0-compatible systems) */
   7.501 -
   7.502 -	if ((rsdp->revision >= 2) && rsdp->xsdt_physical_address) {
   7.503 -
   7.504 -		struct acpi_table_xsdt *mapped_xsdt = NULL;
   7.505 -
   7.506 -		sdt_pa = rsdp->xsdt_physical_address;
   7.507 -
   7.508 -		/* map in just the header */
   7.509 -		header = (struct acpi_table_header *)
   7.510 -		    __acpi_map_table(sdt_pa, sizeof(struct acpi_table_header));
   7.511 -
   7.512 -		if (!header) {
   7.513 -			printk(KERN_WARNING PREFIX
   7.514 -			       "Unable to map XSDT header\n");
   7.515 -			return -ENODEV;
   7.516 -		}
   7.517 -
   7.518 -		/* remap in the entire table before processing */
   7.519 -		mapped_xsdt = (struct acpi_table_xsdt *)
   7.520 -		    __acpi_map_table(sdt_pa, header->length);
   7.521 -		if (!mapped_xsdt) {
   7.522 -			printk(KERN_WARNING PREFIX "Unable to map XSDT\n");
   7.523 -			return -ENODEV;
   7.524 -		}
   7.525 -		header = &mapped_xsdt->header;
   7.526 -
   7.527 -		if (strncmp(header->signature, "XSDT", 4)) {
   7.528 -			printk(KERN_WARNING PREFIX
   7.529 -			       "XSDT signature incorrect\n");
   7.530 -			return -ENODEV;
   7.531 -		}
   7.532 -
   7.533 -		if (acpi_table_compute_checksum(header, header->length)) {
   7.534 -			printk(KERN_WARNING PREFIX "Invalid XSDT checksum\n");
   7.535 -			return -ENODEV;
   7.536 -		}
   7.537 -
   7.538 -		sdt_count =
   7.539 -		    (header->length - sizeof(struct acpi_table_header)) >> 3;
   7.540 -		if (sdt_count > ACPI_MAX_TABLES) {
   7.541 -			printk(KERN_WARNING PREFIX
   7.542 -			       "Truncated %lu XSDT entries\n",
   7.543 -			       (sdt_count - ACPI_MAX_TABLES));
   7.544 -			sdt_count = ACPI_MAX_TABLES;
   7.545 -		}
   7.546 -
   7.547 -		for (i = 0; i < sdt_count; i++)
   7.548 -			sdt_entry[i].pa = (unsigned long)mapped_xsdt->table_offset_entry[i];
   7.549 -	}
   7.550 -
   7.551 -	/* Then check RSDT */
   7.552 -
   7.553 -	else if (rsdp->rsdt_physical_address) {
   7.554 -
   7.555 -		struct acpi_table_rsdt *mapped_rsdt = NULL;
   7.556 -
   7.557 -		sdt_pa = rsdp->rsdt_physical_address;
   7.558 -
   7.559 -		/* map in just the header */
   7.560 -		header = (struct acpi_table_header *)
   7.561 -		    __acpi_map_table(sdt_pa, sizeof(struct acpi_table_header));
   7.562 -		if (!header) {
   7.563 -			printk(KERN_WARNING PREFIX
   7.564 -			       "Unable to map RSDT header\n");
   7.565 -			return -ENODEV;
   7.566 -		}
   7.567 +	struct acpi_table_header *table = NULL;
   7.568  
   7.569 -		/* remap in the entire table before processing */
   7.570 -		mapped_rsdt = (struct acpi_table_rsdt *)
   7.571 -		    __acpi_map_table(sdt_pa, header->length);
   7.572 -		if (!mapped_rsdt) {
   7.573 -			printk(KERN_WARNING PREFIX "Unable to map RSDT\n");
   7.574 -			return -ENODEV;
   7.575 -		}
   7.576 -		header = &mapped_rsdt->header;
   7.577 -
   7.578 -		if (strncmp(header->signature, "RSDT", 4)) {
   7.579 -			printk(KERN_WARNING PREFIX
   7.580 -			       "RSDT signature incorrect\n");
   7.581 -			return -ENODEV;
   7.582 -		}
   7.583 -
   7.584 -		if (acpi_table_compute_checksum(header, header->length)) {
   7.585 -			printk(KERN_WARNING PREFIX "Invalid RSDT checksum\n");
   7.586 -			return -ENODEV;
   7.587 -		}
   7.588 -
   7.589 -		sdt_count =
   7.590 -		    (header->length - sizeof(struct acpi_table_header)) >> 2;
   7.591 -		if (sdt_count > ACPI_MAX_TABLES) {
   7.592 -			printk(KERN_WARNING PREFIX
   7.593 -			       "Truncated %lu RSDT entries\n",
   7.594 -			       (sdt_count - ACPI_MAX_TABLES));
   7.595 -			sdt_count = ACPI_MAX_TABLES;
   7.596 -		}
   7.597 -
   7.598 -		for (i = 0; i < sdt_count; i++)
   7.599 -			sdt_entry[i].pa = (unsigned long)mapped_rsdt->table_offset_entry[i];
   7.600 -	}
   7.601 -
   7.602 -	else {
   7.603 +	acpi_get_table(ACPI_SIG_MADT, 2, &table);
   7.604 +	if (table) {
   7.605  		printk(KERN_WARNING PREFIX
   7.606 -		       "No System Description Table (RSDT/XSDT) specified in RSDP\n");
   7.607 -		return -ENODEV;
   7.608 -	}
   7.609 -
   7.610 -	acpi_table_print(header, sdt_pa);
   7.611 +		       "BIOS bug: multiple APIC/MADT found,"
   7.612 +		       " using %d\n", acpi_apic_instance);
   7.613 +		printk(KERN_WARNING PREFIX
   7.614 +		       "If \"acpi_apic_instance=%d\" works better, "
   7.615 +		       "notify linux-acpi@vger.kernel.org\n",
   7.616 +		       acpi_apic_instance ? 0 : 2);
   7.617  
   7.618 -	for (i = 0; i < sdt_count; i++) {
   7.619 -
   7.620 -		/* map in just the header */
   7.621 -		header = (struct acpi_table_header *)
   7.622 -		    __acpi_map_table(sdt_entry[i].pa,
   7.623 -				     sizeof(struct acpi_table_header));
   7.624 -		if (!header)
   7.625 -			continue;
   7.626 -
   7.627 -		/* remap in the entire table before processing */
   7.628 -		header = (struct acpi_table_header *)
   7.629 -		    __acpi_map_table(sdt_entry[i].pa, header->length);
   7.630 -		if (!header)
   7.631 -			continue;
   7.632 -
   7.633 -		acpi_table_print(header, sdt_entry[i].pa);
   7.634 -
   7.635 -		if (acpi_table_compute_checksum(header, header->length)) {
   7.636 -			printk(KERN_WARNING "  >>> ERROR: Invalid checksum\n");
   7.637 -			continue;
   7.638 -		}
   7.639 +	} else
   7.640 +		acpi_apic_instance = 0;
   7.641  
   7.642 -		sdt_entry[i].size = header->length;
   7.643 -
   7.644 -		for (id = 0; id < ACPI_TABLE_COUNT; id++) {
   7.645 -			if (!strncmp((char *)&header->signature,
   7.646 -				     acpi_table_signatures[id],
   7.647 -				     sizeof(header->signature))) {
   7.648 -				sdt_entry[i].id = id;
   7.649 -			}
   7.650 -		}
   7.651 -	}
   7.652 -
   7.653 -	/* 
   7.654 -	 * The DSDT is *not* in the RSDT (why not? no idea.) but we want
   7.655 -	 * to print its info, because this is what people usually blacklist
   7.656 -	 * against. Unfortunately, we don't know the phys_addr, so just
   7.657 -	 * print 0. Maybe no one will notice.
   7.658 -	 */
   7.659 -	if (!acpi_get_table_header_early(ACPI_DSDT, &header))
   7.660 -		acpi_table_print(header, 0);
   7.661 -
   7.662 -	return 0;
   7.663 +	return;
   7.664  }
   7.665  
   7.666  /*
   7.667 @@ -581,190 +286,26 @@ static int __init acpi_table_get_sdt(str
   7.668   *
   7.669   * find RSDP, find and checksum SDT/XSDT.
   7.670   * checksum all tables, print SDT/XSDT
   7.671 - * 
   7.672 + *
   7.673   * result: sdt_entry[] is initialized
   7.674   */
   7.675  
   7.676  int __init acpi_table_init(void)
   7.677  {
   7.678 -	struct acpi_table_rsdp *rsdp = NULL;
   7.679 -	unsigned long rsdp_phys = 0;
   7.680 -	int result = 0;
   7.681 -
   7.682 -	/* Locate and map the Root System Description Table (RSDP) */
   7.683 -
   7.684 -	rsdp_phys = acpi_find_rsdp();
   7.685 -	if (!rsdp_phys) {
   7.686 -		printk(KERN_ERR PREFIX "Unable to locate RSDP\n");
   7.687 -		return -ENODEV;
   7.688 -	}
   7.689 -
   7.690 -	rsdp = (struct acpi_table_rsdp *)__acpi_map_table(rsdp_phys,
   7.691 -		sizeof(struct acpi_table_rsdp));
   7.692 -	if (!rsdp) {
   7.693 -		printk(KERN_WARNING PREFIX "Unable to map RSDP\n");
   7.694 -		return -ENODEV;
   7.695 -	}
   7.696 -
   7.697 -	printk(KERN_DEBUG PREFIX
   7.698 -	       "RSDP (v%3.3d %6.6s                                ) @ 0x%p\n",
   7.699 -	       rsdp->revision, rsdp->oem_id, (void *)rsdp_phys);
   7.700 -
   7.701 -	if (rsdp->revision < 2)
   7.702 -		result =
   7.703 -		    acpi_table_compute_checksum(rsdp, 20);
   7.704 -	else
   7.705 -		result =
   7.706 -		    acpi_table_compute_checksum(rsdp, rsdp->length);
   7.707 -
   7.708 -	if (result) {
   7.709 -		printk(KERN_WARNING "  >>> ERROR: Invalid checksum\n");
   7.710 -		return -ENODEV;
   7.711 -	}
   7.712 -
   7.713 -	/* Locate and map the System Description table (RSDT/XSDT) */
   7.714 -
   7.715 -	if (acpi_table_get_sdt(rsdp))
   7.716 -		return -ENODEV;
   7.717 -
   7.718 +	acpi_ut_init_globals();
   7.719 +	acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0);
   7.720 +	check_multiple_madt();
   7.721  	return 0;
   7.722  }
   7.723  
   7.724 -int __init
   7.725 -acpi_table_disable(enum acpi_table_id table_id)
   7.726 +static int __init acpi_parse_apic_instance(char *str)
   7.727  {
   7.728 -	struct acpi_table_header *header = NULL;
   7.729 -	struct acpi_table_rsdp *rsdp;
   7.730 -	unsigned long rsdp_phys;
   7.731 -	char *table_name;
   7.732 -	int id;
   7.733 -
   7.734 -	rsdp_phys = acpi_find_rsdp();
   7.735 -	if (!rsdp_phys)
   7.736 -		return -ENODEV;
   7.737 -
   7.738 -	rsdp = (struct acpi_table_rsdp *)__acpi_map_table(rsdp_phys,
   7.739 -		sizeof(struct acpi_table_rsdp));
   7.740 -	if (!rsdp)
   7.741 -		return -ENODEV;
   7.742 -
   7.743 -	for (id = 0; id < sdt_count; id++)
   7.744 -		if (sdt_entry[id].id == table_id)
   7.745 -			break;
   7.746 -
   7.747 -	if (id == sdt_count)
   7.748 -		return -ENOENT;
   7.749 -
   7.750 -	table_name = acpi_table_signatures[table_id];
   7.751 -
   7.752 -	/* First check XSDT (but only on ACPI 2.0-compatible systems) */
   7.753 -
   7.754 -	if ((rsdp->revision >= 2) && rsdp->xsdt_physical_address) {
   7.755 -
   7.756 -		struct acpi_table_xsdt *mapped_xsdt = NULL;
   7.757 -
   7.758 -		sdt_pa = rsdp->xsdt_physical_address;
   7.759 -
   7.760 -		/* map in just the header */
   7.761 -		header = (struct acpi_table_header *)
   7.762 -		    __acpi_map_table(sdt_pa, sizeof(struct acpi_table_header));
   7.763 -
   7.764 -		if (!header) {
   7.765 -			printk(KERN_WARNING PREFIX
   7.766 -			       "Unable to map XSDT header\n");
   7.767 -			return -ENODEV;
   7.768 -		}
   7.769 -
   7.770 -		/* remap in the entire table before processing */
   7.771 -		mapped_xsdt = (struct acpi_table_xsdt *)
   7.772 -		    __acpi_map_table(sdt_pa, header->length);
   7.773 -		if (!mapped_xsdt) {
   7.774 -			printk(KERN_WARNING PREFIX "Unable to map XSDT\n");
   7.775 -			return -ENODEV;
   7.776 -		}
   7.777 -		header = &mapped_xsdt->header;
   7.778 -
   7.779 -		if (strncmp(header->signature, "XSDT", 4)) {
   7.780 -			printk(KERN_WARNING PREFIX
   7.781 -			       "XSDT signature incorrect\n");
   7.782 -			return -ENODEV;
   7.783 -		}
   7.784 -
   7.785 -		if (acpi_table_compute_checksum(header, header->length)) {
   7.786 -			printk(KERN_WARNING PREFIX "Invalid XSDT checksum\n");
   7.787 -			return -ENODEV;
   7.788 -		}
   7.789  
   7.790 -		if (id < sdt_count) {
   7.791 -			header = (struct acpi_table_header *)
   7.792 -			   __acpi_map_table(mapped_xsdt->table_offset_entry[id], sizeof(struct acpi_table_header));
   7.793 -		} else {
   7.794 -			printk(KERN_WARNING PREFIX
   7.795 -			       "Unable to disable entry %d\n",
   7.796 -			       id);
   7.797 -			return -ENODEV;
   7.798 -		}
   7.799 -	}
   7.800 -
   7.801 -	/* Then check RSDT */
   7.802 -
   7.803 -	else if (rsdp->rsdt_physical_address) {
   7.804 -
   7.805 -		struct acpi_table_rsdt *mapped_rsdt = NULL;
   7.806 -
   7.807 -		sdt_pa = rsdp->rsdt_physical_address;
   7.808 -
   7.809 -		/* map in just the header */
   7.810 -		header = (struct acpi_table_header *)
   7.811 -		    __acpi_map_table(sdt_pa, sizeof(struct acpi_table_header));
   7.812 -		if (!header) {
   7.813 -			printk(KERN_WARNING PREFIX
   7.814 -			       "Unable to map RSDT header\n");
   7.815 -			return -ENODEV;
   7.816 -		}
   7.817 +	acpi_apic_instance = simple_strtoul(str, NULL, 0);
   7.818  
   7.819 -		/* remap in the entire table before processing */
   7.820 -		mapped_rsdt = (struct acpi_table_rsdt *)
   7.821 -		    __acpi_map_table(sdt_pa, header->length);
   7.822 -		if (!mapped_rsdt) {
   7.823 -			printk(KERN_WARNING PREFIX "Unable to map RSDT\n");
   7.824 -			return -ENODEV;
   7.825 -		}
   7.826 -		header = &mapped_rsdt->header;
   7.827 -
   7.828 -		if (strncmp(header->signature, "RSDT", 4)) {
   7.829 -			printk(KERN_WARNING PREFIX
   7.830 -			       "RSDT signature incorrect\n");
   7.831 -			return -ENODEV;
   7.832 -		}
   7.833 -
   7.834 -		if (acpi_table_compute_checksum(header, header->length)) {
   7.835 -			printk(KERN_WARNING PREFIX "Invalid RSDT checksum\n");
   7.836 -			return -ENODEV;
   7.837 -		}
   7.838 -		if (id < sdt_count) {
   7.839 -			header = (struct acpi_table_header *)
   7.840 -			   __acpi_map_table(mapped_rsdt->table_offset_entry[id], sizeof(struct acpi_table_header));
   7.841 -		} else {
   7.842 -			printk(KERN_WARNING PREFIX
   7.843 -			       "Unable to disable entry %d\n",
   7.844 -			       id);
   7.845 -			return -ENODEV;
   7.846 -		}
   7.847 -	}
   7.848 -
   7.849 -	else {
   7.850 -		printk(KERN_WARNING PREFIX
   7.851 -		       "No System Description Table (RSDT/XSDT) specified in RSDP\n");
   7.852 -		return -ENODEV;
   7.853 -	}
   7.854 -
   7.855 -	memcpy(header->signature, "OEMx", 4);
   7.856 -	memcpy(header->oem_id, "xxxxxx", 6);
   7.857 -	memcpy(header->oem_id+1, table_name, 4);
   7.858 -	memcpy(header->oem_table_id, "Xen     ", 8);
   7.859 -	header->checksum = 0;
   7.860 -	header->checksum = generate_acpi_checksum(header, header->length);
   7.861 +	printk(KERN_NOTICE PREFIX "Shall use APIC/MADT table %d\n",
   7.862 +	       acpi_apic_instance);
   7.863  
   7.864  	return 0;
   7.865  }
   7.866 +custom_param("acpi_apic_instance", acpi_parse_apic_instance);
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/xen/drivers/acpi/tables/Makefile	Tue Jun 10 13:45:29 2008 +0100
     8.3 @@ -0,0 +1,5 @@
     8.4 +obj-y += tbfadt.o
     8.5 +obj-y += tbinstal.o
     8.6 +obj-y += tbutils.o
     8.7 +obj-y += tbxface.o
     8.8 +obj-y += tbxfroot.o
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/xen/drivers/acpi/tables/tbfadt.c	Tue Jun 10 13:45:29 2008 +0100
     9.3 @@ -0,0 +1,458 @@
     9.4 +/******************************************************************************
     9.5 + *
     9.6 + * Module Name: tbfadt   - FADT table utilities
     9.7 + *
     9.8 + *****************************************************************************/
     9.9 +
    9.10 +/*
    9.11 + * Copyright (C) 2000 - 2008, Intel Corp.
    9.12 + * All rights reserved.
    9.13 + *
    9.14 + * Redistribution and use in source and binary forms, with or without
    9.15 + * modification, are permitted provided that the following conditions
    9.16 + * are met:
    9.17 + * 1. Redistributions of source code must retain the above copyright
    9.18 + *    notice, this list of conditions, and the following disclaimer,
    9.19 + *    without modification.
    9.20 + * 2. Redistributions in binary form must reproduce at minimum a disclaimer
    9.21 + *    substantially similar to the "NO WARRANTY" disclaimer below
    9.22 + *    ("Disclaimer") and any redistribution must be conditioned upon
    9.23 + *    including a substantially similar Disclaimer requirement for further
    9.24 + *    binary redistribution.
    9.25 + * 3. Neither the names of the above-listed copyright holders nor the names
    9.26 + *    of any contributors may be used to endorse or promote products derived
    9.27 + *    from this software without specific prior written permission.
    9.28 + *
    9.29 + * Alternatively, this software may be distributed under the terms of the
    9.30 + * GNU General Public License ("GPL") version 2 as published by the Free
    9.31 + * Software Foundation.
    9.32 + *
    9.33 + * NO WARRANTY
    9.34 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    9.35 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    9.36 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
    9.37 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    9.38 + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    9.39 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    9.40 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    9.41 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
    9.42 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
    9.43 + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    9.44 + * POSSIBILITY OF SUCH DAMAGES.
    9.45 + */
    9.46 +
    9.47 +#include <xen/config.h>
    9.48 +#include <xen/init.h>
    9.49 +#include <acpi/acpi.h>
    9.50 +#include <acpi/actables.h>
    9.51 +
    9.52 +#define _COMPONENT          ACPI_TABLES
    9.53 +ACPI_MODULE_NAME("tbfadt")
    9.54 +
    9.55 +/* Local prototypes */
    9.56 +static void inline
    9.57 +acpi_tb_init_generic_address(struct acpi_generic_address *generic_address,
    9.58 +			     u8 bit_width, u64 address);
    9.59 +
    9.60 +static void acpi_tb_convert_fadt(void);
    9.61 +
    9.62 +static void acpi_tb_validate_fadt(void);
    9.63 +
    9.64 +/* Table for conversion of FADT to common internal format and FADT validation */
    9.65 +
    9.66 +typedef struct acpi_fadt_info {
    9.67 +	char *name;
    9.68 +	u8 target;
    9.69 +	u8 source;
    9.70 +	u8 length;
    9.71 +	u8 type;
    9.72 +
    9.73 +} acpi_fadt_info;
    9.74 +
    9.75 +#define ACPI_FADT_REQUIRED          1
    9.76 +#define ACPI_FADT_SEPARATE_LENGTH   2
    9.77 +
    9.78 +static struct acpi_fadt_info fadt_info_table[] = {
    9.79 +	{"Pm1aEventBlock", ACPI_FADT_OFFSET(xpm1a_event_block),
    9.80 +	 ACPI_FADT_OFFSET(pm1a_event_block),
    9.81 +	 ACPI_FADT_OFFSET(pm1_event_length), ACPI_FADT_REQUIRED},
    9.82 +
    9.83 +	{"Pm1bEventBlock", ACPI_FADT_OFFSET(xpm1b_event_block),
    9.84 +	 ACPI_FADT_OFFSET(pm1b_event_block),
    9.85 +	 ACPI_FADT_OFFSET(pm1_event_length), 0},
    9.86 +
    9.87 +	{"Pm1aControlBlock", ACPI_FADT_OFFSET(xpm1a_control_block),
    9.88 +	 ACPI_FADT_OFFSET(pm1a_control_block),
    9.89 +	 ACPI_FADT_OFFSET(pm1_control_length), ACPI_FADT_REQUIRED},
    9.90 +
    9.91 +	{"Pm1bControlBlock", ACPI_FADT_OFFSET(xpm1b_control_block),
    9.92 +	 ACPI_FADT_OFFSET(pm1b_control_block),
    9.93 +	 ACPI_FADT_OFFSET(pm1_control_length), 0},
    9.94 +
    9.95 +	{"Pm2ControlBlock", ACPI_FADT_OFFSET(xpm2_control_block),
    9.96 +	 ACPI_FADT_OFFSET(pm2_control_block),
    9.97 +	 ACPI_FADT_OFFSET(pm2_control_length), ACPI_FADT_SEPARATE_LENGTH},
    9.98 +
    9.99 +	{"PmTimerBlock", ACPI_FADT_OFFSET(xpm_timer_block),
   9.100 +	 ACPI_FADT_OFFSET(pm_timer_block),
   9.101 +	 ACPI_FADT_OFFSET(pm_timer_length), ACPI_FADT_REQUIRED},
   9.102 +
   9.103 +	{"Gpe0Block", ACPI_FADT_OFFSET(xgpe0_block),
   9.104 +	 ACPI_FADT_OFFSET(gpe0_block),
   9.105 +	 ACPI_FADT_OFFSET(gpe0_block_length), ACPI_FADT_SEPARATE_LENGTH},
   9.106 +
   9.107 +	{"Gpe1Block", ACPI_FADT_OFFSET(xgpe1_block),
   9.108 +	 ACPI_FADT_OFFSET(gpe1_block),
   9.109 +	 ACPI_FADT_OFFSET(gpe1_block_length), ACPI_FADT_SEPARATE_LENGTH}
   9.110 +};
   9.111 +
   9.112 +#define ACPI_FADT_INFO_ENTRIES        (sizeof (fadt_info_table) / sizeof (struct acpi_fadt_info))
   9.113 +
   9.114 +/*******************************************************************************
   9.115 + *
   9.116 + * FUNCTION:    acpi_tb_init_generic_address
   9.117 + *
   9.118 + * PARAMETERS:  generic_address     - GAS struct to be initialized
   9.119 + *              bit_width           - Width of this register
   9.120 + *              Address             - Address of the register
   9.121 + *
   9.122 + * RETURN:      None
   9.123 + *
   9.124 + * DESCRIPTION: Initialize a Generic Address Structure (GAS)
   9.125 + *              See the ACPI specification for a full description and
   9.126 + *              definition of this structure.
   9.127 + *
   9.128 + ******************************************************************************/
   9.129 +
   9.130 +static void inline
   9.131 +acpi_tb_init_generic_address(struct acpi_generic_address *generic_address,
   9.132 +			     u8 bit_width, u64 address)
   9.133 +{
   9.134 +
   9.135 +	/*
   9.136 +	 * The 64-bit Address field is non-aligned in the byte packed
   9.137 +	 * GAS struct.
   9.138 +	 */
   9.139 +	ACPI_MOVE_64_TO_64(&generic_address->address, &address);
   9.140 +
   9.141 +	/* All other fields are byte-wide */
   9.142 +
   9.143 +	generic_address->space_id = ACPI_ADR_SPACE_SYSTEM_IO;
   9.144 +	generic_address->bit_width = bit_width;
   9.145 +	generic_address->bit_offset = 0;
   9.146 +	generic_address->access_width = 0;
   9.147 +}
   9.148 +
   9.149 +/*******************************************************************************
   9.150 + *
   9.151 + * FUNCTION:    acpi_tb_parse_fadt
   9.152 + *
   9.153 + * PARAMETERS:  table_index         - Index for the FADT
   9.154 + *              Flags               - Flags
   9.155 + *
   9.156 + * RETURN:      None
   9.157 + *
   9.158 + * DESCRIPTION: Initialize the FADT, DSDT and FACS tables
   9.159 + *              (FADT contains the addresses of the DSDT and FACS)
   9.160 + *
   9.161 + ******************************************************************************/
   9.162 +
   9.163 +void acpi_tb_parse_fadt(acpi_native_uint table_index, u8 flags)
   9.164 +{
   9.165 +	u32 length;
   9.166 +	struct acpi_table_header *table;
   9.167 +
   9.168 +	/*
   9.169 +	 * The FADT has multiple versions with different lengths,
   9.170 +	 * and it contains pointers to both the DSDT and FACS tables.
   9.171 +	 *
   9.172 +	 * Get a local copy of the FADT and convert it to a common format
   9.173 +	 * Map entire FADT, assumed to be smaller than one page.
   9.174 +	 */
   9.175 +	length = acpi_gbl_root_table_list.tables[table_index].length;
   9.176 +
   9.177 +	table =
   9.178 +	    acpi_os_map_memory(acpi_gbl_root_table_list.tables[table_index].
   9.179 +			       address, length);
   9.180 +	if (!table) {
   9.181 +		return;
   9.182 +	}
   9.183 +
   9.184 +	/*
   9.185 +	 * Validate the FADT checksum before we copy the table. Ignore
   9.186 +	 * checksum error as we want to try to get the DSDT and FACS.
   9.187 +	 */
   9.188 +	(void)acpi_tb_verify_checksum(table, length);
   9.189 +
   9.190 +	/* Obtain a local copy of the FADT in common ACPI 2.0+ format */
   9.191 +
   9.192 +	acpi_tb_create_local_fadt(table, length);
   9.193 +
   9.194 +	/* All done with the real FADT, unmap it */
   9.195 +
   9.196 +	acpi_os_unmap_memory(table, length);
   9.197 +
   9.198 +	/* Obtain the DSDT and FACS tables via their addresses within the FADT */
   9.199 +
   9.200 +	acpi_tb_install_table((acpi_physical_address) acpi_gbl_FADT.Xdsdt,
   9.201 +			      flags, ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT);
   9.202 +
   9.203 +	acpi_tb_install_table((acpi_physical_address) acpi_gbl_FADT.Xfacs,
   9.204 +			      flags, ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS);
   9.205 +}
   9.206 +
   9.207 +/*******************************************************************************
   9.208 + *
   9.209 + * FUNCTION:    acpi_tb_create_local_fadt
   9.210 + *
   9.211 + * PARAMETERS:  Table               - Pointer to BIOS FADT
   9.212 + *              Length              - Length of the table
   9.213 + *
   9.214 + * RETURN:      None
   9.215 + *
   9.216 + * DESCRIPTION: Get a local copy of the FADT and convert it to a common format.
   9.217 + *              Performs validation on some important FADT fields.
   9.218 + *
   9.219 + * NOTE:        We create a local copy of the FADT regardless of the version.
   9.220 + *
   9.221 + ******************************************************************************/
   9.222 +
   9.223 +void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
   9.224 +{
   9.225 +
   9.226 +	/*
   9.227 +	 * Check if the FADT is larger than the largest table that we expect
   9.228 +	 * (the ACPI 2.0/3.0 version). If so, truncate the table, and issue
   9.229 +	 * a warning.
   9.230 +	 */
   9.231 +	if (length > sizeof(struct acpi_table_fadt)) {
   9.232 +		ACPI_WARNING((AE_INFO,
   9.233 +			      "FADT (revision %u) is longer than ACPI 2.0 version, truncating length 0x%X to 0x%zX",
   9.234 +			      table->revision, (unsigned)length,
   9.235 +			      sizeof(struct acpi_table_fadt)));
   9.236 +	}
   9.237 +
   9.238 +	/* Clear the entire local FADT */
   9.239 +
   9.240 +	ACPI_MEMSET(&acpi_gbl_FADT, 0, sizeof(struct acpi_table_fadt));
   9.241 +
   9.242 +	/* Copy the original FADT, up to sizeof (struct acpi_table_fadt) */
   9.243 +
   9.244 +	ACPI_MEMCPY(&acpi_gbl_FADT, table,
   9.245 +		    ACPI_MIN(length, sizeof(struct acpi_table_fadt)));
   9.246 +
   9.247 +	/*
   9.248 +	 * 1) Convert the local copy of the FADT to the common internal format
   9.249 +	 * 2) Validate some of the important values within the FADT
   9.250 +	 */
   9.251 +	acpi_tb_convert_fadt();
   9.252 +	acpi_tb_validate_fadt();
   9.253 +}
   9.254 +
   9.255 +/*******************************************************************************
   9.256 + *
   9.257 + * FUNCTION:    acpi_tb_convert_fadt
   9.258 + *
   9.259 + * PARAMETERS:  None, uses acpi_gbl_FADT
   9.260 + *
   9.261 + * RETURN:      None
   9.262 + *
   9.263 + * DESCRIPTION: Converts all versions of the FADT to a common internal format.
   9.264 + *              Expand all 32-bit addresses to 64-bit.
   9.265 + *
   9.266 + * NOTE:        acpi_gbl_FADT must be of size (struct acpi_table_fadt),
   9.267 + *              and must contain a copy of the actual FADT.
   9.268 + *
   9.269 + * ACPICA will use the "X" fields of the FADT for all addresses.
   9.270 + *
   9.271 + * "X" fields are optional extensions to the original V1.0 fields. Even if
   9.272 + * they are present in the structure, they can be optionally not used by
   9.273 + * setting them to zero. Therefore, we must selectively expand V1.0 fields
   9.274 + * if the corresponding X field is zero.
   9.275 + *
   9.276 + * For ACPI 1.0 FADTs, all address fields are expanded to the corresponding
   9.277 + * "X" fields.
   9.278 + *
   9.279 + * For ACPI 2.0 FADTs, any "X" fields that are NULL are filled in by
   9.280 + * expanding the corresponding ACPI 1.0 field.
   9.281 + *
   9.282 + ******************************************************************************/
   9.283 +
   9.284 +static void acpi_tb_convert_fadt(void)
   9.285 +{
   9.286 +	u8 pm1_register_length;
   9.287 +	struct acpi_generic_address *target;
   9.288 +	acpi_native_uint i;
   9.289 +
   9.290 +	/* Update the local FADT table header length */
   9.291 +
   9.292 +	acpi_gbl_FADT.header.length = sizeof(struct acpi_table_fadt);
   9.293 +
   9.294 +	/* Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary */
   9.295 +
   9.296 +	if (!acpi_gbl_FADT.Xfacs) {
   9.297 +		acpi_gbl_FADT.Xfacs = (u64) acpi_gbl_FADT.facs;
   9.298 +	}
   9.299 +
   9.300 +	if (!acpi_gbl_FADT.Xdsdt) {
   9.301 +		acpi_gbl_FADT.Xdsdt = (u64) acpi_gbl_FADT.dsdt;
   9.302 +	}
   9.303 +
   9.304 +	/*
   9.305 +	 * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which
   9.306 +	 * should be zero are indeed zero. This will workaround BIOSs that
   9.307 +	 * inadvertently place values in these fields.
   9.308 +	 *
   9.309 +	 * The ACPI 1.0 reserved fields that will be zeroed are the bytes located at
   9.310 +	 * offset 45, 55, 95, and the word located at offset 109, 110.
   9.311 +	 */
   9.312 +	if (acpi_gbl_FADT.header.revision < 3) {
   9.313 +		acpi_gbl_FADT.preferred_profile = 0;
   9.314 +		acpi_gbl_FADT.pstate_control = 0;
   9.315 +		acpi_gbl_FADT.cst_control = 0;
   9.316 +		acpi_gbl_FADT.boot_flags = 0;
   9.317 +	}
   9.318 +
   9.319 +	/*
   9.320 +	 * Expand the ACPI 1.0 32-bit V1.0 addresses to the ACPI 2.0 64-bit "X"
   9.321 +	 * generic address structures as necessary.
   9.322 +	 */
   9.323 +	for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) {
   9.324 +		target =
   9.325 +		    ACPI_ADD_PTR(struct acpi_generic_address, &acpi_gbl_FADT,
   9.326 +				 fadt_info_table[i].target);
   9.327 +
   9.328 +		/* Expand only if the X target is null */
   9.329 +
   9.330 +		if (!target->address) {
   9.331 +			acpi_tb_init_generic_address(target,
   9.332 +						     *ACPI_ADD_PTR(u8,
   9.333 +								   &acpi_gbl_FADT,
   9.334 +								   fadt_info_table
   9.335 +								   [i].length),
   9.336 +						     (u64) * ACPI_ADD_PTR(u32,
   9.337 +									  &acpi_gbl_FADT,
   9.338 +									  fadt_info_table
   9.339 +									  [i].
   9.340 +									  source));
   9.341 +		}
   9.342 +	}
   9.343 +
   9.344 +	/*
   9.345 +	 * Calculate separate GAS structs for the PM1 Enable registers.
   9.346 +	 * These addresses do not appear (directly) in the FADT, so it is
   9.347 +	 * useful to calculate them once, here.
   9.348 +	 *
   9.349 +	 * The PM event blocks are split into two register blocks, first is the
   9.350 +	 * PM Status Register block, followed immediately by the PM Enable Register
   9.351 +	 * block. Each is of length (pm1_event_length/2)
   9.352 +	 */
   9.353 +	pm1_register_length = (u8) ACPI_DIV_2(acpi_gbl_FADT.pm1_event_length);
   9.354 +
   9.355 +	/* The PM1A register block is required */
   9.356 +
   9.357 +	acpi_tb_init_generic_address(&acpi_gbl_xpm1a_enable,
   9.358 +				     pm1_register_length,
   9.359 +				     (acpi_gbl_FADT.xpm1a_event_block.address +
   9.360 +				      pm1_register_length));
   9.361 +	/* Don't forget to copy space_id of the GAS */
   9.362 +	acpi_gbl_xpm1a_enable.space_id =
   9.363 +	    acpi_gbl_FADT.xpm1a_event_block.space_id;
   9.364 +
   9.365 +	/* The PM1B register block is optional, ignore if not present */
   9.366 +
   9.367 +	if (acpi_gbl_FADT.xpm1b_event_block.address) {
   9.368 +		acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable,
   9.369 +					     pm1_register_length,
   9.370 +					     (acpi_gbl_FADT.xpm1b_event_block.
   9.371 +					      address + pm1_register_length));
   9.372 +		/* Don't forget to copy space_id of the GAS */
   9.373 +		acpi_gbl_xpm1b_enable.space_id =
   9.374 +		    acpi_gbl_FADT.xpm1a_event_block.space_id;
   9.375 +
   9.376 +	}
   9.377 +}
   9.378 +
   9.379 +/******************************************************************************
   9.380 + *
   9.381 + * FUNCTION:    acpi_tb_validate_fadt
   9.382 + *
   9.383 + * PARAMETERS:  Table           - Pointer to the FADT to be validated
   9.384 + *
   9.385 + * RETURN:      None
   9.386 + *
   9.387 + * DESCRIPTION: Validate various important fields within the FADT. If a problem
   9.388 + *              is found, issue a message, but no status is returned.
   9.389 + *              Used by both the table manager and the disassembler.
   9.390 + *
   9.391 + * Possible additional checks:
   9.392 + * (acpi_gbl_FADT.pm1_event_length >= 4)
   9.393 + * (acpi_gbl_FADT.pm1_control_length >= 2)
   9.394 + * (acpi_gbl_FADT.pm_timer_length >= 4)
   9.395 + * Gpe block lengths must be multiple of 2
   9.396 + *
   9.397 + ******************************************************************************/
   9.398 +
   9.399 +static void acpi_tb_validate_fadt(void)
   9.400 +{
   9.401 +	u32 *address32;
   9.402 +	struct acpi_generic_address *address64;
   9.403 +	u8 length;
   9.404 +	acpi_native_uint i;
   9.405 +
   9.406 +	/* Examine all of the 64-bit extended address fields (X fields) */
   9.407 +
   9.408 +	for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) {
   9.409 +
   9.410 +		/* Generate pointers to the 32-bit and 64-bit addresses and get the length */
   9.411 +
   9.412 +		address64 =
   9.413 +		    ACPI_ADD_PTR(struct acpi_generic_address, &acpi_gbl_FADT,
   9.414 +				 fadt_info_table[i].target);
   9.415 +		address32 =
   9.416 +		    ACPI_ADD_PTR(u32, &acpi_gbl_FADT,
   9.417 +				 fadt_info_table[i].source);
   9.418 +		length =
   9.419 +		    *ACPI_ADD_PTR(u8, &acpi_gbl_FADT,
   9.420 +				  fadt_info_table[i].length);
   9.421 +
   9.422 +		if (fadt_info_table[i].type & ACPI_FADT_REQUIRED) {
   9.423 +			/*
   9.424 +			 * Field is required (Pm1a_event, Pm1a_control, pm_timer).
   9.425 +			 * Both the address and length must be non-zero.
   9.426 +			 */
   9.427 +			if (!address64->address || !length) {
   9.428 +				ACPI_ERROR((AE_INFO,
   9.429 +					    "Required field \"%s\" has zero address and/or length: %8.8X%8.8X/%X",
   9.430 +					    fadt_info_table[i].name,
   9.431 +					    ACPI_FORMAT_UINT64(address64->
   9.432 +							       address),
   9.433 +					    length));
   9.434 +			}
   9.435 +		} else if (fadt_info_table[i].type & ACPI_FADT_SEPARATE_LENGTH) {
   9.436 +			/*
   9.437 +			 * Field is optional (PM2Control, GPE0, GPE1) AND has its own
   9.438 +			 * length field. If present, both the address and length must be valid.
   9.439 +			 */
   9.440 +			if ((address64->address && !length)
   9.441 +			    || (!address64->address && length)) {
   9.442 +				ACPI_WARNING((AE_INFO,
   9.443 +					      "Optional field \"%s\" has zero address or length: %8.8X%8.8X/%X",
   9.444 +					      fadt_info_table[i].name,
   9.445 +					      ACPI_FORMAT_UINT64(address64->
   9.446 +								 address),
   9.447 +					      length));
   9.448 +			}
   9.449 +		}
   9.450 +
   9.451 +		/* If both 32- and 64-bit addresses are valid (non-zero), they must match */
   9.452 +
   9.453 +		if (address64->address && *address32 &&
   9.454 +		    (address64->address != (u64) * address32)) {
   9.455 +			ACPI_ERROR((AE_INFO,
   9.456 +				    "32/64X address mismatch in \"%s\": [%8.8X] [%8.8X%8.8X], using 64X",
   9.457 +				    fadt_info_table[i].name, *address32,
   9.458 +				    ACPI_FORMAT_UINT64(address64->address)));
   9.459 +		}
   9.460 +	}
   9.461 +}
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/xen/drivers/acpi/tables/tbinstal.c	Tue Jun 10 13:45:29 2008 +0100
    10.3 @@ -0,0 +1,150 @@
    10.4 +/******************************************************************************
    10.5 + *
    10.6 + * Module Name: tbinstal - ACPI table installation and removal
    10.7 + *
    10.8 + *****************************************************************************/
    10.9 +
   10.10 +/*
   10.11 + * Copyright (C) 2000 - 2008, Intel Corp.
   10.12 + * All rights reserved.
   10.13 + *
   10.14 + * Redistribution and use in source and binary forms, with or without
   10.15 + * modification, are permitted provided that the following conditions
   10.16 + * are met:
   10.17 + * 1. Redistributions of source code must retain the above copyright
   10.18 + *    notice, this list of conditions, and the following disclaimer,
   10.19 + *    without modification.
   10.20 + * 2. Redistributions in binary form must reproduce at minimum a disclaimer
   10.21 + *    substantially similar to the "NO WARRANTY" disclaimer below
   10.22 + *    ("Disclaimer") and any redistribution must be conditioned upon
   10.23 + *    including a substantially similar Disclaimer requirement for further
   10.24 + *    binary redistribution.
   10.25 + * 3. Neither the names of the above-listed copyright holders nor the names
   10.26 + *    of any contributors may be used to endorse or promote products derived
   10.27 + *    from this software without specific prior written permission.
   10.28 + *
   10.29 + * Alternatively, this software may be distributed under the terms of the
   10.30 + * GNU General Public License ("GPL") version 2 as published by the Free
   10.31 + * Software Foundation.
   10.32 + *
   10.33 + * NO WARRANTY
   10.34 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   10.35 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   10.36 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
   10.37 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   10.38 + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   10.39 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   10.40 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   10.41 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   10.42 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
   10.43 + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   10.44 + * POSSIBILITY OF SUCH DAMAGES.
   10.45 + */
   10.46 +
   10.47 +#include <acpi/acpi.h>
   10.48 +#include <acpi/acnamesp.h>
   10.49 +#include <acpi/actables.h>
   10.50 +
   10.51 +#define _COMPONENT          ACPI_TABLES
   10.52 +ACPI_MODULE_NAME("tbinstal")
   10.53 +
   10.54 +/******************************************************************************
   10.55 + *
   10.56 + * FUNCTION:    acpi_tb_verify_table
   10.57 + *
   10.58 + * PARAMETERS:  table_desc          - table
   10.59 + *
   10.60 + * RETURN:      Status
   10.61 + *
   10.62 + * DESCRIPTION: this function is called to verify and map table
   10.63 + *
   10.64 + *****************************************************************************/
   10.65 +acpi_status acpi_tb_verify_table(struct acpi_table_desc *table_desc)
   10.66 +{
   10.67 +	acpi_status status = AE_OK;
   10.68 +
   10.69 +	ACPI_FUNCTION_TRACE(tb_verify_table);
   10.70 +
   10.71 +	/* Map the table if necessary */
   10.72 +
   10.73 +	if (!table_desc->pointer) {
   10.74 +		if ((table_desc->flags & ACPI_TABLE_ORIGIN_MASK) ==
   10.75 +		    ACPI_TABLE_ORIGIN_MAPPED) {
   10.76 +			table_desc->pointer =
   10.77 +			    acpi_os_map_memory(table_desc->address,
   10.78 +					       table_desc->length);
   10.79 +		}
   10.80 +		if (!table_desc->pointer) {
   10.81 +			return_ACPI_STATUS(AE_NO_MEMORY);
   10.82 +		}
   10.83 +	}
   10.84 +
   10.85 +	/* FACS is the odd table, has no standard ACPI header and no checksum */
   10.86 +
   10.87 +	if (!ACPI_COMPARE_NAME(&table_desc->signature, ACPI_SIG_FACS)) {
   10.88 +
   10.89 +		/* Always calculate checksum, ignore bad checksum if requested */
   10.90 +
   10.91 +		status =
   10.92 +		    acpi_tb_verify_checksum(table_desc->pointer,
   10.93 +					    table_desc->length);
   10.94 +	}
   10.95 +
   10.96 +	return_ACPI_STATUS(status);
   10.97 +}
   10.98 +
   10.99 +/*******************************************************************************
  10.100 + *
  10.101 + * FUNCTION:    acpi_tb_resize_root_table_list
  10.102 + *
  10.103 + * PARAMETERS:  None
  10.104 + *
  10.105 + * RETURN:      Status
  10.106 + *
  10.107 + * DESCRIPTION: Expand the size of global table array
  10.108 + *
  10.109 + ******************************************************************************/
  10.110 +
  10.111 +acpi_status acpi_tb_resize_root_table_list(void)
  10.112 +{
  10.113 +	struct acpi_table_desc *tables;
  10.114 +
  10.115 +	ACPI_FUNCTION_TRACE(tb_resize_root_table_list);
  10.116 +
  10.117 +	/* allow_resize flag is a parameter to acpi_initialize_tables */
  10.118 +
  10.119 +	if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) {
  10.120 +		ACPI_ERROR((AE_INFO,
  10.121 +			    "Resize of Root Table Array is not allowed"));
  10.122 +		return_ACPI_STATUS(AE_SUPPORT);
  10.123 +	}
  10.124 +
  10.125 +	/* Increase the Table Array size */
  10.126 +
  10.127 +	tables = ACPI_ALLOCATE_ZEROED((acpi_gbl_root_table_list.size +
  10.128 +				       ACPI_ROOT_TABLE_SIZE_INCREMENT)
  10.129 +				      * sizeof(struct acpi_table_desc));
  10.130 +	if (!tables) {
  10.131 +		ACPI_ERROR((AE_INFO,
  10.132 +			    "Could not allocate new root table array"));
  10.133 +		return_ACPI_STATUS(AE_NO_MEMORY);
  10.134 +	}
  10.135 +
  10.136 +	/* Copy and free the previous table array */
  10.137 +
  10.138 +	if (acpi_gbl_root_table_list.tables) {
  10.139 +		ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables,
  10.140 +			    acpi_gbl_root_table_list.size *
  10.141 +			    sizeof(struct acpi_table_desc));
  10.142 +
  10.143 +		if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
  10.144 +			ACPI_FREE(acpi_gbl_root_table_list.tables);
  10.145 +		}
  10.146 +	}
  10.147 +
  10.148 +	acpi_gbl_root_table_list.tables = tables;
  10.149 +	acpi_gbl_root_table_list.size += ACPI_ROOT_TABLE_SIZE_INCREMENT;
  10.150 +	acpi_gbl_root_table_list.flags |= (u8) ACPI_ROOT_ORIGIN_ALLOCATED;
  10.151 +
  10.152 +	return_ACPI_STATUS(AE_OK);
  10.153 +}
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/xen/drivers/acpi/tables/tbutils.c	Tue Jun 10 13:45:29 2008 +0100
    11.3 @@ -0,0 +1,560 @@
    11.4 +/******************************************************************************
    11.5 + *
    11.6 + * Module Name: tbutils   - table utilities
    11.7 + *
    11.8 + *****************************************************************************/
    11.9 +
   11.10 +/*
   11.11 + * Copyright (C) 2000 - 2008, Intel Corp.
   11.12 + * All rights reserved.
   11.13 + *
   11.14 + * Redistribution and use in source and binary forms, with or without
   11.15 + * modification, are permitted provided that the following conditions
   11.16 + * are met:
   11.17 + * 1. Redistributions of source code must retain the above copyright
   11.18 + *    notice, this list of conditions, and the following disclaimer,
   11.19 + *    without modification.
   11.20 + * 2. Redistributions in binary form must reproduce at minimum a disclaimer
   11.21 + *    substantially similar to the "NO WARRANTY" disclaimer below
   11.22 + *    ("Disclaimer") and any redistribution must be conditioned upon
   11.23 + *    including a substantially similar Disclaimer requirement for further
   11.24 + *    binary redistribution.
   11.25 + * 3. Neither the names of the above-listed copyright holders nor the names
   11.26 + *    of any contributors may be used to endorse or promote products derived
   11.27 + *    from this software without specific prior written permission.
   11.28 + *
   11.29 + * Alternatively, this software may be distributed under the terms of the
   11.30 + * GNU General Public License ("GPL") version 2 as published by the Free
   11.31 + * Software Foundation.
   11.32 + *
   11.33 + * NO WARRANTY
   11.34 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   11.35 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   11.36 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
   11.37 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   11.38 + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   11.39 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   11.40 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   11.41 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   11.42 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
   11.43 + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   11.44 + * POSSIBILITY OF SUCH DAMAGES.
   11.45 + */
   11.46 +
   11.47 +#include <xen/config.h>
   11.48 +#include <xen/init.h>
   11.49 +#include <acpi/acpi.h>
   11.50 +#include <acpi/actables.h>
   11.51 +
   11.52 +#define _COMPONENT          ACPI_TABLES
   11.53 +ACPI_MODULE_NAME("tbutils")
   11.54 +
   11.55 +/* Local prototypes */
   11.56 +static acpi_physical_address
   11.57 +acpi_tb_get_root_table_entry(u8 * table_entry,
   11.58 +			     acpi_native_uint table_entry_size);
   11.59 +/*******************************************************************************
   11.60 + *
   11.61 + * FUNCTION:    acpi_tb_check_xsdt
   11.62 + *
   11.63 + * PARAMETERS:  address                    - Pointer to the XSDT
   11.64 + *
   11.65 + * RETURN:      status
   11.66 + *		AE_OK - XSDT is okay
   11.67 + *		AE_NO_MEMORY - can't map XSDT
   11.68 + *		AE_INVALID_TABLE_LENGTH - invalid table length
   11.69 + *		AE_NULL_ENTRY - XSDT has NULL entry
   11.70 + *
   11.71 + * DESCRIPTION: validate XSDT
   11.72 +******************************************************************************/
   11.73 +
   11.74 +static acpi_status
   11.75 +acpi_tb_check_xsdt(acpi_physical_address address)
   11.76 +{
   11.77 +	struct acpi_table_header *table;
   11.78 +	u32 length;
   11.79 +	u64 xsdt_entry_address;
   11.80 +	u8 *table_entry;
   11.81 +	u32 table_count;
   11.82 +	int i;
   11.83 +
   11.84 +	table = acpi_os_map_memory(address, sizeof(struct acpi_table_header));
   11.85 +	if (!table)
   11.86 +		return AE_NO_MEMORY;
   11.87 +
   11.88 +	length = table->length;
   11.89 +	acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
   11.90 +	if (length < sizeof(struct acpi_table_header))
   11.91 +		return AE_INVALID_TABLE_LENGTH;
   11.92 +
   11.93 +	table = acpi_os_map_memory(address, length);
   11.94 +	if (!table)
   11.95 +		return AE_NO_MEMORY;
   11.96 +
   11.97 +	/* Calculate the number of tables described in XSDT */
   11.98 +	table_count =
   11.99 +		(u32) ((table->length -
  11.100 +		sizeof(struct acpi_table_header)) / sizeof(u64));
  11.101 +	table_entry =
  11.102 +		ACPI_CAST_PTR(u8, table) + sizeof(struct acpi_table_header);
  11.103 +	for (i = 0; i < table_count; i++) {
  11.104 +		ACPI_MOVE_64_TO_64(&xsdt_entry_address, table_entry);
  11.105 +		if (!xsdt_entry_address) {
  11.106 +			/* XSDT has NULL entry */
  11.107 +			break;
  11.108 +		}
  11.109 +		table_entry += sizeof(u64);
  11.110 +	}
  11.111 +	acpi_os_unmap_memory(table, length);
  11.112 +
  11.113 +	if (i < table_count)
  11.114 +		return AE_NULL_ENTRY;
  11.115 +	else
  11.116 +		return AE_OK;
  11.117 +}
  11.118 +
  11.119 +/*******************************************************************************
  11.120 + *
  11.121 + * FUNCTION:    acpi_tb_tables_loaded
  11.122 + *
  11.123 + * PARAMETERS:  None
  11.124 + *
  11.125 + * RETURN:      TRUE if required ACPI tables are loaded
  11.126 + *
  11.127 + * DESCRIPTION: Determine if the minimum required ACPI tables are present
  11.128 + *              (FADT, FACS, DSDT)
  11.129 + *
  11.130 + ******************************************************************************/
  11.131 +
  11.132 +u8 acpi_tb_tables_loaded(void)
  11.133 +{
  11.134 +
  11.135 +	if (acpi_gbl_root_table_list.count >= 3) {
  11.136 +		return (TRUE);
  11.137 +	}
  11.138 +
  11.139 +	return (FALSE);
  11.140 +}
  11.141 +
  11.142 +/*******************************************************************************
  11.143 + *
  11.144 + * FUNCTION:    acpi_tb_print_table_header
  11.145 + *
  11.146 + * PARAMETERS:  Address             - Table physical address
  11.147 + *              Header              - Table header
  11.148 + *
  11.149 + * RETURN:      None
  11.150 + *
  11.151 + * DESCRIPTION: Print an ACPI table header. Special cases for FACS and RSDP.
  11.152 + *
  11.153 + ******************************************************************************/
  11.154 +
  11.155 +void
  11.156 +acpi_tb_print_table_header(acpi_physical_address address,
  11.157 +			   struct acpi_table_header *header)
  11.158 +{
  11.159 +
  11.160 +	if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_FACS)) {
  11.161 +
  11.162 +		/* FACS only has signature and length fields of common table header */
  11.163 +
  11.164 +		ACPI_INFO((AE_INFO, "%4.4s %08lX, %04X",
  11.165 +			   header->signature, (unsigned long)address,
  11.166 +			   header->length));
  11.167 +	} else if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_RSDP)) {
  11.168 +
  11.169 +		/* RSDP has no common fields */
  11.170 +
  11.171 +		ACPI_INFO((AE_INFO, "RSDP %08lX, %04X (r%d %6.6s)",
  11.172 +			   (unsigned long)address,
  11.173 +			   (ACPI_CAST_PTR(struct acpi_table_rsdp, header)->
  11.174 +			    revision >
  11.175 +			    0) ? ACPI_CAST_PTR(struct acpi_table_rsdp,
  11.176 +					       header)->length : 20,
  11.177 +			   ACPI_CAST_PTR(struct acpi_table_rsdp,
  11.178 +					 header)->revision,
  11.179 +			   ACPI_CAST_PTR(struct acpi_table_rsdp,
  11.180 +					 header)->oem_id));
  11.181 +	} else {
  11.182 +		/* Standard ACPI table with full common header */
  11.183 +
  11.184 +		ACPI_INFO((AE_INFO,
  11.185 +			   "%4.4s %08lX, %04X (r%d %6.6s %8.8s %8X %4.4s %8X)",
  11.186 +			   header->signature, (unsigned long)address,
  11.187 +			   header->length, header->revision, header->oem_id,
  11.188 +			   header->oem_table_id, header->oem_revision,
  11.189 +			   header->asl_compiler_id,
  11.190 +			   header->asl_compiler_revision));
  11.191 +	}
  11.192 +}
  11.193 +
  11.194 +/*******************************************************************************
  11.195 + *
  11.196 + * FUNCTION:    acpi_tb_validate_checksum
  11.197 + *
  11.198 + * PARAMETERS:  Table               - ACPI table to verify
  11.199 + *              Length              - Length of entire table
  11.200 + *
  11.201 + * RETURN:      Status
  11.202 + *
  11.203 + * DESCRIPTION: Verifies that the table checksums to zero. Optionally returns
  11.204 + *              exception on bad checksum.
  11.205 + *
  11.206 + ******************************************************************************/
  11.207 +
  11.208 +acpi_status acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length)
  11.209 +{
  11.210 +	u8 checksum;
  11.211 +
  11.212 +	/* Compute the checksum on the table */
  11.213 +
  11.214 +	checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, table), length);
  11.215 +
  11.216 +	/* Checksum ok? (should be zero) */
  11.217 +
  11.218 +	if (checksum) {
  11.219 +		ACPI_WARNING((AE_INFO,
  11.220 +			      "Incorrect checksum in table [%4.4s] - %2.2X, should be %2.2X",
  11.221 +			      table->signature, table->checksum,
  11.222 +			      (u8) (table->checksum - checksum)));
  11.223 +
  11.224 +#if (ACPI_CHECKSUM_ABORT)
  11.225 +
  11.226 +		return (AE_BAD_CHECKSUM);
  11.227 +#endif
  11.228 +	}
  11.229 +
  11.230 +	return (AE_OK);
  11.231 +}
  11.232 +
  11.233 +/*******************************************************************************
  11.234 + *
  11.235 + * FUNCTION:    acpi_tb_checksum
  11.236 + *
  11.237 + * PARAMETERS:  Buffer          - Pointer to memory region to be checked
  11.238 + *              Length          - Length of this memory region
  11.239 + *
  11.240 + * RETURN:      Checksum (u8)
  11.241 + *
  11.242 + * DESCRIPTION: Calculates circular checksum of memory region.
  11.243 + *
  11.244 + ******************************************************************************/
  11.245 +
  11.246 +u8 acpi_tb_checksum(u8 * buffer, acpi_native_uint length)
  11.247 +{
  11.248 +	u8 sum = 0;
  11.249 +	u8 *end = buffer + length;
  11.250 +
  11.251 +	while (buffer < end) {
  11.252 +		sum = (u8) (sum + *(buffer++));
  11.253 +	}
  11.254 +
  11.255 +	return sum;
  11.256 +}
  11.257 +
  11.258 +/*******************************************************************************
  11.259 + *
  11.260 + * FUNCTION:    acpi_tb_install_table
  11.261 + *
  11.262 + * PARAMETERS:  Address                 - Physical address of DSDT or FACS
  11.263 + *              Flags                   - Flags
  11.264 + *              Signature               - Table signature, NULL if no need to
  11.265 + *                                        match
  11.266 + *              table_index             - Index into root table array
  11.267 + *
  11.268 + * RETURN:      None
  11.269 + *
  11.270 + * DESCRIPTION: Install an ACPI table into the global data structure.
  11.271 + *
  11.272 + ******************************************************************************/
  11.273 +
  11.274 +void
  11.275 +acpi_tb_install_table(acpi_physical_address address,
  11.276 +		      u8 flags, char *signature, acpi_native_uint table_index)
  11.277 +{
  11.278 +	struct acpi_table_header *table;
  11.279 +
  11.280 +	if (!address) {
  11.281 +		ACPI_ERROR((AE_INFO,
  11.282 +			    "Null physical address for ACPI table [%s]",
  11.283 +			    signature));
  11.284 +		return;
  11.285 +	}
  11.286 +
  11.287 +	/* Map just the table header */
  11.288 +
  11.289 +	table = acpi_os_map_memory(address, sizeof(struct acpi_table_header));
  11.290 +	if (!table) {
  11.291 +		return;
  11.292 +	}
  11.293 +
  11.294 +	/* If a particular signature is expected, signature must match */
  11.295 +
  11.296 +	if (signature && !ACPI_COMPARE_NAME(table->signature, signature)) {
  11.297 +		ACPI_ERROR((AE_INFO,
  11.298 +			    "Invalid signature 0x%X for ACPI table [%s]",
  11.299 +			    *ACPI_CAST_PTR(u32, table->signature), signature));
  11.300 +		goto unmap_and_exit;
  11.301 +	}
  11.302 +
  11.303 +	/* Initialize the table entry */
  11.304 +
  11.305 +	acpi_gbl_root_table_list.tables[table_index].address = address;
  11.306 +	acpi_gbl_root_table_list.tables[table_index].length = table->length;
  11.307 +	acpi_gbl_root_table_list.tables[table_index].flags = flags;
  11.308 +
  11.309 +	ACPI_MOVE_32_TO_32(&
  11.310 +			   (acpi_gbl_root_table_list.tables[table_index].
  11.311 +			    signature), table->signature);
  11.312 +
  11.313 +	acpi_tb_print_table_header(address, table);
  11.314 +
  11.315 +	if (table_index == ACPI_TABLE_INDEX_DSDT) {
  11.316 +
  11.317 +		/* Global integer width is based upon revision of the DSDT */
  11.318 +
  11.319 +		acpi_ut_set_integer_width(table->revision);
  11.320 +	}
  11.321 +
  11.322 +      unmap_and_exit:
  11.323 +	acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
  11.324 +}
  11.325 +
  11.326 +/*******************************************************************************
  11.327 + *
  11.328 + * FUNCTION:    acpi_tb_get_root_table_entry
  11.329 + *
  11.330 + * PARAMETERS:  table_entry         - Pointer to the RSDT/XSDT table entry
  11.331 + *              table_entry_size    - sizeof 32 or 64 (RSDT or XSDT)
  11.332 + *
  11.333 + * RETURN:      Physical address extracted from the root table
  11.334 + *
  11.335 + * DESCRIPTION: Get one root table entry. Handles 32-bit and 64-bit cases on
  11.336 + *              both 32-bit and 64-bit platforms
  11.337 + *
  11.338 + * NOTE:        acpi_physical_address is 32-bit on 32-bit platforms, 64-bit on
  11.339 + *              64-bit platforms.
  11.340 + *
  11.341 + ******************************************************************************/
  11.342 +
  11.343 +static acpi_physical_address
  11.344 +acpi_tb_get_root_table_entry(u8 * table_entry,
  11.345 +			     acpi_native_uint table_entry_size)
  11.346 +{
  11.347 +	u64 address64;
  11.348 +
  11.349 +	/*
  11.350 +	 * Get the table physical address (32-bit for RSDT, 64-bit for XSDT):
  11.351 +	 * Note: Addresses are 32-bit aligned (not 64) in both RSDT and XSDT
  11.352 +	 */
  11.353 +	if (table_entry_size == sizeof(u32)) {
  11.354 +		/*
  11.355 +		 * 32-bit platform, RSDT: Return 32-bit table entry
  11.356 +		 * 64-bit platform, RSDT: Expand 32-bit to 64-bit and return
  11.357 +		 */
  11.358 +		return ((acpi_physical_address)
  11.359 +			(*ACPI_CAST_PTR(u32, table_entry)));
  11.360 +	} else {
  11.361 +		/*
  11.362 +		 * 32-bit platform, XSDT: Truncate 64-bit to 32-bit and return
  11.363 +		 * 64-bit platform, XSDT: Move (unaligned) 64-bit to local, return 64-bit
  11.364 +		 */
  11.365 +		ACPI_MOVE_64_TO_64(&address64, table_entry);
  11.366 +
  11.367 +#if ACPI_MACHINE_WIDTH == 32
  11.368 +		if (address64 > ACPI_UINT32_MAX) {
  11.369 +
  11.370 +			/* Will truncate 64-bit address to 32 bits, issue warning */
  11.371 +
  11.372 +			ACPI_WARNING((AE_INFO,
  11.373 +				      "64-bit Physical Address in XSDT is too large (%8.8X%8.8X), truncating",
  11.374 +				      ACPI_FORMAT_UINT64(address64)));
  11.375 +		}
  11.376 +#endif
  11.377 +		return ((acpi_physical_address) (address64));
  11.378 +	}
  11.379 +}
  11.380 +
  11.381 +/*******************************************************************************
  11.382 + *
  11.383 + * FUNCTION:    acpi_tb_parse_root_table
  11.384 + *
  11.385 + * PARAMETERS:  Rsdp                    - Pointer to the RSDP
  11.386 + *              Flags                   - Flags
  11.387 + *
  11.388 + * RETURN:      Status
  11.389 + *
  11.390 + * DESCRIPTION: This function is called to parse the Root System Description
  11.391 + *              Table (RSDT or XSDT)
  11.392 + *
  11.393 + * NOTE:        Tables are mapped (not copied) for efficiency. The FACS must
  11.394 + *              be mapped and cannot be copied because it contains the actual
  11.395 + *              memory location of the ACPI Global Lock.
  11.396 + *
  11.397 + ******************************************************************************/
  11.398 +
  11.399 +acpi_status __init
  11.400 +acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags)
  11.401 +{
  11.402 +	struct acpi_table_rsdp *rsdp;
  11.403 +	acpi_native_uint table_entry_size;
  11.404 +	acpi_native_uint i;
  11.405 +	u32 table_count;
  11.406 +	struct acpi_table_header *table;
  11.407 +	acpi_physical_address address;
  11.408 +	acpi_physical_address uninitialized_var(rsdt_address);
  11.409 +	u32 length;
  11.410 +	u8 *table_entry;
  11.411 +	acpi_status status;
  11.412 +
  11.413 +	ACPI_FUNCTION_TRACE(tb_parse_root_table);
  11.414 +
  11.415 +	/*
  11.416 +	 * Map the entire RSDP and extract the address of the RSDT or XSDT
  11.417 +	 */
  11.418 +	rsdp = acpi_os_map_memory(rsdp_address, sizeof(struct acpi_table_rsdp));
  11.419 +	if (!rsdp) {
  11.420 +		return_ACPI_STATUS(AE_NO_MEMORY);
  11.421 +	}
  11.422 +
  11.423 +	acpi_tb_print_table_header(rsdp_address,
  11.424 +				   ACPI_CAST_PTR(struct acpi_table_header,
  11.425 +						 rsdp));
  11.426 +
  11.427 +	/* Differentiate between RSDT and XSDT root tables */
  11.428 +
  11.429 +	if (rsdp->revision > 1 && rsdp->xsdt_physical_address) {
  11.430 +		/*
  11.431 +		 * Root table is an XSDT (64-bit physical addresses). We must use the
  11.432 +		 * XSDT if the revision is > 1 and the XSDT pointer is present, as per
  11.433 +		 * the ACPI specification.
  11.434 +		 */
  11.435 +		address = (acpi_physical_address) rsdp->xsdt_physical_address;
  11.436 +		table_entry_size = sizeof(u64);
  11.437 +		rsdt_address = (acpi_physical_address)
  11.438 +					rsdp->rsdt_physical_address;
  11.439 +	} else {
  11.440 +		/* Root table is an RSDT (32-bit physical addresses) */
  11.441 +
  11.442 +		address = (acpi_physical_address) rsdp->rsdt_physical_address;
  11.443 +		table_entry_size = sizeof(u32);
  11.444 +	}
  11.445 +
  11.446 +	/*
  11.447 +	 * It is not possible to map more than one entry in some environments,
  11.448 +	 * so unmap the RSDP here before mapping other tables
  11.449 +	 */
  11.450 +	acpi_os_unmap_memory(rsdp, sizeof(struct acpi_table_rsdp));
  11.451 +
  11.452 +	if (table_entry_size == sizeof(u64)) {
  11.453 +		if (acpi_tb_check_xsdt(address) == AE_NULL_ENTRY) {
  11.454 +			/* XSDT has NULL entry, RSDT is used */
  11.455 +			address = rsdt_address;
  11.456 +			table_entry_size = sizeof(u32);
  11.457 +			ACPI_WARNING((AE_INFO, "BIOS XSDT has NULL entry, "
  11.458 +					"using RSDT"));
  11.459 +		}
  11.460 +	}
  11.461 +	/* Map the RSDT/XSDT table header to get the full table length */
  11.462 +
  11.463 +	table = acpi_os_map_memory(address, sizeof(struct acpi_table_header));
  11.464 +	if (!table) {
  11.465 +		return_ACPI_STATUS(AE_NO_MEMORY);
  11.466 +	}
  11.467 +
  11.468 +	acpi_tb_print_table_header(address, table);
  11.469 +
  11.470 +	/* Get the length of the full table, verify length and map entire table */
  11.471 +
  11.472 +	length = table->length;
  11.473 +	acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
  11.474 +
  11.475 +	if (length < sizeof(struct acpi_table_header)) {
  11.476 +		ACPI_ERROR((AE_INFO, "Invalid length 0x%X in RSDT/XSDT",
  11.477 +			    length));
  11.478 +		return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
  11.479 +	}
  11.480 +
  11.481 +	table = acpi_os_map_memory(address, length);
  11.482 +	if (!table) {
  11.483 +		return_ACPI_STATUS(AE_NO_MEMORY);
  11.484 +	}
  11.485 +
  11.486 +	/* Validate the root table checksum */
  11.487 +
  11.488 +	status = acpi_tb_verify_checksum(table, length);
  11.489 +	if (ACPI_FAILURE(status)) {
  11.490 +		acpi_os_unmap_memory(table, length);
  11.491 +		return_ACPI_STATUS(status);
  11.492 +	}
  11.493 +
  11.494 +	/* Calculate the number of tables described in the root table */
  11.495 +
  11.496 +	table_count =
  11.497 +	    (u32) ((table->length -
  11.498 +		    sizeof(struct acpi_table_header)) / table_entry_size);
  11.499 +
  11.500 +	/*
  11.501 +	 * First two entries in the table array are reserved for the DSDT and FACS,
  11.502 +	 * which are not actually present in the RSDT/XSDT - they come from the FADT
  11.503 +	 */
  11.504 +	table_entry =
  11.505 +	    ACPI_CAST_PTR(u8, table) + sizeof(struct acpi_table_header);
  11.506 +	acpi_gbl_root_table_list.count = 2;
  11.507 +
  11.508 +	/*
  11.509 +	 * Initialize the root table array from the RSDT/XSDT
  11.510 +	 */
  11.511 +	for (i = 0; i < table_count; i++) {
  11.512 +		if (acpi_gbl_root_table_list.count >=
  11.513 +		    acpi_gbl_root_table_list.size) {
  11.514 +
  11.515 +			/* There is no more room in the root table array, attempt resize */
  11.516 +
  11.517 +			status = acpi_tb_resize_root_table_list();
  11.518 +			if (ACPI_FAILURE(status)) {
  11.519 +				ACPI_WARNING((AE_INFO,
  11.520 +					      "Truncating %u table entries!",
  11.521 +					      (unsigned)
  11.522 +					      (acpi_gbl_root_table_list.size -
  11.523 +					       acpi_gbl_root_table_list.
  11.524 +					       count)));
  11.525 +				break;
  11.526 +			}
  11.527 +		}
  11.528 +
  11.529 +		/* Get the table physical address (32-bit for RSDT, 64-bit for XSDT) */
  11.530 +
  11.531 +		acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].
  11.532 +		    address =
  11.533 +		    acpi_tb_get_root_table_entry(table_entry, table_entry_size);
  11.534 +
  11.535 +		table_entry += table_entry_size;
  11.536 +		acpi_gbl_root_table_list.count++;
  11.537 +	}
  11.538 +
  11.539 +	/*
  11.540 +	 * It is not possible to map more than one entry in some environments,
  11.541 +	 * so unmap the root table here before mapping other tables
  11.542 +	 */
  11.543 +	acpi_os_unmap_memory(table, length);
  11.544 +
  11.545 +	/*
  11.546 +	 * Complete the initialization of the root table array by examining
  11.547 +	 * the header of each table
  11.548 +	 */
  11.549 +	for (i = 2; i < acpi_gbl_root_table_list.count; i++) {
  11.550 +		acpi_tb_install_table(acpi_gbl_root_table_list.tables[i].
  11.551 +				      address, flags, NULL, i);
  11.552 +
  11.553 +		/* Special case for FADT - get the DSDT and FACS */
  11.554 +
  11.555 +		if (ACPI_COMPARE_NAME
  11.556 +		    (&acpi_gbl_root_table_list.tables[i].signature,
  11.557 +		     ACPI_SIG_FADT)) {
  11.558 +			acpi_tb_parse_fadt(i, flags);
  11.559 +		}
  11.560 +	}
  11.561 +
  11.562 +	return_ACPI_STATUS(AE_OK);
  11.563 +}
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/xen/drivers/acpi/tables/tbxface.c	Tue Jun 10 13:45:29 2008 +0100
    12.3 @@ -0,0 +1,261 @@
    12.4 +/******************************************************************************
    12.5 + *
    12.6 + * Module Name: tbxface - Public interfaces to the ACPI subsystem
    12.7 + *                         ACPI table oriented interfaces
    12.8 + *
    12.9 + *****************************************************************************/
   12.10 +
   12.11 +/*
   12.12 + * Copyright (C) 2000 - 2008, Intel Corp.
   12.13 + * All rights reserved.
   12.14 + *
   12.15 + * Redistribution and use in source and binary forms, with or without
   12.16 + * modification, are permitted provided that the following conditions
   12.17 + * are met:
   12.18 + * 1. Redistributions of source code must retain the above copyright
   12.19 + *    notice, this list of conditions, and the following disclaimer,
   12.20 + *    without modification.
   12.21 + * 2. Redistributions in binary form must reproduce at minimum a disclaimer
   12.22 + *    substantially similar to the "NO WARRANTY" disclaimer below
   12.23 + *    ("Disclaimer") and any redistribution must be conditioned upon
   12.24 + *    including a substantially similar Disclaimer requirement for further
   12.25 + *    binary redistribution.
   12.26 + * 3. Neither the names of the above-listed copyright holders nor the names
   12.27 + *    of any contributors may be used to endorse or promote products derived
   12.28 + *    from this software without specific prior written permission.
   12.29 + *
   12.30 + * Alternatively, this software may be distributed under the terms of the
   12.31 + * GNU General Public License ("GPL") version 2 as published by the Free
   12.32 + * Software Foundation.
   12.33 + *
   12.34 + * NO WARRANTY
   12.35 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   12.36 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   12.37 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
   12.38 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   12.39 + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   12.40 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   12.41 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   12.42 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   12.43 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
   12.44 + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   12.45 + * POSSIBILITY OF SUCH DAMAGES.
   12.46 + */
   12.47 +
   12.48 +#include <xen/config.h>
   12.49 +#include <xen/init.h>
   12.50 +#include <acpi/acpi.h>
   12.51 +#include <acpi/acnamesp.h>
   12.52 +#include <acpi/actables.h>
   12.53 +
   12.54 +#define _COMPONENT          ACPI_TABLES
   12.55 +ACPI_MODULE_NAME("tbxface")
   12.56 +
   12.57 +/*******************************************************************************
   12.58 + *
   12.59 + * FUNCTION:    acpi_allocate_root_table
   12.60 + *
   12.61 + * PARAMETERS:  initial_table_count - Size of initial_table_array, in number of
   12.62 + *                                    struct acpi_table_desc structures
   12.63 + *
   12.64 + * RETURN:      Status
   12.65 + *
   12.66 + * DESCRIPTION: Allocate a root table array. Used by i_aSL compiler and
   12.67 + *              acpi_initialize_tables.
   12.68 + *
   12.69 + ******************************************************************************/
   12.70 +
   12.71 +acpi_status acpi_allocate_root_table(u32 initial_table_count)
   12.72 +{
   12.73 +
   12.74 +	acpi_gbl_root_table_list.size = initial_table_count;
   12.75 +	acpi_gbl_root_table_list.flags = ACPI_ROOT_ALLOW_RESIZE;
   12.76 +
   12.77 +	return (acpi_tb_resize_root_table_list());
   12.78 +}
   12.79 +
   12.80 +/*******************************************************************************
   12.81 + *
   12.82 + * FUNCTION:    acpi_initialize_tables
   12.83 + *
   12.84 + * PARAMETERS:  initial_table_array - Pointer to an array of pre-allocated
   12.85 + *                                    struct acpi_table_desc structures. If NULL, the
   12.86 + *                                    array is dynamically allocated.
   12.87 + *              initial_table_count - Size of initial_table_array, in number of
   12.88 + *                                    struct acpi_table_desc structures
   12.89 + *              allow_realloc       - Flag to tell Table Manager if resize of
   12.90 + *                                    pre-allocated array is allowed. Ignored
   12.91 + *                                    if initial_table_array is NULL.
   12.92 + *
   12.93 + * RETURN:      Status
   12.94 + *
   12.95 + * DESCRIPTION: Initialize the table manager, get the RSDP and RSDT/XSDT.
   12.96 + *
   12.97 + * NOTE:        Allows static allocation of the initial table array in order
   12.98 + *              to avoid the use of dynamic memory in confined environments
   12.99 + *              such as the kernel boot sequence where it may not be available.
  12.100 + *
  12.101 + *              If the host OS memory managers are initialized, use NULL for
  12.102 + *              initial_table_array, and the table will be dynamically allocated.
  12.103 + *
  12.104 + ******************************************************************************/
  12.105 +
  12.106 +acpi_status __init
  12.107 +acpi_initialize_tables(struct acpi_table_desc * initial_table_array,
  12.108 +		       u32 initial_table_count, u8 allow_resize)
  12.109 +{
  12.110 +	acpi_physical_address rsdp_address;
  12.111 +	acpi_status status;
  12.112 +
  12.113 +	ACPI_FUNCTION_TRACE(acpi_initialize_tables);
  12.114 +
  12.115 +	/*
  12.116 +	 * Set up the Root Table Array
  12.117 +	 * Allocate the table array if requested
  12.118 +	 */
  12.119 +	if (!initial_table_array) {
  12.120 +		status = acpi_allocate_root_table(initial_table_count);
  12.121 +		if (ACPI_FAILURE(status)) {
  12.122 +			return_ACPI_STATUS(status);
  12.123 +		}
  12.124 +	} else {
  12.125 +		/* Root Table Array has been statically allocated by the host */
  12.126 +
  12.127 +		ACPI_MEMSET(initial_table_array, 0,
  12.128 +			    initial_table_count *
  12.129 +			    sizeof(struct acpi_table_desc));
  12.130 +
  12.131 +		acpi_gbl_root_table_list.tables = initial_table_array;
  12.132 +		acpi_gbl_root_table_list.size = initial_table_count;
  12.133 +		acpi_gbl_root_table_list.flags = ACPI_ROOT_ORIGIN_UNKNOWN;
  12.134 +		if (allow_resize) {
  12.135 +			acpi_gbl_root_table_list.flags |=
  12.136 +			    ACPI_ROOT_ALLOW_RESIZE;
  12.137 +		}
  12.138 +	}
  12.139 +
  12.140 +	/* Get the address of the RSDP */
  12.141 +
  12.142 +	rsdp_address = acpi_os_get_root_pointer();
  12.143 +	if (!rsdp_address) {
  12.144 +		return_ACPI_STATUS(AE_NOT_FOUND);
  12.145 +	}
  12.146 +
  12.147 +	/*
  12.148 +	 * Get the root table (RSDT or XSDT) and extract all entries to the local
  12.149 +	 * Root Table Array. This array contains the information of the RSDT/XSDT
  12.150 +	 * in a common, more useable format.
  12.151 +	 */
  12.152 +	status =
  12.153 +	    acpi_tb_parse_root_table(rsdp_address, ACPI_TABLE_ORIGIN_MAPPED);
  12.154 +	return_ACPI_STATUS(status);
  12.155 +}
  12.156 +
  12.157 +/*******************************************************************************
  12.158 + *
  12.159 + * FUNCTION:    acpi_reallocate_root_table
  12.160 + *
  12.161 + * PARAMETERS:  None
  12.162 + *
  12.163 + * RETURN:      Status
  12.164 + *
  12.165 + * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the
  12.166 + *              root list from the previously provided scratch area. Should
  12.167 + *              be called once dynamic memory allocation is available in the
  12.168 + *              kernel
  12.169 + *
  12.170 + ******************************************************************************/
  12.171 +acpi_status acpi_reallocate_root_table(void)
  12.172 +{
  12.173 +	struct acpi_table_desc *tables;
  12.174 +	acpi_size new_size;
  12.175 +
  12.176 +	ACPI_FUNCTION_TRACE(acpi_reallocate_root_table);
  12.177 +
  12.178 +	/*
  12.179 +	 * Only reallocate the root table if the host provided a static buffer
  12.180 +	 * for the table array in the call to acpi_initialize_tables.
  12.181 +	 */
  12.182 +	if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
  12.183 +		return_ACPI_STATUS(AE_SUPPORT);
  12.184 +	}
  12.185 +
  12.186 +	new_size =
  12.187 +	    (acpi_gbl_root_table_list.count +
  12.188 +	     ACPI_ROOT_TABLE_SIZE_INCREMENT) * sizeof(struct acpi_table_desc);
  12.189 +
  12.190 +	/* Create new array and copy the old array */
  12.191 +
  12.192 +	tables = ACPI_ALLOCATE_ZEROED(new_size);
  12.193 +	if (!tables) {
  12.194 +		return_ACPI_STATUS(AE_NO_MEMORY);
  12.195 +	}
  12.196 +
  12.197 +	ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, new_size);
  12.198 +
  12.199 +	acpi_gbl_root_table_list.size = acpi_gbl_root_table_list.count;
  12.200 +	acpi_gbl_root_table_list.tables = tables;
  12.201 +	acpi_gbl_root_table_list.flags =
  12.202 +	    ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE;
  12.203 +
  12.204 +	return_ACPI_STATUS(AE_OK);
  12.205 +}
  12.206 +
  12.207 +/*******************************************************************************
  12.208 + *
  12.209 + * FUNCTION:    acpi_get_table
  12.210 + *
  12.211 + * PARAMETERS:  Signature           - ACPI signature of needed table
  12.212 + *              Instance            - Which instance (for SSDTs)
  12.213 + *              out_table           - Where the pointer to the table is returned
  12.214 + *
  12.215 + * RETURN:      Status and pointer to table
  12.216 + *
  12.217 + * DESCRIPTION: Finds and verifies an ACPI table.
  12.218 + *
  12.219 + *****************************************************************************/
  12.220 +acpi_status
  12.221 +acpi_get_table(char *signature,
  12.222 +	       acpi_native_uint instance, struct acpi_table_header **out_table)
  12.223 +{
  12.224 +	acpi_native_uint i;
  12.225 +	acpi_native_uint j;
  12.226 +	acpi_status status;
  12.227 +
  12.228 +	/* Parameter validation */
  12.229 +
  12.230 +	if (!signature || !out_table) {
  12.231 +		return (AE_BAD_PARAMETER);
  12.232 +	}
  12.233 +
  12.234 +	/*
  12.235 +	 * Walk the root table list
  12.236 +	 */
  12.237 +	for (i = 0, j = 0; i < acpi_gbl_root_table_list.count; i++) {
  12.238 +		if (!ACPI_COMPARE_NAME
  12.239 +		    (&(acpi_gbl_root_table_list.tables[i].signature),
  12.240 +		     signature)) {
  12.241 +			continue;
  12.242 +		}
  12.243 +
  12.244 +		if (++j < instance) {
  12.245 +			continue;
  12.246 +		}
  12.247 +
  12.248 +		status =
  12.249 +		    acpi_tb_verify_table(&acpi_gbl_root_table_list.tables[i]);
  12.250 +		if (ACPI_SUCCESS(status)) {
  12.251 +			*out_table = acpi_gbl_root_table_list.tables[i].pointer;
  12.252 +		}
  12.253 +
  12.254 +		/*if (!acpi_gbl_permanent_mmap)*/ {
  12.255 +			acpi_gbl_root_table_list.tables[i].pointer = NULL;
  12.256 +		}
  12.257 +
  12.258 +		return (status);
  12.259 +	}
  12.260 +
  12.261 +	return (AE_NOT_FOUND);
  12.262 +}
  12.263 +
  12.264 +ACPI_EXPORT_SYMBOL(acpi_get_table)
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/xen/drivers/acpi/tables/tbxfroot.c	Tue Jun 10 13:45:29 2008 +0100
    13.3 @@ -0,0 +1,275 @@
    13.4 +/******************************************************************************
    13.5 + *
    13.6 + * Module Name: tbxfroot - Find the root ACPI table (RSDT)
    13.7 + *
    13.8 + *****************************************************************************/
    13.9 +
   13.10 +/*
   13.11 + * Copyright (C) 2000 - 2008, Intel Corp.
   13.12 + * All rights reserved.
   13.13 + *
   13.14 + * Redistribution and use in source and binary forms, with or without
   13.15 + * modification, are permitted provided that the following conditions
   13.16 + * are met:
   13.17 + * 1. Redistributions of source code must retain the above copyright
   13.18 + *    notice, this list of conditions, and the following disclaimer,
   13.19 + *    without modification.
   13.20 + * 2. Redistributions in binary form must reproduce at minimum a disclaimer
   13.21 + *    substantially similar to the "NO WARRANTY" disclaimer below
   13.22 + *    ("Disclaimer") and any redistribution must be conditioned upon
   13.23 + *    including a substantially similar Disclaimer requirement for further
   13.24 + *    binary redistribution.
   13.25 + * 3. Neither the names of the above-listed copyright holders nor the names
   13.26 + *    of any contributors may be used to endorse or promote products derived
   13.27 + *    from this software without specific prior written permission.
   13.28 + *
   13.29 + * Alternatively, this software may be distributed under the terms of the
   13.30 + * GNU General Public License ("GPL") version 2 as published by the Free
   13.31 + * Software Foundation.
   13.32 + *
   13.33 + * NO WARRANTY
   13.34 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   13.35 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   13.36 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
   13.37 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   13.38 + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   13.39 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   13.40 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   13.41 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   13.42 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
   13.43 + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   13.44 + * POSSIBILITY OF SUCH DAMAGES.
   13.45 + */
   13.46 +
   13.47 +#include <xen/config.h>
   13.48 +#include <xen/init.h>
   13.49 +#include <acpi/acpi.h>
   13.50 +#include <acpi/actables.h>
   13.51 +
   13.52 +#define _COMPONENT          ACPI_TABLES
   13.53 +ACPI_MODULE_NAME("tbxfroot")
   13.54 +
   13.55 +/* Local prototypes */
   13.56 +static u8 *acpi_tb_scan_memory_for_rsdp(u8 * start_address, u32 length);
   13.57 +
   13.58 +static acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp);
   13.59 +
   13.60 +/*******************************************************************************
   13.61 + *
   13.62 + * FUNCTION:    acpi_tb_validate_rsdp
   13.63 + *
   13.64 + * PARAMETERS:  Rsdp                - Pointer to unvalidated RSDP
   13.65 + *
   13.66 + * RETURN:      Status
   13.67 + *
   13.68 + * DESCRIPTION: Validate the RSDP (ptr)
   13.69 + *
   13.70 + ******************************************************************************/
   13.71 +
   13.72 +static acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp)
   13.73 +{
   13.74 +	ACPI_FUNCTION_ENTRY();
   13.75 +
   13.76 +	/*
   13.77 +	 * The signature and checksum must both be correct
   13.78 +	 *
   13.79 +	 * Note: Sometimes there exists more than one RSDP in memory; the valid
   13.80 +	 * RSDP has a valid checksum, all others have an invalid checksum.
   13.81 +	 */
   13.82 +	if (ACPI_STRNCMP((char *)rsdp, ACPI_SIG_RSDP, sizeof(ACPI_SIG_RSDP) - 1)
   13.83 +	    != 0) {
   13.84 +
   13.85 +		/* Nope, BAD Signature */
   13.86 +
   13.87 +		return (AE_BAD_SIGNATURE);
   13.88 +	}
   13.89 +
   13.90 +	/* Check the standard checksum */
   13.91 +
   13.92 +	if (acpi_tb_checksum((u8 *) rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) {
   13.93 +		return (AE_BAD_CHECKSUM);
   13.94 +	}
   13.95 +
   13.96 +	/* Check extended checksum if table version >= 2 */
   13.97 +
   13.98 +	if ((rsdp->revision >= 2) &&
   13.99 +	    (acpi_tb_checksum((u8 *) rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0)) {
  13.100 +		return (AE_BAD_CHECKSUM);
  13.101 +	}
  13.102 +
  13.103 +	return (AE_OK);
  13.104 +}
  13.105 +
  13.106 +/*******************************************************************************
  13.107 + *
  13.108 + * FUNCTION:    acpi_find_root_pointer
  13.109 + *
  13.110 + * PARAMETERS:  table_address           - Where the table pointer is returned
  13.111 + *
  13.112 + * RETURN:      Status, RSDP physical address
  13.113 + *
  13.114 + * DESCRIPTION: Search lower 1_mbyte of memory for the root system descriptor
  13.115 + *              pointer structure.  If it is found, set *RSDP to point to it.
  13.116 + *
  13.117 + * NOTE1:       The RSDP must be either in the first 1_k of the Extended
  13.118 + *              BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.)
  13.119 + *              Only a 32-bit physical address is necessary.
  13.120 + *
  13.121 + * NOTE2:       This function is always available, regardless of the
  13.122 + *              initialization state of the rest of ACPI.
  13.123 + *
  13.124 + ******************************************************************************/
  13.125 +
  13.126 +acpi_status acpi_find_root_pointer(acpi_native_uint * table_address)
  13.127 +{
  13.128 +	u8 *table_ptr;
  13.129 +	u8 *mem_rover;
  13.130 +	u32 physical_address;
  13.131 +
  13.132 +	ACPI_FUNCTION_TRACE(acpi_find_root_pointer);
  13.133 +
  13.134 +	/* 1a) Get the location of the Extended BIOS Data Area (EBDA) */
  13.135 +
  13.136 +	table_ptr = acpi_os_map_memory((acpi_physical_address)
  13.137 +				       ACPI_EBDA_PTR_LOCATION,
  13.138 +				       ACPI_EBDA_PTR_LENGTH);
  13.139 +	if (!table_ptr) {
  13.140 +		ACPI_ERROR((AE_INFO,
  13.141 +			    "Could not map memory at %8.8X for length %X",
  13.142 +			    ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH));
  13.143 +
  13.144 +		return_ACPI_STATUS(AE_NO_MEMORY);
  13.145 +	}
  13.146 +
  13.147 +	ACPI_MOVE_16_TO_32(&physical_address, table_ptr);
  13.148 +
  13.149 +	/* Convert segment part to physical address */
  13.150 +
  13.151 +	physical_address <<= 4;
  13.152 +	acpi_os_unmap_memory(table_ptr, ACPI_EBDA_PTR_LENGTH);
  13.153 +
  13.154 +	/* EBDA present? */
  13.155 +
  13.156 +	if (physical_address > 0x400) {
  13.157 +		/*
  13.158 +		 * 1b) Search EBDA paragraphs (EBDA is required to be a
  13.159 +		 *     minimum of 1_k length)
  13.160 +		 */
  13.161 +		table_ptr = acpi_os_map_memory((acpi_native_uint)
  13.162 +					       physical_address,
  13.163 +					       ACPI_EBDA_WINDOW_SIZE);
  13.164 +		if (!table_ptr) {
  13.165 +			ACPI_ERROR((AE_INFO,
  13.166 +				    "Could not map memory at %8.8X for length %X",
  13.167 +				    physical_address, ACPI_EBDA_WINDOW_SIZE));
  13.168 +
  13.169 +			return_ACPI_STATUS(AE_NO_MEMORY);
  13.170 +		}
  13.171 +
  13.172 +		mem_rover =
  13.173 +		    acpi_tb_scan_memory_for_rsdp(table_ptr,
  13.174 +						 ACPI_EBDA_WINDOW_SIZE);
  13.175 +		acpi_os_unmap_memory(table_ptr, ACPI_EBDA_WINDOW_SIZE);
  13.176 +
  13.177 +		if (mem_rover) {
  13.178 +
  13.179 +			/* Return the physical address */
  13.180 +
  13.181 +			physical_address +=
  13.182 +			    (u32) ACPI_PTR_DIFF(mem_rover, table_ptr);
  13.183 +
  13.184 +			*table_address = physical_address;
  13.185 +			return_ACPI_STATUS(AE_OK);
  13.186 +		}
  13.187 +	}
  13.188 +
  13.189 +	/*
  13.190 +	 * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh
  13.191 +	 */
  13.192 +	table_ptr = acpi_os_map_memory((acpi_physical_address)
  13.193 +				       ACPI_HI_RSDP_WINDOW_BASE,
  13.194 +				       ACPI_HI_RSDP_WINDOW_SIZE);
  13.195 +
  13.196 +	if (!table_ptr) {
  13.197 +		ACPI_ERROR((AE_INFO,
  13.198 +			    "Could not map memory at %8.8X for length %X",
  13.199 +			    ACPI_HI_RSDP_WINDOW_BASE,
  13.200 +			    ACPI_HI_RSDP_WINDOW_SIZE));
  13.201 +
  13.202 +		return_ACPI_STATUS(AE_NO_MEMORY);
  13.203 +	}
  13.204 +
  13.205 +	mem_rover =
  13.206 +	    acpi_tb_scan_memory_for_rsdp(table_ptr, ACPI_HI_RSDP_WINDOW_SIZE);
  13.207 +	acpi_os_unmap_memory(table_ptr, ACPI_HI_RSDP_WINDOW_SIZE);
  13.208 +
  13.209 +	if (mem_rover) {
  13.210 +
  13.211 +		/* Return the physical address */
  13.212 +
  13.213 +		physical_address = (u32)
  13.214 +		    (ACPI_HI_RSDP_WINDOW_BASE +
  13.215 +		     ACPI_PTR_DIFF(mem_rover, table_ptr));
  13.216 +
  13.217 +		*table_address = physical_address;
  13.218 +		return_ACPI_STATUS(AE_OK);
  13.219 +	}
  13.220 +
  13.221 +	/* A valid RSDP was not found */
  13.222 +
  13.223 +	ACPI_ERROR((AE_INFO, "A valid RSDP was not found"));
  13.224 +	return_ACPI_STATUS(AE_NOT_FOUND);
  13.225 +}
  13.226 +
  13.227 +/*******************************************************************************
  13.228 + *
  13.229 + * FUNCTION:    acpi_tb_scan_memory_for_rsdp
  13.230 + *
  13.231 + * PARAMETERS:  start_address       - Starting pointer for search
  13.232 + *              Length              - Maximum length to search
  13.233 + *
  13.234 + * RETURN:      Pointer to the RSDP if found, otherwise NULL.
  13.235 + *
  13.236 + * DESCRIPTION: Search a block of memory for the RSDP signature
  13.237 + *
  13.238 + ******************************************************************************/
  13.239 +static u8 *acpi_tb_scan_memory_for_rsdp(u8 * start_address, u32 length)
  13.240 +{
  13.241 +	acpi_status status;
  13.242 +	u8 *mem_rover;
  13.243 +	u8 *end_address;
  13.244 +
  13.245 +	ACPI_FUNCTION_TRACE(tb_scan_memory_for_rsdp);
  13.246 +
  13.247 +	end_address = start_address + length;
  13.248 +
  13.249 +	/* Search from given start address for the requested length */
  13.250 +
  13.251 +	for (mem_rover = start_address; mem_rover < end_address;
  13.252 +	     mem_rover += ACPI_RSDP_SCAN_STEP) {
  13.253 +
  13.254 +		/* The RSDP signature and checksum must both be correct */
  13.255 +
  13.256 +		status =
  13.257 +		    acpi_tb_validate_rsdp(ACPI_CAST_PTR
  13.258 +					  (struct acpi_table_rsdp, mem_rover));
  13.259 +		if (ACPI_SUCCESS(status)) {
  13.260 +
  13.261 +			/* Sig and checksum valid, we have found a real RSDP */
  13.262 +
  13.263 +			ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  13.264 +					  "RSDP located at physical address %p\n",
  13.265 +					  mem_rover));
  13.266 +			return_PTR(mem_rover);
  13.267 +		}
  13.268 +
  13.269 +		/* No sig match or bad checksum, keep searching */
  13.270 +	}
  13.271 +
  13.272 +	/* Searched entire block, no RSDP was found */
  13.273 +
  13.274 +	ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  13.275 +			  "Searched entire block from %p, valid RSDP was not found\n",
  13.276 +			  start_address));
  13.277 +	return_PTR(NULL);
  13.278 +}
    14.1 --- a/xen/drivers/acpi/utglobal.c	Tue Jun 10 09:27:01 2008 +0100
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,136 +0,0 @@
    14.4 -/******************************************************************************
    14.5 - *
    14.6 - * Module Name: utglobal - Global variables for the ACPI subsystem
    14.7 - *
    14.8 - *****************************************************************************/
    14.9 -
   14.10 -/*
   14.11 - * Copyright (C) 2000 - 2007, R. Byron Moore
   14.12 - * All rights reserved.
   14.13 - *
   14.14 - * Redistribution and use in source and binary forms, with or without
   14.15 - * modification, are permitted provided that the following conditions
   14.16 - * are met:
   14.17 - * 1. Redistributions of source code must retain the above copyright
   14.18 - *    notice, this list of conditions, and the following disclaimer,
   14.19 - *    without modification.
   14.20 - * 2. Redistributions in binary form must reproduce at minimum a disclaimer
   14.21 - *    substantially similar to the "NO WARRANTY" disclaimer below
   14.22 - *    ("Disclaimer") and any redistribution must be conditioned upon
   14.23 - *    including a substantially similar Disclaimer requirement for further
   14.24 - *    binary redistribution.
   14.25 - * 3. Neither the names of the above-listed copyright holders nor the names
   14.26 - *    of any contributors may be used to endorse or promote products derived
   14.27 - *    from this software without specific prior written permission.
   14.28 - *
   14.29 - * Alternatively, this software may be distributed under the terms of the
   14.30 - * GNU General Public License ("GPL") version 2 as published by the Free
   14.31 - * Software Foundation.
   14.32 - *
   14.33 - * NO WARRANTY
   14.34 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   14.35 - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   14.36 - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
   14.37 - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   14.38 - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   14.39 - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   14.40 - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   14.41 - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   14.42 - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
   14.43 - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   14.44 - * POSSIBILITY OF SUCH DAMAGES.
   14.45 - */
   14.46 -
   14.47 -//#define DEFINE_ACPI_GLOBALS
   14.48 -
   14.49 -#include <acpi/acpi.h>
   14.50 -//#include <acpi/acnamesp.h>
   14.51 -
   14.52 -#define _COMPONENT          ACPI_UTILITIES
   14.53 -    ACPI_MODULE_NAME("utglobal")
   14.54 -
   14.55 -struct acpi_table_fadt acpi_gbl_FADT;
   14.56 -
   14.57 -/* These addresses are calculated from FADT address values */
   14.58 -
   14.59 -struct acpi_generic_address acpi_gbl_xpm1a_enable;
   14.60 -struct acpi_generic_address acpi_gbl_xpm1b_enable;
   14.61 -
   14.62 -/******************************************************************************
   14.63 - *
   14.64 - * Event and Hardware globals
   14.65 - *
   14.66 - ******************************************************************************/
   14.67 -
   14.68 -struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG] = {
   14.69 -	/* Name                                     Parent Register             Register Bit Position                   Register Bit Mask       */
   14.70 -
   14.71 -	/* ACPI_BITREG_TIMER_STATUS         */ {ACPI_REGISTER_PM1_STATUS,
   14.72 -						ACPI_BITPOSITION_TIMER_STATUS,
   14.73 -						ACPI_BITMASK_TIMER_STATUS},
   14.74 -	/* ACPI_BITREG_BUS_MASTER_STATUS    */ {ACPI_REGISTER_PM1_STATUS,
   14.75 -						ACPI_BITPOSITION_BUS_MASTER_STATUS,
   14.76 -						ACPI_BITMASK_BUS_MASTER_STATUS},
   14.77 -	/* ACPI_BITREG_GLOBAL_LOCK_STATUS   */ {ACPI_REGISTER_PM1_STATUS,
   14.78 -						ACPI_BITPOSITION_GLOBAL_LOCK_STATUS,
   14.79 -						ACPI_BITMASK_GLOBAL_LOCK_STATUS},
   14.80 -	/* ACPI_BITREG_POWER_BUTTON_STATUS  */ {ACPI_REGISTER_PM1_STATUS,
   14.81 -						ACPI_BITPOSITION_POWER_BUTTON_STATUS,
   14.82 -						ACPI_BITMASK_POWER_BUTTON_STATUS},
   14.83 -	/* ACPI_BITREG_SLEEP_BUTTON_STATUS  */ {ACPI_REGISTER_PM1_STATUS,
   14.84 -						ACPI_BITPOSITION_SLEEP_BUTTON_STATUS,
   14.85 -						ACPI_BITMASK_SLEEP_BUTTON_STATUS},
   14.86 -	/* ACPI_BITREG_RT_CLOCK_STATUS      */ {ACPI_REGISTER_PM1_STATUS,
   14.87 -						ACPI_BITPOSITION_RT_CLOCK_STATUS,
   14.88 -						ACPI_BITMASK_RT_CLOCK_STATUS},
   14.89 -	/* ACPI_BITREG_WAKE_STATUS          */ {ACPI_REGISTER_PM1_STATUS,
   14.90 -						ACPI_BITPOSITION_WAKE_STATUS,
   14.91 -						ACPI_BITMASK_WAKE_STATUS},
   14.92 -	/* ACPI_BITREG_PCIEXP_WAKE_STATUS   */ {ACPI_REGISTER_PM1_STATUS,
   14.93 -						ACPI_BITPOSITION_PCIEXP_WAKE_STATUS,
   14.94 -						ACPI_BITMASK_PCIEXP_WAKE_STATUS},
   14.95 -
   14.96 -	/* ACPI_BITREG_TIMER_ENABLE         */ {ACPI_REGISTER_PM1_ENABLE,
   14.97 -						ACPI_BITPOSITION_TIMER_ENABLE,
   14.98 -						ACPI_BITMASK_TIMER_ENABLE},
   14.99 -	/* ACPI_BITREG_GLOBAL_LOCK_ENABLE   */ {ACPI_REGISTER_PM1_ENABLE,
  14.100 -						ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE,
  14.101 -						ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
  14.102 -	/* ACPI_BITREG_POWER_BUTTON_ENABLE  */ {ACPI_REGISTER_PM1_ENABLE,
  14.103 -						ACPI_BITPOSITION_POWER_BUTTON_ENABLE,
  14.104 -						ACPI_BITMASK_POWER_BUTTON_ENABLE},
  14.105 -	/* ACPI_BITREG_SLEEP_BUTTON_ENABLE  */ {ACPI_REGISTER_PM1_ENABLE,
  14.106 -						ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE,
  14.107 -						ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
  14.108 -	/* ACPI_BITREG_RT_CLOCK_ENABLE      */ {ACPI_REGISTER_PM1_ENABLE,
  14.109 -						ACPI_BITPOSITION_RT_CLOCK_ENABLE,
  14.110 -						ACPI_BITMASK_RT_CLOCK_ENABLE},
  14.111 -	/* ACPI_BITREG_WAKE_ENABLE          */ {ACPI_REGISTER_PM1_ENABLE, 0, 0},
  14.112 -	/* ACPI_BITREG_PCIEXP_WAKE_DISABLE  */ {ACPI_REGISTER_PM1_ENABLE,
  14.113 -						ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE,
  14.114 -						ACPI_BITMASK_PCIEXP_WAKE_DISABLE},
  14.115 -
  14.116 -	/* ACPI_BITREG_SCI_ENABLE           */ {ACPI_REGISTER_PM1_CONTROL,
  14.117 -						ACPI_BITPOSITION_SCI_ENABLE,
  14.118 -						ACPI_BITMASK_SCI_ENABLE},
  14.119 -	/* ACPI_BITREG_BUS_MASTER_RLD       */ {ACPI_REGISTER_PM1_CONTROL,
  14.120 -						ACPI_BITPOSITION_BUS_MASTER_RLD,
  14.121 -						ACPI_BITMASK_BUS_MASTER_RLD},
  14.122 -	/* ACPI_BITREG_GLOBAL_LOCK_RELEASE  */ {ACPI_REGISTER_PM1_CONTROL,
  14.123 -						ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE,
  14.124 -						ACPI_BITMASK_GLOBAL_LOCK_RELEASE},
  14.125 -	/* ACPI_BITREG_SLEEP_TYPE_A         */ {ACPI_REGISTER_PM1_CONTROL,
  14.126 -						ACPI_BITPOSITION_SLEEP_TYPE_X,
  14.127 -						ACPI_BITMASK_SLEEP_TYPE_X},
  14.128 -	/* ACPI_BITREG_SLEEP_TYPE_B         */ {ACPI_REGISTER_PM1_CONTROL,
  14.129 -						ACPI_BITPOSITION_SLEEP_TYPE_X,
  14.130 -						ACPI_BITMASK_SLEEP_TYPE_X},
  14.131 -	/* ACPI_BITREG_SLEEP_ENABLE         */ {ACPI_REGISTER_PM1_CONTROL,
  14.132 -						ACPI_BITPOSITION_SLEEP_ENABLE,
  14.133 -						ACPI_BITMASK_SLEEP_ENABLE},
  14.134 -
  14.135 -	/* ACPI_BITREG_ARB_DIS              */ {ACPI_REGISTER_PM2_CONTROL,
  14.136 -						ACPI_BITPOSITION_ARB_DISABLE,
  14.137 -						ACPI_BITMASK_ARB_DISABLE}
  14.138 -};
  14.139 -
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/xen/drivers/acpi/utilities/Makefile	Tue Jun 10 13:45:29 2008 +0100
    15.3 @@ -0,0 +1,2 @@
    15.4 +obj-y += utglobal.o
    15.5 +obj-y += utmisc.o
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/xen/drivers/acpi/utilities/utglobal.c	Tue Jun 10 13:45:29 2008 +0100
    16.3 @@ -0,0 +1,740 @@
    16.4 +/******************************************************************************
    16.5 + *
    16.6 + * Module Name: utglobal - Global variables for the ACPI subsystem
    16.7 + *
    16.8 + *****************************************************************************/
    16.9 +
   16.10 +/*
   16.11 + * Copyright (C) 2000 - 2008, Intel Corp.
   16.12 + * All rights reserved.
   16.13 + *
   16.14 + * Redistribution and use in source and binary forms, with or without
   16.15 + * modification, are permitted provided that the following conditions
   16.16 + * are met:
   16.17 + * 1. Redistributions of source code must retain the above copyright
   16.18 + *    notice, this list of conditions, and the following disclaimer,
   16.19 + *    without modification.
   16.20 + * 2. Redistributions in binary form must reproduce at minimum a disclaimer
   16.21 + *    substantially similar to the "NO WARRANTY" disclaimer below
   16.22 + *    ("Disclaimer") and any redistribution must be conditioned upon
   16.23 + *    including a substantially similar Disclaimer requirement for further
   16.24 + *    binary redistribution.
   16.25 + * 3. Neither the names of the above-listed copyright holders nor the names
   16.26 + *    of any contributors may be used to endorse or promote products derived
   16.27 + *    from this software without specific prior written permission.
   16.28 + *
   16.29 + * Alternatively, this software may be distributed under the terms of the
   16.30 + * GNU General Public License ("GPL") version 2 as published by the Free
   16.31 + * Software Foundation.
   16.32 + *
   16.33 + * NO WARRANTY
   16.34 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   16.35 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   16.36 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
   16.37 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   16.38 + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   16.39 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   16.40 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   16.41 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   16.42 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
   16.43 + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   16.44 + * POSSIBILITY OF SUCH DAMAGES.
   16.45 + */
   16.46 +
   16.47 +#define DEFINE_ACPI_GLOBALS
   16.48 +
   16.49 +#include <xen/config.h>
   16.50 +#include <xen/lib.h>
   16.51 +#include <acpi/acpi.h>
   16.52 +#include <acpi/acnamesp.h>
   16.53 +
   16.54 +ACPI_EXPORT_SYMBOL(acpi_gbl_FADT)
   16.55 +#define _COMPONENT          ACPI_UTILITIES
   16.56 +    ACPI_MODULE_NAME("utglobal")
   16.57 +
   16.58 +/*******************************************************************************
   16.59 + *
   16.60 + * Static global variable initialization.
   16.61 + *
   16.62 + ******************************************************************************/
   16.63 +/*
   16.64 + * We want the debug switches statically initialized so they
   16.65 + * are already set when the debugger is entered.
   16.66 + */
   16.67 +/* Debug switch - level and trace mask */
   16.68 +u32 acpi_dbg_level = ACPI_DEBUG_DEFAULT;
   16.69 +
   16.70 +/* Debug switch - layer (component) mask */
   16.71 +
   16.72 +u32 acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS;
   16.73 +u32 acpi_gbl_nesting_level = 0;
   16.74 +
   16.75 +/* Debugger globals */
   16.76 +
   16.77 +u8 acpi_gbl_db_terminate_threads = FALSE;
   16.78 +u8 acpi_gbl_abort_method = FALSE;
   16.79 +u8 acpi_gbl_method_executing = FALSE;
   16.80 +
   16.81 +/* System flags */
   16.82 +
   16.83 +u32 acpi_gbl_startup_flags = 0;
   16.84 +
   16.85 +/* System starts uninitialized */
   16.86 +
   16.87 +u8 acpi_gbl_shutdown = TRUE;
   16.88 +
   16.89 +const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT] = {
   16.90 +	"\\_S0_",
   16.91 +	"\\_S1_",
   16.92 +	"\\_S2_",
   16.93 +	"\\_S3_",
   16.94 +	"\\_S4_",
   16.95 +	"\\_S5_"
   16.96 +};
   16.97 +
   16.98 +const char *acpi_gbl_highest_dstate_names[4] = {
   16.99 +	"_S1D",
  16.100 +	"_S2D",
  16.101 +	"_S3D",
  16.102 +	"_S4D"
  16.103 +};
  16.104 +
  16.105 +/*******************************************************************************
  16.106 + *
  16.107 + * FUNCTION:    acpi_format_exception
  16.108 + *
  16.109 + * PARAMETERS:  Status       - The acpi_status code to be formatted
  16.110 + *
  16.111 + * RETURN:      A string containing the exception text. A valid pointer is
  16.112 + *              always returned.
  16.113 + *
  16.114 + * DESCRIPTION: This function translates an ACPI exception into an ASCII string
  16.115 + *              It is here instead of utxface.c so it is always present.
  16.116 + *
  16.117 + ******************************************************************************/
  16.118 +
  16.119 +const char *acpi_format_exception(acpi_status status)
  16.120 +{
  16.121 +	const char *exception = NULL;
  16.122 +
  16.123 +	ACPI_FUNCTION_ENTRY();
  16.124 +
  16.125 +	exception = acpi_ut_validate_exception(status);
  16.126 +	if (!exception) {
  16.127 +
  16.128 +		/* Exception code was not recognized */
  16.129 +
  16.130 +		ACPI_ERROR((AE_INFO,
  16.131 +			    "Unknown exception code: 0x%8.8X", status));
  16.132 +
  16.133 +		exception = "UNKNOWN_STATUS_CODE";
  16.134 +		dump_execution_state();
  16.135 +	}
  16.136 +
  16.137 +	return (ACPI_CAST_PTR(const char, exception));
  16.138 +}
  16.139 +
  16.140 +ACPI_EXPORT_SYMBOL(acpi_format_exception)
  16.141 +
  16.142 +/*******************************************************************************
  16.143 + *
  16.144 + * Namespace globals
  16.145 + *
  16.146 + ******************************************************************************/
  16.147 +/*
  16.148 + * Predefined ACPI Names (Built-in to the Interpreter)
  16.149 + *
  16.150 + * NOTES:
  16.151 + * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run
  16.152 + *    during the initialization sequence.
  16.153 + * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to
  16.154 + *    perform a Notify() operation on it.
  16.155 + */
  16.156 +const struct acpi_predefined_names acpi_gbl_pre_defined_names[] = {
  16.157 +	{"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL},
  16.158 +	{"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL},
  16.159 +	{"_SB_", ACPI_TYPE_DEVICE, NULL},
  16.160 +	{"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL},
  16.161 +	{"_TZ_", ACPI_TYPE_THERMAL, NULL},
  16.162 +	{"_REV", ACPI_TYPE_INTEGER, (char *)ACPI_CA_SUPPORT_LEVEL},
  16.163 +	{"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME},
  16.164 +	{"_GL_", ACPI_TYPE_MUTEX, (char *)1},
  16.165 +
  16.166 +#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
  16.167 +	{"_OSI", ACPI_TYPE_METHOD, (char *)1},
  16.168 +#endif
  16.169 +
  16.170 +	/* Table terminator */
  16.171 +
  16.172 +	{NULL, ACPI_TYPE_ANY, NULL}
  16.173 +};
  16.174 +
  16.175 +/*
  16.176 + * Properties of the ACPI Object Types, both internal and external.
  16.177 + * The table is indexed by values of acpi_object_type
  16.178 + */
  16.179 +const u8 acpi_gbl_ns_properties[] = {
  16.180 +	ACPI_NS_NORMAL,		/* 00 Any              */
  16.181 +	ACPI_NS_NORMAL,		/* 01 Number           */
  16.182 +	ACPI_NS_NORMAL,		/* 02 String           */
  16.183 +	ACPI_NS_NORMAL,		/* 03 Buffer           */
  16.184 +	ACPI_NS_NORMAL,		/* 04 Package          */
  16.185 +	ACPI_NS_NORMAL,		/* 05 field_unit       */
  16.186 +	ACPI_NS_NEWSCOPE,	/* 06 Device           */
  16.187 +	ACPI_NS_NORMAL,		/* 07 Event            */
  16.188 +	ACPI_NS_NEWSCOPE,	/* 08 Method           */
  16.189 +	ACPI_NS_NORMAL,		/* 09 Mutex            */
  16.190 +	ACPI_NS_NORMAL,		/* 10 Region           */
  16.191 +	ACPI_NS_NEWSCOPE,	/* 11 Power            */
  16.192 +	ACPI_NS_NEWSCOPE,	/* 12 Processor        */
  16.193 +	ACPI_NS_NEWSCOPE,	/* 13 Thermal          */
  16.194 +	ACPI_NS_NORMAL,		/* 14 buffer_field     */
  16.195 +	ACPI_NS_NORMAL,		/* 15 ddb_handle       */
  16.196 +	ACPI_NS_NORMAL,		/* 16 Debug Object     */
  16.197 +	ACPI_NS_NORMAL,		/* 17 def_field        */
  16.198 +	ACPI_NS_NORMAL,		/* 18 bank_field       */
  16.199 +	ACPI_NS_NORMAL,		/* 19 index_field      */
  16.200 +	ACPI_NS_NORMAL,		/* 20 Reference        */
  16.201 +	ACPI_NS_NORMAL,		/* 21 Alias            */
  16.202 +	ACPI_NS_NORMAL,		/* 22 method_alias     */
  16.203 +	ACPI_NS_NORMAL,		/* 23 Notify           */
  16.204 +	ACPI_NS_NORMAL,		/* 24 Address Handler  */
  16.205 +	ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL,	/* 25 Resource Desc    */
  16.206 +	ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL,	/* 26 Resource Field   */
  16.207 +	ACPI_NS_NEWSCOPE,	/* 27 Scope            */
  16.208 +	ACPI_NS_NORMAL,		/* 28 Extra            */
  16.209 +	ACPI_NS_NORMAL,		/* 29 Data             */
  16.210 +	ACPI_NS_NORMAL		/* 30 Invalid          */
  16.211 +};
  16.212 +
  16.213 +/* Hex to ASCII conversion table */
  16.214 +
  16.215 +static const char acpi_gbl_hex_to_ascii[] = {
  16.216 +	'0', '1', '2', '3', '4', '5', '6', '7',
  16.217 +	'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
  16.218 +};
  16.219 +
  16.220 +/*******************************************************************************
  16.221 + *
  16.222 + * FUNCTION:    acpi_ut_hex_to_ascii_char
  16.223 + *
  16.224 + * PARAMETERS:  Integer             - Contains the hex digit
  16.225 + *              Position            - bit position of the digit within the
  16.226 + *                                    integer (multiple of 4)
  16.227 + *
  16.228 + * RETURN:      The converted Ascii character
  16.229 + *
  16.230 + * DESCRIPTION: Convert a hex digit to an Ascii character
  16.231 + *
  16.232 + ******************************************************************************/
  16.233 +
  16.234 +char acpi_ut_hex_to_ascii_char(acpi_integer integer, u32 position)
  16.235 +{
  16.236 +
  16.237 +	return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]);
  16.238 +}
  16.239 +
  16.240 +/******************************************************************************
  16.241 + *
  16.242 + * Event and Hardware globals
  16.243 + *
  16.244 + ******************************************************************************/
  16.245 +
  16.246 +struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG] = {
  16.247 +	/* Name                                     Parent Register             Register Bit Position                   Register Bit Mask       */
  16.248 +
  16.249 +	/* ACPI_BITREG_TIMER_STATUS         */ {ACPI_REGISTER_PM1_STATUS,
  16.250 +						ACPI_BITPOSITION_TIMER_STATUS,
  16.251 +						ACPI_BITMASK_TIMER_STATUS},
  16.252 +	/* ACPI_BITREG_BUS_MASTER_STATUS    */ {ACPI_REGISTER_PM1_STATUS,
  16.253 +						ACPI_BITPOSITION_BUS_MASTER_STATUS,
  16.254 +						ACPI_BITMASK_BUS_MASTER_STATUS},
  16.255 +	/* ACPI_BITREG_GLOBAL_LOCK_STATUS   */ {ACPI_REGISTER_PM1_STATUS,
  16.256 +						ACPI_BITPOSITION_GLOBAL_LOCK_STATUS,
  16.257 +						ACPI_BITMASK_GLOBAL_LOCK_STATUS},
  16.258 +	/* ACPI_BITREG_POWER_BUTTON_STATUS  */ {ACPI_REGISTER_PM1_STATUS,
  16.259 +						ACPI_BITPOSITION_POWER_BUTTON_STATUS,
  16.260 +						ACPI_BITMASK_POWER_BUTTON_STATUS},
  16.261 +	/* ACPI_BITREG_SLEEP_BUTTON_STATUS  */ {ACPI_REGISTER_PM1_STATUS,
  16.262 +						ACPI_BITPOSITION_SLEEP_BUTTON_STATUS,
  16.263 +						ACPI_BITMASK_SLEEP_BUTTON_STATUS},
  16.264 +	/* ACPI_BITREG_RT_CLOCK_STATUS      */ {ACPI_REGISTER_PM1_STATUS,
  16.265 +						ACPI_BITPOSITION_RT_CLOCK_STATUS,
  16.266 +						ACPI_BITMASK_RT_CLOCK_STATUS},
  16.267 +	/* ACPI_BITREG_WAKE_STATUS          */ {ACPI_REGISTER_PM1_STATUS,
  16.268 +						ACPI_BITPOSITION_WAKE_STATUS,
  16.269 +						ACPI_BITMASK_WAKE_STATUS},
  16.270 +	/* ACPI_BITREG_PCIEXP_WAKE_STATUS   */ {ACPI_REGISTER_PM1_STATUS,
  16.271 +						ACPI_BITPOSITION_PCIEXP_WAKE_STATUS,
  16.272 +						ACPI_BITMASK_PCIEXP_WAKE_STATUS},
  16.273 +
  16.274 +	/* ACPI_BITREG_TIMER_ENABLE         */ {ACPI_REGISTER_PM1_ENABLE,
  16.275 +						ACPI_BITPOSITION_TIMER_ENABLE,
  16.276 +						ACPI_BITMASK_TIMER_ENABLE},
  16.277 +	/* ACPI_BITREG_GLOBAL_LOCK_ENABLE   */ {ACPI_REGISTER_PM1_ENABLE,
  16.278 +						ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE,
  16.279 +						ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
  16.280 +	/* ACPI_BITREG_POWER_BUTTON_ENABLE  */ {ACPI_REGISTER_PM1_ENABLE,
  16.281 +						ACPI_BITPOSITION_POWER_BUTTON_ENABLE,
  16.282 +						ACPI_BITMASK_POWER_BUTTON_ENABLE},
  16.283 +	/* ACPI_BITREG_SLEEP_BUTTON_ENABLE  */ {ACPI_REGISTER_PM1_ENABLE,
  16.284 +						ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE,
  16.285 +						ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
  16.286 +	/* ACPI_BITREG_RT_CLOCK_ENABLE      */ {ACPI_REGISTER_PM1_ENABLE,
  16.287 +						ACPI_BITPOSITION_RT_CLOCK_ENABLE,
  16.288 +						ACPI_BITMASK_RT_CLOCK_ENABLE},
  16.289 +	/* ACPI_BITREG_WAKE_ENABLE          */ {ACPI_REGISTER_PM1_ENABLE, 0, 0},
  16.290 +	/* ACPI_BITREG_PCIEXP_WAKE_DISABLE  */ {ACPI_REGISTER_PM1_ENABLE,
  16.291 +						ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE,
  16.292 +						ACPI_BITMASK_PCIEXP_WAKE_DISABLE},
  16.293 +
  16.294 +	/* ACPI_BITREG_SCI_ENABLE           */ {ACPI_REGISTER_PM1_CONTROL,
  16.295 +						ACPI_BITPOSITION_SCI_ENABLE,
  16.296 +						ACPI_BITMASK_SCI_ENABLE},
  16.297 +	/* ACPI_BITREG_BUS_MASTER_RLD       */ {ACPI_REGISTER_PM1_CONTROL,
  16.298 +						ACPI_BITPOSITION_BUS_MASTER_RLD,
  16.299 +						ACPI_BITMASK_BUS_MASTER_RLD},
  16.300 +	/* ACPI_BITREG_GLOBAL_LOCK_RELEASE  */ {ACPI_REGISTER_PM1_CONTROL,
  16.301 +						ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE,
  16.302 +						ACPI_BITMASK_GLOBAL_LOCK_RELEASE},
  16.303 +	/* ACPI_BITREG_SLEEP_TYPE_A         */ {ACPI_REGISTER_PM1_CONTROL,
  16.304 +						ACPI_BITPOSITION_SLEEP_TYPE_X,
  16.305 +						ACPI_BITMASK_SLEEP_TYPE_X},
  16.306 +	/* ACPI_BITREG_SLEEP_TYPE_B         */ {ACPI_REGISTER_PM1_CONTROL,
  16.307 +						ACPI_BITPOSITION_SLEEP_TYPE_X,
  16.308 +						ACPI_BITMASK_SLEEP_TYPE_X},
  16.309 +	/* ACPI_BITREG_SLEEP_ENABLE         */ {ACPI_REGISTER_PM1_CONTROL,
  16.310 +						ACPI_BITPOSITION_SLEEP_ENABLE,
  16.311 +						ACPI_BITMASK_SLEEP_ENABLE},
  16.312 +
  16.313 +	/* ACPI_BITREG_ARB_DIS              */ {ACPI_REGISTER_PM2_CONTROL,
  16.314 +						ACPI_BITPOSITION_ARB_DISABLE,
  16.315 +						ACPI_BITMASK_ARB_DISABLE}
  16.316 +};
  16.317 +
  16.318 +struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] = {
  16.319 +	/* ACPI_EVENT_PMTIMER       */ {ACPI_BITREG_TIMER_STATUS,
  16.320 +					ACPI_BITREG_TIMER_ENABLE,
  16.321 +					ACPI_BITMASK_TIMER_STATUS,
  16.322 +					ACPI_BITMASK_TIMER_ENABLE},
  16.323 +	/* ACPI_EVENT_GLOBAL        */ {ACPI_BITREG_GLOBAL_LOCK_STATUS,
  16.324 +					ACPI_BITREG_GLOBAL_LOCK_ENABLE,
  16.325 +					ACPI_BITMASK_GLOBAL_LOCK_STATUS,
  16.326 +					ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
  16.327 +	/* ACPI_EVENT_POWER_BUTTON  */ {ACPI_BITREG_POWER_BUTTON_STATUS,
  16.328 +					ACPI_BITREG_POWER_BUTTON_ENABLE,
  16.329 +					ACPI_BITMASK_POWER_BUTTON_STATUS,
  16.330 +					ACPI_BITMASK_POWER_BUTTON_ENABLE},
  16.331 +	/* ACPI_EVENT_SLEEP_BUTTON  */ {ACPI_BITREG_SLEEP_BUTTON_STATUS,
  16.332 +					ACPI_BITREG_SLEEP_BUTTON_ENABLE,
  16.333 +					ACPI_BITMASK_SLEEP_BUTTON_STATUS,
  16.334 +					ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
  16.335 +	/* ACPI_EVENT_RTC           */ {ACPI_BITREG_RT_CLOCK_STATUS,
  16.336 +					ACPI_BITREG_RT_CLOCK_ENABLE,
  16.337 +					ACPI_BITMASK_RT_CLOCK_STATUS,
  16.338 +					ACPI_BITMASK_RT_CLOCK_ENABLE},
  16.339 +};
  16.340 +
  16.341 +/*******************************************************************************
  16.342 + *
  16.343 + * FUNCTION:    acpi_ut_get_region_name
  16.344 + *
  16.345 + * PARAMETERS:  None.
  16.346 + *
  16.347 + * RETURN:      Status
  16.348 + *
  16.349 + * DESCRIPTION: Translate a Space ID into a name string (Debug only)
  16.350 + *
  16.351 + ******************************************************************************/
  16.352 +
  16.353 +/* Region type decoding */
  16.354 +
  16.355 +const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = {
  16.356 +	"SystemMemory",
  16.357 +	"SystemIO",
  16.358 +	"PCI_Config",
  16.359 +	"EmbeddedControl",
  16.360 +	"SMBus",
  16.361 +	"CMOS",
  16.362 +	"PCIBARTarget",
  16.363 +	"DataTable"
  16.364 +};
  16.365 +
  16.366 +char *acpi_ut_get_region_name(u8 space_id)
  16.367 +{
  16.368 +
  16.369 +	if (space_id >= ACPI_USER_REGION_BEGIN) {
  16.370 +		return ("UserDefinedRegion");
  16.371 +	} else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS) {
  16.372 +		return ("InvalidSpaceId");
  16.373 +	}
  16.374 +
  16.375 +	return (ACPI_CAST_PTR(char, acpi_gbl_region_types[space_id]));
  16.376 +}
  16.377 +
  16.378 +/*******************************************************************************
  16.379 + *
  16.380 + * FUNCTION:    acpi_ut_get_event_name
  16.381 + *
  16.382 + * PARAMETERS:  None.
  16.383 + *
  16.384 + * RETURN:      Status
  16.385 + *
  16.386 + * DESCRIPTION: Translate a Event ID into a name string (Debug only)
  16.387 + *
  16.388 + ******************************************************************************/
  16.389 +
  16.390 +/* Event type decoding */
  16.391 +
  16.392 +static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = {
  16.393 +	"PM_Timer",
  16.394 +	"GlobalLock",
  16.395 +	"PowerButton",
  16.396 +	"SleepButton",
  16.397 +	"RealTimeClock",
  16.398 +};
  16.399 +
  16.400 +char *acpi_ut_get_event_name(u32 event_id)
  16.401 +{
  16.402 +
  16.403 +	if (event_id > ACPI_EVENT_MAX) {
  16.404 +		return ("InvalidEventID");
  16.405 +	}
  16.406 +
  16.407 +	return (ACPI_CAST_PTR(char, acpi_gbl_event_types[event_id]));
  16.408 +}
  16.409 +
  16.410 +/*******************************************************************************
  16.411 + *
  16.412 + * FUNCTION:    acpi_ut_get_type_name
  16.413 + *
  16.414 + * PARAMETERS:  None.
  16.415 + *
  16.416 + * RETURN:      Status
  16.417 + *
  16.418 + * DESCRIPTION: Translate a Type ID into a name string (Debug only)
  16.419 + *
  16.420 + ******************************************************************************/
  16.421 +
  16.422 +/*
  16.423 + * Elements of acpi_gbl_ns_type_names below must match
  16.424 + * one-to-one with values of acpi_object_type
  16.425 + *
  16.426 + * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching;
  16.427 + * when stored in a table it really means that we have thus far seen no
  16.428 + * evidence to indicate what type is actually going to be stored for this entry.
  16.429 + */
  16.430 +static const char acpi_gbl_bad_type[] = "UNDEFINED";
  16.431 +
  16.432 +/* Printable names of the ACPI object types */
  16.433 +
  16.434 +static const char *acpi_gbl_ns_type_names[] = {
  16.435 +	/* 00 */ "Untyped",
  16.436 +	/* 01 */ "Integer",
  16.437 +	/* 02 */ "String",
  16.438 +	/* 03 */ "Buffer",
  16.439 +	/* 04 */ "Package",
  16.440 +	/* 05 */ "FieldUnit",
  16.441 +	/* 06 */ "Device",
  16.442 +	/* 07 */ "Event",
  16.443 +	/* 08 */ "Method",
  16.444 +	/* 09 */ "Mutex",
  16.445 +	/* 10 */ "Region",
  16.446 +	/* 11 */ "Power",
  16.447 +	/* 12 */ "Processor",
  16.448 +	/* 13 */ "Thermal",
  16.449 +	/* 14 */ "BufferField",
  16.450 +	/* 15 */ "DdbHandle",
  16.451 +	/* 16 */ "DebugObject",
  16.452 +	/* 17 */ "RegionField",
  16.453 +	/* 18 */ "BankField",
  16.454 +	/* 19 */ "IndexField",
  16.455 +	/* 20 */ "Reference",
  16.456 +	/* 21 */ "Alias",
  16.457 +	/* 22 */ "MethodAlias",
  16.458 +	/* 23 */ "Notify",
  16.459 +	/* 24 */ "AddrHandler",
  16.460 +	/* 25 */ "ResourceDesc",
  16.461 +	/* 26 */ "ResourceFld",
  16.462 +	/* 27 */ "Scope",
  16.463 +	/* 28 */ "Extra",
  16.464 +	/* 29 */ "Data",
  16.465 +	/* 30 */ "Invalid"
  16.466 +};
  16.467 +
  16.468 +char *acpi_ut_get_type_name(acpi_object_type type)
  16.469 +{
  16.470 +
  16.471 +	if (type > ACPI_TYPE_INVALID) {
  16.472 +		return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
  16.473 +	}
  16.474 +
  16.475 +	return (ACPI_CAST_PTR(char, acpi_gbl_ns_type_names[type]));
  16.476 +}
  16.477 +
  16.478 +char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc)
  16.479 +{
  16.480 +
  16.481 +	if (!obj_desc) {
  16.482 +		return ("[NULL Object Descriptor]");
  16.483 +	}
  16.484 +
  16.485 +	return (acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE(obj_desc)));
  16.486 +}
  16.487 +
  16.488 +/*******************************************************************************
  16.489 + *
  16.490 + * FUNCTION:    acpi_ut_get_descriptor_name
  16.491 + *
  16.492 + * PARAMETERS:  Object               - An ACPI object
  16.493 + *
  16.494 + * RETURN:      Pointer to a string
  16.495 + *
  16.496 + * DESCRIPTION: Validate object and return the descriptor type
  16.497 + *
  16.498 + ******************************************************************************/
  16.499 +
  16.500 +/* Printable names of object descriptor types */
  16.501 +
  16.502 +static const char *acpi_gbl_desc_type_names[] = {
  16.503 +	/* 00 */ "Invalid",
  16.504 +	/* 01 */ "Cached",
  16.505 +	/* 02 */ "State-Generic",
  16.506 +	/* 03 */ "State-Update",
  16.507 +	/* 04 */ "State-Package",
  16.508 +	/* 05 */ "State-Control",
  16.509 +	/* 06 */ "State-RootParseScope",
  16.510 +	/* 07 */ "State-ParseScope",
  16.511 +	/* 08 */ "State-WalkScope",
  16.512 +	/* 09 */ "State-Result",
  16.513 +	/* 10 */ "State-Notify",
  16.514 +	/* 11 */ "State-Thread",
  16.515 +	/* 12 */ "Walk",
  16.516 +	/* 13 */ "Parser",
  16.517 +	/* 14 */ "Operand",
  16.518 +	/* 15 */ "Node"
  16.519 +};
  16.520 +
  16.521 +char *acpi_ut_get_descriptor_name(void *object)
  16.522 +{
  16.523 +
  16.524 +	if (!object) {
  16.525 +		return ("NULL OBJECT");
  16.526 +	}
  16.527 +
  16.528 +	if (ACPI_GET_DESCRIPTOR_TYPE(object) > ACPI_DESC_TYPE_MAX) {
  16.529 +		return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
  16.530 +	}
  16.531 +
  16.532 +	return (ACPI_CAST_PTR(char,
  16.533 +			      acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE
  16.534 +						       (object)]));
  16.535 +
  16.536 +}
  16.537 +
  16.538 +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
  16.539 +/*
  16.540 + * Strings and procedures used for debug only
  16.541 + */
  16.542 +
  16.543 +/*******************************************************************************
  16.544 + *
  16.545 + * FUNCTION:    acpi_ut_get_mutex_name
  16.546 + *
  16.547 + * PARAMETERS:  mutex_id        - The predefined ID for this mutex.
  16.548 + *
  16.549 + * RETURN:      String containing the name of the mutex. Always returns a valid
  16.550 + *              pointer.
  16.551 + *
  16.552 + * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
  16.553 + *
  16.554 + ******************************************************************************/
  16.555 +
  16.556 +char *acpi_ut_get_mutex_name(u32 mutex_id)
  16.557 +{
  16.558 +
  16.559 +	if (mutex_id > ACPI_MAX_MUTEX) {
  16.560 +		return ("Invalid Mutex ID");
  16.561 +	}
  16.562 +
  16.563 +	return (acpi_gbl_mutex_names[mutex_id]);
  16.564 +}
  16.565 +
  16.566 +/*******************************************************************************
  16.567 + *
  16.568 + * FUNCTION:    acpi_ut_get_notify_name
  16.569 + *
  16.570 + * PARAMETERS:  notify_value    - Value from the Notify() request
  16.571 + *
  16.572 + * RETURN:      String corresponding to the Notify Value.
  16.573 + *
  16.574 + * DESCRIPTION: Translate a Notify Value to a notify namestring.
  16.575 + *
  16.576 + ******************************************************************************/
  16.577 +
  16.578 +/* Names for Notify() values, used for debug output */
  16.579 +
  16.580 +static const char *acpi_gbl_notify_value_names[] = {
  16.581 +	"Bus Check",
  16.582 +	"Device Check",
  16.583 +	"Device Wake",
  16.584 +	"Eject Request",
  16.585 +	"Device Check Light",
  16.586 +	"Frequency Mismatch",
  16.587 +	"Bus Mode Mismatch",
  16.588 +	"Power Fault",
  16.589 +	"Capabilities Check",
  16.590 +	"Device PLD Check",
  16.591 +	"Reserved",
  16.592 +	"System Locality Update"
  16.593 +};
  16.594 +
  16.595 +const char *acpi_ut_get_notify_name(u32 notify_value)
  16.596 +{
  16.597 +
  16.598 +	if (notify_value <= ACPI_NOTIFY_MAX) {
  16.599 +		return (acpi_gbl_notify_value_names[notify_value]);
  16.600 +	} else if (notify_value <= ACPI_MAX_SYS_NOTIFY) {
  16.601 +		return ("Reserved");
  16.602 +	} else {		/* Greater or equal to 0x80 */
  16.603 +
  16.604 +		return ("**Device Specific**");
  16.605 +	}
  16.606 +}
  16.607 +#endif
  16.608 +
  16.609 +/*******************************************************************************
  16.610 + *
  16.611 + * FUNCTION:    acpi_ut_valid_object_type
  16.612 + *
  16.613 + * PARAMETERS:  Type            - Object type to be validated
  16.614 + *
  16.615 + * RETURN:      TRUE if valid object type, FALSE otherwise
  16.616 + *
  16.617 + * DESCRIPTION: Validate an object type
  16.618 + *
  16.619 + ******************************************************************************/
  16.620 +
  16.621 +u8 acpi_ut_valid_object_type(acpi_object_type type)
  16.622 +{
  16.623 +
  16.624 +	if (type > ACPI_TYPE_LOCAL_MAX) {
  16.625 +
  16.626 +		/* Note: Assumes all TYPEs are contiguous (external/local) */
  16.627 +
  16.628 +		return (FALSE);
  16.629 +	}
  16.630 +
  16.631 +	return (TRUE);
  16.632 +}
  16.633 +
  16.634 +/*******************************************************************************
  16.635 + *
  16.636 + * FUNCTION:    acpi_ut_init_globals
  16.637 + *
  16.638 + * PARAMETERS:  None
  16.639 + *
  16.640 + * RETURN:      None
  16.641 + *
  16.642 + * DESCRIPTION: Init library globals.  All globals that require specific
  16.643 + *              initialization should be initialized here!
  16.644 + *
  16.645 + ******************************************************************************/
  16.646 +
  16.647 +void acpi_ut_init_globals(void)
  16.648 +{
  16.649 +#if 0
  16.650 +	acpi_status status;
  16.651 +#endif
  16.652 +	u32 i;
  16.653 +
  16.654 +	ACPI_FUNCTION_TRACE(ut_init_globals);
  16.655 +
  16.656 +#if 0
  16.657 +	/* Create all memory caches */
  16.658 +
  16.659 +	status = acpi_ut_create_caches();
  16.660 +	if (ACPI_FAILURE(status)) {
  16.661 +		return;
  16.662 +	}
  16.663 +#endif
  16.664 +
  16.665 +	/* Mutex locked flags */
  16.666 +
  16.667 +	for (i = 0; i < ACPI_NUM_MUTEX; i++) {
  16.668 +		acpi_gbl_mutex_info[i].mutex = NULL;
  16.669 +		acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
  16.670 +		acpi_gbl_mutex_info[i].use_count = 0;
  16.671 +	}
  16.672 +
  16.673 +	for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) {
  16.674 +		acpi_gbl_owner_id_mask[i] = 0;
  16.675 +	}
  16.676 +	acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000;	/* Last ID is never valid */
  16.677 +
  16.678 +	/* GPE support */
  16.679 +
  16.680 +	acpi_gbl_gpe_xrupt_list_head = NULL;
  16.681 +	acpi_gbl_gpe_fadt_blocks[0] = NULL;
  16.682 +	acpi_gbl_gpe_fadt_blocks[1] = NULL;
  16.683 +
  16.684 +	/* Global handlers */
  16.685 +
  16.686 +	acpi_gbl_system_notify.handler = NULL;
  16.687 +	acpi_gbl_device_notify.handler = NULL;
  16.688 +	acpi_gbl_exception_handler = NULL;
  16.689 +	acpi_gbl_init_handler = NULL;
  16.690 +	/*acpi_gbl_table_handler = NULL;*/
  16.691 +
  16.692 +	/* Global Lock support */
  16.693 +
  16.694 +	acpi_gbl_global_lock_semaphore = NULL;
  16.695 +	acpi_gbl_global_lock_mutex = NULL;
  16.696 +	acpi_gbl_global_lock_acquired = FALSE;
  16.697 +	acpi_gbl_global_lock_handle = 0;
  16.698 +
  16.699 +	/* Miscellaneous variables */
  16.700 +
  16.701 +	acpi_gbl_cm_single_step = FALSE;
  16.702 +	acpi_gbl_db_terminate_threads = FALSE;
  16.703 +	acpi_gbl_shutdown = FALSE;
  16.704 +	acpi_gbl_ns_lookup_count = 0;
  16.705 +	acpi_gbl_ps_find_count = 0;
  16.706 +	acpi_gbl_acpi_hardware_present = TRUE;
  16.707 +	acpi_gbl_last_owner_id_index = 0;
  16.708 +	acpi_gbl_next_owner_id_offset = 0;
  16.709 +	acpi_gbl_trace_method_name = 0;
  16.710 +	acpi_gbl_trace_dbg_level = 0;
  16.711 +	acpi_gbl_trace_dbg_layer = 0;
  16.712 +	acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
  16.713 +	acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT;
  16.714 +
  16.715 +	/* Hardware oriented */
  16.716 +
  16.717 +	acpi_gbl_events_initialized = FALSE;
  16.718 +	acpi_gbl_system_awake_and_running = TRUE;
  16.719 +
  16.720 +	/* Namespace */
  16.721 +
  16.722 +	acpi_gbl_root_node = NULL;
  16.723 +	acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
  16.724 +	acpi_gbl_root_node_struct.descriptor_type = ACPI_DESC_TYPE_NAMED;
  16.725 +	acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
  16.726 +	acpi_gbl_root_node_struct.child = NULL;
  16.727 +	acpi_gbl_root_node_struct.peer = NULL;
  16.728 +	acpi_gbl_root_node_struct.object = NULL;
  16.729 +	acpi_gbl_root_node_struct.flags = ANOBJ_END_OF_PEER_LIST;
  16.730 +
  16.731 +#ifdef ACPI_DEBUG_OUTPUT
  16.732 +	acpi_gbl_lowest_stack_pointer = ACPI_CAST_PTR(acpi_size, ACPI_SIZE_MAX);
  16.733 +#endif
  16.734 +
  16.735 +#ifdef ACPI_DBG_TRACK_ALLOCATIONS
  16.736 +	acpi_gbl_display_final_mem_stats = FALSE;
  16.737 +#endif
  16.738 +
  16.739 +	return_VOID;
  16.740 +}
  16.741 +
  16.742 +ACPI_EXPORT_SYMBOL(acpi_dbg_level)
  16.743 +    ACPI_EXPORT_SYMBOL(acpi_dbg_layer)
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/xen/drivers/acpi/utilities/utmisc.c	Tue Jun 10 13:45:29 2008 +0100
    17.3 @@ -0,0 +1,229 @@
    17.4 +/*******************************************************************************
    17.5 + *
    17.6 + * Module Name: utmisc - common utility procedures
    17.7 + *
    17.8 + ******************************************************************************/
    17.9 +
   17.10 +/*
   17.11 + * Copyright (C) 2000 - 2008, Intel Corp.
   17.12 + * All rights reserved.
   17.13 + *
   17.14 + * Redistribution and use in source and binary forms, with or without
   17.15 + * modification, are permitted provided that the following conditions
   17.16 + * are met:
   17.17 + * 1. Redistributions of source code must retain the above copyright
   17.18 + *    notice, this list of conditions, and the following disclaimer,
   17.19 + *    without modification.
   17.20 + * 2. Redistributions in binary form must reproduce at minimum a disclaimer
   17.21 + *    substantially similar to the "NO WARRANTY" disclaimer below
   17.22 + *    ("Disclaimer") and any redistribution must be conditioned upon
   17.23 + *    including a substantially similar Disclaimer requirement for further
   17.24 + *    binary redistribution.
   17.25 + * 3. Neither the names of the above-listed copyright holders nor the names
   17.26 + *    of any contributors may be used to endorse or promote products derived
   17.27 + *    from this software without specific prior written permission.
   17.28 + *
   17.29 + * Alternatively, this software may be distributed under the terms of the
   17.30 + * GNU General Public License ("GPL") version 2 as published by the Free
   17.31 + * Software Foundation.
   17.32 + *
   17.33 + * NO WARRANTY
   17.34 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   17.35 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   17.36 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
   17.37 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   17.38 + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   17.39 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   17.40 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   17.41 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   17.42 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
   17.43 + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   17.44 + * POSSIBILITY OF SUCH DAMAGES.
   17.45 + */
   17.46 +
   17.47 +#include <xen/config.h>
   17.48 +#include <xen/init.h>
   17.49 +#include <acpi/acpi.h>
   17.50 +
   17.51 +#define _COMPONENT          ACPI_UTILITIES
   17.52 +ACPI_MODULE_NAME("utmisc")
   17.53 +
   17.54 +/*******************************************************************************
   17.55 + *
   17.56 + * FUNCTION:    acpi_ut_validate_exception
   17.57 + *
   17.58 + * PARAMETERS:  Status       - The acpi_status code to be formatted
   17.59 + *
   17.60 + * RETURN:      A string containing the exception text. NULL if exception is
   17.61 + *              not valid.
   17.62 + *
   17.63 + * DESCRIPTION: This function validates and translates an ACPI exception into
   17.64 + *              an ASCII string.
   17.65 + *
   17.66 + ******************************************************************************/
   17.67 +const char *acpi_ut_validate_exception(acpi_status status)
   17.68 +{
   17.69 +	acpi_status sub_status;
   17.70 +	const char *exception = NULL;
   17.71 +
   17.72 +	ACPI_FUNCTION_ENTRY();
   17.73 +
   17.74 +	/*
   17.75 +	 * Status is composed of two parts, a "type" and an actual code
   17.76 +	 */
   17.77 +	sub_status = (status & ~AE_CODE_MASK);
   17.78 +
   17.79 +	switch (status & AE_CODE_MASK) {
   17.80 +	case AE_CODE_ENVIRONMENTAL:
   17.81 +
   17.82 +		if (sub_status <= AE_CODE_ENV_MAX) {
   17.83 +			exception = acpi_gbl_exception_names_env[sub_status];
   17.84 +		}
   17.85 +		break;
   17.86 +
   17.87 +	case AE_CODE_PROGRAMMER:
   17.88 +
   17.89 +		if (sub_status <= AE_CODE_PGM_MAX) {
   17.90 +			exception =
   17.91 +			    acpi_gbl_exception_names_pgm[sub_status - 1];
   17.92 +		}
   17.93 +		break;
   17.94 +
   17.95 +	case AE_CODE_ACPI_TABLES:
   17.96 +
   17.97 +		if (sub_status <= AE_CODE_TBL_MAX) {
   17.98 +			exception =
   17.99 +			    acpi_gbl_exception_names_tbl[sub_status - 1];
  17.100 +		}
  17.101 +		break;
  17.102 +
  17.103 +	case AE_CODE_AML:
  17.104 +
  17.105 +		if (sub_status <= AE_CODE_AML_MAX) {
  17.106 +			exception =
  17.107 +			    acpi_gbl_exception_names_aml[sub_status - 1];
  17.108 +		}
  17.109 +		break;
  17.110 +
  17.111 +	case AE_CODE_CONTROL:
  17.112 +
  17.113 +		if (sub_status <= AE_CODE_CTRL_MAX) {
  17.114 +			exception =
  17.115 +			    acpi_gbl_exception_names_ctrl[sub_status - 1];
  17.116 +		}
  17.117 +		break;
  17.118 +
  17.119 +	default:
  17.120 +		break;
  17.121 +	}
  17.122 +
  17.123 +	return (ACPI_CAST_PTR(const char, exception));
  17.124 +}
  17.125 +
  17.126 +/*******************************************************************************
  17.127 + *
  17.128 + * FUNCTION:    acpi_ut_set_integer_width
  17.129 + *
  17.130 + * PARAMETERS:  Revision            From DSDT header
  17.131 + *
  17.132 + * RETURN:      None
  17.133 + *
  17.134 + * DESCRIPTION: Set the global integer bit width based upon the revision
  17.135 + *              of the DSDT.  For Revision 1 and 0, Integers are 32 bits.
  17.136 + *              For Revision 2 and above, Integers are 64 bits.  Yes, this
  17.137 + *              makes a difference.
  17.138 + *
  17.139 + ******************************************************************************/
  17.140 +
  17.141 +void acpi_ut_set_integer_width(u8 revision)
  17.142 +{
  17.143 +
  17.144 +	if (revision < 2) {
  17.145 +
  17.146 +		/* 32-bit case */
  17.147 +
  17.148 +		acpi_gbl_integer_bit_width = 32;
  17.149 +		acpi_gbl_integer_nybble_width = 8;
  17.150 +		acpi_gbl_integer_byte_width = 4;
  17.151 +	} else {
  17.152 +		/* 64-bit case (ACPI 2.0+) */
  17.153 +
  17.154 +		acpi_gbl_integer_bit_width = 64;
  17.155 +		acpi_gbl_integer_nybble_width = 16;
  17.156 +		acpi_gbl_integer_byte_width = 8;
  17.157 +	}
  17.158 +}
  17.159 +
  17.160 +/*******************************************************************************
  17.161 + *
  17.162 + * FUNCTION:    acpi_ut_error, acpi_ut_warning, acpi_ut_info
  17.163 + *
  17.164 + * PARAMETERS:  module_name         - Caller's module name (for error output)
  17.165 + *              line_number         - Caller's line number (for error output)
  17.166 + *              Format              - Printf format string + additional args
  17.167 + *
  17.168 + * RETURN:      None
  17.169 + *
  17.170 + * DESCRIPTION: Print message with module/line/version info
  17.171 + *
  17.172 + ******************************************************************************/
  17.173 +
  17.174 +void ACPI_INTERNAL_VAR_XFACE
  17.175 +acpi_ut_error(char *module_name, u32 line_number, char *format, ...)
  17.176 +{
  17.177 +	va_list args;
  17.178 +
  17.179 +	acpi_os_printf("ACPI Error (%s-%04d): ", module_name, line_number);
  17.180 +
  17.181 +	va_start(args, format);
  17.182 +	acpi_os_vprintf(format, args);
  17.183 +	acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
  17.184 +	va_end(args);
  17.185 +}
  17.186 +
  17.187 +void ACPI_INTERNAL_VAR_XFACE
  17.188 +acpi_ut_exception(char *module_name,
  17.189 +		  u32 line_number, acpi_status status, char *format, ...)
  17.190 +{
  17.191 +	va_list args;
  17.192 +
  17.193 +	acpi_os_printf("ACPI Exception (%s-%04d): %s, ", module_name,
  17.194 +		       line_number, acpi_format_exception(status));
  17.195 +
  17.196 +	va_start(args, format);
  17.197 +	acpi_os_vprintf(format, args);
  17.198 +	acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
  17.199 +}
  17.200 +
  17.201 +EXPORT_SYMBOL(acpi_ut_exception);
  17.202 +
  17.203 +void ACPI_INTERNAL_VAR_XFACE
  17.204 +acpi_ut_warning(char *module_name, u32 line_number, char *format, ...)
  17.205 +{
  17.206 +	va_list args;
  17.207 +
  17.208 +	acpi_os_printf("ACPI Warning (%s-%04d): ", module_name, line_number);
  17.209 +
  17.210 +	va_start(args, format);
  17.211 +	acpi_os_vprintf(format, args);
  17.212 +	acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
  17.213 +	va_end(args);
  17.214 +	va_end(args);
  17.215 +}
  17.216 +
  17.217 +void ACPI_INTERNAL_VAR_XFACE
  17.218 +acpi_ut_info(char *module_name, u32 line_number, char *format, ...)
  17.219 +{
  17.220 +	va_list args;
  17.221 +
  17.222 +	/*
  17.223 +	 * Removed module_name, line_number, and acpica version, not needed
  17.224 +	 * for info output
  17.225 +	 */
  17.226 +	acpi_os_printf("ACPI: ");
  17.227 +
  17.228 +	va_start(args, format);
  17.229 +	acpi_os_vprintf(format, args);
  17.230 +	acpi_os_printf("\n");
  17.231 +	va_end(args);
  17.232 +}
    18.1 --- a/xen/drivers/passthrough/amd/iommu_acpi.c	Tue Jun 10 09:27:01 2008 +0100
    18.2 +++ b/xen/drivers/passthrough/amd/iommu_acpi.c	Tue Jun 10 13:45:29 2008 +0100
    18.3 @@ -794,14 +794,13 @@ static void __init dump_acpi_table_heade
    18.4  
    18.5  }
    18.6  
    18.7 -int __init parse_ivrs_table(unsigned long phys_addr, unsigned long size)
    18.8 +int __init parse_ivrs_table(struct acpi_table_header *_table)
    18.9  {
   18.10      struct acpi_ivrs_block_header *ivrs_block;
   18.11      unsigned long length, i;
   18.12      u8 checksum, *raw_table;
   18.13      int error = 0;
   18.14 -    struct acpi_table_header  *table =
   18.15 -        (struct acpi_table_header *) __acpi_map_table(phys_addr, size);
   18.16 +    struct acpi_table_header *table = (struct acpi_table_header *)_table;
   18.17  
   18.18      BUG_ON(!table);
   18.19  
    19.1 --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c	Tue Jun 10 09:27:01 2008 +0100
    19.2 +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c	Tue Jun 10 13:45:29 2008 +0100
    19.3 @@ -212,7 +212,7 @@ static int __init amd_iommu_init(void)
    19.4              IOMMU_CONTROL_DISABLED;
    19.5      }
    19.6  
    19.7 -    if ( acpi_table_parse(ACPI_IVRS, parse_ivrs_table) != 0 )
    19.8 +    if ( acpi_table_parse(AMD_IOMMU_ACPI_IVRS_SIG, parse_ivrs_table) != 0 )
    19.9          amd_iov_error("Did not find IVRS table!\n");
   19.10  
   19.11      for_each_amd_iommu ( iommu )
    20.1 --- a/xen/drivers/passthrough/vtd/dmar.c	Tue Jun 10 09:27:01 2008 +0100
    20.2 +++ b/xen/drivers/passthrough/vtd/dmar.c	Tue Jun 10 13:45:29 2008 +0100
    20.3 @@ -477,22 +477,13 @@ acpi_parse_one_atsr(struct acpi_dmar_ent
    20.4      return ret;
    20.5  }
    20.6  
    20.7 -static int __init acpi_parse_dmar(unsigned long phys_addr,
    20.8 -                                  unsigned long size)
    20.9 +static int __init acpi_parse_dmar(struct acpi_table_header *table)
   20.10  {
   20.11 -    struct acpi_table_dmar *dmar = NULL;
   20.12 +    struct acpi_table_dmar *dmar;
   20.13      struct acpi_dmar_entry_header *entry_header;
   20.14      int ret = 0;
   20.15  
   20.16 -    if ( !phys_addr || !size )
   20.17 -        return -EINVAL;
   20.18 -
   20.19 -    dmar = (struct acpi_table_dmar *)__acpi_map_table(phys_addr, size);
   20.20 -    if ( !dmar )
   20.21 -    {
   20.22 -        dprintk(XENLOG_WARNING VTDPREFIX, "Unable to map DMAR\n");
   20.23 -        return -ENODEV;
   20.24 -    }
   20.25 +    dmar = (struct acpi_table_dmar *)table;
   20.26  
   20.27      if ( !dmar->width )
   20.28      {
   20.29 @@ -506,7 +497,7 @@ static int __init acpi_parse_dmar(unsign
   20.30  
   20.31      entry_header = (struct acpi_dmar_entry_header *)(dmar + 1);
   20.32      while ( ((unsigned long)entry_header) <
   20.33 -            (((unsigned long)dmar) + size) )
   20.34 +            (((unsigned long)dmar) + table->length) )
   20.35      {
   20.36          switch ( entry_header->type )
   20.37          {
   20.38 @@ -550,7 +541,7 @@ int acpi_dmar_init(void)
   20.39      if ( (rc = vtd_hw_check()) != 0 )
   20.40          goto fail;
   20.41  
   20.42 -    acpi_table_parse(ACPI_DMAR, acpi_parse_dmar);
   20.43 +    acpi_table_parse(ACPI_SIG_DMAR, acpi_parse_dmar);
   20.44  
   20.45      rc = -ENODEV;
   20.46      if ( list_empty(&acpi_drhd_units) )
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/xen/include/acpi/acnamesp.h	Tue Jun 10 13:45:29 2008 +0100
    21.3 @@ -0,0 +1,305 @@
    21.4 +/******************************************************************************
    21.5 + *
    21.6 + * Name: acnamesp.h - Namespace subcomponent prototypes and defines
    21.7 + *
    21.8 + *****************************************************************************/
    21.9 +
   21.10 +/*
   21.11 + * Copyright (C) 2000 - 2008, Intel Corp.
   21.12 + * All rights reserved.
   21.13 + *
   21.14 + * Redistribution and use in source and binary forms, with or without
   21.15 + * modification, are permitted provided that the following conditions
   21.16 + * are met:
   21.17 + * 1. Redistributions of source code must retain the above copyright
   21.18 + *    notice, this list of conditions, and the following disclaimer,
   21.19 + *    without modification.
   21.20 + * 2. Redistributions in binary form must reproduce at minimum a disclaimer
   21.21 + *    substantially similar to the "NO WARRANTY" disclaimer below
   21.22 + *    ("Disclaimer") and any redistribution must be conditioned upon
   21.23 + *    including a substantially similar Disclaimer requirement for further
   21.24 + *    binary redistribution.
   21.25 + * 3. Neither the names of the above-listed copyright holders nor the names
   21.26 + *    of any contributors may be used to endorse or promote products derived
   21.27 + *    from this software without specific prior written permission.
   21.28 + *
   21.29 + * Alternatively, this software may be distributed under the terms of the
   21.30 + * GNU General Public License ("GPL") version 2 as published by the Free
   21.31 + * Software Foundation.
   21.32 + *
   21.33 + * NO WARRANTY
   21.34 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   21.35 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   21.36 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
   21.37 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   21.38 + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   21.39 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   21.40 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21.41 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   21.42 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
   21.43 + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   21.44 + * POSSIBILITY OF SUCH DAMAGES.
   21.45 + */
   21.46 +
   21.47 +#ifndef __ACNAMESP_H__
   21.48 +#define __ACNAMESP_H__
   21.49 +
   21.50 +/* To search the entire name space, pass this as search_base */
   21.51 +
   21.52 +#define ACPI_NS_ALL                 ((acpi_handle)0)
   21.53 +
   21.54 +/*
   21.55 + * Elements of acpi_ns_properties are bit significant
   21.56 + * and should be one-to-one with values of acpi_object_type
   21.57 + */
   21.58 +#define ACPI_NS_NORMAL              0
   21.59 +#define ACPI_NS_NEWSCOPE            1	/* a definition of this type opens a name scope */
   21.60 +#define ACPI_NS_LOCAL               2	/* suppress search of enclosing scopes */
   21.61 +
   21.62 +/* Flags for acpi_ns_lookup, acpi_ns_search_and_enter */
   21.63 +
   21.64 +#define ACPI_NS_NO_UPSEARCH         0
   21.65 +#define ACPI_NS_SEARCH_PARENT       0x01
   21.66 +#define ACPI_NS_DONT_OPEN_SCOPE     0x02
   21.67 +#define ACPI_NS_NO_PEER_SEARCH      0x04
   21.68 +#define ACPI_NS_ERROR_IF_FOUND      0x08
   21.69 +#define ACPI_NS_PREFIX_IS_SCOPE     0x10
   21.70 +#define ACPI_NS_EXTERNAL            0x20
   21.71 +#define ACPI_NS_TEMPORARY           0x40
   21.72 +
   21.73 +/* Flags for acpi_ns_walk_namespace */
   21.74 +
   21.75 +#define ACPI_NS_WALK_NO_UNLOCK      0
   21.76 +#define ACPI_NS_WALK_UNLOCK         0x01
   21.77 +#define ACPI_NS_WALK_TEMP_NODES     0x02
   21.78 +
   21.79 +/*
   21.80 + * nsinit - Namespace initialization
   21.81 + */
   21.82 +acpi_status acpi_ns_initialize_objects(void);
   21.83 +
   21.84 +acpi_status acpi_ns_initialize_devices(void);
   21.85 +
   21.86 +/*
   21.87 + * nsload -  Namespace loading
   21.88 + */
   21.89 +acpi_status acpi_ns_load_namespace(void);
   21.90 +
   21.91 +acpi_status
   21.92 +acpi_ns_load_table(acpi_native_uint table_index,
   21.93 +		   struct acpi_namespace_node *node);
   21.94 +
   21.95 +/*
   21.96 + * nswalk - walk the namespace
   21.97 + */
   21.98 +acpi_status
   21.99 +acpi_ns_walk_namespace(acpi_object_type type,
  21.100 +		       acpi_handle start_object,
  21.101 +		       u32 max_depth,
  21.102 +		       u32 flags,
  21.103 +		       acpi_walk_callback user_function,
  21.104 +		       void *context, void **return_value);
  21.105 +
  21.106 +struct acpi_namespace_node *acpi_ns_get_next_node(acpi_object_type type, struct acpi_namespace_node
  21.107 +						  *parent, struct acpi_namespace_node
  21.108 +						  *child);
  21.109 +
  21.110 +/*
  21.111 + * nsparse - table parsing
  21.112 + */
  21.113 +acpi_status
  21.114 +acpi_ns_parse_table(acpi_native_uint table_index,
  21.115 +		    struct acpi_namespace_node *start_node);
  21.116 +
  21.117 +acpi_status
  21.118 +acpi_ns_one_complete_parse(acpi_native_uint pass_number,
  21.119 +			   acpi_native_uint table_index,
  21.120 +			   struct acpi_namespace_node *start_node);
  21.121 +
  21.122 +/*
  21.123 + * nsaccess - Top-level namespace access
  21.124 + */
  21.125 +acpi_status acpi_ns_root_initialize(void);
  21.126 +
  21.127 +acpi_status
  21.128 +acpi_ns_lookup(union acpi_generic_state *scope_info,
  21.129 +	       char *name,
  21.130 +	       acpi_object_type type,
  21.131 +	       acpi_interpreter_mode interpreter_mode,
  21.132 +	       u32 flags,
  21.133 +	       struct acpi_walk_state *walk_state,
  21.134 +	       struct acpi_namespace_node **ret_node);
  21.135 +
  21.136 +/*
  21.137 + * nsalloc - Named object allocation/deallocation
  21.138 + */
  21.139 +struct acpi_namespace_node *acpi_ns_create_node(u32 name);
  21.140 +
  21.141 +void acpi_ns_delete_node(struct acpi_namespace_node *node);
  21.142 +
  21.143 +void
  21.144 +acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_handle);
  21.145 +
  21.146 +void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id);
  21.147 +
  21.148 +void acpi_ns_detach_object(struct acpi_namespace_node *node);
  21.149 +
  21.150 +void acpi_ns_delete_children(struct acpi_namespace_node *parent);
  21.151 +
  21.152 +int acpi_ns_compare_names(char *name1, char *name2);
  21.153 +
  21.154 +/*
  21.155 + * nsdump - Namespace dump/print utilities
  21.156 + */
  21.157 +#ifdef	ACPI_FUTURE_USAGE
  21.158 +void acpi_ns_dump_tables(acpi_handle search_base, u32 max_depth);
  21.159 +#endif				/* ACPI_FUTURE_USAGE */
  21.160 +
  21.161 +void acpi_ns_dump_entry(acpi_handle handle, u32 debug_level);
  21.162 +
  21.163 +void
  21.164 +acpi_ns_dump_pathname(acpi_handle handle, char *msg, u32 level, u32 component);
  21.165 +
  21.166 +void acpi_ns_print_pathname(u32 num_segments, char *pathname);
  21.167 +
  21.168 +acpi_status
  21.169 +acpi_ns_dump_one_object(acpi_handle obj_handle,
  21.170 +			u32 level, void *context, void **return_value);
  21.171 +
  21.172 +#ifdef	ACPI_FUTURE_USAGE
  21.173 +void
  21.174 +acpi_ns_dump_objects(acpi_object_type type,
  21.175 +		     u8 display_type,
  21.176 +		     u32 max_depth,
  21.177 +		     acpi_owner_id owner_id, acpi_handle start_handle);
  21.178 +#endif				/* ACPI_FUTURE_USAGE */
  21.179 +
  21.180 +/*
  21.181 + * nseval - Namespace evaluation functions
  21.182 + */
  21.183 +acpi_status acpi_ns_evaluate(struct acpi_evaluate_info *info);
  21.184 +
  21.185 +/*
  21.186 + * nsnames - Name and Scope manipulation
  21.187 + */
  21.188 +u32 acpi_ns_opens_scope(acpi_object_type type);
  21.189 +
  21.190 +void
  21.191 +acpi_ns_build_external_path(struct acpi_namespace_node *node,
  21.192 +			    acpi_size size, char *name_buffer);
  21.193 +
  21.194 +char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node);
  21.195 +
  21.196 +char *acpi_ns_name_of_current_scope(struct acpi_walk_state *walk_state);
  21.197 +
  21.198 +acpi_status
  21.199 +acpi_ns_handle_to_pathname(acpi_handle target_handle,
  21.200 +			   struct acpi_buffer *buffer);
  21.201 +
  21.202 +u8
  21.203 +acpi_ns_pattern_match(struct acpi_namespace_node *obj_node, char *search_for);
  21.204 +
  21.205 +acpi_status
  21.206 +acpi_ns_get_node(struct acpi_namespace_node *prefix_node,
  21.207 +		 char *external_pathname,
  21.208 +		 u32 flags, struct acpi_namespace_node **out_node);
  21.209 +
  21.210 +acpi_size acpi_ns_get_pathname_length(struct acpi_namespace_node *node);
  21.211 +
  21.212 +/*
  21.213 + * nsobject - Object management for namespace nodes
  21.214 + */
  21.215 +acpi_status
  21.216 +acpi_ns_attach_object(struct acpi_namespace_node *node,
  21.217 +		      union acpi_operand_object *object, acpi_object_type type);
  21.218 +
  21.219 +union acpi_operand_object *acpi_ns_get_attached_object(struct
  21.220 +						       acpi_namespace_node
  21.221 +						       *node);
  21.222 +
  21.223 +union acpi_operand_object *acpi_ns_get_secondary_object(union
  21.224 +							acpi_operand_object
  21.225 +							*obj_desc);
  21.226 +
  21.227 +acpi_status
  21.228 +acpi_ns_attach_data(struct acpi_namespace_node *node,
  21.229 +		    acpi_object_handler handler, void *data);
  21.230 +
  21.231 +acpi_status
  21.232 +acpi_ns_detach_data(struct acpi_namespace_node *node,
  21.233 +		    acpi_object_handler handler);
  21.234 +
  21.235 +acpi_status
  21.236 +acpi_ns_get_attached_data(struct acpi_namespace_node *node,
  21.237 +			  acpi_object_handler handler, void **data);
  21.238 +
  21.239 +/*
  21.240 + * nssearch - Namespace searching and entry
  21.241 + */
  21.242 +acpi_status
  21.243 +acpi_ns_search_and_enter(u32 entry_name,
  21.244 +			 struct acpi_walk_state *walk_state,
  21.245 +			 struct acpi_namespace_node *node,
  21.246 +			 acpi_interpreter_mode interpreter_mode,
  21.247 +			 acpi_object_type type,
  21.248 +			 u32 flags, struct acpi_namespace_node **ret_node);
  21.249 +
  21.250 +acpi_status
  21.251 +acpi_ns_search_one_scope(u32 entry_name,
  21.252 +			 struct acpi_namespace_node *node,
  21.253 +			 acpi_object_type type,
  21.254 +			 struct acpi_namespace_node **ret_node);
  21.255 +
  21.256 +void
  21.257 +acpi_ns_install_node(struct acpi_walk_state *walk_state,
  21.258 +		     struct acpi_namespace_node *parent_node,
  21.259 +		     struct acpi_namespace_node *node, acpi_object_type type);
  21.260 +
  21.261 +/*
  21.262 + * nsutils - Utility functions
  21.263 + */
  21.264 +u8 acpi_ns_valid_root_prefix(char prefix);
  21.265 +
  21.266 +acpi_object_type acpi_ns_get_type(struct acpi_namespace_node *node);
  21.267 +
  21.268 +u32 acpi_ns_local(acpi_object_type type);
  21.269 +
  21.270 +void
  21.271 +acpi_ns_report_error(char *module_name,
  21.272 +		     u32 line_number,
  21.273 +		     char *internal_name, acpi_status lookup_status);
  21.274 +
  21.275 +void
  21.276 +acpi_ns_report_method_error(char *module_name,
  21.277 +			    u32 line_number,
  21.278 +			    char *message,
  21.279 +			    struct acpi_namespace_node *node,
  21.280 +			    char *path, acpi_status lookup_status);
  21.281 +
  21.282 +void acpi_ns_print_node_pathname(struct acpi_namespace_node *node, char *msg);
  21.283 +
  21.284 +acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info);
  21.285 +
  21.286 +void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info);
  21.287 +
  21.288 +acpi_status acpi_ns_internalize_name(char *dotted_name, char **converted_name);
  21.289 +
  21.290 +acpi_status
  21.291 +acpi_ns_externalize_name(u32 internal_name_length,
  21.292 +			 char *internal_name,
  21.293 +			 u32 * converted_name_length, char **converted_name);
  21.294 +
  21.295 +struct acpi_namespace_node *acpi_ns_map_handle_to_node(acpi_handle handle);
  21.296 +
  21.297 +acpi_handle acpi_ns_convert_entry_to_handle(struct acpi_namespace_node *node);
  21.298 +
  21.299 +void acpi_ns_terminate(void);
  21.300 +
  21.301 +struct acpi_namespace_node *acpi_ns_get_parent_node(struct acpi_namespace_node
  21.302 +						    *node);
  21.303 +
  21.304 +struct acpi_namespace_node *acpi_ns_get_next_valid_node(struct
  21.305 +							acpi_namespace_node
  21.306 +							*node);
  21.307 +
  21.308 +#endif				/* __ACNAMESP_H__ */
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/xen/include/acpi/actables.h	Tue Jun 10 13:45:29 2008 +0100
    22.3 @@ -0,0 +1,118 @@
    22.4 +/******************************************************************************
    22.5 + *
    22.6 + * Name: actables.h - ACPI table management
    22.7 + *
    22.8 + *****************************************************************************/
    22.9 +
   22.10 +/*
   22.11 + * Copyright (C) 2000 - 2008, Intel Corp.
   22.12 + * All rights reserved.
   22.13 + *
   22.14 + * Redistribution and use in source and binary forms, with or without
   22.15 + * modification, are permitted provided that the following conditions
   22.16 + * are met:
   22.17 + * 1. Redistributions of source code must retain the above copyright
   22.18 + *    notice, this list of conditions, and the following disclaimer,
   22.19 + *    without modification.
   22.20 + * 2. Redistributions in binary form must reproduce at minimum a disclaimer
   22.21 + *    substantially similar to the "NO WARRANTY" disclaimer below
   22.22 + *    ("Disclaimer") and any redistribution must be conditioned upon
   22.23 + *    including a substantially similar Disclaimer requirement for further
   22.24 + *    binary redistribution.
   22.25 + * 3. Neither the names of the above-listed copyright holders nor the names
   22.26 + *    of any contributors may be used to endorse or promote products derived
   22.27 + *    from this software without specific prior written permission.
   22.28 + *
   22.29 + * Alternatively, this software may be distributed under the terms of the
   22.30 + * GNU General Public License ("GPL") version 2 as published by the Free
   22.31 + * Software Foundation.
   22.32 + *
   22.33 + * NO WARRANTY
   22.34 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   22.35 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   22.36 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
   22.37 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   22.38 + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   22.39 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   22.40 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   22.41 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   22.42 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
   22.43 + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   22.44 + * POSSIBILITY OF SUCH DAMAGES.
   22.45 + */
   22.46 +
   22.47 +#ifndef __ACTABLES_H__
   22.48 +#define __ACTABLES_H__
   22.49 +
   22.50 +acpi_status acpi_allocate_root_table(u32 initial_table_count);
   22.51 +
   22.52 +/*
   22.53 + * tbfadt - FADT parse/convert/validate
   22.54 + */
   22.55 +void acpi_tb_parse_fadt(acpi_native_uint table_index, u8 flags);
   22.56 +
   22.57 +void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length);
   22.58 +
   22.59 +/*
   22.60 + * tbfind - find ACPI table
   22.61 + */
   22.62 +acpi_status
   22.63 +acpi_tb_find_table(char *signature,
   22.64 +		   char *oem_id,
   22.65 +		   char *oem_table_id, acpi_native_uint * table_index);
   22.66 +
   22.67 +/*
   22.68 + * tbinstal - Table removal and deletion
   22.69 + */
   22.70 +acpi_status acpi_tb_resize_root_table_list(void);
   22.71 +
   22.72 +acpi_status acpi_tb_verify_table(struct acpi_table_desc *table_desc);
   22.73 +
   22.74 +acpi_status
   22.75 +acpi_tb_add_table(struct acpi_table_desc *table_desc,
   22.76 +		  acpi_native_uint * table_index);
   22.77 +
   22.78 +acpi_status
   22.79 +acpi_tb_store_table(acpi_physical_address address,
   22.80 +		    struct acpi_table_header *table,
   22.81 +		    u32 length, u8 flags, acpi_native_uint * table_index);
   22.82 +
   22.83 +void acpi_tb_delete_table(struct acpi_table_desc *table_desc);
   22.84 +
   22.85 +void acpi_tb_terminate(void);
   22.86 +
   22.87 +void acpi_tb_delete_namespace_by_owner(acpi_native_uint table_index);
   22.88 +
   22.89 +acpi_status acpi_tb_allocate_owner_id(acpi_native_uint table_index);
   22.90 +
   22.91 +acpi_status acpi_tb_release_owner_id(acpi_native_uint table_index);
   22.92 +
   22.93 +acpi_status
   22.94 +acpi_tb_get_owner_id(acpi_native_uint table_index, acpi_owner_id * owner_id);
   22.95 +
   22.96 +u8 acpi_tb_is_table_loaded(acpi_native_uint table_index);
   22.97 +
   22.98 +void acpi_tb_set_table_loaded_flag(acpi_native_uint table_index, u8 is_loaded);
   22.99 +
  22.100 +/*
  22.101 + * tbutils - table manager utilities
  22.102 + */
  22.103 +u8 acpi_tb_tables_loaded(void);
  22.104 +
  22.105 +void
  22.106 +acpi_tb_print_table_header(acpi_physical_address address,
  22.107 +			   struct acpi_table_header *header);
  22.108 +
  22.109 +u8 acpi_tb_checksum(u8 * buffer, acpi_native_uint length);
  22.110 +
  22.111 +acpi_status
  22.112 +acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length);
  22.113 +
  22.114 +void
  22.115 +acpi_tb_install_table(acpi_physical_address address,
  22.116 +		      u8 flags, char *signature, acpi_native_uint table_index);
  22.117 +
  22.118 +acpi_status
  22.119 +acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags);
  22.120 +
  22.121 +#endif				/* __ACTABLES_H__ */
    23.1 --- a/xen/include/acpi/platform/aclinux.h	Tue Jun 10 09:27:01 2008 +0100
    23.2 +++ b/xen/include/acpi/platform/aclinux.h	Tue Jun 10 13:45:29 2008 +0100
    23.3 @@ -47,9 +47,8 @@
    23.4  #define ACPI_USE_SYSTEM_CLIBRARY
    23.5  #define ACPI_USE_DO_WHILE_0
    23.6  
    23.7 -#ifdef __XEN__
    23.8 -
    23.9  #include <xen/config.h>
   23.10 +#include <xen/cache.h>
   23.11  #include <xen/string.h>
   23.12  #include <xen/kernel.h>
   23.13  #include <xen/ctype.h>
   23.14 @@ -71,34 +70,6 @@
   23.15  /* Full namespace pathname length limit - arbitrary */
   23.16  #define ACPI_PATHNAME_MAX              256
   23.17  
   23.18 -#else				/* !__XEN__ */
   23.19 -
   23.20 -#include <stdarg.h>
   23.21 -#include <string.h>
   23.22 -#include <stdlib.h>
   23.23 -#include <ctype.h>
   23.24 -#include <unistd.h>
   23.25 -
   23.26 -#if defined(__ia64__) || defined(__x86_64__)
   23.27 -#define ACPI_MACHINE_WIDTH          64
   23.28 -#define COMPILER_DEPENDENT_INT64    long
   23.29 -#define COMPILER_DEPENDENT_UINT64   unsigned long
   23.30 -#else
   23.31 -#define ACPI_MACHINE_WIDTH          32
   23.32 -#define COMPILER_DEPENDENT_INT64    long long
   23.33 -#define COMPILER_DEPENDENT_UINT64   unsigned long long
   23.34 -#define ACPI_USE_NATIVE_DIVIDE
   23.35 -#endif
   23.36 -
   23.37 -#ifndef __cdecl
   23.38 -#define __cdecl
   23.39 -#endif
   23.40 -
   23.41 -#define ACPI_FLUSH_CPU_CACHE()
   23.42 -#endif				/* __XEN__ */
   23.43 -
   23.44 -/* Linux uses GCC */
   23.45 -
   23.46  #include "acgcc.h"
   23.47  
   23.48  #define acpi_cpu_flags unsigned long
   23.49 @@ -110,32 +81,11 @@ static inline acpi_thread_id acpi_os_get
   23.50  	return current;
   23.51  }
   23.52  
   23.53 -#if 0
   23.54 -/*
   23.55 - * The irqs_disabled() check is for resume from RAM.
   23.56 - * Interrupts are off during resume, just like they are for boot.
   23.57 - * However, boot has  (system_state != SYSTEM_RUNNING)
   23.58 - * to quiet __might_sleep() in kmalloc() and resume does not.
   23.59 - */
   23.60 -#include <acpi/actypes.h>
   23.61 -static inline void *acpi_os_allocate(acpi_size size)
   23.62 -{
   23.63 -	return kmalloc(size, irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
   23.64 -}
   23.65 -static inline void *acpi_os_allocate_zeroed(acpi_size size)
   23.66 -{
   23.67 -	return kzalloc(size, irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
   23.68 -}
   23.69 -
   23.70 -static inline void *acpi_os_acquire_object(acpi_cache_t * cache)
   23.71 -{
   23.72 -	return kmem_cache_zalloc(cache,
   23.73 -				 irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
   23.74 -}
   23.75 -
   23.76 -#define ACPI_ALLOCATE(a)	acpi_os_allocate(a)
   23.77 -#define ACPI_ALLOCATE_ZEROED(a)	acpi_os_allocate_zeroed(a)
   23.78 -#define ACPI_FREE(a)		kfree(a)
   23.79 -#endif /* 0 */
   23.80 +#define ACPI_ALLOCATE(a)	xmalloc_bytes(a)
   23.81 +#define ACPI_ALLOCATE_ZEROED(a)	({              \
   23.82 +    void *p = xmalloc_bytes(a);                 \
   23.83 +    if ( p ) memset(p, 0, a);                   \
   23.84 +    p; })
   23.85 +#define ACPI_FREE(a)		xfree(a)
   23.86  
   23.87  #endif				/* __ACLINUX_H__ */
    24.1 --- a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h	Tue Jun 10 09:27:01 2008 +0100
    24.2 +++ b/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h	Tue Jun 10 13:45:29 2008 +0100
    24.3 @@ -88,7 +88,7 @@ void flush_command_buffer(struct amd_iom
    24.4  struct amd_iommu *find_iommu_for_device(int bus, int devfn);
    24.5  
    24.6  /* amd-iommu-acpi functions */
    24.7 -int __init parse_ivrs_table(unsigned long phys_addr, unsigned long size);
    24.8 +int __init parse_ivrs_table(struct acpi_table_header *table);
    24.9  
   24.10  static inline u32 get_field_from_reg_u32(u32 reg_value, u32 mask, u32 shift)
   24.11  {
    25.1 --- a/xen/include/xen/acpi.h	Tue Jun 10 09:27:01 2008 +0100
    25.2 +++ b/xen/include/xen/acpi.h	Tue Jun 10 13:45:29 2008 +0100
    25.3 @@ -47,11 +47,6 @@ enum acpi_irq_model_id {
    25.4  
    25.5  extern enum acpi_irq_model_id	acpi_irq_model;
    25.6  
    25.7 -typedef struct {
    25.8 -	u8			type;
    25.9 -	u8			length;
   25.10 -} __attribute__ ((packed)) acpi_table_entry_header;
   25.11 -
   25.12  enum acpi_madt_entry_id {
   25.13  	ACPI_MADT_LAPIC = 0,
   25.14  	ACPI_MADT_IOAPIC,
   25.15 @@ -72,7 +67,7 @@ typedef struct {
   25.16  } __attribute__ ((packed)) acpi_interrupt_flags;
   25.17  
   25.18  struct acpi_table_lapic {
   25.19 -	acpi_table_entry_header	header;
   25.20 +	struct acpi_subtable_header	header;
   25.21  	u8			acpi_id;
   25.22  	u8			id;
   25.23  	struct {
   25.24 @@ -82,7 +77,7 @@ struct acpi_table_lapic {
   25.25  } __attribute__ ((packed));
   25.26  
   25.27  struct acpi_table_ioapic {
   25.28 -	acpi_table_entry_header	header;
   25.29 +	struct acpi_subtable_header	header;
   25.30  	u8			id;
   25.31  	u8			reserved;
   25.32  	u32			address;
   25.33 @@ -90,7 +85,7 @@ struct acpi_table_ioapic {
   25.34  } __attribute__ ((packed));
   25.35  
   25.36  struct acpi_table_int_src_ovr {
   25.37 -	acpi_table_entry_header	header;
   25.38 +	struct acpi_subtable_header	header;
   25.39  	u8			bus;
   25.40  	u8			bus_irq;
   25.41  	u32			global_irq;
   25.42 @@ -98,26 +93,26 @@ struct acpi_table_int_src_ovr {
   25.43  } __attribute__ ((packed));
   25.44  
   25.45  struct acpi_table_nmi_src {
   25.46 -	acpi_table_entry_header	header;
   25.47 +	struct acpi_subtable_header	header;
   25.48  	acpi_interrupt_flags	flags;
   25.49  	u32			global_irq;
   25.50  } __attribute__ ((packed));
   25.51  
   25.52  struct acpi_table_lapic_nmi {
   25.53 -	acpi_table_entry_header	header;
   25.54 +	struct acpi_subtable_header	header;
   25.55  	u8			acpi_id;
   25.56  	acpi_interrupt_flags	flags;
   25.57  	u8			lint;
   25.58  } __attribute__ ((packed));
   25.59  
   25.60  struct acpi_table_lapic_addr_ovr {
   25.61 -	acpi_table_entry_header	header;
   25.62 +	struct acpi_subtable_header	header;
   25.63  	u8			reserved[2];
   25.64  	u64			address;
   25.65  } __attribute__ ((packed));
   25.66  
   25.67  struct acpi_table_iosapic {
   25.68 -	acpi_table_entry_header	header;
   25.69 +	struct acpi_subtable_header	header;
   25.70  	u8			id;
   25.71  	u8			reserved;
   25.72  	u32			global_irq_base;
   25.73 @@ -125,7 +120,7 @@ struct acpi_table_iosapic {
   25.74  } __attribute__ ((packed));
   25.75  
   25.76  struct acpi_table_lsapic {
   25.77 -	acpi_table_entry_header	header;
   25.78 +	struct acpi_subtable_header	header;
   25.79  	u8			acpi_id;
   25.80  	u8			id;
   25.81  	u8			eid;
   25.82 @@ -137,7 +132,7 @@ struct acpi_table_lsapic {
   25.83  } __attribute__ ((packed));
   25.84  
   25.85  struct acpi_table_plat_int_src {
   25.86 -	acpi_table_entry_header	header;
   25.87 +	struct acpi_subtable_header	header;
   25.88  	acpi_interrupt_flags	flags;
   25.89  	u8			type;	/* See acpi_interrupt_type */
   25.90  	u8			id;
   25.91 @@ -182,7 +177,7 @@ enum acpi_srat_entry_id {
   25.92  };
   25.93  
   25.94  struct acpi_table_processor_affinity {
   25.95 -	acpi_table_entry_header	header;
   25.96 +	struct acpi_subtable_header	header;
   25.97  	u8			proximity_domain;
   25.98  	u8			apic_id;
   25.99  	struct {
  25.100 @@ -194,7 +189,7 @@ struct acpi_table_processor_affinity {
  25.101  } __attribute__ ((packed));
  25.102  
  25.103  struct acpi_table_memory_affinity {
  25.104 -	acpi_table_entry_header	header;
  25.105 +	struct acpi_subtable_header	header;
  25.106  	u8			proximity_domain;
  25.107  	u8			reserved1[5];
  25.108  	u32			base_addr_lo;
  25.109 @@ -218,33 +213,6 @@ enum acpi_address_range_id {
  25.110  	ACPI_ADDRESS_RANGE_COUNT
  25.111  };
  25.112  
  25.113 -/* Table Handlers */
  25.114 -
  25.115 -enum acpi_table_id {
  25.116 -	ACPI_TABLE_UNKNOWN = 0,
  25.117 -	ACPI_APIC,
  25.118 -	ACPI_BOOT,
  25.119 -	ACPI_DBGP,
  25.120 -	ACPI_DSDT,
  25.121 -	ACPI_ECDT,
  25.122 -	ACPI_ETDT,
  25.123 -	ACPI_FADT,
  25.124 -	ACPI_FACS,
  25.125 -	ACPI_OEMX,
  25.126 -	ACPI_PSDT,
  25.127 -	ACPI_SBST,
  25.128 -	ACPI_SLIT,
  25.129 -	ACPI_SPCR,
  25.130 -	ACPI_SRAT,
  25.131 -	ACPI_SSDT,
  25.132 -	ACPI_SPMI,
  25.133 -	ACPI_HPET,
  25.134 -	ACPI_MCFG,
  25.135 -	ACPI_DMAR,
  25.136 -	ACPI_IVRS,
  25.137 -	ACPI_TABLE_COUNT
  25.138 -};
  25.139 -
  25.140  /* DMA Remapping Reporting Table (DMAR) */
  25.141  
  25.142  #define DMAR_FLAGS_INTR_REMAP 0x1       /* intr remap supported */
  25.143 @@ -306,13 +274,11 @@ struct acpi_pci_path {
  25.144  	u8	fn;
  25.145  } __attribute__((packed));
  25.146  
  25.147 -typedef int (*acpi_dmar_entry_handler) (struct acpi_dmar_entry_header *header, const unsigned long end);
  25.148 -
  25.149 -typedef int (*acpi_table_handler) (unsigned long phys_addr, unsigned long size);
  25.150 +typedef int (*acpi_madt_entry_handler) (struct acpi_subtable_header *header, const unsigned long end);
  25.151  
  25.152 -extern acpi_table_handler acpi_table_ops[ACPI_TABLE_COUNT];
  25.153 +typedef int (*acpi_table_handler) (struct acpi_table_header *table);
  25.154  
  25.155 -typedef int (*acpi_madt_entry_handler) (acpi_table_entry_header *header, const unsigned long end);
  25.156 +typedef int (*acpi_table_entry_handler) (struct acpi_subtable_header *header, const unsigned long end);
  25.157  
  25.158  unsigned int acpi_get_processor_id (unsigned int cpu);
  25.159  char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
  25.160 @@ -322,14 +288,13 @@ int acpi_boot_table_init (void);
  25.161  int acpi_numa_init (void);
  25.162  
  25.163  int acpi_table_init (void);
  25.164 -int acpi_table_disable(enum acpi_table_id table_id);
  25.165 -int acpi_table_parse (enum acpi_table_id id, acpi_table_handler handler);
  25.166 -int acpi_get_table_header_early (enum acpi_table_id id, struct acpi_table_header **header);
  25.167 -int acpi_table_parse_madt (enum acpi_madt_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries);
  25.168 -int acpi_table_parse_srat (enum acpi_srat_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries);
  25.169 +int acpi_table_parse(char *id, acpi_table_handler handler);
  25.170 +int acpi_table_parse_entries(char *id, unsigned long table_size,
  25.171 +	int entry_id, acpi_table_entry_handler handler, unsigned int max_entries);
  25.172 +int acpi_table_parse_madt(enum acpi_madt_type id, acpi_table_entry_handler handler, unsigned int max_entries);
  25.173  void acpi_table_print (struct acpi_table_header *header, unsigned long phys_addr);
  25.174 -void acpi_table_print_madt_entry (acpi_table_entry_header *madt);
  25.175 -void acpi_table_print_srat_entry (acpi_table_entry_header *srat);
  25.176 +void acpi_table_print_madt_entry (struct acpi_subtable_header *madt);
  25.177 +void acpi_table_print_srat_entry (struct acpi_subtable_header *srat);
  25.178  uint8_t generate_acpi_checksum(void *tbl, unsigned long len);
  25.179  
  25.180  /* the following four functions are architecture-dependent */
    26.1 --- a/xen/include/xen/compiler.h	Tue Jun 10 09:27:01 2008 +0100
    26.2 +++ b/xen/include/xen/compiler.h	Tue Jun 10 13:45:29 2008 +0100
    26.3 @@ -53,4 +53,10 @@
    26.4      __asm__ ("" : "=r"(__ptr) : "0"(ptr));      \
    26.5      (typeof(ptr)) (__ptr + (off)); })
    26.6  
    26.7 +/*
    26.8 + * A trick to suppress uninitialized variable warning without generating any
    26.9 + * code
   26.10 + */
   26.11 +#define uninitialized_var(x) x = x
   26.12 +
   26.13  #endif /* __LINUX_COMPILER_H */