]> Git Repo - J-linux.git/blob - arch/powerpc/kernel/proc_powerpc.c
Merge tag 'vfs-6.13-rc7.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
[J-linux.git] / arch / powerpc / kernel / proc_powerpc.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen IBM Corporation
4  */
5
6 #include <linux/init.h>
7 #include <linux/memblock.h>
8 #include <linux/mm.h>
9 #include <linux/proc_fs.h>
10 #include <linux/kernel.h>
11 #include <linux/of.h>
12
13 #include <asm/machdep.h>
14 #include <asm/vdso_datapage.h>
15 #include <asm/rtas.h>
16 #include <asm/systemcfg.h>
17 #include <linux/uaccess.h>
18
19 #ifdef CONFIG_PPC64_PROC_SYSTEMCFG
20
21 static loff_t page_map_seek(struct file *file, loff_t off, int whence)
22 {
23         return fixed_size_llseek(file, off, whence, PAGE_SIZE);
24 }
25
26 static ssize_t page_map_read( struct file *file, char __user *buf, size_t nbytes,
27                               loff_t *ppos)
28 {
29         return simple_read_from_buffer(buf, nbytes, ppos,
30                         pde_data(file_inode(file)), PAGE_SIZE);
31 }
32
33 static int page_map_mmap( struct file *file, struct vm_area_struct *vma )
34 {
35         if ((vma->vm_end - vma->vm_start) > PAGE_SIZE)
36                 return -EINVAL;
37
38         return remap_pfn_range(vma, vma->vm_start,
39                                __pa(pde_data(file_inode(file))) >> PAGE_SHIFT,
40                                PAGE_SIZE, vma->vm_page_prot);
41 }
42
43 static const struct proc_ops page_map_proc_ops = {
44         .proc_lseek     = page_map_seek,
45         .proc_read      = page_map_read,
46         .proc_mmap      = page_map_mmap,
47 };
48
49 static union {
50         struct systemcfg        data;
51         u8                      page[PAGE_SIZE];
52 } systemcfg_data_store __page_aligned_data;
53 struct systemcfg *systemcfg = &systemcfg_data_store.data;
54
55 static int __init proc_ppc64_init(void)
56 {
57         struct proc_dir_entry *pde;
58
59         strcpy((char *)systemcfg->eye_catcher, "SYSTEMCFG:PPC64");
60         systemcfg->version.major = SYSTEMCFG_MAJOR;
61         systemcfg->version.minor = SYSTEMCFG_MINOR;
62         systemcfg->processor = mfspr(SPRN_PVR);
63         /*
64          * Fake the old platform number for pSeries and add
65          * in LPAR bit if necessary
66          */
67         systemcfg->platform = 0x100;
68         if (firmware_has_feature(FW_FEATURE_LPAR))
69                 systemcfg->platform |= 1;
70         systemcfg->physicalMemorySize = memblock_phys_mem_size();
71         systemcfg->dcache_size = ppc64_caches.l1d.size;
72         systemcfg->dcache_line_size = ppc64_caches.l1d.line_size;
73         systemcfg->icache_size = ppc64_caches.l1i.size;
74         systemcfg->icache_line_size = ppc64_caches.l1i.line_size;
75
76         pde = proc_create_data("powerpc/systemcfg", S_IFREG | 0444, NULL,
77                                &page_map_proc_ops, systemcfg);
78         if (!pde)
79                 return 1;
80         proc_set_size(pde, PAGE_SIZE);
81
82         return 0;
83 }
84 __initcall(proc_ppc64_init);
85
86 #endif /* CONFIG_PPC64_PROC_SYSTEMCFG */
87
88 /*
89  * Create the ppc64 and ppc64/rtas directories early. This allows us to
90  * assume that they have been previously created in drivers.
91  */
92 static int __init proc_ppc64_create(void)
93 {
94         struct proc_dir_entry *root;
95
96         root = proc_mkdir("powerpc", NULL);
97         if (!root)
98                 return 1;
99
100 #ifdef CONFIG_PPC64
101         if (!proc_symlink("ppc64", NULL, "powerpc"))
102                 pr_err("Failed to create link /proc/ppc64 -> /proc/powerpc\n");
103 #endif
104
105         if (!of_find_node_by_path("/rtas"))
106                 return 0;
107
108         if (!proc_mkdir("rtas", root))
109                 return 1;
110
111         if (!proc_symlink("rtas", NULL, "powerpc/rtas"))
112                 return 1;
113
114         return 0;
115 }
116 core_initcall(proc_ppc64_create);
This page took 0.031455 seconds and 4 git commands to generate.