diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/m32r/mm/discontig.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/m32r/mm/discontig.c')
-rw-r--r-- | arch/m32r/mm/discontig.c | 171 |
1 files changed, 171 insertions, 0 deletions
diff --git a/arch/m32r/mm/discontig.c b/arch/m32r/mm/discontig.c new file mode 100644 index 000000000000..1d1a01e54b3f --- /dev/null +++ b/arch/m32r/mm/discontig.c | |||
@@ -0,0 +1,171 @@ | |||
1 | /* | ||
2 | * linux/arch/m32r/mm/discontig.c | ||
3 | * | ||
4 | * Discontig memory support | ||
5 | * | ||
6 | * Copyright (c) 2003 Hitoshi Yamamoto | ||
7 | */ | ||
8 | |||
9 | #include <linux/config.h> | ||
10 | #include <linux/mm.h> | ||
11 | #include <linux/bootmem.h> | ||
12 | #include <linux/mmzone.h> | ||
13 | #include <linux/initrd.h> | ||
14 | #include <linux/nodemask.h> | ||
15 | |||
16 | #include <asm/setup.h> | ||
17 | |||
18 | extern char _end[]; | ||
19 | |||
20 | struct pglist_data *node_data[MAX_NUMNODES]; | ||
21 | static bootmem_data_t node_bdata[MAX_NUMNODES] __initdata; | ||
22 | |||
23 | pg_data_t m32r_node_data[MAX_NUMNODES]; | ||
24 | |||
25 | /* Memory profile */ | ||
26 | typedef struct { | ||
27 | unsigned long start_pfn; | ||
28 | unsigned long pages; | ||
29 | unsigned long holes; | ||
30 | unsigned long free_pfn; | ||
31 | } mem_prof_t; | ||
32 | static mem_prof_t mem_prof[MAX_NUMNODES]; | ||
33 | |||
34 | static void __init mem_prof_init(void) | ||
35 | { | ||
36 | unsigned long start_pfn, holes, free_pfn; | ||
37 | const unsigned long zone_alignment = 1UL << (MAX_ORDER - 1); | ||
38 | unsigned long ul; | ||
39 | mem_prof_t *mp; | ||
40 | |||
41 | /* Node#0 SDRAM */ | ||
42 | mp = &mem_prof[0]; | ||
43 | mp->start_pfn = PFN_UP(CONFIG_MEMORY_START); | ||
44 | mp->pages = PFN_DOWN(CONFIG_MEMORY_SIZE); | ||
45 | mp->holes = 0; | ||
46 | mp->free_pfn = PFN_UP(__pa(_end)); | ||
47 | |||
48 | /* Node#1 internal SRAM */ | ||
49 | mp = &mem_prof[1]; | ||
50 | start_pfn = free_pfn = PFN_UP(CONFIG_IRAM_START); | ||
51 | holes = 0; | ||
52 | if (start_pfn & (zone_alignment - 1)) { | ||
53 | ul = zone_alignment; | ||
54 | while (start_pfn >= ul) | ||
55 | ul += zone_alignment; | ||
56 | |||
57 | start_pfn = ul - zone_alignment; | ||
58 | holes = free_pfn - start_pfn; | ||
59 | } | ||
60 | |||
61 | mp->start_pfn = start_pfn; | ||
62 | mp->pages = PFN_DOWN(CONFIG_IRAM_SIZE) + holes; | ||
63 | mp->holes = holes; | ||
64 | mp->free_pfn = PFN_UP(CONFIG_IRAM_START); | ||
65 | } | ||
66 | |||
67 | unsigned long __init setup_memory(void) | ||
68 | { | ||
69 | unsigned long bootmap_size; | ||
70 | unsigned long min_pfn; | ||
71 | int nid; | ||
72 | mem_prof_t *mp; | ||
73 | |||
74 | max_low_pfn = 0; | ||
75 | min_low_pfn = -1; | ||
76 | |||
77 | mem_prof_init(); | ||
78 | |||
79 | for_each_online_node(nid) { | ||
80 | mp = &mem_prof[nid]; | ||
81 | NODE_DATA(nid)=(pg_data_t *)&m32r_node_data[nid]; | ||
82 | NODE_DATA(nid)->bdata = &node_bdata[nid]; | ||
83 | min_pfn = mp->start_pfn; | ||
84 | max_pfn = mp->start_pfn + mp->pages; | ||
85 | bootmap_size = init_bootmem_node(NODE_DATA(nid), mp->free_pfn, | ||
86 | mp->start_pfn, max_pfn); | ||
87 | |||
88 | free_bootmem_node(NODE_DATA(nid), PFN_PHYS(mp->start_pfn), | ||
89 | PFN_PHYS(mp->pages)); | ||
90 | |||
91 | reserve_bootmem_node(NODE_DATA(nid), PFN_PHYS(mp->start_pfn), | ||
92 | PFN_PHYS(mp->free_pfn - mp->start_pfn) + bootmap_size); | ||
93 | |||
94 | if (max_low_pfn < max_pfn) | ||
95 | max_low_pfn = max_pfn; | ||
96 | |||
97 | if (min_low_pfn > min_pfn) | ||
98 | min_low_pfn = min_pfn; | ||
99 | } | ||
100 | |||
101 | #ifdef CONFIG_BLK_DEV_INITRD | ||
102 | if (LOADER_TYPE && INITRD_START) { | ||
103 | if (INITRD_START + INITRD_SIZE <= PFN_PHYS(max_low_pfn)) { | ||
104 | reserve_bootmem_node(NODE_DATA(0), INITRD_START, | ||
105 | INITRD_SIZE); | ||
106 | initrd_start = INITRD_START ? | ||
107 | INITRD_START + PAGE_OFFSET : 0; | ||
108 | |||
109 | initrd_end = initrd_start + INITRD_SIZE; | ||
110 | printk("initrd:start[%08lx],size[%08lx]\n", | ||
111 | initrd_start, INITRD_SIZE); | ||
112 | } else { | ||
113 | printk("initrd extends beyond end of memory " | ||
114 | "(0x%08lx > 0x%08lx)\ndisabling initrd\n", | ||
115 | INITRD_START + INITRD_SIZE, | ||
116 | PFN_PHYS(max_low_pfn)); | ||
117 | |||
118 | initrd_start = 0; | ||
119 | } | ||
120 | } | ||
121 | #endif /* CONFIG_BLK_DEV_INITRD */ | ||
122 | |||
123 | return max_low_pfn; | ||
124 | } | ||
125 | |||
126 | #define START_PFN(nid) \ | ||
127 | (NODE_DATA(nid)->bdata->node_boot_start >> PAGE_SHIFT) | ||
128 | #define MAX_LOW_PFN(nid) (NODE_DATA(nid)->bdata->node_low_pfn) | ||
129 | |||
130 | unsigned long __init zone_sizes_init(void) | ||
131 | { | ||
132 | unsigned long zones_size[MAX_NR_ZONES], zholes_size[MAX_NR_ZONES]; | ||
133 | unsigned long low, start_pfn; | ||
134 | unsigned long holes = 0; | ||
135 | int nid, i; | ||
136 | mem_prof_t *mp; | ||
137 | |||
138 | pgdat_list = NULL; | ||
139 | for (nid = num_online_nodes() - 1 ; nid >= 0 ; nid--) { | ||
140 | NODE_DATA(nid)->pgdat_next = pgdat_list; | ||
141 | pgdat_list = NODE_DATA(nid); | ||
142 | } | ||
143 | |||
144 | for_each_online_node(nid) { | ||
145 | mp = &mem_prof[nid]; | ||
146 | for (i = 0 ; i < MAX_NR_ZONES ; i++) { | ||
147 | zones_size[i] = 0; | ||
148 | zholes_size[i] = 0; | ||
149 | } | ||
150 | start_pfn = START_PFN(nid); | ||
151 | low = MAX_LOW_PFN(nid); | ||
152 | zones_size[ZONE_DMA] = low - start_pfn; | ||
153 | zholes_size[ZONE_DMA] = mp->holes; | ||
154 | holes += zholes_size[ZONE_DMA]; | ||
155 | |||
156 | free_area_init_node(nid, NODE_DATA(nid), zones_size, | ||
157 | start_pfn, zholes_size); | ||
158 | } | ||
159 | |||
160 | /* | ||
161 | * For test | ||
162 | * Use all area of internal RAM. | ||
163 | * see __alloc_pages() | ||
164 | */ | ||
165 | NODE_DATA(1)->node_zones->pages_min = 0; | ||
166 | NODE_DATA(1)->node_zones->pages_low = 0; | ||
167 | NODE_DATA(1)->node_zones->pages_high = 0; | ||
168 | |||
169 | return holes; | ||
170 | } | ||
171 | |||