This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / arch / mips / philips / pnx8550 / common / proc.c
1 /*
2  *  This program is free software; you can distribute it and/or modify it
3  *  under the terms of the GNU General Public License (Version 2) as
4  *  published by the Free Software Foundation.
5  *
6  *  This program is distributed in the hope it will be useful, but WITHOUT
7  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9  *  for more details.
10  *
11  *  You should have received a copy of the GNU General Public License along
12  *  with this program; if not, write to the Free Software Foundation, Inc.,
13  *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
14  */
15 #include <linux/init.h>
16 #include <linux/proc_fs.h>
17 #include <linux/irq.h>
18 #include <linux/sched.h>
19 #include <linux/slab.h>
20 #include <linux/interrupt.h>
21 #include <linux/kernel_stat.h>
22 #include <linux/random.h>
23
24 #include <asm/io.h>
25 #include <asm/gdb-stub.h>
26 #include <int.h>
27 #include <uart.h>
28
29
30 static int pnx8550_timers_read (char* page, char** start, off_t offset, int count, int* eof, void* data)
31 {
32         int len = 0;
33         int configPR = read_c0_config7();
34
35         if (offset==0) {
36                 len += sprintf(&page[len],"Timer:       count,  compare, tc, status\n");
37                 len += sprintf(&page[len],"    1: %11i, %8i,  %1i, %s\n",
38                                read_c0_count(), read_c0_compare(),
39                               (configPR>>6)&0x1, ((configPR>>3)&0x1)? "off":"on");
40                 len += sprintf(&page[len],"    2: %11i, %8i,  %1i, %s\n",
41                                read_c0_count2(), read_c0_compare2(),
42                               (configPR>>7)&0x1, ((configPR>>4)&0x1)? "off":"on");
43                 len += sprintf(&page[len],"    3: %11i, %8i,  %1i, %s\n",
44                                read_c0_count3(), read_c0_compare3(),
45                               (configPR>>8)&0x1, ((configPR>>5)&0x1)? "off":"on");
46         }
47
48         return len;
49 }
50
51 static int pnx8550_registers_read (char* page, char** start, off_t offset, int count, int* eof, void* data)
52 {
53         int len = 0;
54
55         if (offset==0) {
56                 len += sprintf(&page[len],"config1:   %#10.8x\n",read_c0_config1());
57                 len += sprintf(&page[len],"config2:   %#10.8x\n",read_c0_config2());
58                 len += sprintf(&page[len],"config3:   %#10.8x\n",read_c0_config3());
59                 len += sprintf(&page[len],"configPR:  %#10.8x\n",read_c0_config7());
60                 len += sprintf(&page[len],"status:    %#10.8x\n",read_c0_status());
61                 len += sprintf(&page[len],"cause:     %#10.8x\n",read_c0_cause());
62                 len += sprintf(&page[len],"count:     %#10.8x\n",read_c0_count());
63                 len += sprintf(&page[len],"count_2:   %#10.8x\n",read_c0_count2());
64                 len += sprintf(&page[len],"count_3:   %#10.8x\n",read_c0_count3());
65                 len += sprintf(&page[len],"compare:   %#10.8x\n",read_c0_compare());
66                 len += sprintf(&page[len],"compare_2: %#10.8x\n",read_c0_compare2());
67                 len += sprintf(&page[len],"compare_3: %#10.8x\n",read_c0_compare3());
68         }
69
70         return len;
71 }
72
73 static struct proc_dir_entry* pnx8550_dir        = NULL;
74 static struct proc_dir_entry* pnx8550_timers     = NULL;
75 static struct proc_dir_entry* pnx8550_registers  = NULL;
76
77 static int pnx8550_proc_init( void )
78 {
79
80         // Create /proc/pnx8550
81         pnx8550_dir = create_proc_entry("pnx8550", S_IFDIR|S_IRUGO, NULL);
82         if (pnx8550_dir){
83                 pnx8550_dir->nlink = 1;
84         }
85         else {
86                 printk(KERN_ERR "Can't create pnx8550 proc dir\n");
87                 return -1;
88         }
89
90         // Create /proc/pnx8550/timers
91         pnx8550_timers = create_proc_entry("timers", S_IFREG|S_IRUGO, pnx8550_dir );
92         if (pnx8550_timers){
93                 pnx8550_timers->nlink = 1;
94                 pnx8550_timers->read_proc = pnx8550_timers_read;
95         }
96         else {
97                 printk(KERN_ERR "Can't create pnx8550 timers proc file\n");
98         }
99
100         // Create /proc/pnx8550/registers
101         pnx8550_registers = create_proc_entry("registers", S_IFREG|S_IRUGO, pnx8550_dir );
102         if (pnx8550_registers){
103                 pnx8550_registers->nlink = 1;
104                 pnx8550_registers->read_proc = pnx8550_registers_read;
105         }
106         else {
107                 printk(KERN_ERR "Can't create pnx8550 registers proc file\n");
108         }
109
110         return 0;
111 }
112
113 __initcall(pnx8550_proc_init);