9 #include <linux/types.h>
10 #include <linux/kernel.h>
16 #include <linux/module.h>
19 #include <asm/pgalloc.h>
24 #undef DEBUG_DISCONTIG
25 #ifdef DEBUG_DISCONTIG
26 #define DBGDCONT(args...) printk(args)
28 #define DBGDCONT(args...)
31 #define for_each_mem_cluster(memdesc, _cluster, i) \
32 for ((_cluster) = (memdesc)->cluster, (i) = 0; \
33 (i) < (memdesc)->numclusters; (i)++, (_cluster)++)
35 static void __init show_mem_layout(
void)
45 printk(
"Raw memory layout:\n");
47 printk(
" memcluster %2d, usage %1lx, start %8lu, end %8lu\n",
54 setup_memory_node(
int nid,
void *kernel_end)
59 unsigned long start_kernel_pfn, end_kernel_pfn;
62 unsigned long node_pfn_start, node_pfn_end;
63 unsigned long node_min_pfn, node_max_pfn;
83 if (cluster->
usage & 3)
89 if (start >= node_pfn_end || end <= node_pfn_start)
94 printk(
"Initializing bootmem allocator on Node ID %d\n", nid);
96 printk(
" memcluster %2d, usage %1lx, start %8lu, end %8lu\n",
100 if (start < node_pfn_start)
101 start = node_pfn_start;
102 if (end > node_pfn_end)
105 if (start < node_min_pfn)
106 node_min_pfn =
start;
107 if (end > node_max_pfn)
111 if (mem_size_limit && node_max_pfn > mem_size_limit) {
112 static int msg_shown = 0;
115 printk(
"setup: forcing memory size to %ldK (from %ldK).\n",
122 if (node_min_pfn >= node_max_pfn)
138 node_min_pfn += node_datasz;
139 if (node_min_pfn >= node_max_pfn) {
140 printk(
" not enough mem to reserve NODE_DATA");
145 printk(
" Detected node memory: start %8lu, end %8lu\n",
146 node_min_pfn, node_max_pfn);
149 DBGDCONT(
" DISCONTIG: NODE_DATA(%d)->bdata is at 0x%p\n", nid,
NODE_DATA(nid)->bdata);
156 if (!nid && (node_max_pfn < end_kernel_pfn || node_min_pfn > start_kernel_pfn))
157 panic(
"kernel loaded out of ram");
170 if (cluster->
usage & 3)
176 if (start >= node_max_pfn || end <= node_min_pfn)
179 if (end > node_max_pfn)
181 if (start < node_min_pfn)
182 start = node_min_pfn;
184 if (start < start_kernel_pfn) {
185 if (end > end_kernel_pfn
186 && end - end_kernel_pfn >= bootmap_pages) {
187 bootmap_start = end_kernel_pfn;
189 }
else if (end > start_kernel_pfn)
190 end = start_kernel_pfn;
191 }
else if (start < end_kernel_pfn)
192 start = end_kernel_pfn;
193 if (end - start >= bootmap_pages) {
194 bootmap_start =
start;
199 if (bootmap_start == -1)
200 panic(
"couldn't find a contiguous place for the bootmap");
204 node_min_pfn, node_max_pfn);
205 DBGDCONT(
" bootmap_start %lu, bootmap_size %lu, bootmap_pages %lu\n",
206 bootmap_start, bootmap_size, bootmap_pages);
210 if (cluster->
usage & 3)
216 if (start >= node_max_pfn || end <= node_min_pfn)
219 if (end > node_max_pfn)
221 if (start < node_min_pfn)
222 start = node_min_pfn;
224 if (start < start_kernel_pfn) {
225 if (end > end_kernel_pfn) {
229 printk(
" freeing pages %ld:%ld\n",
230 start, start_kernel_pfn);
231 start = end_kernel_pfn;
232 }
else if (end > start_kernel_pfn)
233 end = start_kernel_pfn;
234 }
else if (start < end_kernel_pfn)
235 start = end_kernel_pfn;
240 printk(
" freeing pages %ld:%ld\n", start, end);
246 printk(
" reserving pages %ld:%ld\n", bootmap_start, bootmap_start+
PFN_UP(bootmap_size));
263 setup_memory_node(nid, kernel_end);
265 #ifdef CONFIG_BLK_DEV_INITRD
268 extern void *move_initrd(
unsigned long);
271 printk(
"Initial ramdisk at: 0x%p (%lu bytes)\n",
276 printk(
"initrd extends beyond end of memory "
277 "(0x%08lx > 0x%p)\ndisabling initrd\n",
293 unsigned long zones_size[MAX_NR_ZONES] = {0, };
294 unsigned long dma_local_pfn;
310 if (dma_local_pfn >= end_pfn - start_pfn)
311 zones_size[ZONE_DMA] = end_pfn - start_pfn;
313 zones_size[ZONE_DMA] = dma_local_pfn;
314 zones_size[
ZONE_NORMAL] = (end_pfn - start_pfn) - dma_local_pfn;
326 unsigned long codesize, reservedpages, datasize, initsize, pfn;
330 unsigned long nid,
i;
347 codesize = (
unsigned long) &_etext - (
unsigned long) &_text;
348 datasize = (
unsigned long) &_edata - (
unsigned long) &_data;
349 initsize = (
unsigned long) &__init_end - (
unsigned long) &__init_begin;
351 printk(
"Memory: %luk/%luk available (%luk kernel code, %luk reserved, "
352 "%luk data, %luk init)\n",