4 * Creates entries in /proc/sal for various system features.
6 * Copyright (c) 2001 Silicon Graphics, Inc. All rights reserved.
8 * 10/30/2001 jbarnes@sgi.com copied much of Stephane's palinfo
9 * code to create this file
12 #include <linux/types.h>
13 #include <linux/proc_fs.h>
14 #include <linux/module.h>
18 MODULE_AUTHOR("Jesse Barnes <jbarnes@sgi.com>");
19 MODULE_DESCRIPTION("/proc interface to IA-64 SAL features");
20 MODULE_LICENSE("GPL");
22 static int salinfo_read(char *page, char **start, off_t off, int count, int *eof, void *data);
25 const char *name; /* name of the proc entry */
26 unsigned long feature; /* feature bit */
27 struct proc_dir_entry *entry; /* registered entry (removal) */
31 * List {name,feature} pairs for every entry in /proc/sal/<feature>
32 * that this module exports
34 static salinfo_entry_t salinfo_entries[]={
35 { "bus_lock", IA64_SAL_PLATFORM_FEATURE_BUS_LOCK, },
36 { "irq_redirection", IA64_SAL_PLATFORM_FEATURE_IRQ_REDIR_HINT, },
37 { "ipi_redirection", IA64_SAL_PLATFORM_FEATURE_IPI_REDIR_HINT, },
38 { "itc_drift", IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT, },
41 #define NR_SALINFO_ENTRIES (sizeof(salinfo_entries)/sizeof(salinfo_entry_t))
44 * One for each feature and one more for the directory entry...
46 static struct proc_dir_entry *salinfo_proc_entries[NR_SALINFO_ENTRIES + 1];
51 struct proc_dir_entry *salinfo_dir; /* /proc/sal dir entry */
52 struct proc_dir_entry **sdir = salinfo_proc_entries; /* keeps track of every entry */
55 salinfo_dir = proc_mkdir("sal", NULL);
57 for (i=0; i < NR_SALINFO_ENTRIES; i++) {
58 /* pass the feature bit in question as misc data */
59 *sdir = create_proc_read_entry (salinfo_entries[i].name, 0, salinfo_dir,
60 salinfo_read, (void *)salinfo_entries[i].feature);
62 *sdir->owner = THIS_MODULE;
65 *sdir++ = salinfo_dir;
75 for (i = 0; i < NR_SALINFO_ENTRIES ; i++) {
76 if (salinfo_proc_entries[i])
77 remove_proc_entry (salinfo_proc_entries[i]->name, NULL);
82 * 'data' contains an integer that corresponds to the feature we're
86 salinfo_read(char *page, char **start, off_t off, int count, int *eof, void *data)
90 len = sprintf(page, (sal_platform_features & (unsigned long)data) ? "1\n" : "0\n");
92 if (len <= off+count) *eof = 1;
97 if (len>count) len = count;
103 module_init(salinfo_init);
104 module_exit(salinfo_exit);