~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/mips/kernel/segment.c

Version: ~ [ linux-5.2-rc5 ] ~ [ linux-5.1.12 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.53 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.128 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.182 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.182 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.68 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * This file is subject to the terms and conditions of the GNU General Public
  3  * License.  See the file "COPYING" in the main directory of this archive
  4  * for more details.
  5  *
  6  * Copyright (C) 2013 Imagination Technologies Ltd.
  7  */
  8 
  9 #include <linux/kernel.h>
 10 #include <linux/debugfs.h>
 11 #include <linux/seq_file.h>
 12 #include <asm/cpu.h>
 13 #include <asm/debug.h>
 14 #include <asm/mipsregs.h>
 15 
 16 static void build_segment_config(char *str, unsigned int cfg)
 17 {
 18         unsigned int am;
 19         static const char * const am_str[] = {
 20                 "UK", "MK", "MSK", "MUSK", "MUSUK", "USK",
 21                 "RSRVD", "UUSK"};
 22 
 23         /* Segment access mode. */
 24         am = (cfg & MIPS_SEGCFG_AM) >> MIPS_SEGCFG_AM_SHIFT;
 25         str += sprintf(str, "%-5s", am_str[am]);
 26 
 27         /*
 28          * Access modes MK, MSK and MUSK are mapped segments. Therefore
 29          * there is no direct physical address mapping unless it becomes
 30          * unmapped uncached at error level due to EU.
 31          */
 32         if ((am == 0) || (am > 3) || (cfg & MIPS_SEGCFG_EU))
 33                 str += sprintf(str, "         %03lx",
 34                         ((cfg & MIPS_SEGCFG_PA) >> MIPS_SEGCFG_PA_SHIFT));
 35         else
 36                 str += sprintf(str, "         UND");
 37 
 38         if ((am == 0) || (am > 3))
 39                 str += sprintf(str, "         %01ld",
 40                         ((cfg & MIPS_SEGCFG_C) >> MIPS_SEGCFG_C_SHIFT));
 41         else
 42                 str += sprintf(str, "         U");
 43 
 44         /* Exception configuration. */
 45         str += sprintf(str, "       %01ld\n",
 46                 ((cfg & MIPS_SEGCFG_EU) >> MIPS_SEGCFG_EU_SHIFT));
 47 }
 48 
 49 static int show_segments(struct seq_file *m, void *v)
 50 {
 51         unsigned int segcfg;
 52         char str[42];
 53 
 54         seq_puts(m, "Segment   Virtual    Size   Access Mode   Physical   Caching   EU\n");
 55         seq_puts(m, "-------   -------    ----   -----------   --------   -------   --\n");
 56 
 57         segcfg = read_c0_segctl0();
 58         build_segment_config(str, segcfg);
 59         seq_printf(m, "   0      e0000000   512M      %s", str);
 60 
 61         segcfg >>= 16;
 62         build_segment_config(str, segcfg);
 63         seq_printf(m, "   1      c0000000   512M      %s", str);
 64 
 65         segcfg = read_c0_segctl1();
 66         build_segment_config(str, segcfg);
 67         seq_printf(m, "   2      a0000000   512M      %s", str);
 68 
 69         segcfg >>= 16;
 70         build_segment_config(str, segcfg);
 71         seq_printf(m, "   3      80000000   512M      %s", str);
 72 
 73         segcfg = read_c0_segctl2();
 74         build_segment_config(str, segcfg);
 75         seq_printf(m, "   4      40000000    1G       %s", str);
 76 
 77         segcfg >>= 16;
 78         build_segment_config(str, segcfg);
 79         seq_printf(m, "   5      00000000    1G       %s\n", str);
 80 
 81         return 0;
 82 }
 83 
 84 static int segments_open(struct inode *inode, struct file *file)
 85 {
 86         return single_open(file, show_segments, NULL);
 87 }
 88 
 89 static const struct file_operations segments_fops = {
 90         .open           = segments_open,
 91         .read           = seq_read,
 92         .llseek         = seq_lseek,
 93         .release        = single_release,
 94 };
 95 
 96 static int __init segments_info(void)
 97 {
 98         struct dentry *segments;
 99 
100         if (cpu_has_segments) {
101                 if (!mips_debugfs_dir)
102                         return -ENODEV;
103 
104                 segments = debugfs_create_file("segments", S_IRUGO,
105                                                mips_debugfs_dir, NULL,
106                                                &segments_fops);
107                 if (!segments)
108                         return -ENOMEM;
109         }
110         return 0;
111 }
112 
113 device_initcall(segments_info);
114 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp