2 * linux/arch/m32r/mm/discontig.c
4 * Discontig memory support
6 * Copyright (c) 2003 Hitoshi Yamamoto
10 #include <linux/bootmem.h>
11 #include <linux/mmzone.h>
12 #include <linux/initrd.h>
13 #include <linux/nodemask.h>
14 #include <linux/module.h>
15 #include <linux/pfn.h>
17 #include <asm/setup.h>
21 struct pglist_data
*node_data
[MAX_NUMNODES
];
22 EXPORT_SYMBOL(node_data
);
24 pg_data_t m32r_node_data
[MAX_NUMNODES
];
28 unsigned long start_pfn
;
31 unsigned long free_pfn
;
33 static mem_prof_t mem_prof
[MAX_NUMNODES
];
35 static void __init
mem_prof_init(void)
37 unsigned long start_pfn
, holes
, free_pfn
;
38 const unsigned long zone_alignment
= 1UL << (MAX_ORDER
- 1);
44 mp
->start_pfn
= PFN_UP(CONFIG_MEMORY_START
);
45 mp
->pages
= PFN_DOWN(CONFIG_MEMORY_SIZE
);
47 mp
->free_pfn
= PFN_UP(__pa(_end
));
49 /* Node#1 internal SRAM */
51 start_pfn
= free_pfn
= PFN_UP(CONFIG_IRAM_START
);
53 if (start_pfn
& (zone_alignment
- 1)) {
55 while (start_pfn
>= ul
)
58 start_pfn
= ul
- zone_alignment
;
59 holes
= free_pfn
- start_pfn
;
62 mp
->start_pfn
= start_pfn
;
63 mp
->pages
= PFN_DOWN(CONFIG_IRAM_SIZE
) + holes
;
65 mp
->free_pfn
= PFN_UP(CONFIG_IRAM_START
);
68 unsigned long __init
setup_memory(void)
70 unsigned long bootmap_size
;
71 unsigned long min_pfn
;
80 for_each_online_node(nid
) {
82 NODE_DATA(nid
)=(pg_data_t
*)&m32r_node_data
[nid
];
83 NODE_DATA(nid
)->bdata
= &bootmem_node_data
[nid
];
84 min_pfn
= mp
->start_pfn
;
85 max_pfn
= mp
->start_pfn
+ mp
->pages
;
86 bootmap_size
= init_bootmem_node(NODE_DATA(nid
), mp
->free_pfn
,
87 mp
->start_pfn
, max_pfn
);
89 free_bootmem_node(NODE_DATA(nid
), PFN_PHYS(mp
->start_pfn
),
92 reserve_bootmem_node(NODE_DATA(nid
), PFN_PHYS(mp
->start_pfn
),
93 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
,
107 INITRD_SIZE
, BOOTMEM_DEFAULT
);
108 initrd_start
= INITRD_START
+ PAGE_OFFSET
;
109 initrd_end
= initrd_start
+ INITRD_SIZE
;
110 printk("initrd:start[%08lx],size[%08lx]\n",
111 initrd_start
, INITRD_SIZE
);
113 printk("initrd extends beyond end of memory "
114 "(0x%08lx > 0x%08llx)\ndisabling initrd\n",
115 INITRD_START
+ INITRD_SIZE
,
116 (unsigned long long)PFN_PHYS(max_low_pfn
));
121 #endif /* CONFIG_BLK_DEV_INITRD */
126 #define START_PFN(nid) (NODE_DATA(nid)->bdata->node_min_pfn)
127 #define MAX_LOW_PFN(nid) (NODE_DATA(nid)->bdata->node_low_pfn)
129 unsigned long __init
zone_sizes_init(void)
131 unsigned long zones_size
[MAX_NR_ZONES
], zholes_size
[MAX_NR_ZONES
];
132 unsigned long low
, start_pfn
;
133 unsigned long holes
= 0;
137 for_each_online_node(nid
) {
139 for (i
= 0 ; i
< MAX_NR_ZONES
; i
++) {
143 start_pfn
= START_PFN(nid
);
144 low
= MAX_LOW_PFN(nid
);
145 zones_size
[ZONE_DMA
] = low
- start_pfn
;
146 zholes_size
[ZONE_DMA
] = mp
->holes
;
147 holes
+= zholes_size
[ZONE_DMA
];
149 free_area_init_node(nid
, zones_size
, start_pfn
, zholes_size
);
154 * Use all area of internal RAM.
155 * see __alloc_pages()
157 NODE_DATA(1)->node_zones
->watermark
[WMARK_MIN
] = 0;
158 NODE_DATA(1)->node_zones
->watermark
[WMARK_LOW
] = 0;
159 NODE_DATA(1)->node_zones
->watermark
[WMARK_HIGH
] = 0;