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

TOMOYO Linux Cross Reference
Linux/arch/ia64/sn/kernel/sn2/prominfo_proc.c

Version: ~ [ linux-5.5-rc7 ] ~ [ linux-5.4.13 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.97 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.166 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.210 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.210 ] ~ [ 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.81 ] ~ [ 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.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) 1999,2001-2004, 2006 Silicon Graphics, Inc.  All Rights Reserved.
  7  *
  8  * Module to export the system's Firmware Interface Tables, including
  9  * PROM revision numbers and banners, in /proc
 10  */
 11 #include <linux/module.h>
 12 #include <linux/slab.h>
 13 #include <linux/proc_fs.h>
 14 #include <linux/seq_file.h>
 15 #include <linux/nodemask.h>
 16 #include <asm/io.h>
 17 #include <asm/sn/sn_sal.h>
 18 #include <asm/sn/sn_cpuid.h>
 19 #include <asm/sn/addrs.h>
 20 
 21 MODULE_DESCRIPTION("PROM version reporting for /proc");
 22 MODULE_AUTHOR("Chad Talbott");
 23 MODULE_LICENSE("GPL");
 24 
 25 /* Standard Intel FIT entry types */
 26 #define FIT_ENTRY_FIT_HEADER    0x00    /* FIT header entry */
 27 #define FIT_ENTRY_PAL_B         0x01    /* PAL_B entry */
 28 /* Entries 0x02 through 0x0D reserved by Intel */
 29 #define FIT_ENTRY_PAL_A_PROC    0x0E    /* Processor-specific PAL_A entry */
 30 #define FIT_ENTRY_PAL_A         0x0F    /* PAL_A entry, same as... */
 31 #define FIT_ENTRY_PAL_A_GEN     0x0F    /* ...Generic PAL_A entry */
 32 #define FIT_ENTRY_UNUSED        0x7F    /* Unused (reserved by Intel?) */
 33 /* OEM-defined entries range from 0x10 to 0x7E. */
 34 #define FIT_ENTRY_SAL_A         0x10    /* SAL_A entry */
 35 #define FIT_ENTRY_SAL_B         0x11    /* SAL_B entry */
 36 #define FIT_ENTRY_SALRUNTIME    0x12    /* SAL runtime entry */
 37 #define FIT_ENTRY_EFI           0x1F    /* EFI entry */
 38 #define FIT_ENTRY_FPSWA         0x20    /* embedded fpswa entry */
 39 #define FIT_ENTRY_VMLINUX       0x21    /* embedded vmlinux entry */
 40 
 41 #define FIT_MAJOR_SHIFT (32 + 8)
 42 #define FIT_MAJOR_MASK  ((1 << 8) - 1)
 43 #define FIT_MINOR_SHIFT 32
 44 #define FIT_MINOR_MASK  ((1 << 8) - 1)
 45 
 46 #define FIT_MAJOR(q)    \
 47         ((unsigned) ((q) >> FIT_MAJOR_SHIFT) & FIT_MAJOR_MASK)
 48 #define FIT_MINOR(q)    \
 49         ((unsigned) ((q) >> FIT_MINOR_SHIFT) & FIT_MINOR_MASK)
 50 
 51 #define FIT_TYPE_SHIFT  (32 + 16)
 52 #define FIT_TYPE_MASK   ((1 << 7) - 1)
 53 
 54 #define FIT_TYPE(q)     \
 55         ((unsigned) ((q) >> FIT_TYPE_SHIFT) & FIT_TYPE_MASK)
 56 
 57 struct fit_type_map_t {
 58         unsigned char type;
 59         const char *name;
 60 };
 61 
 62 static const struct fit_type_map_t fit_entry_types[] = {
 63         {FIT_ENTRY_FIT_HEADER, "FIT Header"},
 64         {FIT_ENTRY_PAL_A_GEN, "Generic PAL_A"},
 65         {FIT_ENTRY_PAL_A_PROC, "Processor-specific PAL_A"},
 66         {FIT_ENTRY_PAL_A, "PAL_A"},
 67         {FIT_ENTRY_PAL_B, "PAL_B"},
 68         {FIT_ENTRY_SAL_A, "SAL_A"},
 69         {FIT_ENTRY_SAL_B, "SAL_B"},
 70         {FIT_ENTRY_SALRUNTIME, "SAL runtime"},
 71         {FIT_ENTRY_EFI, "EFI"},
 72         {FIT_ENTRY_VMLINUX, "Embedded Linux"},
 73         {FIT_ENTRY_FPSWA, "Embedded FPSWA"},
 74         {FIT_ENTRY_UNUSED, "Unused"},
 75         {0xff, "Error"},
 76 };
 77 
 78 static const char *fit_type_name(unsigned char type)
 79 {
 80         struct fit_type_map_t const *mapp;
 81 
 82         for (mapp = fit_entry_types; mapp->type != 0xff; mapp++)
 83                 if (type == mapp->type)
 84                         return mapp->name;
 85 
 86         if ((type > FIT_ENTRY_PAL_A) && (type < FIT_ENTRY_UNUSED))
 87                 return "OEM type";
 88         if ((type > FIT_ENTRY_PAL_B) && (type < FIT_ENTRY_PAL_A))
 89                 return "Reserved";
 90 
 91         return "Unknown type";
 92 }
 93 
 94 static int
 95 get_fit_entry(unsigned long nasid, int index, unsigned long *fentry,
 96               char *banner, int banlen)
 97 {
 98         return ia64_sn_get_fit_compt(nasid, index, fentry, banner, banlen);
 99 }
