upgrade to linux 2.6.10-1.12_FC2
[linux-2.6.git] / arch / ia64 / kernel / acpi.c
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 <linux/nodemask.h>
47 #include <asm/io.h>
48 #include <asm/iosapic.h>
49 #include <asm/machvec.h>
50 #include <asm/page.h>
51 #include <asm/system.h>
52 #include <asm/numa.h>
53 #include <asm/sal.h>
54 #include <asm/cyclone.h>
55
56 #define BAD_MADT_ENTRY(entry, end) (                                        \
57                 (!entry) || (unsigned long)entry + sizeof(*entry) > end ||  \
58                 ((acpi_table_entry_header *)entry)->length != sizeof(*entry))
59
60 #define PREFIX                  "ACPI: "
61
62 void (*pm_idle) (void);
63 EXPORT_SYMBOL(pm_idle);
64 void (*pm_power_off) (void);
65 EXPORT_SYMBOL(pm_power_off);
66
67 unsigned char acpi_kbd_controller_present = 1;
68 unsigned char acpi_legacy_devices;
69
70 #define MAX_SAPICS 256
71 u16 ia64_acpiid_to_sapicid[MAX_SAPICS] =
72         { [0 ... MAX_SAPICS - 1] = -1 };
73 EXPORT_SYMBOL(ia64_acpiid_to_sapicid);
74
75 const char *
76 acpi_get_sysname (void)
77 {
78 #ifdef CONFIG_IA64_GENERIC
79         unsigned long rsdp_phys;
80         struct acpi20_table_rsdp *rsdp;
81         struct acpi_table_xsdt *xsdt;
82         struct acpi_table_header *hdr;
83
84         rsdp_phys = acpi_find_rsdp();
85         if (!rsdp_phys) {
86                 printk(KERN_ERR "ACPI 2.0 RSDP not found, default to \"dig\"\n");
87                 return "dig";
88         }
89
90         rsdp = (struct acpi20_table_rsdp *) __va(rsdp_phys);
91         if (strncmp(rsdp->signature, RSDP_SIG, sizeof(RSDP_SIG) - 1)) {
92                 printk(KERN_ERR "ACPI 2.0 RSDP signature incorrect, default to \"dig\"\n");
93                 return "dig";
94         }
95
96         xsdt = (struct acpi_table_xsdt *) __va(rsdp->xsdt_address);
97         hdr = &xsdt->header;
98         if (strncmp(hdr->signature, XSDT_SIG, sizeof(XSDT_SIG) - 1)) {
99                 printk(KERN_ERR "ACPI 2.0 XSDT signature incorrect, default to \"dig\"\n");
100                 return "dig";
101         }
102
103         if (!strcmp(hdr->oem_id, "HP")) {
104                 return "hpzx1";
105         }
106         else if (!strcmp(hdr->oem_id, "SGI")) {
107                 return "sn2";
108         }
109
110         return "dig";
111 #else
112 # if defined (CONFIG_IA64_HP_SIM)
113         return "hpsim";
114 # elif defined (CONFIG_IA64_HP_ZX1)
115         return "hpzx1";
116 # elif defined (CONFIG_IA64_SGI_SN2)
117         return "sn2";
118 # elif defined (CONFIG_IA64_DIG)
119         return "dig";
120 # else
121 #       error Unknown platform.  Fix acpi.c.
122 # endif
123 #endif
124 }
125
126 #ifdef CONFIG_ACPI_BOOT
127
128 #define ACPI_MAX_PLATFORM_INTERRUPTS    256
129
130 /* Array to record platform interrupt vectors for generic interrupt routing. */
131 int platform_intr_list[ACPI_MAX_PLATFORM_INTERRUPTS] = {
132         [0 ... ACPI_MAX_PLATFORM_INTERRUPTS - 1] = -1
133 };
134
135 enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_IOSAPIC;
136
137 /*
138  * Interrupt routing API for device drivers.  Provides interrupt vector for
139  * a generic platform event.  Currently only CPEI is implemented.
140  */
141 int
142 acpi_request_vector (u32 int_type)
143 {
144         int vector = -1;
145
146         if (int_type < ACPI_MAX_PLATFORM_INTERRUPTS) {
147                 /* corrected platform error interrupt */
148                 vector = platform_intr_list[int_type];
149         } else
150                 printk(KERN_ERR "acpi_request_vector(): invalid interrupt type\n");
151         return vector;
152 }
153
154 char *
155 __acpi_map_table (unsigned long phys_addr, unsigned long size)
156 {
157         return __va(phys_addr);
158 }
159
160 /* --------------------------------------------------------------------------
161                             Boot-time Table Parsing
162    -------------------------------------------------------------------------- */
163
164 static int                      total_cpus __initdata;
165 static int                      available_cpus __initdata;
166 struct acpi_table_madt *        acpi_madt __initdata;
167 static u8                       has_8259;
168
169
170 static int __init
171 acpi_parse_lapic_addr_ovr (
172         acpi_table_entry_header *header, const unsigned long end)
173 {
174         struct acpi_table_lapic_addr_ovr *lapic;
175
176         lapic = (struct acpi_table_lapic_addr_ovr *) header;
177
178         if (BAD_MADT_ENTRY(lapic, end))
179                 return -EINVAL;
180
181         if (lapic->address) {
182                 iounmap(ipi_base_addr);
183                 ipi_base_addr = 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         if (lsapic->flags.enabled) {
200 #ifdef CONFIG_SMP
201                 smp_boot_data.cpu_phys_id[available_cpus] = (lsapic->id << 8) | lsapic->eid;
202 #endif
203                 ia64_acpiid_to_sapicid[lsapic->acpi_id] = (lsapic->id << 8) | lsapic->eid;
204                 ++available_cpus;
205         }
206
207         total_cpus++;
208         return 0;
209 }
210
211
212 static int __init
213 acpi_parse_lapic_nmi (acpi_table_entry_header *header, const unsigned long end)
214 {
215         struct acpi_table_lapic_nmi *lacpi_nmi;
216
217         lacpi_nmi = (struct acpi_table_lapic_nmi*) header;
218
219         if (BAD_MADT_ENTRY(lacpi_nmi, end))
220                 return -EINVAL;
221
222         /* TBD: Support lapic_nmi entries */
223         return 0;
224 }
225
226
227 static int __init
228 acpi_parse_iosapic (acpi_table_entry_header *header, const unsigned long end)
229 {
230         struct acpi_table_iosapic *iosapic;
231
232         iosapic = (struct acpi_table_iosapic *) header;
233
234         if (BAD_MADT_ENTRY(iosapic, end))
235                 return -EINVAL;
236
237         iosapic_init(iosapic->address, iosapic->global_irq_base);
238
239         return 0;
240 }
241
242
243 static int __init
244 acpi_parse_plat_int_src (
245         acpi_table_entry_header *header, const unsigned long end)
246 {
247         struct acpi_table_plat_int_src *plintsrc;
248         int vector;
249
250         plintsrc = (struct acpi_table_plat_int_src *) header;
251
252         if (BAD_MADT_ENTRY(plintsrc, end))
253                 return -EINVAL;
254
255         /*
256          * Get vector assignment for this interrupt, set attributes,
257          * and program the IOSAPIC routing table.
258          */
259         vector = iosapic_register_platform_intr(plintsrc->type,
260                                                 plintsrc->global_irq,
261                                                 plintsrc->iosapic_vector,
262                                                 plintsrc->eid,
263                                                 plintsrc->id,
264                                                 (plintsrc->flags.polarity == 1) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW,
265                                                 (plintsrc->flags.trigger == 1) ? IOSAPIC_EDGE : IOSAPIC_LEVEL);
266
267         platform_intr_list[plintsrc->type] = vector;
268         return 0;
269 }
270
271
272 static int __init
273 acpi_parse_int_src_ovr (
274         acpi_table_entry_header *header, const unsigned long end)
275 {
276         struct acpi_table_int_src_ovr *p;
277
278         p = (struct acpi_table_int_src_ovr *) header;
279
280         if (BAD_MADT_ENTRY(p, end))
281                 return -EINVAL;
282
283         iosapic_override_isa_irq(p->bus_irq, p->global_irq,
284                                  (p->flags.polarity == 1) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW,
285                                  (p->flags.trigger == 1) ? IOSAPIC_EDGE : IOSAPIC_LEVEL);
286         return 0;
287 }
288
289
290 static int __init
291 acpi_parse_nmi_src (acpi_table_entry_header *header, const unsigned long end)
292 {
293         struct acpi_table_nmi_src *nmi_src;
294
295         nmi_src = (struct acpi_table_nmi_src*) header;
296
297         if (BAD_MADT_ENTRY(nmi_src, end))
298                 return -EINVAL;
299
300         /* TBD: Support nimsrc entries */
301         return 0;
302 }
303
304 static void __init
305 acpi_madt_oem_check (char *oem_id, char *oem_table_id)
306 {
307         if (!strncmp(oem_id, "IBM", 3) &&
308             (!strncmp(oem_table_id, "SERMOW", 6))) {
309
310                 /*
311                  * Unfortunately ITC_DRIFT is not yet part of the
312                  * official SAL spec, so the ITC_DRIFT bit is not
313                  * set by the BIOS on this hardware.
314                  */
315                 sal_platform_features |= IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT;
316
317                 cyclone_setup();
318         }
319 }
320
321 static int __init
322 acpi_parse_madt (unsigned long phys_addr, unsigned long size)
323 {
324         if (!phys_addr || !size)
325                 return -EINVAL;
326
327         acpi_madt = (struct acpi_table_madt *) __va(phys_addr);
328
329         /* remember the value for reference after free_initmem() */
330 #ifdef CONFIG_ITANIUM
331         has_8259 = 1; /* Firmware on old Itanium systems is broken */
332 #else
333         has_8259 = acpi_madt->flags.pcat_compat;
334 #endif
335         iosapic_system_init(has_8259);
336
337         /* Get base address of IPI Message Block */
338
339         if (acpi_madt->lapic_address)
340                 ipi_base_addr = ioremap(acpi_madt->lapic_address, 0);
341
342         printk(KERN_INFO PREFIX "Local APIC address %p\n", ipi_base_addr);
343
344         acpi_madt_oem_check(acpi_madt->header.oem_id,
345                 acpi_madt->header.oem_table_id);
346
347         return 0;
348 }
349
350
351 #ifdef CONFIG_ACPI_NUMA
352
353 #undef SLIT_DEBUG
354
355 #define PXM_FLAG_LEN ((MAX_PXM_DOMAINS + 1)/32)
356
357 static int __initdata srat_num_cpus;                    /* number of cpus */
358 static u32 __initdata pxm_flag[PXM_FLAG_LEN];
359 #define pxm_bit_set(bit)        (set_bit(bit,(void *)pxm_flag))
360 #define pxm_bit_test(bit)       (test_bit(bit,(void *)pxm_flag))
361 /* maps to convert between proximity domain and logical node ID */
362 int __initdata pxm_to_nid_map[MAX_PXM_DOMAINS];
363 int __initdata nid_to_pxm_map[MAX_NUMNODES];
364 static struct acpi_table_slit __initdata *slit_table;
365
366 /*
367  * ACPI 2.0 SLIT (System Locality Information Table)
368  * http://devresource.hp.com/devresource/Docs/TechPapers/IA64/slit.pdf
369  */
370 void __init
371 acpi_numa_slit_init (struct acpi_table_slit *slit)
372 {
373         u32 len;
374
375         len = sizeof(struct acpi_table_header) + 8
376                 + slit->localities * slit->localities;
377         if (slit->header.length != len) {
378                 printk(KERN_ERR "ACPI 2.0 SLIT: size mismatch: %d expected, %d actual\n",
379                        len, slit->header.length);
380                 memset(numa_slit, 10, sizeof(numa_slit));
381                 return;
382         }
383         slit_table = slit;
384 }
385
386 void __init
387 acpi_numa_processor_affinity_init (struct acpi_table_processor_affinity *pa)
388 {
389         /* record this node in proximity bitmap */
390         pxm_bit_set(pa->proximity_domain);
391
392         node_cpuid[srat_num_cpus].phys_id = (pa->apic_id << 8) | (pa->lsapic_eid);
393         /* nid should be overridden as logical node id later */
394         node_cpuid[srat_num_cpus].nid = pa->proximity_domain;
395         srat_num_cpus++;
396 }
397
398 void __init
399 acpi_numa_memory_affinity_init (struct acpi_table_memory_affinity *ma)
400 {
401         unsigned long paddr, size;
402         u8 pxm;
403         struct node_memblk_s *p, *q, *pend;
404
405         pxm = ma->proximity_domain;
406
407         /* fill node memory chunk structure */
408         paddr = ma->base_addr_hi;
409         paddr = (paddr << 32) | ma->base_addr_lo;
410         size = ma->length_hi;
411         size = (size << 32) | ma->length_lo;
412
413         /* Ignore disabled entries */
414         if (!ma->flags.enabled)
415                 return;
416
417         /* record this node in proximity bitmap */
418         pxm_bit_set(pxm);
419
420         /* Insertion sort based on base address */
421         pend = &node_memblk[num_node_memblks];
422         for (p = &node_memblk[0]; p < pend; p++) {
423                 if (paddr < p->start_paddr)
424                         break;
425         }
426         if (p < pend) {
427                 for (q = pend - 1; q >= p; q--)
428                         *(q + 1) = *q;
429         }
430         p->start_paddr = paddr;
431         p->size = size;
432         p->nid = pxm;
433         num_node_memblks++;
434 }
435
436 void __init
437 acpi_numa_arch_fixup (void)
438 {
439         int i, j, node_from, node_to;
440
441         /* If there's no SRAT, fix the phys_id and mark node 0 online */
442         if (srat_num_cpus == 0) {
443                 node_set_online(0);
444                 node_cpuid[0].phys_id = hard_smp_processor_id();
445                 return;
446         }
447
448         /* calculate total number of nodes in system from PXM bitmap */
449         numnodes = 0;           /* init total nodes in system */
450
451         memset(pxm_to_nid_map, -1, sizeof(pxm_to_nid_map));
452         memset(nid_to_pxm_map, -1, sizeof(nid_to_pxm_map));
453         for (i = 0; i < MAX_PXM_DOMAINS; i++) {
454                 if (pxm_bit_test(i)) {
455                         pxm_to_nid_map[i] = numnodes;
456                         node_set_online(numnodes);
457                         nid_to_pxm_map[numnodes++] = i;
458                 }
459         }
460
461         /* set logical node id in memory chunk structure */
462         for (i = 0; i < num_node_memblks; i++)
463                 node_memblk[i].nid = pxm_to_nid_map[node_memblk[i].nid];
464
465         /* assign memory bank numbers for each chunk on each node */
466         for (i = 0; i < numnodes; i++) {
467                 int bank;
468
469                 bank = 0;
470                 for (j = 0; j < num_node_memblks; j++)
471                         if (node_memblk[j].nid == i)
472                                 node_memblk[j].bank = bank++;
473         }
474
475         /* set logical node id in cpu structure */
476         for (i = 0; i < srat_num_cpus; i++)
477                 node_cpuid[i].nid = pxm_to_nid_map[node_cpuid[i].nid];
478
479         printk(KERN_INFO "Number of logical nodes in system = %d\n", numnodes);
480         printk(KERN_INFO "Number of memory chunks in system = %d\n", num_node_memblks);
481
482         if (!slit_table) return;
483         memset(numa_slit, -1, sizeof(numa_slit));
484         for (i=0; i<slit_table->localities; i++) {
485                 if (!pxm_bit_test(i))
486                         continue;
487                 node_from = pxm_to_nid_map[i];
488                 for (j=0; j<slit_table->localities; j++) {
489                         if (!pxm_bit_test(j))
490                                 continue;
491                         node_to = pxm_to_nid_map[j];
492                         node_distance(node_from, node_to) =
493                                 slit_table->entry[i*slit_table->localities + j];
494                 }
495         }
496
497 #ifdef SLIT_DEBUG
498         printk("ACPI 2.0 SLIT locality table:\n");
499         for (i = 0; i < numnodes; i++) {
500                 for (j = 0; j < numnodes; j++)
501                         printk("%03d ", node_distance(i,j));
502                 printk("\n");
503         }
504 #endif
505 }
506 #endif /* CONFIG_ACPI_NUMA */
507
508 unsigned int
509 acpi_register_gsi (u32 gsi, int edge_level, int active_high_low)
510 {
511         if (has_8259 && gsi < 16)
512                 return isa_irq_to_vector(gsi);
513
514         return iosapic_register_intr(gsi,
515                         (active_high_low == ACPI_ACTIVE_HIGH) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW,
516                         (edge_level == ACPI_EDGE_SENSITIVE) ? IOSAPIC_EDGE : IOSAPIC_LEVEL);
517 }
518 EXPORT_SYMBOL(acpi_register_gsi);
519
520 static int __init
521 acpi_parse_fadt (unsigned long phys_addr, unsigned long size)
522 {
523         struct acpi_table_header *fadt_header;
524         struct fadt_descriptor_rev2 *fadt;
525
526         if (!phys_addr || !size)
527                 return -EINVAL;
528
529         fadt_header = (struct acpi_table_header *) __va(phys_addr);
530         if (fadt_header->revision != 3)
531                 return -ENODEV;         /* Only deal with ACPI 2.0 FADT */
532
533         fadt = (struct fadt_descriptor_rev2 *) fadt_header;
534
535         if (!(fadt->iapc_boot_arch & BAF_8042_KEYBOARD_CONTROLLER))
536                 acpi_kbd_controller_present = 0;
537
538         if (fadt->iapc_boot_arch & BAF_LEGACY_DEVICES)
539                 acpi_legacy_devices = 1;
540
541         acpi_register_gsi(fadt->sci_int, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW);
542         return 0;
543 }
544
545
546 unsigned long __init
547 acpi_find_rsdp (void)
548 {
549         unsigned long rsdp_phys = 0;
550
551         if (efi.acpi20)
552                 rsdp_phys = __pa(efi.acpi20);
553         else if (efi.acpi)
554                 printk(KERN_WARNING PREFIX "v1.0/r0.71 tables no longer supported\n");
555         return rsdp_phys;
556 }
557
558
559 int __init
560 acpi_boot_init (void)
561 {
562
563         /*
564          * MADT
565          * ----
566          * Parse the Multiple APIC Description Table (MADT), if exists.
567          * Note that this table provides platform SMP configuration
568          * information -- the successor to MPS tables.
569          */
570
571         if (acpi_table_parse(ACPI_APIC, acpi_parse_madt) < 1) {
572                 printk(KERN_ERR PREFIX "Can't find MADT\n");
573                 goto skip_madt;
574         }
575
576         /* Local APIC */
577
578         if (acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR, acpi_parse_lapic_addr_ovr, 0) < 0)
579                 printk(KERN_ERR PREFIX "Error parsing LAPIC address override entry\n");
580
581         if (acpi_table_parse_madt(ACPI_MADT_LSAPIC, acpi_parse_lsapic, NR_CPUS) < 1)
582                 printk(KERN_ERR PREFIX "Error parsing MADT - no LAPIC entries\n");
583
584         if (acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0) < 0)
585                 printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
586
587         /* I/O APIC */
588
589         if (acpi_table_parse_madt(ACPI_MADT_IOSAPIC, acpi_parse_iosapic, NR_IOSAPICS) < 1)
590                 printk(KERN_ERR PREFIX "Error parsing MADT - no IOSAPIC entries\n");
591
592         /* System-Level Interrupt Routing */
593
594         if (acpi_table_parse_madt(ACPI_MADT_PLAT_INT_SRC, acpi_parse_plat_int_src, ACPI_MAX_PLATFORM_INTERRUPTS) < 0)
595                 printk(KERN_ERR PREFIX "Error parsing platform interrupt source entry\n");
596
597         if (acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr, 0) < 0)
598                 printk(KERN_ERR PREFIX "Error parsing interrupt source overrides entry\n");
599
600         if (acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src, 0) < 0)
601                 printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
602   skip_madt:
603
604         /*
605          * FADT says whether a legacy keyboard controller is present.
606          * The FADT also contains an SCI_INT line, by which the system
607          * gets interrupts such as power and sleep buttons.  If it's not
608          * on a Legacy interrupt, it needs to be setup.
609          */
610         if (acpi_table_parse(ACPI_FADT, acpi_parse_fadt) < 1)
611                 printk(KERN_ERR PREFIX "Can't find FADT\n");
612
613 #ifdef CONFIG_SMP
614         if (available_cpus == 0) {
615                 printk(KERN_INFO "ACPI: Found 0 CPUS; assuming 1\n");
616                 printk(KERN_INFO "CPU 0 (0x%04x)", hard_smp_processor_id());
617                 smp_boot_data.cpu_phys_id[available_cpus] = hard_smp_processor_id();
618                 available_cpus = 1; /* We've got at least one of these, no? */
619         }
620         smp_boot_data.cpu_count = available_cpus;
621
622         smp_build_cpu_map();
623 # ifdef CONFIG_ACPI_NUMA
624         if (srat_num_cpus == 0) {
625                 int cpu, i = 1;
626                 for (cpu = 0; cpu < smp_boot_data.cpu_count; cpu++)
627                         if (smp_boot_data.cpu_phys_id[cpu] != hard_smp_processor_id())
628                                 node_cpuid[i++].phys_id = smp_boot_data.cpu_phys_id[cpu];
629         }
630         build_cpu_to_node_map();
631 # endif
632 #endif
633         /* Make boot-up look pretty */
634         printk(KERN_INFO "%d CPUs available, %d CPUs total\n", available_cpus, total_cpus);
635         return 0;
636 }
637
638 int
639 acpi_gsi_to_irq (u32 gsi, unsigned int *irq)
640 {
641         int vector;
642
643         if (has_8259 && gsi < 16)
644                 *irq = isa_irq_to_vector(gsi);
645         else {
646                 vector = gsi_to_vector(gsi);
647                 if (vector == -1)
648                         return -1;
649
650                 *irq = vector;
651         }
652         return 0;
653 }
654
655 #ifdef CONFIG_NUMA
656 acpi_status __init
657 acpi_map_iosapic (acpi_handle handle, u32 depth, void *context, void **ret)
658 {
659         struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
660         union acpi_object *obj;
661         struct acpi_table_iosapic *iosapic;
662         unsigned int gsi_base;
663         int node;
664
665         /* Only care about objects w/ a method that returns the MADT */
666         if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
667                 return AE_OK;
668
669         if (!buffer.length || !buffer.pointer)
670                 return AE_OK;
671
672         obj = buffer.pointer;
673         if (obj->type != ACPI_TYPE_BUFFER ||
674             obj->buffer.length < sizeof(*iosapic)) {
675                 acpi_os_free(buffer.pointer);
676                 return AE_OK;
677         }
678
679         iosapic = (struct acpi_table_iosapic *)obj->buffer.pointer;
680
681         if (iosapic->header.type != ACPI_MADT_IOSAPIC) {
682                 acpi_os_free(buffer.pointer);
683                 return AE_OK;
684         }
685
686         gsi_base = iosapic->global_irq_base;
687
688         acpi_os_free(buffer.pointer);
689         buffer.length = ACPI_ALLOCATE_BUFFER;
690         buffer.pointer = NULL;
691
692         /*
693          * OK, it's an IOSAPIC MADT entry, look for a _PXM method to tell
694          * us which node to associate this with.
695          */
696         if (ACPI_FAILURE(acpi_evaluate_object(handle, "_PXM", NULL, &buffer)))
697                 return AE_OK;
698
699         if (!buffer.length || !buffer.pointer)
700                 return AE_OK;
701
702         obj = buffer.pointer;
703
704         if (obj->type != ACPI_TYPE_INTEGER ||
705             obj->integer.value >= MAX_PXM_DOMAINS) {
706                 acpi_os_free(buffer.pointer);
707                 return AE_OK;
708         }
709
710         node = pxm_to_nid_map[obj->integer.value];
711         acpi_os_free(buffer.pointer);
712
713         if (node >= MAX_NUMNODES || !node_online(node) ||
714             cpus_empty(node_to_cpumask(node)))
715                 return AE_OK;
716
717         /* We know a gsi to node mapping! */
718         map_iosapic_to_node(gsi_base, node);
719         return AE_OK;
720 }
721 #endif /* CONFIG_NUMA */
722 #endif /* CONFIG_ACPI_BOOT */