aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorYinghai Lu <yhlu.kernel@gmail.com>2008-06-23 15:00:45 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-08 06:50:18 -0400
commit90d967e0ef68f5312ed4b081d5c9312ff53c1c93 (patch)
tree1708f6209d77699ed09c6a6edc057159aa5b1165 /arch
parent7f0be02c5ed1deb04c54c6a17f412e04f417df11 (diff)
x86: move find_max_low_pfn to init_32.c
Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kernel/setup_32.c77
-rw-r--r--arch/x86/mm/init_32.c89
2 files changed, 88 insertions, 78 deletions
diff --git a/arch/x86/kernel/setup_32.c b/arch/x86/kernel/setup_32.c
index 3149f434d7d0..13155009ce94 100644
--- a/arch/x86/kernel/setup_32.c
+++ b/arch/x86/kernel/setup_32.c
@@ -129,9 +129,6 @@ unsigned int BIOS_revision;
129/* Boot loader ID as an integer, for the benefit of proc_dointvec */ 129/* Boot loader ID as an integer, for the benefit of proc_dointvec */
130int bootloader_type; 130int bootloader_type;
131 131
132/* user-defined highmem size */
133static unsigned int highmem_pages = -1;
134
135/* 132/*
136 * Early DMI memory 133 * Early DMI memory
137 */ 134 */
@@ -188,21 +185,6 @@ static inline void copy_edd(void)
188#endif 185#endif
189 186
190/* 187/*
191 * highmem=size forces highmem to be exactly 'size' bytes.
192 * This works even on boxes that have no highmem otherwise.
193 * This also works to reduce highmem size on bigger boxes.
194 */
195static int __init parse_highmem(char *arg)
196{
197 if (!arg)
198 return -EINVAL;
199
200 highmem_pages = memparse(arg, &arg) >> PAGE_SHIFT;
201 return 0;
202}
203early_param("highmem", parse_highmem);
204
205/*
206 * vmalloc=size forces the vmalloc area to be exactly 'size' 188 * vmalloc=size forces the vmalloc area to be exactly 'size'
207 * bytes. This can be used to increase (or decrease) the 189 * bytes. This can be used to increase (or decrease) the
208 * vmalloc area - the default is 128m. 190 * vmalloc area - the default is 128m.
@@ -235,65 +217,6 @@ static int __init parse_reservetop(char *arg)
235} 217}
236early_param("reservetop", parse_reservetop); 218early_param("reservetop", parse_reservetop);
237 219
238/*
239 * Determine low and high memory ranges:
240 */
241unsigned long __init find_max_low_pfn(void)
242{
243 unsigned long max_low_pfn;
244
245 max_low_pfn = max_pfn;
246 if (max_low_pfn > MAXMEM_PFN) {
247 if (highmem_pages == -1)
248 highmem_pages = max_pfn - MAXMEM_PFN;
249 if (highmem_pages + MAXMEM_PFN < max_pfn)
250 max_pfn = MAXMEM_PFN + highmem_pages;
251 if (highmem_pages + MAXMEM_PFN > max_pfn) {
252 printk("only %luMB highmem pages available, ignoring highmem size of %uMB.\n", pages_to_mb(max_pfn - MAXMEM_PFN), pages_to_mb(highmem_pages));
253 highmem_pages = 0;
254 }
255 max_low_pfn = MAXMEM_PFN;
256#ifndef CONFIG_HIGHMEM
257 /* Maximum memory usable is what is directly addressable */
258 printk(KERN_WARNING "Warning only %ldMB will be used.\n",
259 MAXMEM>>20);
260 if (max_pfn > MAX_NONPAE_PFN)
261 printk(KERN_WARNING "Use a HIGHMEM64G enabled kernel.\n");
262 else
263 printk(KERN_WARNING "Use a HIGHMEM enabled kernel.\n");
264 max_pfn = MAXMEM_PFN;
265#else /* !CONFIG_HIGHMEM */
266#ifndef CONFIG_HIGHMEM64G
267 if (max_pfn > MAX_NONPAE_PFN) {
268 max_pfn = MAX_NONPAE_PFN;
269 printk(KERN_WARNING "Warning only 4GB will be used.\n");
270 printk(KERN_WARNING "Use a HIGHMEM64G enabled kernel.\n");
271 }
272#endif /* !CONFIG_HIGHMEM64G */
273#endif /* !CONFIG_HIGHMEM */
274 } else {
275 if (highmem_pages == -1)
276 highmem_pages = 0;
277#ifdef CONFIG_HIGHMEM
278 if (highmem_pages >= max_pfn) {
279 printk(KERN_ERR "highmem size specified (%uMB) is bigger than pages available (%luMB)!.\n", pages_to_mb(highmem_pages), pages_to_mb(max_pfn));
280 highmem_pages = 0;
281 }
282 if (highmem_pages) {
283 if (max_low_pfn-highmem_pages < 64*1024*1024/PAGE_SIZE){
284 printk(KERN_ERR "highmem size %uMB results in smaller than 64MB lowmem, ignoring it.\n", pages_to_mb(highmem_pages));
285 highmem_pages = 0;
286 }
287 max_low_pfn -= highmem_pages;
288 }
289#else
290 if (highmem_pages)
291 printk(KERN_ERR "ignoring highmem size on non-highmem kernel!\n");
292#endif
293 }
294 return max_low_pfn;
295}
296
297#ifdef CONFIG_BLK_DEV_INITRD 220#ifdef CONFIG_BLK_DEV_INITRD
298 221
299static bool do_relocate_initrd = false; 222static bool do_relocate_initrd = false;
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 98080782ee47..d1017336f1b5 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -540,8 +540,95 @@ static void __init set_nx(void)
540} 540}
541#endif 541#endif
542 542
543/* user-defined highmem size */
544static unsigned int highmem_pages = -1;
545
546/*
547 * highmem=size forces highmem to be exactly 'size' bytes.
548 * This works even on boxes that have no highmem otherwise.
549 * This also works to reduce highmem size on bigger boxes.
550 */
551static int __init parse_highmem(char *arg)
552{
553 if (!arg)
554 return -EINVAL;
555
556 highmem_pages = memparse(arg, &arg) >> PAGE_SHIFT;
557 return 0;
558}
559early_param("highmem", parse_highmem);
560
561/*
562 * Determine low and high memory ranges:
563 */
564unsigned long __init find_max_low_pfn(void)
565{
566 unsigned long max_low_pfn;
567
568 max_low_pfn = max_pfn;
569 if (max_low_pfn > MAXMEM_PFN) {
570 if (highmem_pages == -1)
571 highmem_pages = max_pfn - MAXMEM_PFN;
572 if (highmem_pages + MAXMEM_PFN < max_pfn)
573 max_pfn = MAXMEM_PFN + highmem_pages;
574 if (highmem_pages + MAXMEM_PFN > max_pfn) {
575 printk(KERN_WARNING "only %luMB highmem pages "
576 "available, ignoring highmem size of %uMB.\n",
577 pages_to_mb(max_pfn - MAXMEM_PFN),
578 pages_to_mb(highmem_pages));
579 highmem_pages = 0;
580 }
581 max_low_pfn = MAXMEM_PFN;
582#ifndef CONFIG_HIGHMEM
583 /* Maximum memory usable is what is directly addressable */
584 printk(KERN_WARNING "Warning only %ldMB will be used.\n",
585 MAXMEM>>20);
586 if (max_pfn > MAX_NONPAE_PFN)
587 printk(KERN_WARNING
588 "Use a HIGHMEM64G enabled kernel.\n");
589 else
590 printk(KERN_WARNING "Use a HIGHMEM enabled kernel.\n");
591 max_pfn = MAXMEM_PFN;
592#else /* !CONFIG_HIGHMEM */
593#ifndef CONFIG_HIGHMEM64G
594 if (max_pfn > MAX_NONPAE_PFN) {
595 max_pfn = MAX_NONPAE_PFN;
596 printk(KERN_WARNING "Warning only 4GB will be used."
597 "Use a HIGHMEM64G enabled kernel.\n");
598 }
599#endif /* !CONFIG_HIGHMEM64G */
600#endif /* !CONFIG_HIGHMEM */
601 } else {
602 if (highmem_pages == -1)
603 highmem_pages = 0;
604#ifdef CONFIG_HIGHMEM
605 if (highmem_pages >= max_pfn) {
606 printk(KERN_ERR "highmem size specified (%uMB) is "
607 "bigger than pages available (%luMB)!.\n",
608 pages_to_mb(highmem_pages),
609 pages_to_mb(max_pfn));
610 highmem_pages = 0;
611 }
612 if (highmem_pages) {
613 if (max_low_pfn - highmem_pages <
614 64*1024*1024/PAGE_SIZE){
615 printk(KERN_ERR "highmem size %uMB results in "
616 "smaller than 64MB lowmem, ignoring it.\n"
617 , pages_to_mb(highmem_pages));
618 highmem_pages = 0;
619 }
620 max_low_pfn -= highmem_pages;
621 }
622#else
623 if (highmem_pages)
624 printk(KERN_ERR "ignoring highmem size on non-highmem"
625 " kernel!\n");
626#endif
627 }
628 return max_low_pfn;
629}
630
543#ifndef CONFIG_NEED_MULTIPLE_NODES 631#ifndef CONFIG_NEED_MULTIPLE_NODES
544extern unsigned long find_max_low_pfn(void);
545unsigned long __init initmem_init(unsigned long start_pfn, 632unsigned long __init initmem_init(unsigned long start_pfn,
546 unsigned long end_pfn) 633 unsigned long end_pfn)
547{ 634{