2 * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen IBM Corporation
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include <linux/config.h>
20 #include <linux/init.h>
22 #include <linux/proc_fs.h>
23 #include <linux/slab.h>
24 #include <linux/kernel.h>
26 #include <asm/vdso_datapage.h>
28 #include <asm/uaccess.h>
31 static loff_t page_map_seek( struct file *file, loff_t off, int whence);
32 static ssize_t page_map_read( struct file *file, char __user *buf, size_t nbytes,
34 static int page_map_mmap( struct file *file, struct vm_area_struct *vma );
36 static struct file_operations page_map_fops = {
37 .llseek = page_map_seek,
38 .read = page_map_read,
43 * Create the ppc64 and ppc64/rtas directories early. This allows us to
44 * assume that they have been previously created in drivers.
46 static int __init proc_ppc64_create(void)
48 struct proc_dir_entry *root;
50 root = proc_mkdir("ppc64", NULL);
54 if (!(platform_is_pseries() || _machine == PLATFORM_CELL))
57 if (!proc_mkdir("rtas", root))
60 if (!proc_symlink("rtas", NULL, "ppc64/rtas"))
65 core_initcall(proc_ppc64_create);
67 static int __init proc_ppc64_init(void)
69 struct proc_dir_entry *pde;
71 pde = create_proc_entry("ppc64/systemcfg", S_IFREG|S_IRUGO, NULL);
75 pde->data = vdso_data;
76 pde->size = PAGE_SIZE;
77 pde->proc_fops = &page_map_fops;
81 __initcall(proc_ppc64_init);
83 static loff_t page_map_seek( struct file *file, loff_t off, int whence)
86 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
93 new = file->f_pos + off;
101 if ( new < 0 || new > dp->size )
103 return (file->f_pos = new);
106 static ssize_t page_map_read( struct file *file, char __user *buf, size_t nbytes,
109 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
110 return simple_read_from_buffer(buf, nbytes, ppos, dp->data, dp->size);
113 static int page_map_mmap( struct file *file, struct vm_area_struct *vma )
115 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
117 vma->vm_flags |= VM_SHM | VM_LOCKED;
119 if ((vma->vm_end - vma->vm_start) > dp->size)
122 remap_pfn_range(vma, vma->vm_start, __pa(dp->data) >> PAGE_SHIFT,
123 dp->size, vma->vm_page_prot);