aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Starikovskiy <alexey.y.starikovskiy@intel.com>2007-02-02 11:48:22 -0500
committerLen Brown <len.brown@intel.com>2007-02-02 21:14:28 -0500
commitceb6c46839021d5c7c338d48deac616944660124 (patch)
tree191485a16c3a19bccde887f1c8938a7a26020401
parenta7a22fa9c368ba22f13b87585052b8cdbbc18f7a (diff)
ACPICA: Remove duplicate table manager
Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r--arch/i386/kernel/acpi/boot.c40
-rw-r--r--arch/i386/kernel/acpi/earlyquirk.c4
-rw-r--r--arch/i386/mach-es7000/es7000.h9
-rw-r--r--arch/i386/mach-es7000/es7000plat.c53
-rw-r--r--arch/i386/pci/mmconfig.c2
-rw-r--r--drivers/acpi/tables.c396
-rw-r--r--include/linux/acpi.h7
7 files changed, 50 insertions, 461 deletions
diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c
index 9adabc4dba70..543eac5da176 100644
--- a/arch/i386/kernel/acpi/boot.c
+++ b/arch/i386/kernel/acpi/boot.c
@@ -169,16 +169,16 @@ char *__acpi_map_table(unsigned long phys, unsigned long size)
169struct acpi_table_mcfg_config *pci_mmcfg_config; 169struct acpi_table_mcfg_config *pci_mmcfg_config;
170int pci_mmcfg_config_num; 170int pci_mmcfg_config_num;
171 171
172int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size) 172int __init acpi_parse_mcfg(struct acpi_table_header *header)
173{ 173{
174 struct acpi_table_mcfg *mcfg; 174 struct acpi_table_mcfg *mcfg;
175 unsigned long i; 175 unsigned long i;
176 int config_size; 176 int config_size;
177 177
178 if (!phys_addr || !size) 178 if (!header)
179 return -EINVAL; 179 return -EINVAL;
180 180
181 mcfg = (struct acpi_table_mcfg *)__acpi_map_table(phys_addr, size); 181 mcfg = (struct acpi_table_mcfg *)header;
182 if (!mcfg) { 182 if (!mcfg) {
183 printk(KERN_WARNING PREFIX "Unable to map MCFG\n"); 183 printk(KERN_WARNING PREFIX "Unable to map MCFG\n");
184 return -ENODEV; 184 return -ENODEV;
@@ -186,7 +186,7 @@ int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size)
186 186
187 /* how many config structures do we have */ 187 /* how many config structures do we have */
188 pci_mmcfg_config_num = 0; 188 pci_mmcfg_config_num = 0;
189 i = size - sizeof(struct acpi_table_mcfg); 189 i = header->length - sizeof(struct acpi_table_mcfg);
190 while (i >= sizeof(struct acpi_table_mcfg_config)) { 190 while (i >= sizeof(struct acpi_table_mcfg_config)) {
191 ++pci_mmcfg_config_num; 191 ++pci_mmcfg_config_num;
192 i -= sizeof(struct acpi_table_mcfg_config); 192 i -= sizeof(struct acpi_table_mcfg_config);
@@ -220,14 +220,14 @@ int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size)
220#endif /* CONFIG_PCI_MMCONFIG */ 220#endif /* CONFIG_PCI_MMCONFIG */
221 221
222#ifdef CONFIG_X86_LOCAL_APIC 222#ifdef CONFIG_X86_LOCAL_APIC
223static int __init acpi_parse_madt(unsigned long phys_addr, unsigned long size) 223static int __init acpi_parse_madt(struct acpi_table_header *header)
224{ 224{
225 struct acpi_table_madt *madt = NULL; 225 struct acpi_table_madt *madt = NULL;
226 226
227 if (!phys_addr || !size || !cpu_has_apic) 227 if (!header|| !cpu_has_apic)
228 return -EINVAL; 228 return -EINVAL;
229 229
230 madt = (struct acpi_table_madt *)__acpi_map_table(phys_addr, size); 230 madt = (struct acpi_table_madt *)header;
231 if (!madt) { 231 if (!madt) {
232 printk(KERN_WARNING PREFIX "Unable to map MADT\n"); 232 printk(KERN_WARNING PREFIX "Unable to map MADT\n");
233 return -ENODEV; 233 return -ENODEV;
@@ -619,14 +619,14 @@ acpi_scan_rsdp(unsigned long start, unsigned long length)
619 return 0; 619 return 0;
620} 620}
621 621
622static int __init acpi_parse_sbf(unsigned long phys_addr, unsigned long size) 622static int __init acpi_parse_sbf(struct acpi_table_header *header)
623{ 623{
624 struct acpi_table_sbf *sb; 624 struct acpi_table_sbf *sb;
625 625
626 if (!phys_addr || !size) 626 if (!header)
627 return -EINVAL; 627 return -EINVAL;
628 628
629 sb = (struct acpi_table_sbf *)__acpi_map_table(phys_addr, size); 629 sb = (struct acpi_table_sbf *)header;
630 if (!sb) { 630 if (!sb) {
631 printk(KERN_WARNING PREFIX "Unable to map SBF\n"); 631 printk(KERN_WARNING PREFIX "Unable to map SBF\n");
632 return -ENODEV; 632 return -ENODEV;
@@ -639,16 +639,16 @@ static int __init acpi_parse_sbf(unsigned long phys_addr, unsigned long size)
639 639
640#ifdef CONFIG_HPET_TIMER 640#ifdef CONFIG_HPET_TIMER
641 641
642static int __init acpi_parse_hpet(unsigned long phys, unsigned long size) 642static int __init acpi_parse_hpet(struct acpi_table_header *header)
643{ 643{
644 struct acpi_table_hpet *hpet_tbl; 644 struct acpi_table_hpet *hpet_tbl;
645 struct resource *hpet_res; 645 struct resource *hpet_res;
646 resource_size_t res_start; 646 resource_size_t res_start;
647 647
648 if (!phys || !size) 648 if (!header)
649 return -EINVAL; 649 return -EINVAL;
650 650
651 hpet_tbl = (struct acpi_table_hpet *)__acpi_map_table(phys, size); 651 hpet_tbl = (struct acpi_table_hpet *)header;
652 if (!hpet_tbl) { 652 if (!hpet_tbl) {
653 printk(KERN_WARNING PREFIX "Unable to map HPET\n"); 653 printk(KERN_WARNING PREFIX "Unable to map HPET\n");
654 return -ENODEV; 654 return -ENODEV;
@@ -707,11 +707,11 @@ static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
707extern u32 pmtmr_ioport; 707extern u32 pmtmr_ioport;
708#endif 708#endif
709 709
710static int __init acpi_parse_fadt(unsigned long phys, unsigned long size) 710static int __init acpi_parse_fadt(struct acpi_table_header *header)
711{ 711{
712 struct fadt_descriptor *fadt = NULL; 712 struct fadt_descriptor *fadt = NULL;
713 713
714 fadt = (struct fadt_descriptor *)__acpi_map_table(phys, size); 714 fadt = (struct fadt_descriptor *)header;
715 if (!fadt) { 715 if (!fadt) {
716 printk(KERN_WARNING PREFIX "Unable to map FADT\n"); 716 printk(KERN_WARNING PREFIX "Unable to map FADT\n");
717 return 0; 717 return 0;
@@ -901,7 +901,7 @@ static void __init acpi_process_madt(void)
901#ifdef CONFIG_X86_LOCAL_APIC 901#ifdef CONFIG_X86_LOCAL_APIC
902 int count, error; 902 int count, error;
903 903
904 count = acpi_table_parse(ACPI_APIC, acpi_parse_madt); 904 count = acpi_table_parse("APIC", acpi_parse_madt);
905 if (count >= 1) { 905 if (count >= 1) {
906 906
907 /* 907 /*
@@ -1197,7 +1197,7 @@ int __init acpi_boot_table_init(void)
1197 return error; 1197 return error;
1198 } 1198 }
1199 1199
1200 acpi_table_parse(ACPI_BOOT, acpi_parse_sbf); 1200 acpi_table_parse("BOOT", acpi_parse_sbf);
1201 1201
1202 /* 1202 /*
1203 * blacklist may disable ACPI entirely 1203 * blacklist may disable ACPI entirely
@@ -1225,19 +1225,19 @@ int __init acpi_boot_init(void)
1225 if (acpi_disabled && !acpi_ht) 1225 if (acpi_disabled && !acpi_ht)
1226 return 1; 1226 return 1;
1227 1227
1228 acpi_table_parse(ACPI_BOOT, acpi_parse_sbf); 1228 acpi_table_parse("BOOT", acpi_parse_sbf);
1229 1229
1230 /* 1230 /*
1231 * set sci_int and PM timer address 1231 * set sci_int and PM timer address
1232 */ 1232 */
1233 acpi_table_parse(ACPI_FADT, acpi_parse_fadt); 1233 acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt);
1234 1234
1235 /* 1235 /*
1236 * Process the Multiple APIC Description Table (MADT), if present 1236 * Process the Multiple APIC Description Table (MADT), if present
1237 */ 1237 */
1238 acpi_process_madt(); 1238 acpi_process_madt();
1239 1239
1240 acpi_table_parse(ACPI_HPET, acpi_parse_hpet); 1240 acpi_table_parse("HPET", acpi_parse_hpet);
1241 1241
1242 return 0; 1242 return 0;
1243} 1243}
diff --git a/arch/i386/kernel/acpi/earlyquirk.c b/arch/i386/kernel/acpi/earlyquirk.c
index 4b60af7f91dd..4261c8501b7e 100644
--- a/arch/i386/kernel/acpi/earlyquirk.c
+++ b/arch/i386/kernel/acpi/earlyquirk.c
@@ -16,7 +16,7 @@
16 16
17static int nvidia_hpet_detected __initdata; 17static int nvidia_hpet_detected __initdata;
18 18
19static int __init nvidia_hpet_check(unsigned long phys, unsigned long size) 19static int __init nvidia_hpet_check(struct acpi_table_header *header)
20{ 20{
21 nvidia_hpet_detected = 1; 21 nvidia_hpet_detected = 1;
22 return 0; 22 return 0;
@@ -30,7 +30,7 @@ static int __init check_bridge(int vendor, int device)
30 is enabled. */ 30 is enabled. */
31 if (!acpi_use_timer_override && vendor == PCI_VENDOR_ID_NVIDIA) { 31 if (!acpi_use_timer_override && vendor == PCI_VENDOR_ID_NVIDIA) {
32 nvidia_hpet_detected = 0; 32 nvidia_hpet_detected = 0;
33 acpi_table_parse(ACPI_HPET, nvidia_hpet_check); 33 acpi_table_parse("HPET", nvidia_hpet_check);
34 if (nvidia_hpet_detected == 0) { 34 if (nvidia_hpet_detected == 0) {
35 acpi_skip_timer_override = 1; 35 acpi_skip_timer_override = 1;
36 printk(KERN_INFO "Nvidia board " 36 printk(KERN_INFO "Nvidia board "
diff --git a/arch/i386/mach-es7000/es7000.h b/arch/i386/mach-es7000/es7000.h
index 80566ca4a80a..c8d5aa132fa0 100644
--- a/arch/i386/mach-es7000/es7000.h
+++ b/arch/i386/mach-es7000/es7000.h
@@ -84,15 +84,6 @@ struct es7000_oem_table {
84}; 84};
85 85
86#ifdef CONFIG_ACPI 86#ifdef CONFIG_ACPI
87struct acpi_table_sdt {
88 unsigned long pa;
89 unsigned long count;
90 struct {
91 unsigned long pa;
92 enum acpi_table_id id;
93 unsigned long size;
94 } entry[50];
95};
96 87
97struct oem_table { 88struct oem_table {
98 struct acpi_table_header Header; 89 struct acpi_table_header Header;
diff --git a/arch/i386/mach-es7000/es7000plat.c b/arch/i386/mach-es7000/es7000plat.c
index 3d0fc853516d..9be6ceabf042 100644
--- a/arch/i386/mach-es7000/es7000plat.c
+++ b/arch/i386/mach-es7000/es7000plat.c
@@ -160,51 +160,14 @@ parse_unisys_oem (char *oemptr)
160int __init 160int __init
161find_unisys_acpi_oem_table(unsigned long *oem_addr) 161find_unisys_acpi_oem_table(unsigned long *oem_addr)
162{ 162{
163 struct acpi_table_rsdp *rsdp = NULL; 163 struct acpi_table_header *header = NULL;
164 unsigned long rsdp_phys = 0; 164 int i = 0;
165 struct acpi_table_header *header = NULL; 165 while (ACPI_SUCCESS(acpi_get_table("OEM1", i++, &header))) {
166 int i; 166 if (!memcmp((char *) &header->oem_id, "UNISYS", 6)) {
167 struct acpi_table_sdt sdt; 167 struct oem_table *t = (struct oem_table *)header;
168 168 *oem_addr = (unsigned long)__acpi_map_table(t->OEMTableAddr,
169 rsdp_phys = acpi_find_rsdp(); 169 t->OEMTableSize);
170 rsdp = __va(rsdp_phys); 170 return 0;
171 if (rsdp->rsdt_address) {
172 struct acpi_table_rsdt *mapped_rsdt = NULL;
173 sdt.pa = rsdp->rsdt_address;
174
175 header = (struct acpi_table_header *)
176 __acpi_map_table(sdt.pa, sizeof(struct acpi_table_header));
177 if (!header)
178 return -ENODEV;
179
180 sdt.count = (header->length - sizeof(struct acpi_table_header)) >> 3;
181 mapped_rsdt = (struct acpi_table_rsdt *)
182 __acpi_map_table(sdt.pa, header->length);
183 if (!mapped_rsdt)
184 return -ENODEV;
185
186 header = &mapped_rsdt->header;
187
188 for (i = 0; i < sdt.count; i++)
189 sdt.entry[i].pa = (unsigned long) mapped_rsdt->entry[i];
190 };
191 for (i = 0; i < sdt.count; i++) {
192
193 header = (struct acpi_table_header *)
194 __acpi_map_table(sdt.entry[i].pa,
195 sizeof(struct acpi_table_header));
196 if (!header)
197 continue;
198 if (!strncmp((char *) &header->signature, "OEM1", 4)) {
199 if (!strncmp((char *) &header->oem_id, "UNISYS", 6)) {
200 void *addr;
201 struct oem_table *t;
202 acpi_table_print(header, sdt.entry[i].pa);
203 t = (struct oem_table *) __acpi_map_table(sdt.entry[i].pa, header->length);
204 addr = (void *) __acpi_map_table(t->OEMTableAddr, t->OEMTableSize);
205 *oem_addr = (unsigned long) addr;
206 return 0;
207 }
208 } 171 }
209 } 172 }
210 return -1; 173 return -1;
diff --git a/arch/i386/pci/mmconfig.c b/arch/i386/pci/mmconfig.c
index e2616a266e13..80522e331e34 100644
--- a/arch/i386/pci/mmconfig.c
+++ b/arch/i386/pci/mmconfig.c
@@ -199,7 +199,7 @@ void __init pci_mmcfg_init(int type)
199 if ((pci_probe & PCI_PROBE_MMCONF) == 0) 199 if ((pci_probe & PCI_PROBE_MMCONF) == 0)
200 return; 200 return;
201 201
202 acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg); 202 acpi_table_parse("MCFG", acpi_parse_mcfg);
203 if ((pci_mmcfg_config_num == 0) || 203 if ((pci_mmcfg_config_num == 0) ||
204 (pci_mmcfg_config == NULL) || 204 (pci_mmcfg_config == NULL) ||
205 (pci_mmcfg_config[0].base_address == 0)) 205 (pci_mmcfg_config[0].base_address == 0))
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index 5bb143151169..962ff29fbf07 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -38,71 +38,11 @@
38 38
39#define ACPI_MAX_TABLES 128 39#define ACPI_MAX_TABLES 128
40 40
41static char *acpi_table_signatures[ACPI_TABLE_COUNT] = {
42 [ACPI_TABLE_UNKNOWN] = "????",
43 [ACPI_APIC] = "APIC",
44 [ACPI_BOOT] = "BOOT",
45 [ACPI_DBGP] = "DBGP",
46 [ACPI_DSDT] = "DSDT",
47 [ACPI_ECDT] = "ECDT",
48 [ACPI_ETDT] = "ETDT",
49 [ACPI_FADT] = "FACP",
50 [ACPI_FACS] = "FACS",
51 [ACPI_OEMX] = "OEM",
52 [ACPI_PSDT] = "PSDT",
53 [ACPI_SBST] = "SBST",
54 [ACPI_SLIT] = "SLIT",
55 [ACPI_SPCR] = "SPCR",
56 [ACPI_SRAT] = "SRAT",
57 [ACPI_SSDT] = "SSDT",
58 [ACPI_SPMI] = "SPMI",
59 [ACPI_HPET] = "HPET",
60 [ACPI_MCFG] = "MCFG",
61};
62
63static char *mps_inti_flags_polarity[] = { "dfl", "high", "res", "low" }; 41static char *mps_inti_flags_polarity[] = { "dfl", "high", "res", "low" };
64static char *mps_inti_flags_trigger[] = { "dfl", "edge", "res", "level" }; 42static char *mps_inti_flags_trigger[] = { "dfl", "edge", "res", "level" };
65 43
66/* System Description Table (RSDT/XSDT) */
67struct acpi_table_sdt {
68 unsigned long pa;
69 enum acpi_table_id id;
70 unsigned long size;
71} __attribute__ ((packed));
72
73static unsigned long sdt_pa; /* Physical Address */
74static unsigned long sdt_count; /* Table count */
75
76static struct acpi_table_sdt sdt_entry[ACPI_MAX_TABLES] __initdata;
77static struct acpi_table_desc initial_tables[ACPI_MAX_TABLES] __initdata; 44static struct acpi_table_desc initial_tables[ACPI_MAX_TABLES] __initdata;
78 45
79void acpi_table_print(struct acpi_table_header *header, unsigned long phys_addr)
80{
81 char *name = NULL;
82
83 if (!header)
84 return;
85
86 /* Some table signatures aren't good table names */
87
88 if (!strncmp((char *)&header->signature,
89 acpi_table_signatures[ACPI_APIC],
90 sizeof(header->signature))) {
91 name = "MADT";
92 } else if (!strncmp((char *)&header->signature,
93 acpi_table_signatures[ACPI_FADT],
94 sizeof(header->signature))) {
95 name = "FADT";
96 } else
97 name = header->signature;
98
99 printk(KERN_DEBUG PREFIX
100 "%.4s (v%3.3d %6.6s %8.8s 0x%08x %.4s 0x%08x) @ 0x%p\n", name,
101 header->revision, header->oem_id, header->oem_table_id,
102 header->oem_revision, header->asl_compiler_id,
103 header->asl_compiler_revision, (void *)phys_addr);
104}
105
106void acpi_table_print_madt_entry(acpi_table_entry_header * header) 46void acpi_table_print_madt_entry(acpi_table_entry_header * header)
107{ 47{
108 if (!header) 48 if (!header)
@@ -226,123 +166,32 @@ void acpi_table_print_madt_entry(acpi_table_entry_header * header)
226 } 166 }
227} 167}
228 168
229static int
230acpi_table_compute_checksum(void *table_pointer, unsigned long length)
231{
232 u8 *p = table_pointer;
233 unsigned long remains = length;
234 unsigned long sum = 0;
235
236 if (!p || !length)
237 return -EINVAL;
238
239 while (remains--)
240 sum += *p++;
241
242 return (sum & 0xFF);
243}
244
245/*
246 * acpi_get_table_header_early()
247 * for acpi_blacklisted(), acpi_table_get_sdt()
248 */
249int __init
250acpi_get_table_header_early(enum acpi_table_id id,
251 struct acpi_table_header **header)
252{
253 unsigned int i;
254 enum acpi_table_id temp_id;
255
256 /* DSDT is different from the rest */
257 if (id == ACPI_DSDT)
258 temp_id = ACPI_FADT;
259 else
260 temp_id = id;
261
262 /* Locate the table. */
263
264 for (i = 0; i < sdt_count; i++) {
265 if (sdt_entry[i].id != temp_id)
266 continue;
267 *header = (void *)
268 __acpi_map_table(sdt_entry[i].pa, sdt_entry[i].size);
269 if (!*header) {
270 printk(KERN_WARNING PREFIX "Unable to map %s\n",
271 acpi_table_signatures[temp_id]);
272 return -ENODEV;
273 }
274 break;
275 }
276
277 if (!*header) {
278 printk(KERN_WARNING PREFIX "%s not present\n",
279 acpi_table_signatures[id]);
280 return -ENODEV;
281 }
282
283 /* Map the DSDT header via the pointer in the FADT */
284 if (id == ACPI_DSDT) {
285 struct fadt_descriptor *fadt =
286 (struct fadt_descriptor *)*header;
287
288 if (fadt->header.revision == 3 && fadt->Xdsdt) {
289 *header = (void *)__acpi_map_table(fadt->Xdsdt,
290 sizeof(struct
291 acpi_table_header));
292 } else if (fadt->dsdt) {
293 *header = (void *)__acpi_map_table(fadt->dsdt,
294 sizeof(struct
295 acpi_table_header));
296 } else
297 *header = NULL;
298
299 if (!*header) {
300 printk(KERN_WARNING PREFIX "Unable to map DSDT\n");
301 return -ENODEV;
302 }
303 }
304
305 return 0;
306}
307 169
308int __init 170int __init
309acpi_table_parse_madt_family(enum acpi_table_id id, 171acpi_table_parse_madt_family(char *id,
310 unsigned long madt_size, 172 unsigned long madt_size,
311 int entry_id, 173 int entry_id,
312 acpi_madt_entry_handler handler, 174 acpi_madt_entry_handler handler,
313 unsigned int max_entries) 175 unsigned int max_entries)
314{ 176{
315 void *madt = NULL; 177 struct acpi_table_header *madt = NULL;
316 acpi_table_entry_header *entry; 178 acpi_table_entry_header *entry;
317 unsigned int count = 0; 179 unsigned int count = 0;
318 unsigned long madt_end; 180 unsigned long madt_end;
319 unsigned int i;
320 181
321 if (!handler) 182 if (!handler)
322 return -EINVAL; 183 return -EINVAL;
323 184
324 /* Locate the MADT (if exists). There should only be one. */ 185 /* Locate the MADT (if exists). There should only be one. */
325 186
326 for (i = 0; i < sdt_count; i++) { 187 acpi_get_table(id, 0, &madt);
327 if (sdt_entry[i].id != id)
328 continue;
329 madt = (void *)
330 __acpi_map_table(sdt_entry[i].pa, sdt_entry[i].size);
331 if (!madt) {
332 printk(KERN_WARNING PREFIX "Unable to map %s\n",
333 acpi_table_signatures[id]);
334 return -ENODEV;
335 }
336 break;
337 }
338 188
339 if (!madt) { 189 if (!madt) {
340 printk(KERN_WARNING PREFIX "%s not present\n", 190 printk(KERN_WARNING PREFIX "%4.4s not present\n", id);
341 acpi_table_signatures[id]);
342 return -ENODEV; 191 return -ENODEV;
343 } 192 }
344 193
345 madt_end = (unsigned long)madt + sdt_entry[i].size; 194 madt_end = (unsigned long)madt + madt->length;
346 195
347 /* Parse all entries looking for a match. */ 196 /* Parse all entries looking for a match. */
348 197
@@ -360,9 +209,8 @@ acpi_table_parse_madt_family(enum acpi_table_id id,
360 ((unsigned long)entry + entry->length); 209 ((unsigned long)entry + entry->length);
361 } 210 }
362 if (max_entries && count > max_entries) { 211 if (max_entries && count > max_entries) {
363 printk(KERN_WARNING PREFIX "[%s:0x%02x] ignored %i entries of " 212 printk(KERN_WARNING PREFIX "[%4.4s:0x%02x] ignored %i entries of "
364 "%i found\n", acpi_table_signatures[id], entry_id, 213 "%i found\n", id, entry_id, count - max_entries, count);
365 count - max_entries, count);
366 } 214 }
367 215
368 return count; 216 return count;
@@ -372,195 +220,24 @@ int __init
372acpi_table_parse_madt(enum acpi_madt_entry_id id, 220acpi_table_parse_madt(enum acpi_madt_entry_id id,
373 acpi_madt_entry_handler handler, unsigned int max_entries) 221 acpi_madt_entry_handler handler, unsigned int max_entries)
374{ 222{
375 return acpi_table_parse_madt_family(ACPI_APIC, 223 return acpi_table_parse_madt_family("APIC",
376 sizeof(struct acpi_table_madt), id, 224 sizeof(struct acpi_table_madt), id,
377 handler, max_entries); 225 handler, max_entries);
378} 226}
379 227
380int __init acpi_table_parse(enum acpi_table_id id, acpi_table_handler handler) 228int __init acpi_table_parse(char *id, acpi_table_handler handler)
381{ 229{
382 int count = 0; 230 struct acpi_table_header *table = NULL;
383 unsigned int i = 0;
384 231
385 if (!handler) 232 if (!handler)
386 return -EINVAL; 233 return -EINVAL;
387 234
388 for (i = 0; i < sdt_count; i++) { 235 acpi_get_table(id, 0, &table);
389 if (sdt_entry[i].id != id) 236 if (table) {
390 continue; 237 handler(table);
391 count++; 238 return 1;
392 if (count == 1) 239 } else
393 handler(sdt_entry[i].pa, sdt_entry[i].size); 240 return 0;
394
395 else
396 printk(KERN_WARNING PREFIX
397 "%d duplicate %s table ignored.\n", count,
398 acpi_table_signatures[id]);
399 }
400
401 return count;
402}
403
404static int __init acpi_table_get_sdt(struct acpi_table_rsdp *rsdp)
405{
406 struct acpi_table_header *header = NULL;
407 unsigned int i, id = 0;
408
409 if (!rsdp)
410 return -EINVAL;
411
412 /* First check XSDT (but only on ACPI 2.0-compatible systems) */
413
414 if ((rsdp->revision >= 2) && rsdp->xsdt_physical_address) {
415
416 struct acpi_table_xsdt *mapped_xsdt = NULL;
417
418 sdt_pa = rsdp->xsdt_physical_address;
419
420 /* map in just the header */
421 header = (struct acpi_table_header *)
422 __acpi_map_table(sdt_pa, sizeof(struct acpi_table_header));
423
424 if (!header) {
425 printk(KERN_WARNING PREFIX
426 "Unable to map XSDT header\n");
427 return -ENODEV;
428 }
429
430 /* remap in the entire table before processing */
431 mapped_xsdt = (struct acpi_table_xsdt *)
432 __acpi_map_table(sdt_pa, header->length);
433 if (!mapped_xsdt) {
434 printk(KERN_WARNING PREFIX "Unable to map XSDT\n");
435 return -ENODEV;
436 }
437 header = &mapped_xsdt->header;
438
439 if (strncmp(header->signature, "XSDT", 4)) {
440 printk(KERN_WARNING PREFIX
441 "XSDT signature incorrect\n");
442 return -ENODEV;
443 }
444
445 if (acpi_table_compute_checksum(header, header->length)) {
446 printk(KERN_WARNING PREFIX "Invalid XSDT checksum\n");
447 return -ENODEV;
448 }
449
450 sdt_count =
451 (header->length - sizeof(struct acpi_table_header)) >> 3;
452 if (sdt_count > ACPI_MAX_TABLES) {
453 printk(KERN_WARNING PREFIX
454 "Truncated %lu XSDT entries\n",
455 (sdt_count - ACPI_MAX_TABLES));
456 sdt_count = ACPI_MAX_TABLES;
457 }
458
459 for (i = 0; i < sdt_count; i++)
460 sdt_entry[i].pa = (unsigned long)mapped_xsdt->table_offset_entry[i];
461 }
462
463 /* Then check RSDT */
464
465 else if (rsdp->rsdt_physical_address) {
466
467 struct acpi_table_rsdt *mapped_rsdt = NULL;
468
469 sdt_pa = rsdp->rsdt_physical_address;
470
471 /* map in just the header */
472 header = (struct acpi_table_header *)
473 __acpi_map_table(sdt_pa, sizeof(struct acpi_table_header));
474 if (!header) {
475 printk(KERN_WARNING PREFIX
476 "Unable to map RSDT header\n");
477 return -ENODEV;
478 }
479
480 /* remap in the entire table before processing */
481 mapped_rsdt = (struct acpi_table_rsdt *)
482 __acpi_map_table(sdt_pa, header->length);
483 if (!mapped_rsdt) {
484 printk(KERN_WARNING PREFIX "Unable to map RSDT\n");
485 return -ENODEV;
486 }
487 header = &mapped_rsdt->header;
488
489 if (strncmp(header->signature, "RSDT", 4)) {
490 printk(KERN_WARNING PREFIX
491 "RSDT signature incorrect\n");
492 return -ENODEV;
493 }
494
495 if (acpi_table_compute_checksum(header, header->length)) {
496 printk(KERN_WARNING PREFIX "Invalid RSDT checksum\n");
497 return -ENODEV;
498 }
499
500 sdt_count =
501 (header->length - sizeof(struct acpi_table_header)) >> 2;
502 if (sdt_count > ACPI_MAX_TABLES) {
503 printk(KERN_WARNING PREFIX
504 "Truncated %lu RSDT entries\n",
505 (sdt_count - ACPI_MAX_TABLES));
506 sdt_count = ACPI_MAX_TABLES;
507 }
508
509 for (i = 0; i < sdt_count; i++)
510 sdt_entry[i].pa = (unsigned long)mapped_rsdt->table_offset_entry[i];
511 }
512
513 else {
514 printk(KERN_WARNING PREFIX
515 "No System Description Table (RSDT/XSDT) specified in RSDP\n");
516 return -ENODEV;
517 }
518
519 acpi_table_print(header, sdt_pa);
520
521 for (i = 0; i < sdt_count; i++) {
522
523 /* map in just the header */
524 header = (struct acpi_table_header *)
525 __acpi_map_table(sdt_entry[i].pa,
526 sizeof(struct acpi_table_header));
527 if (!header)
528 continue;
529
530 /* remap in the entire table before processing */
531 header = (struct acpi_table_header *)
532 __acpi_map_table(sdt_entry[i].pa, header->length);
533 if (!header)
534 continue;
535
536 acpi_table_print(header, sdt_entry[i].pa);
537
538 if (acpi_table_compute_checksum(header, header->length)) {
539 printk(KERN_WARNING " >>> ERROR: Invalid checksum\n");
540 continue;
541 }
542
543 sdt_entry[i].size = header->length;
544
545 for (id = 0; id < ACPI_TABLE_COUNT; id++) {
546 if (!strncmp((char *)&header->signature,
547 acpi_table_signatures[id],
548 sizeof(header->signature))) {
549 sdt_entry[i].id = id;
550 }
551 }
552 }
553
554 /*
555 * The DSDT is *not* in the RSDT (why not? no idea.) but we want
556 * to print its info, because this is what people usually blacklist
557 * against. Unfortunately, we don't know the phys_addr, so just
558 * print 0. Maybe no one will notice.
559 */
560 if (!acpi_get_table_header_early(ACPI_DSDT, &header))
561 acpi_table_print(header, 0);
562
563 return 0;
564} 241}
565 242
566/* 243/*
@@ -574,47 +251,6 @@ static int __init acpi_table_get_sdt(struct acpi_table_rsdp *rsdp)
574 251
575int __init acpi_table_init(void) 252int __init acpi_table_init(void)
576{ 253{
577 struct acpi_table_rsdp *rsdp = NULL;
578 unsigned long rsdp_phys = 0;
579 int result = 0;
580
581 /* Locate and map the Root System Description Table (RSDP) */
582
583 rsdp_phys = acpi_find_rsdp();
584 if (!rsdp_phys) {
585 printk(KERN_ERR PREFIX "Unable to locate RSDP\n");
586 return -ENODEV;
587 }
588
589 rsdp = (struct acpi_table_rsdp *)__acpi_map_table(rsdp_phys,
590 sizeof(struct acpi_table_rsdp));
591 if (!rsdp) {
592 printk(KERN_WARNING PREFIX "Unable to map RSDP\n");
593 return -ENODEV;
594 }
595
596 printk(KERN_DEBUG PREFIX
597 "RSDP (v%3.3d %6.6s ) @ 0x%p\n",
598 rsdp->revision, rsdp->oem_id, (void *)rsdp_phys);
599
600 if (rsdp->revision < 2)
601 result =
602 acpi_table_compute_checksum(rsdp, ACPI_RSDP_REV0_SIZE);
603 else
604 result =
605 acpi_table_compute_checksum(rsdp, rsdp->length);
606
607 if (result) {
608 printk(KERN_WARNING " >>> ERROR: Invalid checksum\n");
609 return -ENODEV;
610 }
611
612 /* Locate and map the System Description table (RSDT/XSDT) */
613
614 if (acpi_table_get_sdt(rsdp))
615 return -ENODEV;
616
617 acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0); 254 acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0);
618
619 return 0; 255 return 0;
620} 256}
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index b3e8a268f6d6..88cb1fe22b48 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -340,7 +340,7 @@ enum acpi_table_id {
340 ACPI_TABLE_COUNT 340 ACPI_TABLE_COUNT
341}; 341};
342 342
343typedef int (*acpi_table_handler) (unsigned long phys_addr, unsigned long size); 343typedef int (*acpi_table_handler) (struct acpi_table_header *header);
344 344
345extern acpi_table_handler acpi_table_ops[ACPI_TABLE_COUNT]; 345extern acpi_table_handler acpi_table_ops[ACPI_TABLE_COUNT];
346 346
@@ -353,11 +353,10 @@ int acpi_boot_table_init (void);
353int acpi_numa_init (void); 353int acpi_numa_init (void);
354 354
355int acpi_table_init (void); 355int acpi_table_init (void);
356int acpi_table_parse (enum acpi_table_id id, acpi_table_handler handler); 356int acpi_table_parse (char *id, acpi_table_handler handler);
357int acpi_get_table_header_early (enum acpi_table_id id, struct acpi_table_header **header);
358int acpi_table_parse_madt (enum acpi_madt_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries); 357int acpi_table_parse_madt (enum acpi_madt_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries);
359int acpi_table_parse_srat (enum acpi_srat_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries); 358int acpi_table_parse_srat (enum acpi_srat_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries);
360int acpi_parse_mcfg (unsigned long phys_addr, unsigned long size); 359int acpi_parse_mcfg (struct acpi_table_header *header);
361void acpi_table_print (struct acpi_table_header *header, unsigned long phys_addr); 360void acpi_table_print (struct acpi_table_header *header, unsigned long phys_addr);
362void acpi_table_print_madt_entry (acpi_table_entry_header *madt); 361void acpi_table_print_madt_entry (acpi_table_entry_header *madt);
363void acpi_table_print_srat_entry (acpi_table_entry_header *srat); 362void acpi_table_print_srat_entry (acpi_table_entry_header *srat);