salinfo.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. /*
  2. * salinfo.c
  3. *
  4. * Creates entries in /proc/sal for various system features.
  5. *
  6. * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.
  7. * Copyright (c) 2003 Hewlett-Packard Co
  8. * Bjorn Helgaas <bjorn.helgaas@hp.com>
  9. *
  10. * 10/30/2001 jbarnes@sgi.com copied much of Stephane's palinfo
  11. * code to create this file
  12. * Oct 23 2003 kaos@sgi.com
  13. * Replace IPI with set_cpus_allowed() to read a record from the required cpu.
  14. * Redesign salinfo log processing to separate interrupt and user space
  15. * contexts.
  16. * Cache the record across multi-block reads from user space.
  17. * Support > 64 cpus.
  18. * Delete module_exit and MOD_INC/DEC_COUNT, salinfo cannot be a module.
  19. *
  20. * Jan 28 2004 kaos@sgi.com
  21. * Periodically check for outstanding MCA or INIT records.
  22. *
  23. * Dec 5 2004 kaos@sgi.com
  24. * Standardize which records are cleared automatically.
  25. */
  26. #include <linux/types.h>
  27. #include <linux/proc_fs.h>
  28. #include <linux/module.h>
  29. #include <linux/smp.h>
  30. #include <linux/smp_lock.h>
  31. #include <linux/timer.h>
  32. #include <linux/vmalloc.h>
  33. #include <asm/semaphore.h>
  34. #include <asm/sal.h>
  35. #include <asm/uaccess.h>
  36. MODULE_AUTHOR("Jesse Barnes <jbarnes@sgi.com>");
  37. MODULE_DESCRIPTION("/proc interface to IA-64 SAL features");
  38. MODULE_LICENSE("GPL");
  39. static int salinfo_read(char *page, char **start, off_t off, int count, int *eof, void *data);
  40. typedef struct {
  41. const char *name; /* name of the proc entry */
  42. unsigned long feature; /* feature bit */
  43. struct proc_dir_entry *entry; /* registered entry (removal) */
  44. } salinfo_entry_t;
  45. /*
  46. * List {name,feature} pairs for every entry in /proc/sal/<feature>
  47. * that this module exports
  48. */
  49. static salinfo_entry_t salinfo_entries[]={
  50. { "bus_lock", IA64_SAL_PLATFORM_FEATURE_BUS_LOCK, },
  51. { "irq_redirection", IA64_SAL_PLATFORM_FEATURE_IRQ_REDIR_HINT, },
  52. { "ipi_redirection", IA64_SAL_PLATFORM_FEATURE_IPI_REDIR_HINT, },
  53. { "itc_drift", IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT, },
  54. };
  55. #define NR_SALINFO_ENTRIES ARRAY_SIZE(salinfo_entries)
  56. static char *salinfo_log_name[] = {
  57. "mca",
  58. "init",
  59. "cmc",
  60. "cpe",
  61. };
  62. static struct proc_dir_entry *salinfo_proc_entries[
  63. ARRAY_SIZE(salinfo_entries) + /* /proc/sal/bus_lock */
  64. ARRAY_SIZE(salinfo_log_name) + /* /proc/sal/{mca,...} */
  65. (2 * ARRAY_SIZE(salinfo_log_name)) + /* /proc/sal/mca/{event,data} */
  66. 1]; /* /proc/sal */
  67. /* Some records we get ourselves, some are accessed as saved data in buffers
  68. * that are owned by mca.c.
  69. */
  70. struct salinfo_data_saved {
  71. u8* buffer;
  72. u64 size;
  73. u64 id;
  74. int cpu;
  75. };
  76. /* State transitions. Actions are :-
  77. * Write "read <cpunum>" to the data file.
  78. * Write "clear <cpunum>" to the data file.
  79. * Write "oemdata <cpunum> <offset> to the data file.
  80. * Read from the data file.
  81. * Close the data file.
  82. *
  83. * Start state is NO_DATA.
  84. *
  85. * NO_DATA
  86. * write "read <cpunum>" -> NO_DATA or LOG_RECORD.
  87. * write "clear <cpunum>" -> NO_DATA or LOG_RECORD.
  88. * write "oemdata <cpunum> <offset> -> return -EINVAL.
  89. * read data -> return EOF.
  90. * close -> unchanged. Free record areas.
  91. *
  92. * LOG_RECORD
  93. * write "read <cpunum>" -> NO_DATA or LOG_RECORD.
  94. * write "clear <cpunum>" -> NO_DATA or LOG_RECORD.
  95. * write "oemdata <cpunum> <offset> -> format the oem data, goto OEMDATA.
  96. * read data -> return the INIT/MCA/CMC/CPE record.
  97. * close -> unchanged. Keep record areas.
  98. *
  99. * OEMDATA
  100. * write "read <cpunum>" -> NO_DATA or LOG_RECORD.
  101. * write "clear <cpunum>" -> NO_DATA or LOG_RECORD.
  102. * write "oemdata <cpunum> <offset> -> format the oem data, goto OEMDATA.
  103. * read data -> return the formatted oemdata.
  104. * close -> unchanged. Keep record areas.
  105. *
  106. * Closing the data file does not change the state. This allows shell scripts
  107. * to manipulate salinfo data, each shell redirection opens the file, does one
  108. * action then closes it again. The record areas are only freed at close when
  109. * the state is NO_DATA.
  110. */
  111. enum salinfo_state {
  112. STATE_NO_DATA,
  113. STATE_LOG_RECORD,
  114. STATE_OEMDATA,
  115. };
  116. struct salinfo_data {
  117. volatile cpumask_t cpu_event; /* which cpus have outstanding events */
  118. struct semaphore sem; /* count of cpus with outstanding events (bits set in cpu_event) */
  119. u8 *log_buffer;
  120. u64 log_size;
  121. u8 *oemdata; /* decoded oem data */
  122. u64 oemdata_size;
  123. int open; /* single-open to prevent races */
  124. u8 type;
  125. u8 saved_num; /* using a saved record? */
  126. enum salinfo_state state :8; /* processing state */
  127. u8 padding;
  128. int cpu_check; /* next CPU to check */
  129. struct salinfo_data_saved data_saved[5];/* save last 5 records from mca.c, must be < 255 */
  130. };
  131. static struct salinfo_data salinfo_data[ARRAY_SIZE(salinfo_log_name)];
  132. static DEFINE_SPINLOCK(data_lock);
  133. static DEFINE_SPINLOCK(data_saved_lock);
  134. /** salinfo_platform_oemdata - optional callback to decode oemdata from an error
  135. * record.
  136. * @sect_header: pointer to the start of the section to decode.
  137. * @oemdata: returns vmalloc area containing the decded output.
  138. * @oemdata_size: returns length of decoded output (strlen).
  139. *
  140. * Description: If user space asks for oem data to be decoded by the kernel
  141. * and/or prom and the platform has set salinfo_platform_oemdata to the address
  142. * of a platform specific routine then call that routine. salinfo_platform_oemdata
  143. * vmalloc's and formats its output area, returning the address of the text
  144. * and its strlen. Returns 0 for success, -ve for error. The callback is
  145. * invoked on the cpu that generated the error record.
  146. */
  147. int (*salinfo_platform_oemdata)(const u8 *sect_header, u8 **oemdata, u64 *oemdata_size);
  148. struct salinfo_platform_oemdata_parms {
  149. const u8 *efi_guid;
  150. u8 **oemdata;
  151. u64 *oemdata_size;
  152. int ret;
  153. };
  154. static void
  155. salinfo_platform_oemdata_cpu(void *context)
  156. {
  157. struct salinfo_platform_oemdata_parms *parms = context;
  158. parms->ret = salinfo_platform_oemdata(parms->efi_guid, parms->oemdata, parms->oemdata_size);
  159. }
  160. static void
  161. shift1_data_saved (struct salinfo_data *data, int shift)
  162. {
  163. memcpy(data->data_saved+shift, data->data_saved+shift+1,
  164. (ARRAY_SIZE(data->data_saved) - (shift+1)) * sizeof(data->data_saved[0]));
  165. memset(data->data_saved + ARRAY_SIZE(data->data_saved) - 1, 0,
  166. sizeof(data->data_saved[0]));
  167. }
  168. /* This routine is invoked in interrupt context. Note: mca.c enables
  169. * interrupts before calling this code for CMC/CPE. MCA and INIT events are
  170. * not irq safe, do not call any routines that use spinlocks, they may deadlock.
  171. * MCA and INIT records are recorded, a timer event will look for any
  172. * outstanding events and wake up the user space code.
  173. *
  174. * The buffer passed from mca.c points to the output from ia64_log_get. This is
  175. * a persistent buffer but its contents can change between the interrupt and
  176. * when user space processes the record. Save the record id to identify
  177. * changes.
  178. */
  179. void
  180. salinfo_log_wakeup(int type, u8 *buffer, u64 size, int irqsafe)
  181. {
  182. struct salinfo_data *data = salinfo_data + type;
  183. struct salinfo_data_saved *data_saved;
  184. unsigned long flags = 0;
  185. int i;
  186. int saved_size = ARRAY_SIZE(data->data_saved);
  187. BUG_ON(type >= ARRAY_SIZE(salinfo_log_name));
  188. if (irqsafe)
  189. spin_lock_irqsave(&data_saved_lock, flags);
  190. for (i = 0, data_saved = data->data_saved; i < saved_size; ++i, ++data_saved) {
  191. if (!data_saved->buffer)
  192. break;
  193. }
  194. if (i == saved_size) {
  195. if (!data->saved_num) {
  196. shift1_data_saved(data, 0);
  197. data_saved = data->data_saved + saved_size - 1;
  198. } else
  199. data_saved = NULL;
  200. }
  201. if (data_saved) {
  202. data_saved->cpu = smp_processor_id();
  203. data_saved->id = ((sal_log_record_header_t *)buffer)->id;
  204. data_saved->size = size;
  205. data_saved->buffer = buffer;
  206. }
  207. if (irqsafe)
  208. spin_unlock_irqrestore(&data_saved_lock, flags);
  209. if (!test_and_set_bit(smp_processor_id(), &data->cpu_event)) {
  210. if (irqsafe)
  211. up(&data->sem);
  212. }
  213. }
  214. /* Check for outstanding MCA/INIT records every minute (arbitrary) */
  215. #define SALINFO_TIMER_DELAY (60*HZ)
  216. static struct timer_list salinfo_timer;
  217. static void
  218. salinfo_timeout_check(struct salinfo_data *data)
  219. {
  220. int i;
  221. if (!data->open)
  222. return;
  223. for (i = 0; i < NR_CPUS; ++i) {
  224. if (test_bit(i, &data->cpu_event)) {
  225. /* double up() is not a problem, user space will see no
  226. * records for the additional "events".
  227. */
  228. up(&data->sem);
  229. }
  230. }
  231. }
  232. static void
  233. salinfo_timeout (unsigned long arg)
  234. {
  235. salinfo_timeout_check(salinfo_data + SAL_INFO_TYPE_MCA);
  236. salinfo_timeout_check(salinfo_data + SAL_INFO_TYPE_INIT);
  237. salinfo_timer.expires = jiffies + SALINFO_TIMER_DELAY;
  238. add_timer(&salinfo_timer);
  239. }
  240. static int
  241. salinfo_event_open(struct inode *inode, struct file *file)
  242. {
  243. if (!capable(CAP_SYS_ADMIN))
  244. return -EPERM;
  245. return 0;
  246. }
  247. static ssize_t
  248. salinfo_event_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
  249. {
  250. struct inode *inode = file->f_dentry->d_inode;
  251. struct proc_dir_entry *entry = PDE(inode);
  252. struct salinfo_data *data = entry->data;
  253. char cmd[32];
  254. size_t size;
  255. int i, n, cpu = -1;
  256. retry:
  257. if (down_trylock(&data->sem)) {
  258. if (file->f_flags & O_NONBLOCK)
  259. return -EAGAIN;
  260. if (down_interruptible(&data->sem))
  261. return -ERESTARTSYS;
  262. }
  263. n = data->cpu_check;
  264. for (i = 0; i < NR_CPUS; i++) {
  265. if (test_bit(n, &data->cpu_event)) {
  266. cpu = n;
  267. break;
  268. }
  269. if (++n == NR_CPUS)
  270. n = 0;
  271. }
  272. if (cpu == -1)
  273. goto retry;
  274. /* events are sticky until the user says "clear" */
  275. up(&data->sem);
  276. /* for next read, start checking at next CPU */
  277. data->cpu_check = cpu;
  278. if (++data->cpu_check == NR_CPUS)
  279. data->cpu_check = 0;
  280. snprintf(cmd, sizeof(cmd), "read %d\n", cpu);
  281. size = strlen(cmd);
  282. if (size > count)
  283. size = count;
  284. if (copy_to_user(buffer, cmd, size))
  285. return -EFAULT;
  286. return size;
  287. }
  288. static struct file_operations salinfo_event_fops = {
  289. .open = salinfo_event_open,
  290. .read = salinfo_event_read,
  291. };
  292. static int
  293. salinfo_log_open(struct inode *inode, struct file *file)
  294. {
  295. struct proc_dir_entry *entry = PDE(inode);
  296. struct salinfo_data *data = entry->data;
  297. if (!capable(CAP_SYS_ADMIN))
  298. return -EPERM;
  299. spin_lock(&data_lock);
  300. if (data->open) {
  301. spin_unlock(&data_lock);
  302. return -EBUSY;
  303. }
  304. data->open = 1;
  305. spin_unlock(&data_lock);
  306. if (data->state == STATE_NO_DATA &&
  307. !(data->log_buffer = vmalloc(ia64_sal_get_state_info_size(data->type)))) {
  308. data->open = 0;
  309. return -ENOMEM;
  310. }
  311. return 0;
  312. }
  313. static int
  314. salinfo_log_release(struct inode *inode, struct file *file)
  315. {
  316. struct proc_dir_entry *entry = PDE(inode);
  317. struct salinfo_data *data = entry->data;
  318. if (data->state == STATE_NO_DATA) {
  319. vfree(data->log_buffer);
  320. vfree(data->oemdata);
  321. data->log_buffer = NULL;
  322. data->oemdata = NULL;
  323. }
  324. spin_lock(&data_lock);
  325. data->open = 0;
  326. spin_unlock(&data_lock);
  327. return 0;
  328. }
  329. static void
  330. call_on_cpu(int cpu, void (*fn)(void *), void *arg)
  331. {
  332. cpumask_t save_cpus_allowed, new_cpus_allowed;
  333. memcpy(&save_cpus_allowed, &current->cpus_allowed, sizeof(save_cpus_allowed));
  334. memset(&new_cpus_allowed, 0, sizeof(new_cpus_allowed));
  335. set_bit(cpu, &new_cpus_allowed);
  336. set_cpus_allowed(current, new_cpus_allowed);
  337. (*fn)(arg);
  338. set_cpus_allowed(current, save_cpus_allowed);
  339. }
  340. static void
  341. salinfo_log_read_cpu(void *context)
  342. {
  343. struct salinfo_data *data = context;
  344. sal_log_record_header_t *rh;
  345. data->log_size = ia64_sal_get_state_info(data->type, (u64 *) data->log_buffer);
  346. rh = (sal_log_record_header_t *)(data->log_buffer);
  347. /* Clear corrected errors as they are read from SAL */
  348. if (rh->severity == sal_log_severity_corrected)
  349. ia64_sal_clear_state_info(data->type);
  350. }
  351. static void
  352. salinfo_log_new_read(int cpu, struct salinfo_data *data)
  353. {
  354. struct salinfo_data_saved *data_saved;
  355. unsigned long flags;
  356. int i;
  357. int saved_size = ARRAY_SIZE(data->data_saved);
  358. data->saved_num = 0;
  359. spin_lock_irqsave(&data_saved_lock, flags);
  360. retry:
  361. for (i = 0, data_saved = data->data_saved; i < saved_size; ++i, ++data_saved) {
  362. if (data_saved->buffer && data_saved->cpu == cpu) {
  363. sal_log_record_header_t *rh = (sal_log_record_header_t *)(data_saved->buffer);
  364. data->log_size = data_saved->size;
  365. memcpy(data->log_buffer, rh, data->log_size);
  366. barrier(); /* id check must not be moved */
  367. if (rh->id == data_saved->id) {
  368. data->saved_num = i+1;
  369. break;
  370. }
  371. /* saved record changed by mca.c since interrupt, discard it */
  372. shift1_data_saved(data, i);
  373. goto retry;
  374. }
  375. }
  376. spin_unlock_irqrestore(&data_saved_lock, flags);
  377. if (!data->saved_num)
  378. call_on_cpu(cpu, salinfo_log_read_cpu, data);
  379. if (!data->log_size) {
  380. data->state = STATE_NO_DATA;
  381. clear_bit(cpu, &data->cpu_event);
  382. } else {
  383. data->state = STATE_LOG_RECORD;
  384. }
  385. }
  386. static ssize_t
  387. salinfo_log_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
  388. {
  389. struct inode *inode = file->f_dentry->d_inode;
  390. struct proc_dir_entry *entry = PDE(inode);
  391. struct salinfo_data *data = entry->data;
  392. u8 *buf;
  393. u64 bufsize;
  394. if (data->state == STATE_LOG_RECORD) {
  395. buf = data->log_buffer;
  396. bufsize = data->log_size;
  397. } else if (data->state == STATE_OEMDATA) {
  398. buf = data->oemdata;
  399. bufsize = data->oemdata_size;
  400. } else {
  401. buf = NULL;
  402. bufsize = 0;
  403. }
  404. return simple_read_from_buffer(buffer, count, ppos, buf, bufsize);
  405. }
  406. static void
  407. salinfo_log_clear_cpu(void *context)
  408. {
  409. struct salinfo_data *data = context;
  410. ia64_sal_clear_state_info(data->type);
  411. }
  412. static int
  413. salinfo_log_clear(struct salinfo_data *data, int cpu)
  414. {
  415. sal_log_record_header_t *rh;
  416. data->state = STATE_NO_DATA;
  417. if (!test_bit(cpu, &data->cpu_event))
  418. return 0;
  419. down(&data->sem);
  420. clear_bit(cpu, &data->cpu_event);
  421. if (data->saved_num) {
  422. unsigned long flags;
  423. spin_lock_irqsave(&data_saved_lock, flags);
  424. shift1_data_saved(data, data->saved_num - 1 );
  425. data->saved_num = 0;
  426. spin_unlock_irqrestore(&data_saved_lock, flags);
  427. }
  428. rh = (sal_log_record_header_t *)(data->log_buffer);
  429. /* Corrected errors have already been cleared from SAL */
  430. if (rh->severity != sal_log_severity_corrected)
  431. call_on_cpu(cpu, salinfo_log_clear_cpu, data);
  432. /* clearing a record may make a new record visible */
  433. salinfo_log_new_read(cpu, data);
  434. if (data->state == STATE_LOG_RECORD &&
  435. !test_and_set_bit(cpu, &data->cpu_event))
  436. up(&data->sem);
  437. return 0;
  438. }
  439. static ssize_t
  440. salinfo_log_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
  441. {
  442. struct inode *inode = file->f_dentry->d_inode;
  443. struct proc_dir_entry *entry = PDE(inode);
  444. struct salinfo_data *data = entry->data;
  445. char cmd[32];
  446. size_t size;
  447. u32 offset;
  448. int cpu;
  449. size = sizeof(cmd);
  450. if (count < size)
  451. size = count;
  452. if (copy_from_user(cmd, buffer, size))
  453. return -EFAULT;
  454. if (sscanf(cmd, "read %d", &cpu) == 1) {
  455. salinfo_log_new_read(cpu, data);
  456. } else if (sscanf(cmd, "clear %d", &cpu) == 1) {
  457. int ret;
  458. if ((ret = salinfo_log_clear(data, cpu)))
  459. count = ret;
  460. } else if (sscanf(cmd, "oemdata %d %d", &cpu, &offset) == 2) {
  461. if (data->state != STATE_LOG_RECORD && data->state != STATE_OEMDATA)
  462. return -EINVAL;
  463. if (offset > data->log_size - sizeof(efi_guid_t))
  464. return -EINVAL;
  465. data->state = STATE_OEMDATA;
  466. if (salinfo_platform_oemdata) {
  467. struct salinfo_platform_oemdata_parms parms = {
  468. .efi_guid = data->log_buffer + offset,
  469. .oemdata = &data->oemdata,
  470. .oemdata_size = &data->oemdata_size
  471. };
  472. call_on_cpu(cpu, salinfo_platform_oemdata_cpu, &parms);
  473. if (parms.ret)
  474. count = parms.ret;
  475. } else
  476. data->oemdata_size = 0;
  477. } else
  478. return -EINVAL;
  479. return count;
  480. }
  481. static struct file_operations salinfo_data_fops = {
  482. .open = salinfo_log_open,
  483. .release = salinfo_log_release,
  484. .read = salinfo_log_read,
  485. .write = salinfo_log_write,
  486. };
  487. static int __init
  488. salinfo_init(void)
  489. {
  490. struct proc_dir_entry *salinfo_dir; /* /proc/sal dir entry */
  491. struct proc_dir_entry **sdir = salinfo_proc_entries; /* keeps track of every entry */
  492. struct proc_dir_entry *dir, *entry;
  493. struct salinfo_data *data;
  494. int i, j, online;
  495. salinfo_dir = proc_mkdir("sal", NULL);
  496. if (!salinfo_dir)
  497. return 0;
  498. for (i=0; i < NR_SALINFO_ENTRIES; i++) {
  499. /* pass the feature bit in question as misc data */
  500. *sdir++ = create_proc_read_entry (salinfo_entries[i].name, 0, salinfo_dir,
  501. salinfo_read, (void *)salinfo_entries[i].feature);
  502. }
  503. for (i = 0; i < ARRAY_SIZE(salinfo_log_name); i++) {
  504. data = salinfo_data + i;
  505. data->type = i;
  506. sema_init(&data->sem, 0);
  507. dir = proc_mkdir(salinfo_log_name[i], salinfo_dir);
  508. if (!dir)
  509. continue;
  510. entry = create_proc_entry("event", S_IRUSR, dir);
  511. if (!entry)
  512. continue;
  513. entry->data = data;
  514. entry->proc_fops = &salinfo_event_fops;
  515. *sdir++ = entry;
  516. entry = create_proc_entry("data", S_IRUSR | S_IWUSR, dir);
  517. if (!entry)
  518. continue;
  519. entry->data = data;
  520. entry->proc_fops = &salinfo_data_fops;
  521. *sdir++ = entry;
  522. /* we missed any events before now */
  523. online = 0;
  524. for (j = 0; j < NR_CPUS; j++)
  525. if (cpu_online(j)) {
  526. set_bit(j, &data->cpu_event);
  527. ++online;
  528. }
  529. sema_init(&data->sem, online);
  530. *sdir++ = dir;
  531. }
  532. *sdir++ = salinfo_dir;
  533. init_timer(&salinfo_timer);
  534. salinfo_timer.expires = jiffies + SALINFO_TIMER_DELAY;
  535. salinfo_timer.function = &salinfo_timeout;
  536. add_timer(&salinfo_timer);
  537. return 0;
  538. }
  539. /*
  540. * 'data' contains an integer that corresponds to the feature we're
  541. * testing
  542. */
  543. static int
  544. salinfo_read(char *page, char **start, off_t off, int count, int *eof, void *data)
  545. {
  546. int len = 0;
  547. len = sprintf(page, (sal_platform_features & (unsigned long)data) ? "1\n" : "0\n");
  548. if (len <= off+count) *eof = 1;
  549. *start = page + off;
  550. len -= off;
  551. if (len>count) len = count;
  552. if (len<0) len = 0;
  553. return len;
  554. }
  555. module_init(salinfo_init);