2 * linux/arch/m32r/mm/discontig.c
4 * Discontig memory support
6 * Copyright (c) 2003 Hitoshi Yamamoto
9 #include <linux/config.h>
11 #include <linux/bootmem.h>
12 #include <linux/mmzone.h>
13 #include <linux/initrd.h>
14 #include <linux/nodemask.h>
15 #include <linux/module.h>
17 #include <asm/setup.h>
21 struct pglist_data *node_data[MAX_NUMNODES];
22 EXPORT_SYMBOL(node_data);
23 static bootmem_data_t node_bdata[MAX_NUMNODES] __initdata;
25 pg_data_t m32r_node_data[MAX_NUMNODES];
29 unsigned long start_pfn;
32 unsigned long free_pfn;
34 static mem_prof_t mem_prof[MAX_NUMNODES];
36 static void __init mem_prof_init(void)
38 unsigned long start_pfn, holes, free_pfn;
39 const unsigned long zone_alignment = 1UL << (MAX_ORDER - 1);
45 mp->start_pfn = PFN_UP(CONFIG_MEMORY_START);
46 mp->pages = PFN_DOWN(CONFIG_MEMORY_SIZE);
48 mp->free_pfn = PFN_UP(__pa(_end));
50 /* Node#1 internal SRAM */
52 start_pfn = free_pfn = PFN_UP(CONFIG_IRAM_START);
54 if (start_pfn & (zone_alignment - 1)) {
56 while (start_pfn >= ul)
59 start_pfn = ul - zone_alignment;
60 holes = free_pfn - start_pfn;
63 mp->start_pfn = start_pfn;
64 mp->pages = PFN_DOWN(CONFIG_IRAM_SIZE) + holes;
66 mp->free_pfn = PFN_UP(CONFIG_IRAM_START);
69 unsigned long __init setup_memory(void)
71 unsigned long bootmap_size;
72 unsigned long min_pfn;
81 for_each_online_node(nid) {
83 NODE_DATA(nid)=(pg_data_t *)&m32r_node_data[nid];
84 NODE_DATA(nid)->bdata = &node_bdata[nid];
85 min_pfn = mp->start_pfn;
86 max_pfn = mp->start_pfn + mp->pages;
87 bootmap_size = init_bootmem_node(NODE_DATA(nid), mp->free_pfn,
88 mp->start_pfn, max_pfn);
90 free_bootmem_node(NODE_DATA(nid), PFN_PHYS(mp->start_pfn),
93 reserve_bootmem_node(NODE_DATA(nid), PFN_PHYS(mp->start_pfn),
94 PFN_PHYS(mp->free_pfn - mp->start_pfn) + bootmap_size);
96 if (max_low_pfn < max_pfn)
97 max_low_pfn = max_pfn;
99 if (min_low_pfn > min_pfn)
100 min_low_pfn = min_pfn;
103 #ifdef CONFIG_BLK_DEV_INITRD
104 if (LOADER_TYPE && INITRD_START) {
105 if (INITRD_START + INITRD_SIZE <= PFN_PHYS(max_low_pfn)) {
106 reserve_bootmem_node(NODE_DATA(0), INITRD_START,
108 initrd_start = INITRD_START ?
109 INITRD_START + PAGE_OFFSET : 0;
111 initrd_end = initrd_start + INITRD_SIZE;
112 printk("initrd:start[%08lx],size[%08lx]\n",
113 initrd_start, INITRD_SIZE);
115 printk("initrd extends beyond end of memory "
116 "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
117 INITRD_START + INITRD_SIZE,
118 PFN_PHYS(max_low_pfn));
123 #endif /* CONFIG_BLK_DEV_INITRD */
128 #define START_PFN(nid) \
129 (NODE_DATA(nid)->bdata->node_boot_start >> PAGE_SHIFT)
130 #define MAX_LOW_PFN(nid) (NODE_DATA(nid)->bdata->node_low_pfn)
132 unsigned long __init zone_sizes_init(void)
134 unsigned long zones_size[MAX_NR_ZONES], zholes_size[MAX_NR_ZONES];
135 unsigned long low, start_pfn;
136 unsigned long holes = 0;
141 for (nid = num_online_nodes() - 1 ; nid >= 0 ; nid--) {
142 NODE_DATA(nid)->pgdat_next = pgdat_list;
143 pgdat_list = NODE_DATA(nid);
146 for_each_online_node(nid) {
148 for (i = 0 ; i < MAX_NR_ZONES ; i++) {
152 start_pfn = START_PFN(nid);
153 low = MAX_LOW_PFN(nid);
154 zones_size[ZONE_DMA] = low - start_pfn;
155 zholes_size[ZONE_DMA] = mp->holes;
156 holes += zholes_size[ZONE_DMA];
158 free_area_init_node(nid, NODE_DATA(nid), zones_size,
159 start_pfn, zholes_size);
164 * Use all area of internal RAM.
165 * see __alloc_pages()
167 NODE_DATA(1)->node_zones->pages_min = 0;
168 NODE_DATA(1)->node_zones->pages_low = 0;
169 NODE_DATA(1)->node_zones->pages_high = 0;