diff options
Diffstat (limited to 'arch/blackfin/kernel/cplb-mpu/cplbinfo.c')
-rw-r--r-- | arch/blackfin/kernel/cplb-mpu/cplbinfo.c | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/arch/blackfin/kernel/cplb-mpu/cplbinfo.c b/arch/blackfin/kernel/cplb-mpu/cplbinfo.c new file mode 100644 index 000000000000..bd072299f7f2 --- /dev/null +++ b/arch/blackfin/kernel/cplb-mpu/cplbinfo.c | |||
@@ -0,0 +1,144 @@ | |||
1 | /* | ||
2 | * File: arch/blackfin/mach-common/cplbinfo.c | ||
3 | * Based on: | ||
4 | * Author: Sonic Zhang <sonic.zhang@analog.com> | ||
5 | * | ||
6 | * Created: Jan. 2005 | ||
7 | * Description: Display CPLB status | ||
8 | * | ||
9 | * Modified: | ||
10 | * Copyright 2004-2006 Analog Devices Inc. | ||
11 | * | ||
12 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or modify | ||
15 | * it under the terms of the GNU General Public License as published by | ||
16 | * the Free Software Foundation; either version 2 of the License, or | ||
17 | * (at your option) any later version. | ||
18 | * | ||
19 | * This program is distributed in the hope that it will be useful, | ||
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
22 | * GNU General Public License for more details. | ||
23 | * | ||
24 | * You should have received a copy of the GNU General Public License | ||
25 | * along with this program; if not, see the file COPYING, or write | ||
26 | * to the Free Software Foundation, Inc., | ||
27 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
28 | */ | ||
29 | |||
30 | #include <linux/module.h> | ||
31 | #include <linux/kernel.h> | ||
32 | #include <linux/init.h> | ||
33 | #include <linux/proc_fs.h> | ||
34 | #include <linux/uaccess.h> | ||
35 | |||
36 | #include <asm/current.h> | ||
37 | #include <asm/system.h> | ||
38 | #include <asm/cplb.h> | ||
39 | #include <asm/cplbinit.h> | ||
40 | #include <asm/blackfin.h> | ||
41 | |||
42 | #define CPLB_I 1 | ||
43 | #define CPLB_D 2 | ||
44 | |||
45 | #define SYNC_SYS SSYNC() | ||
46 | #define SYNC_CORE CSYNC() | ||
47 | |||
48 | #define CPLB_BIT_PAGESIZE 0x30000 | ||
49 | |||
50 | static char page_size_string_table[][4] = { "1K", "4K", "1M", "4M" }; | ||
51 | |||
52 | static char *cplb_print_entry(char *buf, struct cplb_entry *tbl, int switched) | ||
53 | { | ||
54 | int i; | ||
55 | buf += sprintf(buf, "Index\tAddress\t\tData\tSize\tU/RD\tU/WR\tS/WR\tSwitch\n"); | ||
56 | for (i = 0; i < MAX_CPLBS; i++) { | ||
57 | unsigned long data = tbl[i].data; | ||
58 | unsigned long addr = tbl[i].addr; | ||
59 | if (!(data & CPLB_VALID)) | ||
60 | continue; | ||
61 | |||
62 | buf += | ||
63 | sprintf(buf, | ||
64 | "%d\t0x%08lx\t%06lx\t%s\t%c\t%c\t%c\t%c\n", | ||
65 | i, addr, data, | ||
66 | page_size_string_table[(data & 0x30000) >> 16], | ||
67 | (data & CPLB_USER_RD) ? 'Y' : 'N', | ||
68 | (data & CPLB_USER_WR) ? 'Y' : 'N', | ||
69 | (data & CPLB_SUPV_WR) ? 'Y' : 'N', | ||
70 | i < switched ? 'N' : 'Y'); | ||
71 | } | ||
72 | buf += sprintf(buf, "\n"); | ||
73 | |||
74 | return buf; | ||
75 | } | ||
76 | |||
77 | int cplbinfo_proc_output(char *buf) | ||
78 | { | ||
79 | char *p; | ||
80 | |||
81 | p = buf; | ||
82 | |||
83 | p += sprintf(p, "------------------ CPLB Information ------------------\n\n"); | ||
84 | |||
85 | if (bfin_read_IMEM_CONTROL() & ENICPLB) { | ||
86 | p += sprintf(p, "Instruction CPLB entry:\n"); | ||
87 | p = cplb_print_entry(p, icplb_tbl, first_switched_icplb); | ||
88 | } else | ||
89 | p += sprintf(p, "Instruction CPLB is disabled.\n\n"); | ||
90 | |||
91 | if (1 || bfin_read_DMEM_CONTROL() & ENDCPLB) { | ||
92 | p += sprintf(p, "Data CPLB entry:\n"); | ||
93 | p = cplb_print_entry(p, dcplb_tbl, first_switched_dcplb); | ||
94 | } else | ||
95 | p += sprintf(p, "Data CPLB is disabled.\n"); | ||
96 | |||
97 | p += sprintf(p, "ICPLB miss: %d\nICPLB supervisor miss: %d\n", | ||
98 | nr_icplb_miss, nr_icplb_supv_miss); | ||
99 | p += sprintf(p, "DCPLB miss: %d\nDCPLB protection fault:%d\n", | ||
100 | nr_dcplb_miss, nr_dcplb_prot); | ||
101 | p += sprintf(p, "CPLB flushes: %d\n", | ||
102 | nr_cplb_flush); | ||
103 | |||
104 | return p - buf; | ||
105 | } | ||
106 | |||
107 | static int cplbinfo_read_proc(char *page, char **start, off_t off, | ||
108 | int count, int *eof, void *data) | ||
109 | { | ||
110 | int len; | ||
111 | |||
112 | len = cplbinfo_proc_output(page); | ||
113 | if (len <= off + count) | ||
114 | *eof = 1; | ||
115 | *start = page + off; | ||
116 | len -= off; | ||
117 | if (len > count) | ||
118 | len = count; | ||
119 | if (len < 0) | ||
120 | len = 0; | ||
121 | return len; | ||
122 | } | ||
123 | |||
124 | static int __init cplbinfo_init(void) | ||
125 | { | ||
126 | struct proc_dir_entry *entry; | ||
127 | |||
128 | entry = create_proc_entry("cplbinfo", 0, NULL); | ||
129 | if (!entry) | ||
130 | return -ENOMEM; | ||
131 | |||
132 | entry->read_proc = cplbinfo_read_proc; | ||
133 | entry->data = NULL; | ||
134 | |||
135 | return 0; | ||
136 | } | ||
137 | |||
138 | static void __exit cplbinfo_exit(void) | ||
139 | { | ||
140 | remove_proc_entry("cplbinfo", NULL); | ||
141 | } | ||
142 | |||
143 | module_init(cplbinfo_init); | ||
144 | module_exit(cplbinfo_exit); | ||