1 /* sysctl.c: implementation of /proc/sys files relating to FRV specifically
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #include <linux/slab.h>
13 #include <linux/sysctl.h>
14 #include <linux/proc_fs.h>
15 #include <linux/init.h>
16 #include <asm/uaccess.h>
18 static const char frv_cache_wback
[] = "wback";
19 static const char frv_cache_wthru
[] = "wthru";
21 static void frv_change_dcache_mode(unsigned long newmode
)
23 unsigned long flags
, hsr0
;
25 local_irq_save(flags
);
31 asm volatile(" dcef @(gr0,gr0),#1 \n"
36 hsr0
= (hsr0
& ~HSR0_CBM
) | newmode
;
41 local_irq_restore(flags
);
43 //printk("HSR0 now %08lx\n", hsr0);
46 /*****************************************************************************/
48 * handle requests to dynamically switch the write caching mode delivered by /proc
50 static int procctl_frv_cachemode(ctl_table
*table
, int write
, struct file
*filp
,
51 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
60 /* potential state change */
61 if (len
<= 1 || len
> sizeof(buff
) - 1)
64 if (copy_from_user(buff
, buffer
, len
) != 0)
67 if (buff
[len
- 1] == '\n')
72 if (strcmp(buff
, frv_cache_wback
) == 0) {
73 /* switch dcache into write-back mode */
74 frv_change_dcache_mode(HSR0_CBM_COPY_BACK
);
78 if (strcmp(buff
, frv_cache_wthru
) == 0) {
79 /* switch dcache into write-through mode */
80 frv_change_dcache_mode(HSR0_CBM_WRITE_THRU
);
88 if (filp
->f_pos
> 0) {
94 switch (hsr0
& HSR0_CBM
) {
95 case HSR0_CBM_WRITE_THRU
:
96 memcpy(buff
, frv_cache_wthru
, sizeof(frv_cache_wthru
) - 1);
97 buff
[sizeof(frv_cache_wthru
) - 1] = '\n';
98 len
= sizeof(frv_cache_wthru
);
101 memcpy(buff
, frv_cache_wback
, sizeof(frv_cache_wback
) - 1);
102 buff
[sizeof(frv_cache_wback
) - 1] = '\n';
103 len
= sizeof(frv_cache_wback
);
110 if (copy_to_user(buffer
, buff
, len
) != 0)
117 } /* end procctl_frv_cachemode() */
119 /*****************************************************************************/
121 * permit the mm_struct the nominated process is using have its MMU context ID pinned
124 static int procctl_frv_pin_cxnr(ctl_table
*table
, int write
, struct file
*filp
,
125 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
134 /* potential state change */
135 if (len
<= 1 || len
> sizeof(buff
) - 1)
138 if (copy_from_user(buff
, buffer
, len
) != 0)
141 if (buff
[len
- 1] == '\n')
142 buff
[len
- 1] = '\0';
146 pid
= simple_strtoul(buff
, &p
, 10);
150 return cxn_pin_by_pid(pid
);
153 /* read the currently pinned CXN */
154 if (filp
->f_pos
> 0) {
159 len
= snprintf(buff
, sizeof(buff
), "%d\n", cxn_pinned
);
163 if (copy_to_user(buffer
, buff
, len
) != 0)
170 } /* end procctl_frv_pin_cxnr() */
174 * FR-V specific sysctls
176 static struct ctl_table frv_table
[] =
180 .procname
= "cache-mode",
184 .proc_handler
= &procctl_frv_cachemode
,
189 .procname
= "pin-cxnr",
193 .proc_handler
= &procctl_frv_pin_cxnr
200 * Use a temporary sysctl number. Horrid, but will be cleaned up in 2.6
201 * when all the PM interfaces exist nicely.
203 static struct ctl_table frv_dir_table
[] =
215 * Initialize power interface
217 static int __init
frv_sysctl_init(void)
219 register_sysctl_table(frv_dir_table
, 0);
223 __initcall(frv_sysctl_init
);