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 | |
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')
-rw-r--r-- | arch/x86/kernel/apic_64.c | 87 | ||||
-rw-r--r-- | arch/x86/kernel/io_apic_64.c | 90 | ||||
-rw-r--r-- | arch/x86/kernel/setup_64.c | 1 |
3 files changed, 91 insertions, 87 deletions
diff --git a/arch/x86/kernel/apic_64.c b/arch/x86/kernel/apic_64.c index 0cb14d4c2c5c..e0191cdd6f7a 100644 --- a/arch/x86/kernel/apic_64.c +++ b/arch/x86/kernel/apic_64.c | |||
@@ -49,7 +49,6 @@ static int apic_calibrate_pmtmr __initdata; | |||
49 | int local_apic_timer_c2_ok; | 49 | int local_apic_timer_c2_ok; |
50 | EXPORT_SYMBOL_GPL(local_apic_timer_c2_ok); | 50 | EXPORT_SYMBOL_GPL(local_apic_timer_c2_ok); |
51 | 51 | ||
52 | static struct resource *ioapic_resources; | ||
53 | static struct resource lapic_resource = { | 52 | static struct resource lapic_resource = { |
54 | .name = "Local APIC", | 53 | .name = "Local APIC", |
55 | .flags = IORESOURCE_MEM | IORESOURCE_BUSY, | 54 | .flags = IORESOURCE_MEM | IORESOURCE_BUSY, |
@@ -714,64 +713,6 @@ static int __init detect_init_APIC (void) | |||
714 | return 0; | 713 | return 0; |
715 | } | 714 | } |
716 | 715 | ||
717 | #ifdef CONFIG_X86_IO_APIC | ||
718 | static struct resource * __init ioapic_setup_resources(void) | ||
719 | { | ||
720 | #define IOAPIC_RESOURCE_NAME_SIZE 11 | ||
721 | unsigned long n; | ||
722 | struct resource *res; | ||
723 | char *mem; | ||
724 | int i; | ||
725 | |||
726 | if (nr_ioapics <= 0) | ||
727 | return NULL; | ||
728 | |||
729 | n = IOAPIC_RESOURCE_NAME_SIZE + sizeof(struct resource); | ||
730 | n *= nr_ioapics; | ||
731 | |||
732 | mem = alloc_bootmem(n); | ||
733 | res = (void *)mem; | ||
734 | |||
735 | if (mem != NULL) { | ||
736 | memset(mem, 0, n); | ||
737 | mem += sizeof(struct resource) * nr_ioapics; | ||
738 | |||
739 | for (i = 0; i < nr_ioapics; i++) { | ||
740 | res[i].name = mem; | ||
741 | res[i].flags = IORESOURCE_MEM | IORESOURCE_BUSY; | ||
742 | sprintf(mem, "IOAPIC %u", i); | ||
743 | mem += IOAPIC_RESOURCE_NAME_SIZE; | ||
744 | } | ||
745 | } | ||
746 | |||
747 | ioapic_resources = res; | ||
748 | |||
749 | return res; | ||
750 | } | ||
751 | |||
752 | static int __init ioapic_insert_resources(void) | ||
753 | { | ||
754 | int i; | ||
755 | struct resource *r = ioapic_resources; | ||
756 | |||
757 | if (!r) { | ||
758 | printk("IO APIC resources could be not be allocated.\n"); | ||
759 | return -1; | ||
760 | } | ||
761 | |||
762 | for (i = 0; i < nr_ioapics; i++) { | ||
763 | insert_resource(&iomem_resource, r); | ||
764 | r++; | ||
765 | } | ||
766 | |||
767 | return 0; | ||
768 | } | ||
769 | |||
770 | /* Insert the IO APIC resources after PCI initialization has occured to handle | ||
771 | * IO APICS that are mapped in on a BAR in PCI space. */ | ||
772 | late_initcall(ioapic_insert_resources); | ||
773 | #endif | ||
774 | |||
775 | void __init init_apic_mappings(void) | 716 | void __init init_apic_mappings(void) |
776 | { | 717 | { |
777 | unsigned long apic_phys; | 718 | unsigned long apic_phys; |
@@ -801,34 +742,6 @@ void __init init_apic_mappings(void) | |||
801 | * default configuration (or the MP table is broken). | 742 | * default configuration (or the MP table is broken). |
802 | */ | 743 | */ |
803 | boot_cpu_id = GET_APIC_ID(apic_read(APIC_ID)); | 744 | boot_cpu_id = GET_APIC_ID(apic_read(APIC_ID)); |
804 | |||
805 | { | ||
806 | unsigned long ioapic_phys, idx = FIX_IO_APIC_BASE_0; | ||
807 | int i; | ||
808 | struct resource *ioapic_res; | ||
809 | |||
810 | ioapic_res = ioapic_setup_resources(); | ||
811 | for (i = 0; i < nr_ioapics; i++) { | ||
812 | if (smp_found_config) { | ||
813 | ioapic_phys = mp_ioapics[i].mpc_apicaddr; | ||
814 | } else { | ||
815 | ioapic_phys = (unsigned long) | ||
816 | alloc_bootmem_pages(PAGE_SIZE); | ||
817 | ioapic_phys = __pa(ioapic_phys); | ||
818 | } | ||
819 | set_fixmap_nocache(idx, ioapic_phys); | ||
820 | apic_printk(APIC_VERBOSE, | ||
821 | "mapped IOAPIC to %016lx (%016lx)\n", | ||
822 | __fix_to_virt(idx), ioapic_phys); | ||
823 | idx++; | ||
824 | |||
825 | if (ioapic_res != NULL) { | ||
826 | ioapic_res->start = ioapic_phys; | ||
827 | ioapic_res->end = ioapic_phys + (4 * 1024) - 1; | ||
828 | ioapic_res++; | ||
829 | } | ||
830 | } | ||
831 | } | ||
832 | } | 745 | } |
833 | 746 | ||
834 | /* | 747 | /* |
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 | |||
diff --git a/arch/x86/kernel/setup_64.c b/arch/x86/kernel/setup_64.c index a84a4efc7fe6..bcb5f3aaa097 100644 --- a/arch/x86/kernel/setup_64.c +++ b/arch/x86/kernel/setup_64.c | |||
@@ -433,6 +433,7 @@ void __init setup_arch(char **cmdline_p) | |||
433 | if (smp_found_config) | 433 | if (smp_found_config) |
434 | get_smp_config(); | 434 | get_smp_config(); |
435 | init_apic_mappings(); | 435 | init_apic_mappings(); |
436 | ioapic_init_mappings(); | ||
436 | 437 | ||
437 | /* | 438 | /* |
438 | * We trust e820 completely. No explicit ROM probing in memory. | 439 | * We trust e820 completely. No explicit ROM probing in memory. |