aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc
diff options
context:
space:
mode:
authorbob picco <bpicco@meloft.net>2014-03-03 11:54:42 -0500
committerDavid S. Miller <davem@davemloft.net>2014-07-22 00:37:05 -0400
commitf6d4fb5cc0475c36437a618db31cbb7f2bf7c282 (patch)
tree6923493e9823f2827d4f2ad1a50a0a1ca3527b0e /arch/sparc
parent9a3c4145af32125c5ee39c0272662b47307a8323 (diff)
sparc64 - add mem to iomem resource
This patch adds sparc RAM to /proc/iomem. It also identifies the code, data and bss regions of the kernel. Signed-off-by: Bob Picco <bob.picco@oracle.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc')
-rw-r--r--arch/sparc/mm/init_64.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
index 16b58ff11e65..9f4f532e2627 100644
--- a/arch/sparc/mm/init_64.c
+++ b/arch/sparc/mm/init_64.c
@@ -22,6 +22,7 @@
22#include <linux/kprobes.h> 22#include <linux/kprobes.h>
23#include <linux/cache.h> 23#include <linux/cache.h>
24#include <linux/sort.h> 24#include <linux/sort.h>
25#include <linux/ioport.h>
25#include <linux/percpu.h> 26#include <linux/percpu.h>
26#include <linux/memblock.h> 27#include <linux/memblock.h>
27#include <linux/mmzone.h> 28#include <linux/mmzone.h>
@@ -2699,3 +2700,67 @@ void hugetlb_setup(struct pt_regs *regs)
2699 } 2700 }
2700} 2701}
2701#endif 2702#endif
2703
2704static struct resource code_resource = {
2705 .name = "Kernel code",
2706 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
2707};
2708
2709static struct resource data_resource = {
2710 .name = "Kernel data",
2711 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
2712};
2713
2714static struct resource bss_resource = {
2715 .name = "Kernel bss",
2716 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
2717};
2718
2719static inline resource_size_t compute_kern_paddr(void *addr)
2720{
2721 return (resource_size_t) (addr - KERNBASE + kern_base);
2722}
2723
2724static void __init kernel_lds_init(void)
2725{
2726 code_resource.start = compute_kern_paddr(_text);
2727 code_resource.end = compute_kern_paddr(_etext - 1);
2728 data_resource.start = compute_kern_paddr(_etext);
2729 data_resource.end = compute_kern_paddr(_edata - 1);
2730 bss_resource.start = compute_kern_paddr(__bss_start);
2731 bss_resource.end = compute_kern_paddr(_end - 1);
2732}
2733
2734static int __init report_memory(void)
2735{
2736 int i;
2737 struct resource *res;
2738
2739 kernel_lds_init();
2740
2741 for (i = 0; i < pavail_ents; i++) {
2742 res = kzalloc(sizeof(struct resource), GFP_KERNEL);
2743
2744 if (!res) {
2745 pr_warn("Failed to allocate source.\n");
2746 break;
2747 }
2748
2749 res->name = "System RAM";
2750 res->start = pavail[i].phys_addr;
2751 res->end = pavail[i].phys_addr + pavail[i].reg_size - 1;
2752 res->flags = IORESOURCE_BUSY | IORESOURCE_MEM;
2753
2754 if (insert_resource(&iomem_resource, res) < 0) {
2755 pr_warn("Resource insertion failed.\n");
2756 break;
2757 }
2758
2759 insert_resource(res, &code_resource);
2760 insert_resource(res, &data_resource);
2761 insert_resource(res, &bss_resource);
2762 }
2763
2764 return 0;
2765}
2766device_initcall(report_memory);