1 // SPDX-License-Identifier: GPL-2.0
3 * linux/arch/m32r/mm/discontig.c
5 * Discontig memory support
7 * Copyright (c) 2003 Hitoshi Yamamoto
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>
16 #include <linux/pfn.h>
18 #include <asm/setup.h>
22 struct pglist_data
*node_data
[MAX_NUMNODES
];
23 EXPORT_SYMBOL(node_data
);
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 extern unsigned long memory_start
;
37 extern unsigned long memory_end
;
39 static void __init
mem_prof_init(void)
41 unsigned long start_pfn
, holes
, free_pfn
;
42 const unsigned long zone_alignment
= 1UL << (MAX_ORDER
- 1);
48 mp
->start_pfn
= PFN_UP(CONFIG_MEMORY_START
);
49 mp
->pages
= PFN_DOWN(memory_end
- memory_start
);
51 mp
->free_pfn
= PFN_UP(__pa(_end
));
53 /* Node#1 internal SRAM */
55 start_pfn
= free_pfn
= PFN_UP(CONFIG_IRAM_START
);
57 if (start_pfn
& (zone_alignment
- 1)) {
59 while (start_pfn
>= ul
)
62 start_pfn
= ul
- zone_alignment
;
63 holes
= free_pfn
- start_pfn
;
66 mp
->start_pfn
= start_pfn
;
67 mp
->pages
= PFN_DOWN(CONFIG_IRAM_SIZE
) + holes
;
69 mp
->free_pfn
= PFN_UP(CONFIG_IRAM_START
);
72 unsigned long __init
setup_memory(void)
74 unsigned long bootmap_size
;
75 unsigned long min_pfn
;
84 for_each_online_node(nid
) {
86 NODE_DATA(nid
)=(pg_data_t
*)&m32r_node_data
[nid
];
87 NODE_DATA(nid
)->bdata
= &bootmem_node_data
[nid
];
88 min_pfn
= mp
->start_pfn
;
89 max_pfn
= mp
->start_pfn
+ mp
->pages
;
90 bootmap_size
= init_bootmem_node(NODE_DATA(nid
), mp
->free_pfn
,
91 mp
->start_pfn
, max_pfn
);
93 free_bootmem_node(NODE_DATA(nid
), PFN_PHYS(mp
->start_pfn
),
96 reserve_bootmem_node(NODE_DATA(nid
), PFN_PHYS(mp
->start_pfn
),
97 PFN_PHYS(mp
->free_pfn
- mp
->start_pfn
) + bootmap_size
,
100 if (max_low_pfn
< max_pfn
)
101 max_low_pfn
= max_pfn
;
103 if (min_low_pfn
> min_pfn
)
104 min_low_pfn
= min_pfn
;
107 #ifdef CONFIG_BLK_DEV_INITRD
108 if (LOADER_TYPE
&& INITRD_START
) {
109 if (INITRD_START
+ INITRD_SIZE
<= PFN_PHYS(max_low_pfn
)) {
110 reserve_bootmem_node(NODE_DATA(0), INITRD_START
,
111 INITRD_SIZE
, BOOTMEM_DEFAULT
);
112 initrd_start
= INITRD_START
+ PAGE_OFFSET
;
113 initrd_end
= initrd_start
+ INITRD_SIZE
;
114 printk("initrd:start[%08lx],size[%08lx]\n",
115 initrd_start
, INITRD_SIZE
);
117 printk("initrd extends beyond end of memory "
118 "(0x%08lx > 0x%08llx)\ndisabling initrd\n",
119 INITRD_START
+ INITRD_SIZE
,
120 (unsigned long long)PFN_PHYS(max_low_pfn
));
125 #endif /* CONFIG_BLK_DEV_INITRD */
130 #define START_PFN(nid) (NODE_DATA(nid)->bdata->node_min_pfn)
131 #define MAX_LOW_PFN(nid) (NODE_DATA(nid)->bdata->node_low_pfn)
133 void __init
zone_sizes_init(void)
135 unsigned long zones_size
[MAX_NR_ZONES
], zholes_size
[MAX_NR_ZONES
];
136 unsigned long low
, start_pfn
;
140 for_each_online_node(nid
) {
142 for (i
= 0 ; i
< MAX_NR_ZONES
; i
++) {
146 start_pfn
= START_PFN(nid
);
147 low
= MAX_LOW_PFN(nid
);
148 zones_size
[ZONE_DMA
] = low
- start_pfn
;
149 zholes_size
[ZONE_DMA
] = mp
->holes
;
151 node_set_state(nid
, N_NORMAL_MEMORY
);
152 free_area_init_node(nid
, zones_size
, start_pfn
, zholes_size
);
157 * Use all area of internal RAM.
158 * see __alloc_pages()
160 NODE_DATA(1)->node_zones
->watermark
[WMARK_MIN
] = 0;
161 NODE_DATA(1)->node_zones
->watermark
[WMARK_LOW
] = 0;
162 NODE_DATA(1)->node_zones
->watermark
[WMARK_HIGH
] = 0;