1 | /* |
---|
2 | * acpi.c - Architecture-Specific Low-Level ACPI Support |
---|
3 | * |
---|
4 | * Copyright (C) 1999 VA Linux Systems |
---|
5 | * Copyright (C) 1999,2000 Walt Drummond <drummond@valinux.com> |
---|
6 | * Copyright (C) 2000, 2002-2003 Hewlett-Packard Co. |
---|
7 | * David Mosberger-Tang <davidm@hpl.hp.com> |
---|
8 | * Copyright (C) 2000 Intel Corp. |
---|
9 | * Copyright (C) 2000,2001 J.I. Lee <jung-ik.lee@intel.com> |
---|
10 | * Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> |
---|
11 | * Copyright (C) 2001 Jenna Hall <jenna.s.hall@intel.com> |
---|
12 | * Copyright (C) 2001 Takayoshi Kochi <t-kochi@bq.jp.nec.com> |
---|
13 | * Copyright (C) 2002 Erich Focht <efocht@ess.nec.de> |
---|
14 | * |
---|
15 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
16 | * |
---|
17 | * This program is free software; you can redistribute it and/or modify |
---|
18 | * it under the terms of the GNU General Public License as published by |
---|
19 | * the Free Software Foundation; either version 2 of the License, or |
---|
20 | * (at your option) any later version. |
---|
21 | * |
---|
22 | * This program is distributed in the hope that it will be useful, |
---|
23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
25 | * GNU General Public License for more details. |
---|
26 | * |
---|
27 | * You should have received a copy of the GNU General Public License |
---|
28 | * along with this program; if not, write to the Free Software |
---|
29 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
30 | * |
---|
31 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
32 | */ |
---|
33 | |
---|
34 | #include <linux/config.h> |
---|
35 | #include <linux/module.h> |
---|
36 | #include <linux/init.h> |
---|
37 | #include <linux/kernel.h> |
---|
38 | #include <linux/sched.h> |
---|
39 | #include <linux/smp.h> |
---|
40 | #include <linux/string.h> |
---|
41 | #include <linux/types.h> |
---|
42 | #include <linux/irq.h> |
---|
43 | #include <linux/acpi.h> |
---|
44 | #include <linux/efi.h> |
---|
45 | #include <linux/mmzone.h> |
---|
46 | #include <asm/io.h> |
---|
47 | #include <asm/iosapic.h> |
---|
48 | #include <asm/machvec.h> |
---|
49 | #include <asm/page.h> |
---|
50 | #include <asm/system.h> |
---|
51 | #include <asm/numa.h> |
---|
52 | #include <asm/sal.h> |
---|
53 | #include <asm/hw_irq.h> |
---|
54 | #ifdef XEN |
---|
55 | #include <xen/errno.h> |
---|
56 | #include <xen/nodemask.h> |
---|
57 | #endif |
---|
58 | |
---|
59 | #define BAD_MADT_ENTRY(entry, end) ( \ |
---|
60 | (!entry) || (unsigned long)entry + sizeof(*entry) > end || \ |
---|
61 | ((acpi_table_entry_header *)entry)->length != sizeof(*entry)) |
---|
62 | |
---|
63 | #define PREFIX "ACPI: " |
---|
64 | |
---|
65 | void (*pm_idle) (void); |
---|
66 | EXPORT_SYMBOL(pm_idle); |
---|
67 | void (*pm_power_off) (void); |
---|
68 | |
---|
69 | unsigned char acpi_kbd_controller_present = 1; |
---|
70 | unsigned char acpi_legacy_devices; |
---|
71 | |
---|
72 | const char * |
---|
73 | acpi_get_sysname (void) |
---|
74 | { |
---|
75 | /* #ifdef CONFIG_IA64_GENERIC */ |
---|
76 | unsigned long rsdp_phys; |
---|
77 | struct acpi20_table_rsdp *rsdp; |
---|
78 | struct acpi_table_xsdt *xsdt; |
---|
79 | struct acpi_table_header *hdr; |
---|
80 | |
---|
81 | rsdp_phys = acpi_find_rsdp(); |
---|
82 | if (!rsdp_phys) { |
---|
83 | printk(KERN_ERR "ACPI 2.0 RSDP not found, default to \"dig\"\n"); |
---|
84 | return "dig"; |
---|
85 | } |
---|
86 | |
---|
87 | rsdp = (struct acpi20_table_rsdp *) __va(rsdp_phys); |
---|
88 | if (strncmp(rsdp->signature, RSDP_SIG, sizeof(RSDP_SIG) - 1)) { |
---|
89 | printk(KERN_ERR "ACPI 2.0 RSDP signature incorrect, default to \"dig\"\n"); |
---|
90 | return "dig"; |
---|
91 | } |
---|
92 | |
---|
93 | xsdt = (struct acpi_table_xsdt *) __va(rsdp->xsdt_address); |
---|
94 | hdr = &xsdt->header; |
---|
95 | if (strncmp(hdr->signature, XSDT_SIG, sizeof(XSDT_SIG) - 1)) { |
---|
96 | printk(KERN_ERR "ACPI 2.0 XSDT signature incorrect, default to \"dig\"\n"); |
---|
97 | return "dig"; |
---|
98 | } |
---|
99 | |
---|
100 | if (!strcmp(hdr->oem_id, "HP")) { |
---|
101 | return "hpzx1"; |
---|
102 | } |
---|
103 | else if (!strcmp(hdr->oem_id, "SGI")) { |
---|
104 | return "sn2"; |
---|
105 | } |
---|
106 | |
---|
107 | return "dig"; |
---|
108 | /* |
---|
109 | #else |
---|
110 | # if defined (CONFIG_IA64_HP_SIM) |
---|
111 | return "hpsim"; |
---|
112 | # elif defined (CONFIG_IA64_HP_ZX1) |
---|
113 | return "hpzx1"; |
---|
114 | # elif defined (CONFIG_IA64_SGI_SN2) |
---|
115 | return "sn2"; |
---|
116 | # elif defined (CONFIG_IA64_DIG) |
---|
117 | return "dig"; |
---|
118 | # else |
---|
119 | # error Unknown platform. Fix acpi.c. |
---|
120 | # endif |
---|
121 | #endif |
---|
122 | */ |
---|
123 | } |
---|
124 | |
---|
125 | #ifdef CONFIG_ACPI_BOOT |
---|
126 | |
---|
127 | #define ACPI_MAX_PLATFORM_INTERRUPTS 256 |
---|
128 | |
---|
129 | /* Array to record platform interrupt vectors for generic interrupt routing. */ |
---|
130 | int platform_intr_list[ACPI_MAX_PLATFORM_INTERRUPTS] = { |
---|
131 | [0 ... ACPI_MAX_PLATFORM_INTERRUPTS - 1] = -1 |
---|
132 | }; |
---|
133 | |
---|
134 | enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_IOSAPIC; |
---|
135 | |
---|
136 | /* |
---|
137 | * Interrupt routing API for device drivers. Provides interrupt vector for |
---|
138 | * a generic platform event. Currently only CPEI is implemented. |
---|
139 | */ |
---|
140 | int |
---|
141 | acpi_request_vector (u32 int_type) |
---|
142 | { |
---|
143 | int vector = -1; |
---|
144 | |
---|
145 | if (int_type < ACPI_MAX_PLATFORM_INTERRUPTS) { |
---|
146 | /* corrected platform error interrupt */ |
---|
147 | vector = platform_intr_list[int_type]; |
---|
148 | } else |
---|
149 | printk(KERN_ERR "acpi_request_vector(): invalid interrupt type\n"); |
---|
150 | return vector; |
---|
151 | } |
---|
152 | |
---|
153 | char * |
---|
154 | __acpi_map_table (unsigned long phys_addr, unsigned long size) |
---|
155 | { |
---|
156 | return __va(phys_addr); |
---|
157 | } |
---|
158 | |
---|
159 | /* -------------------------------------------------------------------------- |
---|
160 | Boot-time Table Parsing |
---|
161 | -------------------------------------------------------------------------- */ |
---|
162 | |
---|
163 | static int total_cpus __initdata; |
---|
164 | static int available_cpus __initdata; |
---|
165 | struct acpi_table_madt * acpi_madt __initdata; |
---|
166 | static u8 has_8259; |
---|
167 | |
---|
168 | static int __init |
---|
169 | acpi_parse_lapic_addr_ovr ( |
---|
170 | acpi_table_entry_header *header, const unsigned long end) |
---|
171 | { |
---|
172 | struct acpi_table_lapic_addr_ovr *lapic; |
---|
173 | |
---|
174 | lapic = (struct acpi_table_lapic_addr_ovr *) header; |
---|
175 | |
---|
176 | if (BAD_MADT_ENTRY(lapic, end)) |
---|
177 | return -EINVAL; |
---|
178 | |
---|
179 | acpi_table_print_madt_entry(header); |
---|
180 | |
---|
181 | if (lapic->address) { |
---|
182 | iounmap((void *) ipi_base_addr); |
---|
183 | ipi_base_addr = (void __iomem *) ioremap(lapic->address, 0); |
---|
184 | } |
---|
185 | return 0; |
---|
186 | } |
---|
187 | |
---|
188 | |
---|
189 | static int __init |
---|
190 | acpi_parse_lsapic (acpi_table_entry_header *header, const unsigned long end) |
---|
191 | { |
---|
192 | struct acpi_table_lsapic *lsapic; |
---|
193 | |
---|
194 | lsapic = (struct acpi_table_lsapic *) header; |
---|
195 | |
---|
196 | if (BAD_MADT_ENTRY(lsapic, end)) |
---|
197 | return -EINVAL; |
---|
198 | |
---|
199 | acpi_table_print_madt_entry(header); |
---|
200 | |
---|
201 | printk(KERN_INFO "CPU %d (0x%04x)", total_cpus, (lsapic->id << 8) | lsapic->eid); |
---|
202 | |
---|
203 | if (!lsapic->flags.enabled) |
---|
204 | printk(" disabled"); |
---|
205 | else { |
---|
206 | printk(" enabled"); |
---|
207 | #ifdef CONFIG_SMP |
---|
208 | if (available_cpus < NR_CPUS) { |
---|
209 | smp_boot_data.cpu_phys_id[available_cpus] = (lsapic->id << 8) | lsapic->eid; |
---|
210 | if (hard_smp_processor_id() |
---|
211 | == (unsigned int) smp_boot_data.cpu_phys_id[available_cpus]) |
---|
212 | printk(" (BSP)"); |
---|
213 | ++available_cpus; |
---|
214 | } else { |
---|
215 | printk(" - however, ignored..."); |
---|
216 | } |
---|
217 | #else |
---|
218 | ++available_cpus; |
---|
219 | #endif |
---|
220 | } |
---|
221 | |
---|
222 | printk("\n"); |
---|
223 | |
---|
224 | total_cpus++; |
---|
225 | return 0; |
---|
226 | } |
---|
227 | |
---|
228 | |
---|
229 | static int __init |
---|
230 | acpi_parse_lapic_nmi (acpi_table_entry_header *header, const unsigned long end) |
---|
231 | { |
---|
232 | struct acpi_table_lapic_nmi *lacpi_nmi; |
---|
233 | |
---|
234 | lacpi_nmi = (struct acpi_table_lapic_nmi*) header; |
---|
235 | |
---|
236 | if (BAD_MADT_ENTRY(lacpi_nmi, end)) |
---|
237 | return -EINVAL; |
---|
238 | |
---|
239 | acpi_table_print_madt_entry(header); |
---|
240 | |
---|
241 | /* TBD: Support lapic_nmi entries */ |
---|
242 | return 0; |
---|
243 | } |
---|
244 | |
---|
245 | |
---|
246 | static int __init |
---|
247 | acpi_parse_iosapic (acpi_table_entry_header *header, const unsigned long end) |
---|
248 | { |
---|
249 | struct acpi_table_iosapic *iosapic; |
---|
250 | |
---|
251 | iosapic = (struct acpi_table_iosapic *) header; |
---|
252 | |
---|
253 | if (BAD_MADT_ENTRY(iosapic, end)) |
---|
254 | return -EINVAL; |
---|
255 | |
---|
256 | acpi_table_print_madt_entry(header); |
---|
257 | |
---|
258 | iosapic_init(iosapic->address, iosapic->global_irq_base); |
---|
259 | |
---|
260 | return 0; |
---|
261 | } |
---|
262 | |
---|
263 | static int __init |
---|
264 | acpi_parse_plat_int_src ( |
---|
265 | acpi_table_entry_header *header, const unsigned long end) |
---|
266 | { |
---|
267 | struct acpi_table_plat_int_src *plintsrc; |
---|
268 | int vector; |
---|
269 | |
---|
270 | plintsrc = (struct acpi_table_plat_int_src *) header; |
---|
271 | |
---|
272 | if (BAD_MADT_ENTRY(plintsrc, end)) |
---|
273 | return -EINVAL; |
---|
274 | |
---|
275 | acpi_table_print_madt_entry(header); |
---|
276 | |
---|
277 | /* |
---|
278 | * Get vector assignment for this interrupt, set attributes, |
---|
279 | * and program the IOSAPIC routing table. |
---|
280 | */ |
---|
281 | vector = iosapic_register_platform_intr(plintsrc->type, |
---|
282 | plintsrc->global_irq, |
---|
283 | plintsrc->iosapic_vector, |
---|
284 | plintsrc->eid, |
---|
285 | plintsrc->id, |
---|
286 | (plintsrc->flags.polarity == 1) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW, |
---|
287 | (plintsrc->flags.trigger == 1) ? IOSAPIC_EDGE : IOSAPIC_LEVEL); |
---|
288 | |
---|
289 | platform_intr_list[plintsrc->type] = vector; |
---|
290 | return 0; |
---|
291 | } |
---|
292 | |
---|
293 | |
---|
294 | static int __init |
---|
295 | acpi_parse_int_src_ovr ( |
---|
296 | acpi_table_entry_header *header, const unsigned long end) |
---|
297 | { |
---|
298 | struct acpi_table_int_src_ovr *p; |
---|
299 | |
---|
300 | p = (struct acpi_table_int_src_ovr *) header; |
---|
301 | |
---|
302 | if (BAD_MADT_ENTRY(p, end)) |
---|
303 | return -EINVAL; |
---|
304 | |
---|
305 | acpi_table_print_madt_entry(header); |
---|
306 | |
---|
307 | iosapic_override_isa_irq(p->bus_irq, p->global_irq, |
---|
308 | (p->flags.polarity == 1) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW, |
---|
309 | (p->flags.trigger == 1) ? IOSAPIC_EDGE : IOSAPIC_LEVEL); |
---|
310 | return 0; |
---|
311 | } |
---|
312 | |
---|
313 | static int __init |
---|
314 | acpi_parse_nmi_src (acpi_table_entry_header *header, const unsigned long end) |
---|
315 | { |
---|
316 | struct acpi_table_nmi_src *nmi_src; |
---|
317 | |
---|
318 | nmi_src = (struct acpi_table_nmi_src*) header; |
---|
319 | |
---|
320 | if (BAD_MADT_ENTRY(nmi_src, end)) |
---|
321 | return -EINVAL; |
---|
322 | |
---|
323 | acpi_table_print_madt_entry(header); |
---|
324 | |
---|
325 | /* TBD: Support nimsrc entries */ |
---|
326 | return 0; |
---|
327 | } |
---|
328 | /* Hook from generic ACPI tables.c */ |
---|
329 | void __init acpi_madt_oem_check(char *oem_id, char *oem_table_id) |
---|
330 | { |
---|
331 | if (!strncmp(oem_id, "IBM", 3) && |
---|
332 | (!strncmp(oem_table_id, "SERMOW", 6))){ |
---|
333 | |
---|
334 | /* Unfortunatly ITC_DRIFT is not yet part of the |
---|
335 | * official SAL spec, so the ITC_DRIFT bit is not |
---|
336 | * set by the BIOS on this hardware. |
---|
337 | */ |
---|
338 | sal_platform_features |= IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT; |
---|
339 | |
---|
340 | #if 0 |
---|
341 | /*Start cyclone clock*/ |
---|
342 | cyclone_setup(0); |
---|
343 | #endif |
---|
344 | } |
---|
345 | } |
---|
346 | |
---|
347 | static int __init |
---|
348 | acpi_parse_madt (unsigned long phys_addr, unsigned long size) |
---|
349 | { |
---|
350 | if (!phys_addr || !size) |
---|
351 | return -EINVAL; |
---|
352 | |
---|
353 | acpi_madt = (struct acpi_table_madt *) __va(phys_addr); |
---|
354 | |
---|
355 | /* remember the value for reference after free_initmem() */ |
---|
356 | #ifdef CONFIG_ITANIUM |
---|
357 | has_8259 = 1; /* Firmware on old Itanium systems is broken */ |
---|
358 | #else |
---|
359 | has_8259 = acpi_madt->flags.pcat_compat; |
---|
360 | #endif |
---|
361 | iosapic_system_init(has_8259); |
---|
362 | |
---|
363 | /* Get base address of IPI Message Block */ |
---|
364 | |
---|
365 | if (acpi_madt->lapic_address) |
---|
366 | ipi_base_addr = (void __iomem *) ioremap(acpi_madt->lapic_address, 0); |
---|
367 | |
---|
368 | printk(KERN_INFO PREFIX "Local APIC address %p\n", ipi_base_addr); |
---|
369 | |
---|
370 | acpi_madt_oem_check(acpi_madt->header.oem_id, |
---|
371 | acpi_madt->header.oem_table_id); |
---|
372 | |
---|
373 | return 0; |
---|
374 | } |
---|
375 | |
---|
376 | #ifdef CONFIG_ACPI_NUMA |
---|
377 | |
---|
378 | #undef SLIT_DEBUG |
---|
379 | |
---|
380 | #define PXM_FLAG_LEN ((MAX_PXM_DOMAINS + 1)/32) |
---|
381 | |
---|
382 | static int __initdata srat_num_cpus; /* number of cpus */ |
---|
383 | static u32 __initdata pxm_flag[PXM_FLAG_LEN]; |
---|
384 | #define pxm_bit_set(bit) (set_bit(bit,(void *)pxm_flag)) |
---|
385 | #define pxm_bit_test(bit) (test_bit(bit,(void *)pxm_flag)) |
---|
386 | /* maps to convert between proximity domain and logical node ID */ |
---|
387 | int __initdata pxm_to_nid_map[MAX_PXM_DOMAINS]; |
---|
388 | int __initdata nid_to_pxm_map[MAX_NUMNODES]; |
---|
389 | static struct acpi_table_slit __initdata *slit_table; |
---|
390 | |
---|
391 | /* |
---|
392 | * ACPI 2.0 SLIT (System Locality Information Table) |
---|
393 | * http://devresource.hp.com/devresource/Docs/TechPapers/IA64/slit.pdf |
---|
394 | */ |
---|
395 | void __init |
---|
396 | acpi_numa_slit_init (struct acpi_table_slit *slit) |
---|
397 | { |
---|
398 | u32 len; |
---|
399 | |
---|
400 | len = sizeof(struct acpi_table_header) + 8 |
---|
401 | + slit->localities * slit->localities; |
---|
402 | if (slit->header.length != len) { |
---|
403 | printk(KERN_ERR "ACPI 2.0 SLIT: size mismatch: %d expected, %d actual\n", |
---|
404 | len, slit->header.length); |
---|
405 | memset(numa_slit, 10, sizeof(numa_slit)); |
---|
406 | return; |
---|
407 | } |
---|
408 | slit_table = slit; |
---|
409 | } |
---|
410 | |
---|
411 | void __init |
---|
412 | acpi_numa_processor_affinity_init (struct acpi_table_processor_affinity *pa) |
---|
413 | { |
---|
414 | /* record this node in proximity bitmap */ |
---|
415 | pxm_bit_set(pa->proximity_domain); |
---|
416 | |
---|
417 | node_cpuid[srat_num_cpus].phys_id = (pa->apic_id << 8) | (pa->lsapic_eid); |
---|
418 | /* nid should be overridden as logical node id later */ |
---|
419 | node_cpuid[srat_num_cpus].nid = pa->proximity_domain; |
---|
420 | srat_num_cpus++; |
---|
421 | } |
---|
422 | |
---|
423 | void __init |
---|
424 | acpi_numa_memory_affinity_init (struct acpi_table_memory_affinity *ma) |
---|
425 | { |
---|
426 | unsigned long paddr, size; |
---|
427 | u8 pxm; |
---|
428 | struct node_memblk_s *p, *q, *pend; |
---|
429 | |
---|
430 | pxm = ma->proximity_domain; |
---|
431 | |
---|
432 | /* fill node memory chunk structure */ |
---|
433 | paddr = ma->base_addr_hi; |
---|
434 | paddr = (paddr << 32) | ma->base_addr_lo; |
---|
435 | size = ma->length_hi; |
---|
436 | size = (size << 32) | ma->length_lo; |
---|
437 | |
---|
438 | /* Ignore disabled entries */ |
---|
439 | if (!ma->flags.enabled) |
---|
440 | return; |
---|
441 | |
---|
442 | /* record this node in proximity bitmap */ |
---|
443 | pxm_bit_set(pxm); |
---|
444 | |
---|
445 | /* Insertion sort based on base address */ |
---|
446 | pend = &node_memblk[num_node_memblks]; |
---|
447 | for (p = &node_memblk[0]; p < pend; p++) { |
---|
448 | if (paddr < p->start_paddr) |
---|
449 | break; |
---|
450 | } |
---|
451 | if (p < pend) { |
---|
452 | for (q = pend - 1; q >= p; q--) |
---|
453 | *(q + 1) = *q; |
---|
454 | } |
---|
455 | p->start_paddr = paddr; |
---|
456 | p->size = size; |
---|
457 | p->nid = pxm; |
---|
458 | num_node_memblks++; |
---|
459 | } |
---|
460 | |
---|
461 | static unsigned int numnodes; |
---|
462 | void __init |
---|
463 | acpi_numa_arch_fixup (void) |
---|
464 | { |
---|
465 | int i, j, node_from, node_to; |
---|
466 | |
---|
467 | /* If there's no SRAT, fix the phys_id */ |
---|
468 | if (srat_num_cpus == 0) { |
---|
469 | node_cpuid[0].phys_id = hard_smp_processor_id(); |
---|
470 | return; |
---|
471 | } |
---|
472 | |
---|
473 | /* calculate total number of nodes in system from PXM bitmap */ |
---|
474 | numnodes = 0; /* init total nodes in system */ |
---|
475 | |
---|
476 | memset(pxm_to_nid_map, -1, sizeof(pxm_to_nid_map)); |
---|
477 | memset(nid_to_pxm_map, -1, sizeof(nid_to_pxm_map)); |
---|
478 | for (i = 0; i < MAX_PXM_DOMAINS; i++) { |
---|
479 | if (pxm_bit_test(i)) { |
---|
480 | pxm_to_nid_map[i] = numnodes; |
---|
481 | node_set_online(numnodes); |
---|
482 | nid_to_pxm_map[numnodes++] = i; |
---|
483 | } |
---|
484 | } |
---|
485 | |
---|
486 | /* set logical node id in memory chunk structure */ |
---|
487 | for (i = 0; i < num_node_memblks; i++) |
---|
488 | node_memblk[i].nid = pxm_to_nid_map[node_memblk[i].nid]; |
---|
489 | |
---|
490 | /* assign memory bank numbers for each chunk on each node */ |
---|
491 | for (i = 0; i < numnodes; i++) { |
---|
492 | int bank; |
---|
493 | |
---|
494 | bank = 0; |
---|
495 | for (j = 0; j < num_node_memblks; j++) |
---|
496 | if (node_memblk[j].nid == i) |
---|
497 | node_memblk[j].bank = bank++; |
---|
498 | } |
---|
499 | |
---|
500 | /* set logical node id in cpu structure */ |
---|
501 | for (i = 0; i < srat_num_cpus; i++) |
---|
502 | node_cpuid[i].nid = pxm_to_nid_map[node_cpuid[i].nid]; |
---|
503 | |
---|
504 | printk(KERN_INFO "Number of logical nodes in system = %d\n", numnodes); |
---|
505 | printk(KERN_INFO "Number of memory chunks in system = %d\n", num_node_memblks); |
---|
506 | |
---|
507 | if (!slit_table) return; |
---|
508 | memset(numa_slit, -1, sizeof(numa_slit)); |
---|
509 | for (i=0; i<slit_table->localities; i++) { |
---|
510 | if (!pxm_bit_test(i)) |
---|
511 | continue; |
---|
512 | node_from = pxm_to_nid_map[i]; |
---|
513 | for (j=0; j<slit_table->localities; j++) { |
---|
514 | if (!pxm_bit_test(j)) |
---|
515 | continue; |
---|
516 | node_to = pxm_to_nid_map[j]; |
---|
517 | node_distance(node_from, node_to) = |
---|
518 | slit_table->entry[i*slit_table->localities + j]; |
---|
519 | } |
---|
520 | } |
---|
521 | |
---|
522 | #ifdef SLIT_DEBUG |
---|
523 | printk("ACPI 2.0 SLIT locality table:\n"); |
---|
524 | for (i = 0; i < numnodes; i++) { |
---|
525 | for (j = 0; j < numnodes; j++) |
---|
526 | printk("%03d ", node_distance(i,j)); |
---|
527 | printk("\n"); |
---|
528 | } |
---|
529 | #endif |
---|
530 | } |
---|
531 | #endif /* CONFIG_ACPI_NUMA */ |
---|
532 | |
---|
533 | #if 0 |
---|
534 | unsigned int |
---|
535 | acpi_register_gsi (u32 gsi, int polarity, int trigger) |
---|
536 | { |
---|
537 | return acpi_register_irq(gsi, polarity, trigger); |
---|
538 | } |
---|
539 | EXPORT_SYMBOL(acpi_register_gsi); |
---|
540 | #endif |
---|
541 | static int __init |
---|
542 | acpi_parse_fadt (unsigned long phys_addr, unsigned long size) |
---|
543 | { |
---|
544 | struct acpi_table_header *fadt_header; |
---|
545 | struct fadt_descriptor_rev2 *fadt; |
---|
546 | |
---|
547 | if (!phys_addr || !size) |
---|
548 | return -EINVAL; |
---|
549 | |
---|
550 | fadt_header = (struct acpi_table_header *) __va(phys_addr); |
---|
551 | if (fadt_header->revision != 3) |
---|
552 | return -ENODEV; /* Only deal with ACPI 2.0 FADT */ |
---|
553 | |
---|
554 | fadt = (struct fadt_descriptor_rev2 *) fadt_header; |
---|
555 | |
---|
556 | if (!(fadt->iapc_boot_arch & BAF_8042_KEYBOARD_CONTROLLER)) |
---|
557 | acpi_kbd_controller_present = 0; |
---|
558 | |
---|
559 | if (fadt->iapc_boot_arch & BAF_LEGACY_DEVICES) |
---|
560 | acpi_legacy_devices = 1; |
---|
561 | |
---|
562 | #if 0 |
---|
563 | acpi_register_gsi(fadt->sci_int, ACPI_ACTIVE_LOW, ACPI_LEVEL_SENSITIVE); |
---|
564 | #endif |
---|
565 | return 0; |
---|
566 | } |
---|
567 | |
---|
568 | unsigned long __init |
---|
569 | acpi_find_rsdp (void) |
---|
570 | { |
---|
571 | unsigned long rsdp_phys = 0; |
---|
572 | |
---|
573 | if (efi.acpi20) |
---|
574 | rsdp_phys = __pa(efi.acpi20); |
---|
575 | else if (efi.acpi) |
---|
576 | printk(KERN_WARNING PREFIX "v1.0/r0.71 tables no longer supported\n"); |
---|
577 | return rsdp_phys; |
---|
578 | } |
---|
579 | |
---|
580 | int __init |
---|
581 | acpi_boot_init (void) |
---|
582 | { |
---|
583 | |
---|
584 | /* |
---|
585 | * MADT |
---|
586 | * ---- |
---|
587 | * Parse the Multiple APIC Description Table (MADT), if exists. |
---|
588 | * Note that this table provides platform SMP configuration |
---|
589 | * information -- the successor to MPS tables. |
---|
590 | */ |
---|
591 | |
---|
592 | if (acpi_table_parse(ACPI_APIC, acpi_parse_madt) < 1) { |
---|
593 | printk(KERN_ERR PREFIX "Can't find MADT\n"); |
---|
594 | goto skip_madt; |
---|
595 | } |
---|
596 | |
---|
597 | /* Local APIC */ |
---|
598 | |
---|
599 | if (acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR, acpi_parse_lapic_addr_ovr, 0) < 0) |
---|
600 | printk(KERN_ERR PREFIX "Error parsing LAPIC address override entry\n"); |
---|
601 | |
---|
602 | if (acpi_table_parse_madt(ACPI_MADT_LSAPIC, acpi_parse_lsapic, NR_CPUS) < 1) |
---|
603 | printk(KERN_ERR PREFIX "Error parsing MADT - no LSAPIC entries\n"); |
---|
604 | |
---|
605 | if (acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0) < 0) |
---|
606 | printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n"); |
---|
607 | |
---|
608 | /* I/O APIC */ |
---|
609 | |
---|
610 | if (acpi_table_parse_madt(ACPI_MADT_IOSAPIC, acpi_parse_iosapic, NR_IOSAPICS) < 1) |
---|
611 | printk(KERN_ERR PREFIX "Error parsing MADT - no IOSAPIC entries\n"); |
---|
612 | |
---|
613 | /* System-Level Interrupt Routing */ |
---|
614 | |
---|
615 | if (acpi_table_parse_madt(ACPI_MADT_PLAT_INT_SRC, acpi_parse_plat_int_src, ACPI_MAX_PLATFORM_INTERRUPTS) < 0) |
---|
616 | printk(KERN_ERR PREFIX "Error parsing platform interrupt source entry\n"); |
---|
617 | |
---|
618 | if (acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr, 0) < 0) |
---|
619 | printk(KERN_ERR PREFIX "Error parsing interrupt source overrides entry\n"); |
---|
620 | |
---|
621 | if (acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src, 0) < 0) |
---|
622 | printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n"); |
---|
623 | skip_madt: |
---|
624 | |
---|
625 | /* |
---|
626 | * FADT says whether a legacy keyboard controller is present. |
---|
627 | * The FADT also contains an SCI_INT line, by which the system |
---|
628 | * gets interrupts such as power and sleep buttons. If it's not |
---|
629 | * on a Legacy interrupt, it needs to be setup. |
---|
630 | */ |
---|
631 | if (acpi_table_parse(ACPI_FADT, acpi_parse_fadt) < 1) |
---|
632 | printk(KERN_ERR PREFIX "Can't find FADT\n"); |
---|
633 | |
---|
634 | #ifdef CONFIG_SMP |
---|
635 | if (available_cpus == 0) { |
---|
636 | printk(KERN_INFO "ACPI: Found 0 CPUS; assuming 1\n"); |
---|
637 | printk(KERN_INFO "CPU 0 (0x%04x)\n", hard_smp_processor_id()); |
---|
638 | smp_boot_data.cpu_phys_id[available_cpus] = hard_smp_processor_id(); |
---|
639 | available_cpus = 1; /* We've got at least one of these, no? */ |
---|
640 | } |
---|
641 | smp_boot_data.cpu_count = available_cpus; |
---|
642 | |
---|
643 | smp_build_cpu_map(); |
---|
644 | # ifdef CONFIG_ACPI_NUMA |
---|
645 | if (srat_num_cpus == 0) { |
---|
646 | int cpu, i = 1; |
---|
647 | for (cpu = 0; cpu < smp_boot_data.cpu_count; cpu++) |
---|
648 | if (smp_boot_data.cpu_phys_id[cpu] != hard_smp_processor_id()) |
---|
649 | node_cpuid[i++].phys_id = smp_boot_data.cpu_phys_id[cpu]; |
---|
650 | } |
---|
651 | build_cpu_to_node_map(); |
---|
652 | # endif |
---|
653 | #endif |
---|
654 | /* Make boot-up look pretty */ |
---|
655 | printk(KERN_INFO "%d CPUs available, %d CPUs total\n", available_cpus, total_cpus); |
---|
656 | return 0; |
---|
657 | } |
---|
658 | |
---|
659 | int |
---|
660 | acpi_gsi_to_irq (u32 gsi, unsigned int *irq) |
---|
661 | { |
---|
662 | int vector; |
---|
663 | |
---|
664 | if (has_8259 && gsi < 16) |
---|
665 | *irq = isa_irq_to_vector(gsi); |
---|
666 | else { |
---|
667 | vector = gsi_to_vector(gsi); |
---|
668 | if (vector == -1) |
---|
669 | return -1; |
---|
670 | |
---|
671 | *irq = vector; |
---|
672 | } |
---|
673 | return 0; |
---|
674 | } |
---|
675 | #if 0 |
---|
676 | int |
---|
677 | acpi_register_irq (u32 gsi, u32 polarity, u32 trigger) |
---|
678 | { |
---|
679 | if (has_8259 && gsi < 16) |
---|
680 | return isa_irq_to_vector(gsi); |
---|
681 | |
---|
682 | return iosapic_register_intr(gsi, |
---|
683 | (polarity == ACPI_ACTIVE_HIGH) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW, |
---|
684 | (trigger == ACPI_EDGE_SENSITIVE) ? IOSAPIC_EDGE : IOSAPIC_LEVEL); |
---|
685 | } |
---|
686 | EXPORT_SYMBOL(acpi_register_irq); |
---|
687 | #endif |
---|
688 | #endif /* CONFIG_ACPI_BOOT */ |
---|