aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ppc64/kernel/proc_ppc64.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/ppc64/kernel/proc_ppc64.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/ppc64/kernel/proc_ppc64.c')
-rw-r--r--arch/ppc64/kernel/proc_ppc64.c128
1 files changed, 128 insertions, 0 deletions
diff --git a/arch/ppc64/kernel/proc_ppc64.c b/arch/ppc64/kernel/proc_ppc64.c
new file mode 100644
index 000000000000..0914b0669b05
--- /dev/null
+++ b/arch/ppc64/kernel/proc_ppc64.c
@@ -0,0 +1,128 @@
1/*
2 * arch/ppc64/kernel/proc_ppc64.c
3 *
4 * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen IBM Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/config.h>
22#include <linux/init.h>
23#include <linux/mm.h>
24#include <linux/proc_fs.h>
25#include <linux/slab.h>
26#include <linux/kernel.h>
27
28#include <asm/systemcfg.h>
29#include <asm/rtas.h>
30#include <asm/uaccess.h>
31#include <asm/prom.h>
32
33static loff_t page_map_seek( struct file *file, loff_t off, int whence);
34static ssize_t page_map_read( struct file *file, char __user *buf, size_t nbytes,
35 loff_t *ppos);
36static int page_map_mmap( struct file *file, struct vm_area_struct *vma );
37
38static struct file_operations page_map_fops = {
39 .llseek = page_map_seek,
40 .read = page_map_read,
41 .mmap = page_map_mmap
42};
43
44/*
45 * Create the ppc64 and ppc64/rtas directories early. This allows us to
46 * assume that they have been previously created in drivers.
47 */
48static int __init proc_ppc64_create(void)
49{
50 struct proc_dir_entry *root;
51
52 root = proc_mkdir("ppc64", NULL);
53 if (!root)
54 return 1;
55
56 if (!(systemcfg->platform & PLATFORM_PSERIES))
57 return 0;
58
59 if (!proc_mkdir("rtas", root))
60 return 1;
61
62 if (!proc_symlink("rtas", NULL, "ppc64/rtas"))
63 return 1;
64
65 return 0;
66}
67core_initcall(proc_ppc64_create);
68
69static int __init proc_ppc64_init(void)
70{
71 struct proc_dir_entry *pde;
72
73 pde = create_proc_entry("ppc64/systemcfg", S_IFREG|S_IRUGO, NULL);
74 if (!pde)
75 return 1;
76 pde->nlink = 1;
77 pde->data = systemcfg;
78 pde->size = PAGE_SIZE;
79 pde->proc_fops = &page_map_fops;
80
81 return 0;
82}
83__initcall(proc_ppc64_init);
84
85static loff_t page_map_seek( struct file *file, loff_t off, int whence)
86{
87 loff_t new;
88 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
89
90 switch(whence) {
91 case 0:
92 new = off;
93 break;
94 case 1:
95 new = file->f_pos + off;
96 break;
97 case 2:
98 new = dp->size + off;
99 break;
100 default:
101 return -EINVAL;
102 }
103 if ( new < 0 || new > dp->size )
104 return -EINVAL;
105 return (file->f_pos = new);
106}
107
108static ssize_t page_map_read( struct file *file, char __user *buf, size_t nbytes,
109 loff_t *ppos)
110{
111 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
112 return simple_read_from_buffer(buf, nbytes, ppos, dp->data, dp->size);
113}
114
115static int page_map_mmap( struct file *file, struct vm_area_struct *vma )
116{
117 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
118
119 vma->vm_flags |= VM_SHM | VM_LOCKED;
120
121 if ((vma->vm_end - vma->vm_start) > dp->size)
122 return -EINVAL;
123
124 remap_pfn_range(vma, vma->vm_start, __pa(dp->data) >> PAGE_SHIFT,
125 dp->size, vma->vm_page_prot);
126 return 0;
127}
128