x86: apic - unify smp_spurious/error_interrupt declaration
[linux-2.6/mini2440.git] / init / dyn_array.c
blobc4cd902a1180ef233aad21eb25e235e39c526d52
1 #include <linux/types.h>
2 #include <linux/kernel.h>
3 #include <linux/kallsyms.h>
4 #include <linux/init.h>
5 #include <linux/bootmem.h>
6 #include <linux/irq.h>
8 void __init pre_alloc_dyn_array(void)
10 #ifdef CONFIG_HAVE_DYN_ARRAY
11 unsigned long total_size = 0, size, phys;
12 unsigned long max_align = 1;
13 struct dyn_array **daa;
14 char *ptr;
16 /* get the total size at first */
17 for (daa = __dyn_array_start ; daa < __dyn_array_end; daa++) {
18 struct dyn_array *da = *daa;
20 size = da->size * (*da->nr);
21 print_fn_descriptor_symbol("dyn_array %s ", da->name);
22 printk(KERN_CONT "size:%#lx nr:%d align:%#lx\n",
23 da->size, *da->nr, da->align);
24 total_size += roundup(size, da->align);
25 if (da->align > max_align)
26 max_align = da->align;
28 if (total_size)
29 printk(KERN_DEBUG "dyn_array total_size: %#lx\n",
30 total_size);
31 else
32 return;
34 /* allocate them all together */
35 max_align = max_t(unsigned long, max_align, PAGE_SIZE);
36 ptr = __alloc_bootmem_nopanic(total_size, max_align, 0);
37 if (!ptr)
38 panic("Can not alloc dyn_alloc\n");
40 phys = virt_to_phys(ptr);
41 for (daa = __dyn_array_start ; daa < __dyn_array_end; daa++) {
42 struct dyn_array *da = *daa;
44 size = da->size * (*da->nr);
45 print_fn_descriptor_symbol("dyn_array %s ", da->name);
47 phys = roundup(phys, da->align);
48 *da->name = phys_to_virt(phys);
49 printk(KERN_CONT " ==> [%#lx - %#lx]\n", phys, phys + size);
51 phys += size;
53 if (da->init_work)
54 da->init_work(da);
56 #else
57 #ifdef CONFIF_GENERIC_HARDIRQS
58 unsigned int i;
60 for (i = 0; i < NR_IRQS; i++)
61 irq_desc[i].irq = i;
62 #endif
63 #endif
66 unsigned long __init per_cpu_dyn_array_size(unsigned long *align)
68 unsigned long total_size = 0;
69 #ifdef CONFIG_HAVE_DYN_ARRAY
70 unsigned long size;
71 struct dyn_array **daa;
72 unsigned max_align = 1;
74 for (daa = __per_cpu_dyn_array_start ; daa < __per_cpu_dyn_array_end; daa++) {
75 struct dyn_array *da = *daa;
77 size = da->size * (*da->nr);
78 print_fn_descriptor_symbol("per_cpu_dyn_array %s ", da->name);
79 printk(KERN_CONT "size:%#lx nr:%d align:%#lx\n",
80 da->size, *da->nr, da->align);
81 total_size += roundup(size, da->align);
82 if (da->align > max_align)
83 max_align = da->align;
85 if (total_size) {
86 printk(KERN_DEBUG "per_cpu_dyn_array total_size: %#lx\n",
87 total_size);
88 *align = max_align;
90 #endif
91 return total_size;
94 void __init per_cpu_alloc_dyn_array(int cpu, char *ptr)
96 #ifdef CONFIG_HAVE_DYN_ARRAY
97 unsigned long size, phys;
98 struct dyn_array **daa;
99 unsigned long addr;
100 void **array;
102 phys = virt_to_phys(ptr);
103 for (daa = __per_cpu_dyn_array_start ; daa < __per_cpu_dyn_array_end; daa++) {
104 struct dyn_array *da = *daa;
106 size = da->size * (*da->nr);
107 print_fn_descriptor_symbol("per_cpu_dyn_array %s ", da->name);
109 phys = roundup(phys, da->align);
110 addr = (unsigned long)da->name;
111 addr += per_cpu_offset(cpu);
112 array = (void **)addr;
113 *array = phys_to_virt(phys);
114 *da->name = *array; /* so init_work could use it directly */
115 printk(KERN_CONT " ==> [%#lx - %#lx]\n", phys, phys + size);
117 phys += size;
119 if (da->init_work) {
120 da->init_work(da);
123 #endif