1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2018, Christophe Leroy CS S.I.
4 * <christophe.leroy@c-s.fr>
6 * This dumps the content of Segment Registers
9 #include <asm/debugfs.h>
11 static void seg_show(struct seq_file
*m
, int i
)
13 u32 val
= mfsrin(i
<< 28);
15 seq_printf(m
, "0x%01x0000000-0x%01xfffffff ", i
, i
);
16 seq_printf(m
, "Kern key %d ", (val
>> 30) & 1);
17 seq_printf(m
, "User key %d ", (val
>> 29) & 1);
18 if (val
& 0x80000000) {
19 seq_printf(m
, "Device 0x%03x", (val
>> 20) & 0x1ff);
20 seq_printf(m
, "-0x%05x", val
& 0xfffff);
23 seq_puts(m
, "No Exec ");
24 seq_printf(m
, "VSID 0x%06x", val
& 0xffffff);
29 static int sr_show(struct seq_file
*m
, void *v
)
33 seq_puts(m
, "---[ User Segments ]---\n");
34 for (i
= 0; i
< TASK_SIZE
>> 28; i
++)
37 seq_puts(m
, "\n---[ Kernel Segments ]---\n");
44 static int sr_open(struct inode
*inode
, struct file
*file
)
46 return single_open(file
, sr_show
, NULL
);
49 static const struct file_operations sr_fops
= {
53 .release
= single_release
,
56 static int __init
sr_init(void)
58 debugfs_create_file("segment_registers", 0400, powerpc_debugfs_root
,
62 device_initcall(sr_init
);