diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2008-01-30 07:30:19 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:30:19 -0500 |
commit | 3e35a0e525253837fc0ea4d0e060de3302bd9537 (patch) | |
tree | bb7afd99762bd691866a934b23ddcf8e92ce8f2f /arch/x86/kernel/io_apic_64.c | |
parent | 84c873ed2a00eab3e8ac49dc7889d7aad142ce22 (diff) |
x86: move ioapic code where it belongs
The commit 399287229c775a8962a852a761d65dc9475dec7c hacked the
ioapic resource mapping into apic.c for no good reason.
Move the code into io_apic_64.c where it belongs.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/io_apic_64.c')
-rw-r--r-- | arch/x86/kernel/io_apic_64.c | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/arch/x86/kernel/io_apic_64.c b/arch/x86/kernel/io_apic_64.c index d4f5286101a9..c6de7854ac63 100644 --- a/arch/x86/kernel/io_apic_64.c +++ b/arch/x86/kernel/io_apic_64.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #ifdef CONFIG_ACPI | 35 | #ifdef CONFIG_ACPI |
36 | #include <acpi/acpi_bus.h> | 36 | #include <acpi/acpi_bus.h> |
37 | #endif | 37 | #endif |
38 | #include <linux/bootmem.h> | ||
38 | 39 | ||
39 | #include <asm/idle.h> | 40 | #include <asm/idle.h> |
40 | #include <asm/io.h> | 41 | #include <asm/io.h> |
@@ -2288,3 +2289,92 @@ void __init setup_ioapic_dest(void) | |||
2288 | } | 2289 | } |
2289 | #endif | 2290 | #endif |
2290 | 2291 | ||
2292 | #define IOAPIC_RESOURCE_NAME_SIZE 11 | ||
2293 | |||
2294 | static struct resource *ioapic_resources; | ||
2295 | |||
2296 | static struct resource * __init ioapic_setup_resources(void) | ||
2297 | { | ||
2298 | unsigned long n; | ||
2299 | struct resource *res; | ||
2300 | char *mem; | ||
2301 | int i; | ||
2302 | |||
2303 | if (nr_ioapics <= 0) | ||
2304 | return NULL; | ||
2305 | |||
2306 | n = IOAPIC_RESOURCE_NAME_SIZE + sizeof(struct resource); | ||
2307 | n *= nr_ioapics; | ||
2308 | |||
2309 | mem = alloc_bootmem(n); | ||
2310 | res = (void *)mem; | ||
2311 | |||
2312 | if (mem != NULL) { | ||
2313 | memset(mem, 0, n); | ||
2314 | mem += sizeof(struct resource) * nr_ioapics; | ||
2315 | |||
2316 | for (i = 0; i < nr_ioapics; i++) { | ||
2317 | res[i].name = mem; | ||
2318 | res[i].flags = IORESOURCE_MEM | IORESOURCE_BUSY; | ||
2319 | sprintf(mem, "IOAPIC %u", i); | ||
2320 | mem += IOAPIC_RESOURCE_NAME_SIZE; | ||
2321 | } | ||
2322 | } | ||
2323 | |||
2324 | ioapic_resources = res; | ||
2325 | |||
2326 | return res; | ||
2327 | } | ||
2328 | |||
2329 | void __init ioapic_init_mappings(void) | ||
2330 | { | ||
2331 | unsigned long ioapic_phys, idx = FIX_IO_APIC_BASE_0; | ||
2332 | struct resource *ioapic_res; | ||
2333 | int i; | ||
2334 | |||
2335 | ioapic_res = ioapic_setup_resources(); | ||
2336 | for (i = 0; i < nr_ioapics; i++) { | ||
2337 | if (smp_found_config) { | ||
2338 | ioapic_phys = mp_ioapics[i].mpc_apicaddr; | ||
2339 | } else { | ||
2340 | ioapic_phys = (unsigned long) | ||
2341 | alloc_bootmem_pages(PAGE_SIZE); | ||
2342 | ioapic_phys = __pa(ioapic_phys); | ||
2343 | } | ||
2344 | set_fixmap_nocache(idx, ioapic_phys); | ||
2345 | apic_printk(APIC_VERBOSE, | ||
2346 | "mapped IOAPIC to %016lx (%016lx)\n", | ||
2347 | __fix_to_virt(idx), ioapic_phys); | ||
2348 | idx++; | ||
2349 | |||
2350 | if (ioapic_res != NULL) { | ||
2351 | ioapic_res->start = ioapic_phys; | ||
2352 | ioapic_res->end = ioapic_phys + (4 * 1024) - 1; | ||
2353 | ioapic_res++; | ||
2354 | } | ||
2355 | } | ||
2356 | } | ||
2357 | |||
2358 | static int __init ioapic_insert_resources(void) | ||
2359 | { | ||
2360 | int i; | ||
2361 | struct resource *r = ioapic_resources; | ||
2362 | |||
2363 | if (!r) { | ||
2364 | printk(KERN_ERR | ||
2365 | "IO APIC resources could be not be allocated.\n"); | ||
2366 | return -1; | ||
2367 | } | ||
2368 | |||
2369 | for (i = 0; i < nr_ioapics; i++) { | ||
2370 | insert_resource(&iomem_resource, r); | ||
2371 | r++; | ||
2372 | } | ||
2373 | |||
2374 | return 0; | ||
2375 | } | ||
2376 | |||
2377 | /* Insert the IO APIC resources after PCI initialization has occured to handle | ||
2378 | * IO APICS that are mapped in on a BAR in PCI space. */ | ||
2379 | late_initcall(ioapic_insert_resources); | ||
2380 | |||