ia64/xen-unstable

view xen/drivers/acpi/numa.c @ 14230:aae662fdf53e

xen: Fix ACPI SLIT/SRAT parsing to correctly map highmem.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Mon Mar 05 10:37:01 2007 +0000 (2007-03-05)
parents f312c2d01d8b
children 13cba2e78a65
line source
1 /*
2 * acpi_numa.c - ACPI NUMA support
3 *
4 * Copyright (C) 2002 Takayoshi Kochi <t-kochi@bq.jp.nec.com>
5 *
6 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 *
24 */
25 #include <xen/config.h>
26 #include <xen/init.h>
27 #include <xen/types.h>
28 #include <xen/errno.h>
29 #include <xen/acpi.h>
30 #include <xen/numa.h>
31 #include <acpi/acpi_bus.h>
32 #include <acpi/acmacros.h>
34 #define ACPI_NUMA 0x80000000
35 #define _COMPONENT ACPI_NUMA
36 ACPI_MODULE_NAME("numa")
38 extern int __init acpi_table_parse_madt_family(enum acpi_table_id id,
39 unsigned long madt_size,
40 int entry_id,
41 acpi_madt_entry_handler handler,
42 unsigned int max_entries);
44 void __init acpi_table_print_srat_entry(acpi_table_entry_header * header)
45 {
47 ACPI_FUNCTION_NAME("acpi_table_print_srat_entry");
49 if (!header)
50 return;
52 switch (header->type) {
54 case ACPI_SRAT_PROCESSOR_AFFINITY:
55 #ifdef ACPI_DEBUG_OUTPUT
56 {
57 struct acpi_table_processor_affinity *p =
58 (struct acpi_table_processor_affinity *)header;
59 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
60 "SRAT Processor (id[0x%02x] eid[0x%02x]) in proximity domain %d %s\n",
61 p->apic_id, p->lsapic_eid,
62 p->proximity_domain,
63 p->flags.
64 enabled ? "enabled" : "disabled"));
65 }
66 #endif /* ACPI_DEBUG_OUTPUT */
67 break;
69 case ACPI_SRAT_MEMORY_AFFINITY:
70 #ifdef ACPI_DEBUG_OUTPUT
71 {
72 struct acpi_table_memory_affinity *p =
73 (struct acpi_table_memory_affinity *)header;
74 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
75 "SRAT Memory (0x%08x%08x length 0x%08x%08x type 0x%x) in proximity domain %d %s%s\n",
76 p->base_addr_hi, p->base_addr_lo,
77 p->length_hi, p->length_lo,
78 p->memory_type, p->proximity_domain,
79 p->flags.
80 enabled ? "enabled" : "disabled",
81 p->flags.
82 hot_pluggable ? " hot-pluggable" :
83 ""));
84 }
85 #endif /* ACPI_DEBUG_OUTPUT */
86 break;
88 default:
89 printk(KERN_WARNING PREFIX
90 "Found unsupported SRAT entry (type = 0x%x)\n",
91 header->type);
92 break;
93 }
94 }
96 static int __init acpi_parse_slit(unsigned long phys_addr, unsigned long size)
97 {
98 struct acpi_table_slit *slit;
99 u32 localities;
101 if (!phys_addr || !size)
102 return -EINVAL;
104 slit = (struct acpi_table_slit *)__acpi_map_table(phys_addr, size);
106 /* downcast just for %llu vs %lu for i386/ia64 */
107 localities = (u32) slit->localities;
109 acpi_numa_slit_init(slit);
111 return 0;
112 }
114 static int __init
115 acpi_parse_processor_affinity(acpi_table_entry_header * header,
116 const unsigned long end)
117 {
118 struct acpi_table_processor_affinity *processor_affinity;
120 processor_affinity = (struct acpi_table_processor_affinity *)header;
121 if (!processor_affinity)
122 return -EINVAL;
124 acpi_table_print_srat_entry(header);
126 /* let architecture-dependent part to do it */
127 acpi_numa_processor_affinity_init(processor_affinity);
129 return 0;
130 }
132 static int __init
133 acpi_parse_memory_affinity(acpi_table_entry_header * header,
134 const unsigned long end)
135 {
136 struct acpi_table_memory_affinity *memory_affinity;
138 memory_affinity = (struct acpi_table_memory_affinity *)header;
139 if (!memory_affinity)
140 return -EINVAL;
142 acpi_table_print_srat_entry(header);
144 /* let architecture-dependent part to do it */
145 acpi_numa_memory_affinity_init(memory_affinity);
147 return 0;
148 }
150 static int __init acpi_parse_srat(unsigned long phys_addr, unsigned long size)
151 {
152 struct acpi_table_srat *srat;
154 if (!phys_addr || !size)
155 return -EINVAL;
157 srat = (struct acpi_table_srat *)__acpi_map_table(phys_addr, size);
159 return 0;
160 }
162 int __init
163 acpi_table_parse_srat(enum acpi_srat_entry_id id,
164 acpi_madt_entry_handler handler, unsigned int max_entries)
165 {
166 return acpi_table_parse_madt_family(ACPI_SRAT,
167 sizeof(struct acpi_table_srat), id,
168 handler, max_entries);
169 }
171 int __init acpi_numa_init(void)
172 {
173 int result;
175 /* SRAT: Static Resource Affinity Table */
176 result = acpi_table_parse(ACPI_SRAT, acpi_parse_srat);
178 if (result > 0) {
179 result = acpi_table_parse_srat(ACPI_SRAT_PROCESSOR_AFFINITY,
180 acpi_parse_processor_affinity,
181 NR_CPUS);
182 result = acpi_table_parse_srat(ACPI_SRAT_MEMORY_AFFINITY, acpi_parse_memory_affinity, NR_NODE_MEMBLKS); // IA64 specific
183 }
185 /* SLIT: System Locality Information Table */
186 result = acpi_table_parse(ACPI_SLIT, acpi_parse_slit);
188 acpi_numa_arch_fixup();
189 return 0;
190 }
192 #if 0
193 int acpi_get_pxm(acpi_handle h)
194 {
195 unsigned long pxm;
196 acpi_status status;
197 acpi_handle handle;
198 acpi_handle phandle = h;
200 do {
201 handle = phandle;
202 status = acpi_evaluate_integer(handle, "_PXM", NULL, &pxm);
203 if (ACPI_SUCCESS(status))
204 return (int)pxm;
205 status = acpi_get_parent(handle, &phandle);
206 } while (ACPI_SUCCESS(status));
207 return -1;
208 }
210 EXPORT_SYMBOL(acpi_get_pxm);
211 #endif