aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/kernel/setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/kernel/setup.c')
-rw-r--r--arch/mips/kernel/setup.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 290dc6a1d7a3..8c41187801ce 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -22,6 +22,7 @@
22#include <linux/console.h> 22#include <linux/console.h>
23#include <linux/pfn.h> 23#include <linux/pfn.h>
24#include <linux/debugfs.h> 24#include <linux/debugfs.h>
25#include <linux/kexec.h>
25 26
26#include <asm/addrspace.h> 27#include <asm/addrspace.h>
27#include <asm/bootinfo.h> 28#include <asm/bootinfo.h>
@@ -536,12 +537,64 @@ static void __init arch_mem_init(char **cmdline_p)
536 } 537 }
537 538
538 bootmem_init(); 539 bootmem_init();
540#ifdef CONFIG_KEXEC
541 if (crashk_res.start != crashk_res.end)
542 reserve_bootmem(crashk_res.start,
543 crashk_res.end - crashk_res.start + 1,
544 BOOTMEM_DEFAULT);
545#endif
539 device_tree_init(); 546 device_tree_init();
540 sparse_init(); 547 sparse_init();
541 plat_swiotlb_setup(); 548 plat_swiotlb_setup();
542 paging_init(); 549 paging_init();
543} 550}
544 551
552#ifdef CONFIG_KEXEC
553static inline unsigned long long get_total_mem(void)
554{
555 unsigned long long total;
556
557 total = max_pfn - min_low_pfn;
558 return total << PAGE_SHIFT;
559}
560
561static void __init mips_parse_crashkernel(void)
562{
563 unsigned long long total_mem;
564 unsigned long long crash_size, crash_base;
565 int ret;
566
567 total_mem = get_total_mem();
568 ret = parse_crashkernel(boot_command_line, total_mem,
569 &crash_size, &crash_base);
570 if (ret != 0 || crash_size <= 0)
571 return;
572
573 crashk_res.start = crash_base;
574 crashk_res.end = crash_base + crash_size - 1;
575}
576
577static void __init request_crashkernel(struct resource *res)
578{
579 int ret;
580
581 ret = request_resource(res, &crashk_res);
582 if (!ret)
583 pr_info("Reserving %ldMB of memory at %ldMB for crashkernel\n",
584 (unsigned long)((crashk_res.end -
585 crashk_res.start + 1) >> 20),
586 (unsigned long)(crashk_res.start >> 20));
587}
588#else /* !defined(CONFIG_KEXEC) */
589static void __init mips_parse_crashkernel(void)
590{
591}
592
593static void __init request_crashkernel(struct resource *res)
594{
595}
596#endif /* !defined(CONFIG_KEXEC) */
597
545static void __init resource_init(void) 598static void __init resource_init(void)
546{ 599{
547 int i; 600 int i;
@@ -557,6 +610,8 @@ static void __init resource_init(void)
557 /* 610 /*
558 * Request address space for all standard RAM. 611 * Request address space for all standard RAM.
559 */ 612 */
613 mips_parse_crashkernel();
614
560 for (i = 0; i < boot_mem_map.nr_map; i++) { 615 for (i = 0; i < boot_mem_map.nr_map; i++) {
561 struct resource *res; 616 struct resource *res;
562 unsigned long start, end; 617 unsigned long start, end;
@@ -593,6 +648,7 @@ static void __init resource_init(void)
593 */ 648 */
594 request_resource(res, &code_resource); 649 request_resource(res, &code_resource);
595 request_resource(res, &data_resource); 650 request_resource(res, &data_resource);
651 request_crashkernel(res);
596 } 652 }
597} 653}
598 654