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/sysctl.h>
13 #include <linux/proc_fs.h>
14 #include <linux/init.h>
15 #include <asm/uaccess.h>
17 static const char frv_cache_wback
[] = "wback";
18 static const char frv_cache_wthru
[] = "wthru";
20 static void frv_change_dcache_mode(unsigned long newmode
)
22 unsigned long flags
, hsr0
;
24 local_irq_save(flags
);
30 asm volatile(" dcef @(gr0,gr0),#1 \n"
35 hsr0
= (hsr0
& ~HSR0_CBM
) | newmode
;
40 local_irq_restore(flags
);
42 //printk("HSR0 now %08lx\n", hsr0);
45 /*****************************************************************************/
47 * handle requests to dynamically switch the write caching mode delivered by /proc
49 static int procctl_frv_cachemode(ctl_table
*table
, int write
, struct file
*filp
,
50 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
59 /* potential state change */
60 if (len
<= 1 || len
> sizeof(buff
) - 1)
63 if (copy_from_user(buff
, buffer
, len
) != 0)
66 if (buff
[len
- 1] == '\n')
71 if (strcmp(buff
, frv_cache_wback
) == 0) {
72 /* switch dcache into write-back mode */
73 frv_change_dcache_mode(HSR0_CBM_COPY_BACK
);
77 if (strcmp(buff
, frv_cache_wthru
) == 0) {
78 /* switch dcache into write-through mode */
79 frv_change_dcache_mode(HSR0_CBM_WRITE_THRU
);
87 if (filp
->f_pos
> 0) {
93 switch (hsr0
& HSR0_CBM
) {
94 case HSR0_CBM_WRITE_THRU
:
95 memcpy(buff
, frv_cache_wthru
, sizeof(frv_cache_wthru
) - 1);
96 buff
[sizeof(frv_cache_wthru
) - 1] = '\n';
97 len
= sizeof(frv_cache_wthru
);
100 memcpy(buff
, frv_cache_wback
, sizeof(frv_cache_wback
) - 1);
101 buff
[sizeof(frv_cache_wback
) - 1] = '\n';
102 len
= sizeof(frv_cache_wback
);
109 if (copy_to_user(buffer
, buff
, len
) != 0)
116 } /* end procctl_frv_cachemode() */
118 /*****************************************************************************/
120 * permit the mm_struct the nominated process is using have its MMU context ID pinned
123 static int procctl_frv_pin_cxnr(ctl_table
*table
, int write
, struct file
*filp
,
124 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
133 /* potential state change */
134 if (len
<= 1 || len
> sizeof(buff
) - 1)
137 if (copy_from_user(buff
, buffer
, len
) != 0)
140 if (buff
[len
- 1] == '\n')
141 buff
[len
- 1] = '\0';
145 pid
= simple_strtoul(buff
, &p
, 10);
149 return cxn_pin_by_pid(pid
);
152 /* read the currently pinned CXN */
153 if (filp
->f_pos
> 0) {
158 len
= snprintf(buff
, sizeof(buff
), "%d\n", cxn_pinned
);
162 if (copy_to_user(buffer
, buff
, len
) != 0)
169 } /* end procctl_frv_pin_cxnr() */
173 * FR-V specific sysctls
175 static struct ctl_table frv_table
[] =
178 .procname
= "cache-mode",
182 .proc_handler
= procctl_frv_cachemode
,
186 .procname
= "pin-cxnr",
190 .proc_handler
= procctl_frv_pin_cxnr
197 * Use a temporary sysctl number. Horrid, but will be cleaned up in 2.6
198 * when all the PM interfaces exist nicely.
200 static struct ctl_table frv_dir_table
[] =
211 * Initialize power interface
213 static int __init
frv_sysctl_init(void)
215 register_sysctl_table(frv_dir_table
);
219 __initcall(frv_sysctl_init
);