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>
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
;
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
;
29 printk(KERN_DEBUG
"dyn_array total_size: %#lx\n",
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);
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
);
57 #ifdef CONFIF_GENERIC_HARDIRQS
60 for (i
= 0; i
< NR_IRQS
; i
++)
66 unsigned long __init
per_cpu_dyn_array_size(unsigned long *align
)
68 unsigned long total_size
= 0;
69 #ifdef CONFIG_HAVE_DYN_ARRAY
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
;
86 printk(KERN_DEBUG
"per_cpu_dyn_array total_size: %#lx\n",
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
;
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
);