100 
101 
102 /*
103  * These two routines display the FIT table for each node.
104  */
105 static void dump_fit_entry(struct seq_file *m, unsigned long *fentry)
106 {
107         unsigned type;
108 
109         type = FIT_TYPE(fentry[1]);
110         seq_printf(m, "%02x %-25s %x.%02x %016lx %u\n",
111                    type,
112                    fit_type_name(type),
113                    FIT_MAJOR(fentry[1]), FIT_MINOR(fentry[1]),
114                    fentry[0],
115                    /* mult by sixteen to get size in bytes */
116                    (unsigned)(fentry[1] & 0xffffff) * 16);
117 }
118 
119 
120 /*
121  * We assume that the fit table will be small enough that we can print
122  * the whole thing into one page.  (This is true for our default 16kB
123  * pages -- each entry is about 60 chars wide when printed.)  I read
124  * somewhere that the maximum size of the FIT is 128 entries, so we're
125  * OK except for 4kB pages (and no one is going to do that on SN
126  * anyway).
127  */
128 static int proc_fit_show(struct seq_file *m, void *v)
129 {
130         unsigned long nasid = (unsigned long)m->private;
131         unsigned long fentry[2];
132         int index;
133 
134         for (index=0;;index++) {
135                 BUG_ON(index * 60 > PAGE_SIZE);
136                 if (get_fit_entry(nasid, index, fentry, NULL, 0))
137                         break;
138                 dump_fit_entry(m, fentry);
139         }
140         return 0;
141 }
142 
143 static int proc_version_show(struct seq_file *m, void *v)
144 {
145         unsigned long nasid = (unsigned long)m->private;
146         unsigned long fentry[2];
147         char banner[128];
148         int index;
149 
150         for (index = 0; ; index++) {
151                 if (get_fit_entry(nasid, index, fentry, banner,
152                                   sizeof(banner)))
153                         return 0;
154                 if (FIT_TYPE(fentry[1]) == FIT_ENTRY_SAL_A)
155                         break;
156         }
157 
158         seq_printf(m, "%x.%02x\n", FIT_MAJOR(fentry[1]), FIT_MINOR(fentry[1]));
159 
160         if (banner[0])
161                 seq_printf(m, "%s\n", banner);
162         return 0;
163 }
164 
165 /* module entry points */
166 int __init prominfo_init(void);
167 void __exit prominfo_exit(void);
168 
169 module_init(prominfo_init);
170 module_exit(prominfo_exit);
171 
172 #define NODE_NAME_LEN 11
173 
174 int __init prominfo_init(void)
175 {
176         struct proc_dir_entry *sgi_prominfo_entry;
177         cnodeid_t cnodeid;
178 
179         if (!ia64_platform_is("sn2"))
180                 return 0;
181 
182         sgi_prominfo_entry = proc_mkdir("sgi_prominfo", NULL);
183         if (!sgi_prominfo_entry)
184                 return -ENOMEM;
185 
186         for_each_online_node(cnodeid) {
187                 struct proc_dir_entry *dir;
188                 unsigned long nasid;
189                 char name[NODE_NAME_LEN];
190 
191                 sprintf(name, "node%d", cnodeid);
192                 dir = proc_mkdir(name, sgi_prominfo_entry);
193                 if (!dir)
194                         continue;
195                 nasid = cnodeid_to_nasid(cnodeid);
196                 proc_create_single_data("fit", 0, dir, proc_fit_show, 
197                                 (void *)nasid);
198                 proc_create_single_data("version", 0, dir, proc_version_show,
199                                 (void *)nasid);
200         }
201         return 0;
202 }
203 
204 void __exit prominfo_exit(void)
205 {
206         remove_proc_subtree("sgi_prominfo", NULL);
207 }
208 

~ [ 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