1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
// SPDX-License-Identifier: GPL-2.0-only
#include <linux/module.h>
#include <linux/init.h>
#include <linux/seq_file.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/types.h>
#include <linux/proc_fs.h>
#include <asm/sysreg.h>
static int ttbr1_show(struct seq_file *m, void *v)
{
unsigned long ttbr;
int cpu;
preempt_disable();
cpu = smp_processor_id();
ttbr = read_sysreg(ttbr1_el1);
preempt_enable();
seq_printf(m, "CPU%u: TTBR1 0x%08lx\n", cpu, ttbr);
return 0;
}
static int ttbr1_open(struct inode *inode, struct file *file)
{
return single_open(file, ttbr1_show, NULL);
}
static const struct proc_ops ttbr1_fops = {
.proc_open = ttbr1_open,
.proc_read = seq_read,
.proc_lseek = seq_lseek,
.proc_release = single_release,
};
extern const char ktext_nid[32];
static int nid_show(struct seq_file *m, void *v)
{
int cpu;
preempt_disable();
cpu = smp_processor_id();
seq_printf(m, "CPU%u: nid %s\n",
cpu, ktext_nid);
preempt_enable();
return 0;
}
static int nid_open(struct inode *inode, struct file *file)
{
return single_open(file, nid_show, NULL);
}
static const struct proc_ops nid_fops = {
.proc_open = nid_open,
.proc_read = seq_read,
.proc_lseek = seq_lseek,
.proc_release = single_release,
};
static int ttbr1_init(void)
{
struct proc_dir_entry *dir;
dir = proc_mkdir("ktext", NULL);
if (!dir)
return -ENOMEM;
if (!proc_create("ttbr1", S_IRUSR, dir, &ttbr1_fops) ||
!proc_create("text_nid", S_IRUSR, dir, &nid_fops)) {
remove_proc_subtree("ktext", NULL);
return -ENOMEM;
}
return 0;
}
module_init(ttbr1_init);
static void ttbr1_fin(void)
{
remove_proc_subtree("ktext", NULL);
}
module_exit(ttbr1_fin);
MODULE_AUTHOR("Russell King");
MODULE_LICENSE("GPL");
|