aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ia64/kernel/acpi.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/ia64/kernel/acpi.c')
-rw-r--r--arch/ia64/kernel/acpi.c324
1 files changed, 167 insertions, 157 deletions
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index d362ecf5381b..f3046bdd4b14 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -74,12 +74,11 @@ unsigned int acpi_cpei_override;
74unsigned int acpi_cpei_phys_cpuid; 74unsigned int acpi_cpei_phys_cpuid;
75 75
76#define MAX_SAPICS 256 76#define MAX_SAPICS 256
77u16 ia64_acpiid_to_sapicid[MAX_SAPICS] = 77u16 ia64_acpiid_to_sapicid[MAX_SAPICS] = {[0...MAX_SAPICS - 1] = -1 };
78 { [0 ... MAX_SAPICS - 1] = -1 }; 78
79EXPORT_SYMBOL(ia64_acpiid_to_sapicid); 79EXPORT_SYMBOL(ia64_acpiid_to_sapicid);
80 80
81const char * 81const char *acpi_get_sysname(void)
82acpi_get_sysname (void)
83{ 82{
84#ifdef CONFIG_IA64_GENERIC 83#ifdef CONFIG_IA64_GENERIC
85 unsigned long rsdp_phys; 84 unsigned long rsdp_phys;
@@ -89,27 +88,29 @@ acpi_get_sysname (void)
89 88
90 rsdp_phys = acpi_find_rsdp(); 89 rsdp_phys = acpi_find_rsdp();
91 if (!rsdp_phys) { 90 if (!rsdp_phys) {
92 printk(KERN_ERR "ACPI 2.0 RSDP not found, default to \"dig\"\n"); 91 printk(KERN_ERR
92 "ACPI 2.0 RSDP not found, default to \"dig\"\n");
93 return "dig"; 93 return "dig";
94 } 94 }
95 95
96 rsdp = (struct acpi20_table_rsdp *) __va(rsdp_phys); 96 rsdp = (struct acpi20_table_rsdp *)__va(rsdp_phys);
97 if (strncmp(rsdp->signature, RSDP_SIG, sizeof(RSDP_SIG) - 1)) { 97 if (strncmp(rsdp->signature, RSDP_SIG, sizeof(RSDP_SIG) - 1)) {
98 printk(KERN_ERR "ACPI 2.0 RSDP signature incorrect, default to \"dig\"\n"); 98 printk(KERN_ERR
99 "ACPI 2.0 RSDP signature incorrect, default to \"dig\"\n");
99 return "dig"; 100 return "dig";
100 } 101 }
101 102
102 xsdt = (struct acpi_table_xsdt *) __va(rsdp->xsdt_address); 103 xsdt = (struct acpi_table_xsdt *)__va(rsdp->xsdt_address);
103 hdr = &xsdt->header; 104 hdr = &xsdt->header;
104 if (strncmp(hdr->signature, XSDT_SIG, sizeof(XSDT_SIG) - 1)) { 105 if (strncmp(hdr->signature, XSDT_SIG, sizeof(XSDT_SIG) - 1)) {
105 printk(KERN_ERR "ACPI 2.0 XSDT signature incorrect, default to \"dig\"\n"); 106 printk(KERN_ERR
107 "ACPI 2.0 XSDT signature incorrect, default to \"dig\"\n");
106 return "dig"; 108 return "dig";
107 } 109 }
108 110
109 if (!strcmp(hdr->oem_id, "HP")) { 111 if (!strcmp(hdr->oem_id, "HP")) {
110 return "hpzx1"; 112 return "hpzx1";
111 } 113 } else if (!strcmp(hdr->oem_id, "SGI")) {
112 else if (!strcmp(hdr->oem_id, "SGI")) {
113 return "sn2"; 114 return "sn2";
114 } 115 }
115 116
@@ -137,7 +138,7 @@ acpi_get_sysname (void)
137 138
138/* Array to record platform interrupt vectors for generic interrupt routing. */ 139/* Array to record platform interrupt vectors for generic interrupt routing. */
139int platform_intr_list[ACPI_MAX_PLATFORM_INTERRUPTS] = { 140int platform_intr_list[ACPI_MAX_PLATFORM_INTERRUPTS] = {
140 [0 ... ACPI_MAX_PLATFORM_INTERRUPTS - 1] = -1 141 [0...ACPI_MAX_PLATFORM_INTERRUPTS - 1] = -1
141}; 142};
142 143
143enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_IOSAPIC; 144enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_IOSAPIC;
@@ -146,8 +147,7 @@ enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_IOSAPIC;
146 * Interrupt routing API for device drivers. Provides interrupt vector for 147 * Interrupt routing API for device drivers. Provides interrupt vector for
147 * a generic platform event. Currently only CPEI is implemented. 148 * a generic platform event. Currently only CPEI is implemented.
148 */ 149 */
149int 150int acpi_request_vector(u32 int_type)
150acpi_request_vector (u32 int_type)
151{ 151{
152 int vector = -1; 152 int vector = -1;
153 153
@@ -155,12 +155,12 @@ acpi_request_vector (u32 int_type)
155 /* corrected platform error interrupt */ 155 /* corrected platform error interrupt */
156 vector = platform_intr_list[int_type]; 156 vector = platform_intr_list[int_type];
157 } else 157 } else
158 printk(KERN_ERR "acpi_request_vector(): invalid interrupt type\n"); 158 printk(KERN_ERR
159 "acpi_request_vector(): invalid interrupt type\n");
159 return vector; 160 return vector;
160} 161}
161 162
162char * 163char *__acpi_map_table(unsigned long phys_addr, unsigned long size)
163__acpi_map_table (unsigned long phys_addr, unsigned long size)
164{ 164{
165 return __va(phys_addr); 165 return __va(phys_addr);
166} 166}
@@ -169,19 +169,18 @@ __acpi_map_table (unsigned long phys_addr, unsigned long size)
169 Boot-time Table Parsing 169 Boot-time Table Parsing
170 -------------------------------------------------------------------------- */ 170 -------------------------------------------------------------------------- */
171 171
172static int total_cpus __initdata; 172static int total_cpus __initdata;
173static int available_cpus __initdata; 173static int available_cpus __initdata;
174struct acpi_table_madt * acpi_madt __initdata; 174struct acpi_table_madt *acpi_madt __initdata;
175static u8 has_8259; 175static u8 has_8259;
176
177 176
178static int __init 177static int __init
179acpi_parse_lapic_addr_ovr ( 178acpi_parse_lapic_addr_ovr(acpi_table_entry_header * header,
180 acpi_table_entry_header *header, const unsigned long end) 179 const unsigned long end)
181{ 180{
182 struct acpi_table_lapic_addr_ovr *lapic; 181 struct acpi_table_lapic_addr_ovr *lapic;
183 182
184 lapic = (struct acpi_table_lapic_addr_ovr *) header; 183 lapic = (struct acpi_table_lapic_addr_ovr *)header;
185 184
186 if (BAD_MADT_ENTRY(lapic, end)) 185 if (BAD_MADT_ENTRY(lapic, end))
187 return -EINVAL; 186 return -EINVAL;
@@ -193,22 +192,23 @@ acpi_parse_lapic_addr_ovr (
193 return 0; 192 return 0;
194} 193}
195 194
196
197static int __init 195static int __init
198acpi_parse_lsapic (acpi_table_entry_header *header, const unsigned long end) 196acpi_parse_lsapic(acpi_table_entry_header * header, const unsigned long end)
199{ 197{
200 struct acpi_table_lsapic *lsapic; 198 struct acpi_table_lsapic *lsapic;
201 199
202 lsapic = (struct acpi_table_lsapic *) header; 200 lsapic = (struct acpi_table_lsapic *)header;
203 201
204 if (BAD_MADT_ENTRY(lsapic, end)) 202 if (BAD_MADT_ENTRY(lsapic, end))
205 return -EINVAL; 203 return -EINVAL;
206 204
207 if (lsapic->flags.enabled) { 205 if (lsapic->flags.enabled) {
208#ifdef CONFIG_SMP 206#ifdef CONFIG_SMP
209 smp_boot_data.cpu_phys_id[available_cpus] = (lsapic->id << 8) | lsapic->eid; 207 smp_boot_data.cpu_phys_id[available_cpus] =
208 (lsapic->id << 8) | lsapic->eid;
210#endif 209#endif
211 ia64_acpiid_to_sapicid[lsapic->acpi_id] = (lsapic->id << 8) | lsapic->eid; 210 ia64_acpiid_to_sapicid[lsapic->acpi_id] =
211 (lsapic->id << 8) | lsapic->eid;
212 ++available_cpus; 212 ++available_cpus;
213 } 213 }
214 214
@@ -216,13 +216,12 @@ acpi_parse_lsapic (acpi_table_entry_header *header, const unsigned long end)
216 return 0; 216 return 0;
217} 217}
218 218
219
220static int __init 219static int __init
221acpi_parse_lapic_nmi (acpi_table_entry_header *header, const unsigned long end) 220acpi_parse_lapic_nmi(acpi_table_entry_header * header, const unsigned long end)
222{ 221{
223 struct acpi_table_lapic_nmi *lacpi_nmi; 222 struct acpi_table_lapic_nmi *lacpi_nmi;
224 223
225 lacpi_nmi = (struct acpi_table_lapic_nmi*) header; 224 lacpi_nmi = (struct acpi_table_lapic_nmi *)header;
226 225
227 if (BAD_MADT_ENTRY(lacpi_nmi, end)) 226 if (BAD_MADT_ENTRY(lacpi_nmi, end))
228 return -EINVAL; 227 return -EINVAL;
@@ -231,13 +230,12 @@ acpi_parse_lapic_nmi (acpi_table_entry_header *header, const unsigned long end)
231 return 0; 230 return 0;
232} 231}
233 232
234
235static int __init 233static int __init
236acpi_parse_iosapic (acpi_table_entry_header *header, const unsigned long end) 234acpi_parse_iosapic(acpi_table_entry_header * header, const unsigned long end)
237{ 235{
238 struct acpi_table_iosapic *iosapic; 236 struct acpi_table_iosapic *iosapic;
239 237
240 iosapic = (struct acpi_table_iosapic *) header; 238 iosapic = (struct acpi_table_iosapic *)header;
241 239
242 if (BAD_MADT_ENTRY(iosapic, end)) 240 if (BAD_MADT_ENTRY(iosapic, end))
243 return -EINVAL; 241 return -EINVAL;
@@ -245,15 +243,14 @@ acpi_parse_iosapic (acpi_table_entry_header *header, const unsigned long end)
245 return iosapic_init(iosapic->address, iosapic->global_irq_base); 243 return iosapic_init(iosapic->address, iosapic->global_irq_base);
246} 244}
247 245
248
249static int __init 246static int __init
250acpi_parse_plat_int_src ( 247acpi_parse_plat_int_src(acpi_table_entry_header * header,
251 acpi_table_entry_header *header, const unsigned long end) 248 const unsigned long end)
252{ 249{
253 struct acpi_table_plat_int_src *plintsrc; 250 struct acpi_table_plat_int_src *plintsrc;
254 int vector; 251 int vector;
255 252
256 plintsrc = (struct acpi_table_plat_int_src *) header; 253 plintsrc = (struct acpi_table_plat_int_src *)header;
257 254
258 if (BAD_MADT_ENTRY(plintsrc, end)) 255 if (BAD_MADT_ENTRY(plintsrc, end))
259 return -EINVAL; 256 return -EINVAL;
@@ -267,8 +264,12 @@ acpi_parse_plat_int_src (
267 plintsrc->iosapic_vector, 264 plintsrc->iosapic_vector,
268 plintsrc->eid, 265 plintsrc->eid,
269 plintsrc->id, 266 plintsrc->id,
270 (plintsrc->flags.polarity == 1) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW, 267 (plintsrc->flags.polarity ==
271 (plintsrc->flags.trigger == 1) ? IOSAPIC_EDGE : IOSAPIC_LEVEL); 268 1) ? IOSAPIC_POL_HIGH :
269 IOSAPIC_POL_LOW,
270 (plintsrc->flags.trigger ==
271 1) ? IOSAPIC_EDGE :
272 IOSAPIC_LEVEL);
272 273
273 platform_intr_list[plintsrc->type] = vector; 274 platform_intr_list[plintsrc->type] = vector;
274 if (acpi_madt_rev > 1) { 275 if (acpi_madt_rev > 1) {
@@ -283,7 +284,6 @@ acpi_parse_plat_int_src (
283 return 0; 284 return 0;
284} 285}
285 286
286
287unsigned int can_cpei_retarget(void) 287unsigned int can_cpei_retarget(void)
288{ 288{
289 extern int cpe_vector; 289 extern int cpe_vector;
@@ -322,29 +322,30 @@ unsigned int get_cpei_target_cpu(void)
322} 322}
323 323
324static int __init 324static int __init
325acpi_parse_int_src_ovr ( 325acpi_parse_int_src_ovr(acpi_table_entry_header * header,
326 acpi_table_entry_header *header, const unsigned long end) 326 const unsigned long end)
327{ 327{
328 struct acpi_table_int_src_ovr *p; 328 struct acpi_table_int_src_ovr *p;
329 329
330 p = (struct acpi_table_int_src_ovr *) header; 330 p = (struct acpi_table_int_src_ovr *)header;
331 331
332 if (BAD_MADT_ENTRY(p, end)) 332 if (BAD_MADT_ENTRY(p, end))
333 return -EINVAL; 333 return -EINVAL;
334 334
335 iosapic_override_isa_irq(p->bus_irq, p->global_irq, 335 iosapic_override_isa_irq(p->bus_irq, p->global_irq,
336 (p->flags.polarity == 1) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW, 336 (p->flags.polarity ==
337 (p->flags.trigger == 1) ? IOSAPIC_EDGE : IOSAPIC_LEVEL); 337 1) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW,
338 (p->flags.trigger ==
339 1) ? IOSAPIC_EDGE : IOSAPIC_LEVEL);
338 return 0; 340 return 0;
339} 341}
340 342
341
342static int __init 343static int __init
343acpi_parse_nmi_src (acpi_table_entry_header *header, const unsigned long end) 344acpi_parse_nmi_src(acpi_table_entry_header * header, const unsigned long end)
344{ 345{
345 struct acpi_table_nmi_src *nmi_src; 346 struct acpi_table_nmi_src *nmi_src;
346 347
347 nmi_src = (struct acpi_table_nmi_src*) header; 348 nmi_src = (struct acpi_table_nmi_src *)header;
348 349
349 if (BAD_MADT_ENTRY(nmi_src, end)) 350 if (BAD_MADT_ENTRY(nmi_src, end))
350 return -EINVAL; 351 return -EINVAL;
@@ -353,11 +354,9 @@ acpi_parse_nmi_src (acpi_table_entry_header *header, const unsigned long end)
353 return 0; 354 return 0;
354} 355}
355 356
356static void __init 357static void __init acpi_madt_oem_check(char *oem_id, char *oem_table_id)
357acpi_madt_oem_check (char *oem_id, char *oem_table_id)
358{ 358{
359 if (!strncmp(oem_id, "IBM", 3) && 359 if (!strncmp(oem_id, "IBM", 3) && (!strncmp(oem_table_id, "SERMOW", 6))) {
360 (!strncmp(oem_table_id, "SERMOW", 6))) {
361 360
362 /* 361 /*
363 * Unfortunately ITC_DRIFT is not yet part of the 362 * Unfortunately ITC_DRIFT is not yet part of the
@@ -370,19 +369,18 @@ acpi_madt_oem_check (char *oem_id, char *oem_table_id)
370 } 369 }
371} 370}
372 371
373static int __init 372static int __init acpi_parse_madt(unsigned long phys_addr, unsigned long size)
374acpi_parse_madt (unsigned long phys_addr, unsigned long size)
375{ 373{
376 if (!phys_addr || !size) 374 if (!phys_addr || !size)
377 return -EINVAL; 375 return -EINVAL;
378 376
379 acpi_madt = (struct acpi_table_madt *) __va(phys_addr); 377 acpi_madt = (struct acpi_table_madt *)__va(phys_addr);
380 378
381 acpi_madt_rev = acpi_madt->header.revision; 379 acpi_madt_rev = acpi_madt->header.revision;
382 380
383 /* remember the value for reference after free_initmem() */ 381 /* remember the value for reference after free_initmem() */
384#ifdef CONFIG_ITANIUM 382#ifdef CONFIG_ITANIUM
385 has_8259 = 1; /* Firmware on old Itanium systems is broken */ 383 has_8259 = 1; /* Firmware on old Itanium systems is broken */
386#else 384#else
387 has_8259 = acpi_madt->flags.pcat_compat; 385 has_8259 = acpi_madt->flags.pcat_compat;
388#endif 386#endif
@@ -396,19 +394,18 @@ acpi_parse_madt (unsigned long phys_addr, unsigned long size)
396 printk(KERN_INFO PREFIX "Local APIC address %p\n", ipi_base_addr); 394 printk(KERN_INFO PREFIX "Local APIC address %p\n", ipi_base_addr);
397 395
398 acpi_madt_oem_check(acpi_madt->header.oem_id, 396 acpi_madt_oem_check(acpi_madt->header.oem_id,
399 acpi_madt->header.oem_table_id); 397 acpi_madt->header.oem_table_id);
400 398
401 return 0; 399 return 0;
402} 400}
403 401
404
405#ifdef CONFIG_ACPI_NUMA 402#ifdef CONFIG_ACPI_NUMA
406 403
407#undef SLIT_DEBUG 404#undef SLIT_DEBUG
408 405
409#define PXM_FLAG_LEN ((MAX_PXM_DOMAINS + 1)/32) 406#define PXM_FLAG_LEN ((MAX_PXM_DOMAINS + 1)/32)
410 407
411static int __initdata srat_num_cpus; /* number of cpus */ 408static int __initdata srat_num_cpus; /* number of cpus */
412static u32 __devinitdata pxm_flag[PXM_FLAG_LEN]; 409static u32 __devinitdata pxm_flag[PXM_FLAG_LEN];
413#define pxm_bit_set(bit) (set_bit(bit,(void *)pxm_flag)) 410#define pxm_bit_set(bit) (set_bit(bit,(void *)pxm_flag))
414#define pxm_bit_test(bit) (test_bit(bit,(void *)pxm_flag)) 411#define pxm_bit_test(bit) (test_bit(bit,(void *)pxm_flag))
@@ -421,15 +418,15 @@ static struct acpi_table_slit __initdata *slit_table;
421 * ACPI 2.0 SLIT (System Locality Information Table) 418 * ACPI 2.0 SLIT (System Locality Information Table)
422 * http://devresource.hp.com/devresource/Docs/TechPapers/IA64/slit.pdf 419 * http://devresource.hp.com/devresource/Docs/TechPapers/IA64/slit.pdf
423 */ 420 */
424void __init 421void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
425acpi_numa_slit_init (struct acpi_table_slit *slit)
426{ 422{
427 u32 len; 423 u32 len;
428 424
429 len = sizeof(struct acpi_table_header) + 8 425 len = sizeof(struct acpi_table_header) + 8
430 + slit->localities * slit->localities; 426 + slit->localities * slit->localities;
431 if (slit->header.length != len) { 427 if (slit->header.length != len) {
432 printk(KERN_ERR "ACPI 2.0 SLIT: size mismatch: %d expected, %d actual\n", 428 printk(KERN_ERR
429 "ACPI 2.0 SLIT: size mismatch: %d expected, %d actual\n",
433 len, slit->header.length); 430 len, slit->header.length);
434 memset(numa_slit, 10, sizeof(numa_slit)); 431 memset(numa_slit, 10, sizeof(numa_slit));
435 return; 432 return;
@@ -438,19 +435,20 @@ acpi_numa_slit_init (struct acpi_table_slit *slit)
438} 435}
439 436
440void __init 437void __init
441acpi_numa_processor_affinity_init (struct acpi_table_processor_affinity *pa) 438acpi_numa_processor_affinity_init(struct acpi_table_processor_affinity *pa)
442{ 439{
443 /* record this node in proximity bitmap */ 440 /* record this node in proximity bitmap */
444 pxm_bit_set(pa->proximity_domain); 441 pxm_bit_set(pa->proximity_domain);
445 442
446 node_cpuid[srat_num_cpus].phys_id = (pa->apic_id << 8) | (pa->lsapic_eid); 443 node_cpuid[srat_num_cpus].phys_id =
444 (pa->apic_id << 8) | (pa->lsapic_eid);
447 /* nid should be overridden as logical node id later */ 445 /* nid should be overridden as logical node id later */
448 node_cpuid[srat_num_cpus].nid = pa->proximity_domain; 446 node_cpuid[srat_num_cpus].nid = pa->proximity_domain;
449 srat_num_cpus++; 447 srat_num_cpus++;
450} 448}
451 449
452void __init 450void __init
453acpi_numa_memory_affinity_init (struct acpi_table_memory_affinity *ma) 451acpi_numa_memory_affinity_init(struct acpi_table_memory_affinity *ma)
454{ 452{
455 unsigned long paddr, size; 453 unsigned long paddr, size;
456 u8 pxm; 454 u8 pxm;
@@ -487,8 +485,7 @@ acpi_numa_memory_affinity_init (struct acpi_table_memory_affinity *ma)
487 num_node_memblks++; 485 num_node_memblks++;
488} 486}
489 487
490void __init 488void __init acpi_numa_arch_fixup(void)
491acpi_numa_arch_fixup (void)
492{ 489{
493 int i, j, node_from, node_to; 490 int i, j, node_from, node_to;
494 491
@@ -534,21 +531,24 @@ acpi_numa_arch_fixup (void)
534 for (i = 0; i < srat_num_cpus; i++) 531 for (i = 0; i < srat_num_cpus; i++)
535 node_cpuid[i].nid = pxm_to_nid_map[node_cpuid[i].nid]; 532 node_cpuid[i].nid = pxm_to_nid_map[node_cpuid[i].nid];
536 533
537 printk(KERN_INFO "Number of logical nodes in system = %d\n", num_online_nodes()); 534 printk(KERN_INFO "Number of logical nodes in system = %d\n",
538 printk(KERN_INFO "Number of memory chunks in system = %d\n", num_node_memblks); 535 num_online_nodes());
536 printk(KERN_INFO "Number of memory chunks in system = %d\n",
537 num_node_memblks);
539 538
540 if (!slit_table) return; 539 if (!slit_table)
540 return;
541 memset(numa_slit, -1, sizeof(numa_slit)); 541 memset(numa_slit, -1, sizeof(numa_slit));
542 for (i=0; i<slit_table->localities; i++) { 542 for (i = 0; i < slit_table->localities; i++) {
543 if (!pxm_bit_test(i)) 543 if (!pxm_bit_test(i))
544 continue; 544 continue;
545 node_from = pxm_to_nid_map[i]; 545 node_from = pxm_to_nid_map[i];
546 for (j=0; j<slit_table->localities; j++) { 546 for (j = 0; j < slit_table->localities; j++) {
547 if (!pxm_bit_test(j)) 547 if (!pxm_bit_test(j))
548 continue; 548 continue;
549 node_to = pxm_to_nid_map[j]; 549 node_to = pxm_to_nid_map[j];
550 node_distance(node_from, node_to) = 550 node_distance(node_from, node_to) =
551 slit_table->entry[i*slit_table->localities + j]; 551 slit_table->entry[i * slit_table->localities + j];
552 } 552 }
553 } 553 }
554 554
@@ -556,40 +556,43 @@ acpi_numa_arch_fixup (void)
556 printk("ACPI 2.0 SLIT locality table:\n"); 556 printk("ACPI 2.0 SLIT locality table:\n");
557 for_each_online_node(i) { 557 for_each_online_node(i) {
558 for_each_online_node(j) 558 for_each_online_node(j)
559 printk("%03d ", node_distance(i,j)); 559 printk("%03d ", node_distance(i, j));
560 printk("\n"); 560 printk("\n");
561 } 561 }
562#endif 562#endif
563} 563}
564#endif /* CONFIG_ACPI_NUMA */ 564#endif /* CONFIG_ACPI_NUMA */
565 565
566/* 566/*
567 * success: return IRQ number (>=0) 567 * success: return IRQ number (>=0)
568 * failure: return < 0 568 * failure: return < 0
569 */ 569 */
570int 570int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low)
571acpi_register_gsi (u32 gsi, int edge_level, int active_high_low)
572{ 571{
573 if (has_8259 && gsi < 16) 572 if (has_8259 && gsi < 16)
574 return isa_irq_to_vector(gsi); 573 return isa_irq_to_vector(gsi);
575 574
576 return iosapic_register_intr(gsi, 575 return iosapic_register_intr(gsi,
577 (active_high_low == ACPI_ACTIVE_HIGH) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW, 576 (active_high_low ==
578 (edge_level == ACPI_EDGE_SENSITIVE) ? IOSAPIC_EDGE : IOSAPIC_LEVEL); 577 ACPI_ACTIVE_HIGH) ? IOSAPIC_POL_HIGH :
578 IOSAPIC_POL_LOW,
579 (edge_level ==
580 ACPI_EDGE_SENSITIVE) ? IOSAPIC_EDGE :
581 IOSAPIC_LEVEL);
579} 582}
583
580EXPORT_SYMBOL(acpi_register_gsi); 584EXPORT_SYMBOL(acpi_register_gsi);
581 585
582#ifdef CONFIG_ACPI_DEALLOCATE_IRQ 586#ifdef CONFIG_ACPI_DEALLOCATE_IRQ
583void 587void acpi_unregister_gsi(u32 gsi)
584acpi_unregister_gsi (u32 gsi)
585{ 588{
586 iosapic_unregister_intr(gsi); 589 iosapic_unregister_intr(gsi);
587} 590}
591
588EXPORT_SYMBOL(acpi_unregister_gsi); 592EXPORT_SYMBOL(acpi_unregister_gsi);
589#endif /* CONFIG_ACPI_DEALLOCATE_IRQ */ 593#endif /* CONFIG_ACPI_DEALLOCATE_IRQ */
590 594
591static int __init 595static int __init acpi_parse_fadt(unsigned long phys_addr, unsigned long size)
592acpi_parse_fadt (unsigned long phys_addr, unsigned long size)
593{ 596{
594 struct acpi_table_header *fadt_header; 597 struct acpi_table_header *fadt_header;
595 struct fadt_descriptor_rev2 *fadt; 598 struct fadt_descriptor_rev2 *fadt;
@@ -597,11 +600,11 @@ acpi_parse_fadt (unsigned long phys_addr, unsigned long size)
597 if (!phys_addr || !size) 600 if (!phys_addr || !size)
598 return -EINVAL; 601 return -EINVAL;
599 602
600 fadt_header = (struct acpi_table_header *) __va(phys_addr); 603 fadt_header = (struct acpi_table_header *)__va(phys_addr);
601 if (fadt_header->revision != 3) 604 if (fadt_header->revision != 3)
602 return -ENODEV; /* Only deal with ACPI 2.0 FADT */ 605 return -ENODEV; /* Only deal with ACPI 2.0 FADT */
603 606
604 fadt = (struct fadt_descriptor_rev2 *) fadt_header; 607 fadt = (struct fadt_descriptor_rev2 *)fadt_header;
605 608
606 if (!(fadt->iapc_boot_arch & BAF_8042_KEYBOARD_CONTROLLER)) 609 if (!(fadt->iapc_boot_arch & BAF_8042_KEYBOARD_CONTROLLER))
607 acpi_kbd_controller_present = 0; 610 acpi_kbd_controller_present = 0;
@@ -613,22 +616,19 @@ acpi_parse_fadt (unsigned long phys_addr, unsigned long size)
613 return 0; 616 return 0;
614} 617}
615 618
616 619unsigned long __init acpi_find_rsdp(void)
617unsigned long __init
618acpi_find_rsdp (void)
619{ 620{
620 unsigned long rsdp_phys = 0; 621 unsigned long rsdp_phys = 0;
621 622
622 if (efi.acpi20) 623 if (efi.acpi20)
623 rsdp_phys = __pa(efi.acpi20); 624 rsdp_phys = __pa(efi.acpi20);
624 else if (efi.acpi) 625 else if (efi.acpi)
625 printk(KERN_WARNING PREFIX "v1.0/r0.71 tables no longer supported\n"); 626 printk(KERN_WARNING PREFIX
627 "v1.0/r0.71 tables no longer supported\n");
626 return rsdp_phys; 628 return rsdp_phys;
627} 629}
628 630
629 631int __init acpi_boot_init(void)
630int __init
631acpi_boot_init (void)
632{ 632{
633 633
634 /* 634 /*
@@ -646,31 +646,43 @@ acpi_boot_init (void)
646 646
647 /* Local APIC */ 647 /* Local APIC */
648 648
649 if (acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR, acpi_parse_lapic_addr_ovr, 0) < 0) 649 if (acpi_table_parse_madt
650 printk(KERN_ERR PREFIX "Error parsing LAPIC address override entry\n"); 650 (ACPI_MADT_LAPIC_ADDR_OVR, acpi_parse_lapic_addr_ovr, 0) < 0)
651 printk(KERN_ERR PREFIX
652 "Error parsing LAPIC address override entry\n");
651 653
652 if (acpi_table_parse_madt(ACPI_MADT_LSAPIC, acpi_parse_lsapic, NR_CPUS) < 1) 654 if (acpi_table_parse_madt(ACPI_MADT_LSAPIC, acpi_parse_lsapic, NR_CPUS)
653 printk(KERN_ERR PREFIX "Error parsing MADT - no LAPIC entries\n"); 655 < 1)
656 printk(KERN_ERR PREFIX
657 "Error parsing MADT - no LAPIC entries\n");
654 658
655 if (acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0) < 0) 659 if (acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0)
660 < 0)
656 printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n"); 661 printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
657 662
658 /* I/O APIC */ 663 /* I/O APIC */
659 664
660 if (acpi_table_parse_madt(ACPI_MADT_IOSAPIC, acpi_parse_iosapic, NR_IOSAPICS) < 1) 665 if (acpi_table_parse_madt
661 printk(KERN_ERR PREFIX "Error parsing MADT - no IOSAPIC entries\n"); 666 (ACPI_MADT_IOSAPIC, acpi_parse_iosapic, NR_IOSAPICS) < 1)
667 printk(KERN_ERR PREFIX
668 "Error parsing MADT - no IOSAPIC entries\n");
662 669
663 /* System-Level Interrupt Routing */ 670 /* System-Level Interrupt Routing */
664 671
665 if (acpi_table_parse_madt(ACPI_MADT_PLAT_INT_SRC, acpi_parse_plat_int_src, ACPI_MAX_PLATFORM_INTERRUPTS) < 0) 672 if (acpi_table_parse_madt
666 printk(KERN_ERR PREFIX "Error parsing platform interrupt source entry\n"); 673 (ACPI_MADT_PLAT_INT_SRC, acpi_parse_plat_int_src,
674 ACPI_MAX_PLATFORM_INTERRUPTS) < 0)
675 printk(KERN_ERR PREFIX
676 "Error parsing platform interrupt source entry\n");
667 677
668 if (acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr, 0) < 0) 678 if (acpi_table_parse_madt
669 printk(KERN_ERR PREFIX "Error parsing interrupt source overrides entry\n"); 679 (ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr, 0) < 0)
680 printk(KERN_ERR PREFIX
681 "Error parsing interrupt source overrides entry\n");
670 682
671 if (acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src, 0) < 0) 683 if (acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src, 0) < 0)
672 printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n"); 684 printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
673 skip_madt: 685 skip_madt:
674 686
675 /* 687 /*
676 * FADT says whether a legacy keyboard controller is present. 688 * FADT says whether a legacy keyboard controller is present.
@@ -685,8 +697,9 @@ acpi_boot_init (void)
685 if (available_cpus == 0) { 697 if (available_cpus == 0) {
686 printk(KERN_INFO "ACPI: Found 0 CPUS; assuming 1\n"); 698 printk(KERN_INFO "ACPI: Found 0 CPUS; assuming 1\n");
687 printk(KERN_INFO "CPU 0 (0x%04x)", hard_smp_processor_id()); 699 printk(KERN_INFO "CPU 0 (0x%04x)", hard_smp_processor_id());
688 smp_boot_data.cpu_phys_id[available_cpus] = hard_smp_processor_id(); 700 smp_boot_data.cpu_phys_id[available_cpus] =
689 available_cpus = 1; /* We've got at least one of these, no? */ 701 hard_smp_processor_id();
702 available_cpus = 1; /* We've got at least one of these, no? */
690 } 703 }
691 smp_boot_data.cpu_count = available_cpus; 704 smp_boot_data.cpu_count = available_cpus;
692 705
@@ -695,8 +708,10 @@ acpi_boot_init (void)
695 if (srat_num_cpus == 0) { 708 if (srat_num_cpus == 0) {
696 int cpu, i = 1; 709 int cpu, i = 1;
697 for (cpu = 0; cpu < smp_boot_data.cpu_count; cpu++) 710 for (cpu = 0; cpu < smp_boot_data.cpu_count; cpu++)
698 if (smp_boot_data.cpu_phys_id[cpu] != hard_smp_processor_id()) 711 if (smp_boot_data.cpu_phys_id[cpu] !=
699 node_cpuid[i++].phys_id = smp_boot_data.cpu_phys_id[cpu]; 712 hard_smp_processor_id())
713 node_cpuid[i++].phys_id =
714 smp_boot_data.cpu_phys_id[cpu];
700 } 715 }
701# endif 716# endif
702#endif 717#endif
@@ -704,12 +719,12 @@ acpi_boot_init (void)
704 build_cpu_to_node_map(); 719 build_cpu_to_node_map();
705#endif 720#endif
706 /* Make boot-up look pretty */ 721 /* Make boot-up look pretty */
707 printk(KERN_INFO "%d CPUs available, %d CPUs total\n", available_cpus, total_cpus); 722 printk(KERN_INFO "%d CPUs available, %d CPUs total\n", available_cpus,
723 total_cpus);
708 return 0; 724 return 0;
709} 725}
710 726
711int 727int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
712acpi_gsi_to_irq (u32 gsi, unsigned int *irq)
713{ 728{
714 int vector; 729 int vector;
715 730
@@ -730,11 +745,10 @@ acpi_gsi_to_irq (u32 gsi, unsigned int *irq)
730 */ 745 */
731#ifdef CONFIG_ACPI_HOTPLUG_CPU 746#ifdef CONFIG_ACPI_HOTPLUG_CPU
732static 747static
733int 748int acpi_map_cpu2node(acpi_handle handle, int cpu, long physid)
734acpi_map_cpu2node(acpi_handle handle, int cpu, long physid)
735{ 749{
736#ifdef CONFIG_ACPI_NUMA 750#ifdef CONFIG_ACPI_NUMA
737 int pxm_id; 751 int pxm_id;
738 752
739 pxm_id = acpi_get_pxm(handle); 753 pxm_id = acpi_get_pxm(handle);
740 754
@@ -742,31 +756,28 @@ acpi_map_cpu2node(acpi_handle handle, int cpu, long physid)
742 * Assuming that the container driver would have set the proximity 756 * Assuming that the container driver would have set the proximity
743 * domain and would have initialized pxm_to_nid_map[pxm_id] && pxm_flag 757 * domain and would have initialized pxm_to_nid_map[pxm_id] && pxm_flag
744 */ 758 */
745 node_cpuid[cpu].nid = (pxm_id < 0) ? 0: 759 node_cpuid[cpu].nid = (pxm_id < 0) ? 0 : pxm_to_nid_map[pxm_id];
746 pxm_to_nid_map[pxm_id];
747 760
748 node_cpuid[cpu].phys_id = physid; 761 node_cpuid[cpu].phys_id = physid;
749#endif 762#endif
750 return(0); 763 return (0);
751} 764}
752 765
753 766int acpi_map_lsapic(acpi_handle handle, int *pcpu)
754int
755acpi_map_lsapic(acpi_handle handle, int *pcpu)
756{ 767{
757 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 768 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
758 union acpi_object *obj; 769 union acpi_object *obj;
759 struct acpi_table_lsapic *lsapic; 770 struct acpi_table_lsapic *lsapic;
760 cpumask_t tmp_map; 771 cpumask_t tmp_map;
761 long physid; 772 long physid;
762 int cpu; 773 int cpu;
763 774
764 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer))) 775 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
765 return -EINVAL; 776 return -EINVAL;
766 777
767 if (!buffer.length || !buffer.pointer) 778 if (!buffer.length || !buffer.pointer)
768 return -EINVAL; 779 return -EINVAL;
769 780
770 obj = buffer.pointer; 781 obj = buffer.pointer;
771 if (obj->type != ACPI_TYPE_BUFFER || 782 if (obj->type != ACPI_TYPE_BUFFER ||
772 obj->buffer.length < sizeof(*lsapic)) { 783 obj->buffer.length < sizeof(*lsapic)) {
@@ -782,7 +793,7 @@ acpi_map_lsapic(acpi_handle handle, int *pcpu)
782 return -EINVAL; 793 return -EINVAL;
783 } 794 }
784 795
785 physid = ((lsapic->id <<8) | (lsapic->eid)); 796 physid = ((lsapic->id << 8) | (lsapic->eid));
786 797
787 acpi_os_free(buffer.pointer); 798 acpi_os_free(buffer.pointer);
788 buffer.length = ACPI_ALLOCATE_BUFFER; 799 buffer.length = ACPI_ALLOCATE_BUFFER;
@@ -790,50 +801,49 @@ acpi_map_lsapic(acpi_handle handle, int *pcpu)
790 801
791 cpus_complement(tmp_map, cpu_present_map); 802 cpus_complement(tmp_map, cpu_present_map);
792 cpu = first_cpu(tmp_map); 803 cpu = first_cpu(tmp_map);
793 if(cpu >= NR_CPUS) 804 if (cpu >= NR_CPUS)
794 return -EINVAL; 805 return -EINVAL;
795 806
796 acpi_map_cpu2node(handle, cpu, physid); 807 acpi_map_cpu2node(handle, cpu, physid);
797 808
798 cpu_set(cpu, cpu_present_map); 809 cpu_set(cpu, cpu_present_map);
799 ia64_cpu_to_sapicid[cpu] = physid; 810 ia64_cpu_to_sapicid[cpu] = physid;
800 ia64_acpiid_to_sapicid[lsapic->acpi_id] = ia64_cpu_to_sapicid[cpu]; 811 ia64_acpiid_to_sapicid[lsapic->acpi_id] = ia64_cpu_to_sapicid[cpu];
801 812
802 *pcpu = cpu; 813 *pcpu = cpu;
803 return(0); 814 return (0);
804} 815}
805EXPORT_SYMBOL(acpi_map_lsapic);
806 816
817EXPORT_SYMBOL(acpi_map_lsapic);
807 818
808int 819int acpi_unmap_lsapic(int cpu)
809acpi_unmap_lsapic(int cpu)
810{ 820{
811 int i; 821 int i;
812 822
813 for (i=0; i<MAX_SAPICS; i++) { 823 for (i = 0; i < MAX_SAPICS; i++) {
814 if (ia64_acpiid_to_sapicid[i] == ia64_cpu_to_sapicid[cpu]) { 824 if (ia64_acpiid_to_sapicid[i] == ia64_cpu_to_sapicid[cpu]) {
815 ia64_acpiid_to_sapicid[i] = -1; 825 ia64_acpiid_to_sapicid[i] = -1;
816 break; 826 break;
817 } 827 }
818 } 828 }
819 ia64_cpu_to_sapicid[cpu] = -1; 829 ia64_cpu_to_sapicid[cpu] = -1;
820 cpu_clear(cpu,cpu_present_map); 830 cpu_clear(cpu, cpu_present_map);
821 831
822#ifdef CONFIG_ACPI_NUMA 832#ifdef CONFIG_ACPI_NUMA
823 /* NUMA specific cleanup's */ 833 /* NUMA specific cleanup's */
824#endif 834#endif
825 835
826 return(0); 836 return (0);
827} 837}
838
828EXPORT_SYMBOL(acpi_unmap_lsapic); 839EXPORT_SYMBOL(acpi_unmap_lsapic);
829#endif /* CONFIG_ACPI_HOTPLUG_CPU */ 840#endif /* CONFIG_ACPI_HOTPLUG_CPU */
830
831 841
832#ifdef CONFIG_ACPI_NUMA 842#ifdef CONFIG_ACPI_NUMA
833acpi_status __devinit 843acpi_status __devinit
834acpi_map_iosapic (acpi_handle handle, u32 depth, void *context, void **ret) 844acpi_map_iosapic(acpi_handle handle, u32 depth, void *context, void **ret)
835{ 845{
836 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 846 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
837 union acpi_object *obj; 847 union acpi_object *obj;
838 struct acpi_table_iosapic *iosapic; 848 struct acpi_table_iosapic *iosapic;
839 unsigned int gsi_base; 849 unsigned int gsi_base;
@@ -882,10 +892,9 @@ acpi_map_iosapic (acpi_handle handle, u32 depth, void *context, void **ret)
882 map_iosapic_to_node(gsi_base, node); 892 map_iosapic_to_node(gsi_base, node);
883 return AE_OK; 893 return AE_OK;
884} 894}
885#endif /* CONFIG_NUMA */ 895#endif /* CONFIG_NUMA */
886 896
887int 897int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
888acpi_register_ioapic (acpi_handle handle, u64 phys_addr, u32 gsi_base)
889{ 898{
890 int err; 899 int err;
891 900
@@ -894,17 +903,18 @@ acpi_register_ioapic (acpi_handle handle, u64 phys_addr, u32 gsi_base)
894 903
895#if CONFIG_ACPI_NUMA 904#if CONFIG_ACPI_NUMA
896 acpi_map_iosapic(handle, 0, NULL, NULL); 905 acpi_map_iosapic(handle, 0, NULL, NULL);
897#endif /* CONFIG_ACPI_NUMA */ 906#endif /* CONFIG_ACPI_NUMA */
898 907
899 return 0; 908 return 0;
900} 909}
910
901EXPORT_SYMBOL(acpi_register_ioapic); 911EXPORT_SYMBOL(acpi_register_ioapic);
902 912
903int 913int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
904acpi_unregister_ioapic (acpi_handle handle, u32 gsi_base)
905{ 914{
906 return iosapic_remove(gsi_base); 915 return iosapic_remove(gsi_base);
907} 916}
917
908EXPORT_SYMBOL(acpi_unregister_ioapic); 918EXPORT_SYMBOL(acpi_unregister_ioapic);
909 919
910#endif /* CONFIG_ACPI_BOOT */ 920#endif /* CONFIG_ACPI_BOOT */