2 * linux/arch/m68k/mm/init.c
4 * Copyright (C) 1995 Hamish Macdonald
6 * Contains common initialization routines, specific init code moved
7 * to motorola.c and sun3mmu.c
10 #include <linux/module.h>
11 #include <linux/signal.h>
12 #include <linux/sched.h>
14 #include <linux/swap.h>
15 #include <linux/kernel.h>
16 #include <linux/string.h>
17 #include <linux/types.h>
18 #include <linux/init.h>
19 #include <linux/bootmem.h>
20 #include <linux/gfp.h>
22 #include <asm/setup.h>
23 #include <asm/uaccess.h>
25 #include <asm/pgalloc.h>
26 #include <asm/system.h>
27 #include <asm/machdep.h>
30 #include <asm/atari_stram.h>
32 #include <asm/sections.h>
35 pg_data_t pg_data_map
[MAX_NUMNODES
];
36 EXPORT_SYMBOL(pg_data_map
);
38 int m68k_virt_to_node_shift
;
40 #ifndef CONFIG_SINGLE_MEMORY_CHUNK
41 pg_data_t
*pg_data_table
[65];
42 EXPORT_SYMBOL(pg_data_table
);
45 void __init
m68k_setup_node(int node
)
47 #ifndef CONFIG_SINGLE_MEMORY_CHUNK
48 struct mem_info
*info
= m68k_memory
+ node
;
51 i
= (unsigned long)phys_to_virt(info
->addr
) >> __virt_to_node_shift();
52 end
= (unsigned long)phys_to_virt(info
->addr
+ info
->size
- 1) >> __virt_to_node_shift();
53 for (; i
<= end
; i
++) {
55 printk("overlap at %u for chunk %u\n", i
, node
);
56 pg_data_table
[i
] = pg_data_map
+ node
;
59 pg_data_map
[node
].bdata
= bootmem_node_data
+ node
;
60 node_set_online(node
);
65 * ZERO_PAGE is a special page that is used for zero-initialized
69 void *empty_zero_page
;
70 EXPORT_SYMBOL(empty_zero_page
);
72 extern void init_pointer_table(unsigned long ptable
);
74 /* References to section boundaries */
76 extern pmd_t
*zero_pgtable
;
78 void __init
mem_init(void)
86 /* this will put all memory onto the freelists */
87 totalram_pages
= num_physpages
= 0;
88 for_each_online_pgdat(pgdat
) {
89 num_physpages
+= pgdat
->node_present_pages
;
91 totalram_pages
+= free_all_bootmem_node(pgdat
);
92 for (i
= 0; i
< pgdat
->node_spanned_pages
; i
++) {
93 struct page
*page
= pgdat
->node_mem_map
+ i
;
94 char *addr
= page_to_virt(page
);
96 if (!PageReserved(page
))
101 else if (addr
>= __init_begin
&&
110 /* insert pointer tables allocated so far into the tablelist */
111 init_pointer_table((unsigned long)kernel_pg_dir
);
112 for (i
= 0; i
< PTRS_PER_PGD
; i
++) {
113 if (pgd_present(kernel_pg_dir
[i
]))
114 init_pointer_table(__pgd_page(kernel_pg_dir
[i
]));
117 /* insert also pointer table that we used to unmap the zero page */
119 init_pointer_table((unsigned long)zero_pgtable
);
122 printk("Memory: %luk/%luk available (%dk kernel code, %dk data, %dk init)\n",
123 nr_free_pages() << (PAGE_SHIFT
-10),
124 totalram_pages
<< (PAGE_SHIFT
-10),
125 codepages
<< (PAGE_SHIFT
-10),
126 datapages
<< (PAGE_SHIFT
-10),
127 initpages
<< (PAGE_SHIFT
-10));
130 #ifdef CONFIG_BLK_DEV_INITRD
131 void free_initrd_mem(unsigned long start
, unsigned long end
)
134 for (; start
< end
; start
+= PAGE_SIZE
) {
135 ClearPageReserved(virt_to_page(start
));
136 init_page_count(virt_to_page(start
));
141 printk ("Freeing initrd memory: %dk freed\n", pages
);