From: "Andi Kleen" <ak@suse.de>

Split ACPI boot table parsing

Split ACPI boot table parsing into two parts.  First a acpi_boot_table_init()
call that initializes the basic ACPI table parsing machinery and discovers the
RSDP, and then another call to actually parse the various boot tables.

This is needed for a followon patch that implements SRAT support, because
nodes need to be set up before the other ACPI tables can be parsed.

On x86-64 I moved the early initialization very early because that is needed
for the SRAT parser.

On i386 it should be a nop.

Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/arch/i386/kernel/acpi/boot.c |   24 +++++++++++++++++++++---
 25-akpm/arch/i386/kernel/setup.c     |    1 +
 25-akpm/arch/x86_64/kernel/setup.c   |   21 ++++++++++++++-------
 25-akpm/include/linux/acpi.h         |    7 +++++++
 4 files changed, 43 insertions(+), 10 deletions(-)

diff -puN arch/i386/kernel/acpi/boot.c~x86_64-split-acpi-boot-table-parsing arch/i386/kernel/acpi/boot.c
--- 25/arch/i386/kernel/acpi/boot.c~x86_64-split-acpi-boot-table-parsing	Mon Nov 29 11:55:22 2004
+++ 25-akpm/arch/i386/kernel/acpi/boot.c	Mon Nov 29 11:56:00 2004
@@ -810,13 +810,16 @@ acpi_process_madt(void)
 }
 
 /*
- * acpi_boot_init()
+ * acpi_boot_table_init() and acpi_boot_init()
  *  called from setup_arch(), always.
  *	1. checksums all tables
  *	2. enumerates lapics
  *	3. enumerates io-apics
  *
- * side effects:
+ * acpi_table_init() is separate to allow reading SRAT without
+ * other side effects.
+ *
+ * side effects of acpi_boot_init:
  *	acpi_lapic = 1 if LAPIC found
  *	acpi_ioapic = 1 if IOAPIC found
  *	if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
@@ -830,7 +833,7 @@ acpi_process_madt(void)
  */
 
 int __init
-acpi_boot_init (void)
+acpi_boot_table_init(void)
 {
 	int error;
 
@@ -872,6 +875,21 @@ acpi_boot_init (void)
 		}
 	}
 
+	return 0;
+}
+
+
+int __init acpi_boot_init(void)
+{
+	/*
+	 * If acpi_disabled, bail out
+	 * One exception: acpi=ht continues far enough to enumerate LAPICs
+	 */
+	if (acpi_disabled && !acpi_ht)
+		 return 1;
+
+	acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
+
 	/*
 	 * set sci_int and PM timer address
 	 */
diff -puN arch/i386/kernel/setup.c~x86_64-split-acpi-boot-table-parsing arch/i386/kernel/setup.c
--- 25/arch/i386/kernel/setup.c~x86_64-split-acpi-boot-table-parsing	Mon Nov 29 11:55:22 2004
+++ 25-akpm/arch/i386/kernel/setup.c	Mon Nov 29 11:55:22 2004
@@ -1404,6 +1404,7 @@ void __init setup_arch(char **cmdline_p)
 	/*
 	 * Parse the ACPI tables for possible boot-time SMP configuration.
 	 */
+	acpi_boot_table_init();
 	acpi_boot_init();
 
 #ifdef CONFIG_X86_LOCAL_APIC
diff -puN arch/x86_64/kernel/setup.c~x86_64-split-acpi-boot-table-parsing arch/x86_64/kernel/setup.c
--- 25/arch/x86_64/kernel/setup.c~x86_64-split-acpi-boot-table-parsing	Mon Nov 29 11:55:22 2004
+++ 25-akpm/arch/x86_64/kernel/setup.c	Mon Nov 29 11:55:22 2004
@@ -486,6 +486,14 @@ void __init setup_arch(char **cmdline_p)
 
 	init_memory_mapping(); 
 
+#ifdef CONFIG_ACPI_BOOT
+	/*
+	 * Initialize the ACPI boot-time table parser (gets the RSDP and SDT).
+	 * Call this early for SRAT node setup.
+	 */
+	acpi_boot_table_init();
+#endif
+
 #ifdef CONFIG_DISCONTIGMEM
 	numa_initmem_init(0, end_pfn); 
 #else
@@ -552,16 +560,15 @@ void __init setup_arch(char **cmdline_p)
 #endif
 	paging_init();
 
-		check_ioapic();
+	check_ioapic();
+
 #ifdef CONFIG_ACPI_BOOT
-       /*
-        * Initialize the ACPI boot-time table parser (gets the RSDP and SDT).
-        * Must do this after paging_init (due to reliance on fixmap, and thus
-        * the bootmem allocator) but before get_smp_config (to allow parsing
-        * of MADT).
-        */
+	/*
+	 * Read APIC and some other early information from ACPI tables.
+	 */
 	acpi_boot_init();
 #endif
+
 #ifdef CONFIG_X86_LOCAL_APIC
 	/*
 	 * get boot-time SMP configuration:
diff -puN include/linux/acpi.h~x86_64-split-acpi-boot-table-parsing include/linux/acpi.h
--- 25/include/linux/acpi.h~x86_64-split-acpi-boot-table-parsing	Mon Nov 29 11:55:22 2004
+++ 25-akpm/include/linux/acpi.h	Mon Nov 29 11:55:22 2004
@@ -379,6 +379,7 @@ typedef int (*acpi_madt_entry_handler) (
 char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
 unsigned long acpi_find_rsdp (void);
 int acpi_boot_init (void);
+int acpi_boot_table_init (void);
 int acpi_numa_init (void);
 
 int acpi_table_init (void);
@@ -416,6 +417,12 @@ static inline int acpi_boot_init(void)
 {
 	return 0;
 }
+
+
+static inline int acpi_table_init(void)
+{
+	return 0;
+}
 
 #endif 	/*!CONFIG_ACPI_BOOT*/
 
_