1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen IBM Corporation
6 #include <linux/init.h>
8 #include <linux/proc_fs.h>
9 #include <linux/kernel.h>
11 #include <asm/machdep.h>
12 #include <asm/vdso_datapage.h>
14 #include <linux/uaccess.h>
19 static loff_t
page_map_seek(struct file
*file
, loff_t off
, int whence
)
21 return fixed_size_llseek(file
, off
, whence
, PAGE_SIZE
);
24 static ssize_t
page_map_read( struct file
*file
, char __user
*buf
, size_t nbytes
,
27 return simple_read_from_buffer(buf
, nbytes
, ppos
,
28 PDE_DATA(file_inode(file
)), PAGE_SIZE
);
31 static int page_map_mmap( struct file
*file
, struct vm_area_struct
*vma
)
33 if ((vma
->vm_end
- vma
->vm_start
) > PAGE_SIZE
)
36 remap_pfn_range(vma
, vma
->vm_start
,
37 __pa(PDE_DATA(file_inode(file
))) >> PAGE_SHIFT
,
38 PAGE_SIZE
, vma
->vm_page_prot
);
42 static const struct proc_ops page_map_proc_ops
= {
43 .proc_lseek
= page_map_seek
,
44 .proc_read
= page_map_read
,
45 .proc_mmap
= page_map_mmap
,
49 static int __init
proc_ppc64_init(void)
51 struct proc_dir_entry
*pde
;
53 pde
= proc_create_data("powerpc/systemcfg", S_IFREG
| 0444, NULL
,
54 &page_map_proc_ops
, vdso_data
);
57 proc_set_size(pde
, PAGE_SIZE
);
61 __initcall(proc_ppc64_init
);
63 #endif /* CONFIG_PPC64 */
66 * Create the ppc64 and ppc64/rtas directories early. This allows us to
67 * assume that they have been previously created in drivers.
69 static int __init
proc_ppc64_create(void)
71 struct proc_dir_entry
*root
;
73 root
= proc_mkdir("powerpc", NULL
);
78 if (!proc_symlink("ppc64", NULL
, "powerpc"))
79 pr_err("Failed to create link /proc/ppc64 -> /proc/powerpc\n");
82 if (!of_find_node_by_path("/rtas"))
85 if (!proc_mkdir("rtas", root
))
88 if (!proc_symlink("rtas", NULL
, "powerpc/rtas"))
93 core_initcall(proc_ppc64_create
);