salinfo.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  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 spinlock_t data_lock, data_saved_lock;
  133. /** salinfo_platform_oemdata - optional callback to decode oemdata from an error
  134. * record.
  135. * @sect_header: pointer to the start of the section to decode.
  136. * @oemdata: returns vmalloc area containing the decded output.
  137. * @oemdata_size: returns length of decoded output (strlen).
  138. *
  139. * Description: If user space asks for oem data to be decoded by the kernel
  140. * and/or prom and the platform has set salinfo_platform_oemdata to the address
  141. * of a platform specific routine then call that routine. salinfo_platform_oemdata
  142. * vmalloc's and formats its output area, returning the address of the text
  143. * and its strlen. Returns 0 for success, -ve for error. The callback is
  144. * invoked on the cpu that generated the error record.
  145. */
  146. int (*salinfo_platform_oemdata)(const u8 *sect_header, u8 **oemdata, u64 *oemdata_size);
  147. struct salinfo_platform_oemdata_parms {
  148. const u8 *efi_guid;
  149. u8 **oemdata;
  150. u64 *oemdata_size;
  151. int ret;
  152. };
  153. static void
  154. salinfo_platform_oemdata_cpu(void *context)
  155. {
  156. struct salinfo_platform_oemdata_parms *parms = context;
  157. parms->ret = salinfo_platform_oemdata(parms->efi_guid, parms->oemdata, parms->oemdata_size);
  158. }
  159. static void
  160. shift1_data_saved (struct salinfo_data *data, int shift)
  161. {
  162. memcpy(data->data_saved+shift, data->data_saved+shift+1,
  163. (ARRAY_SIZE(data->data_saved) - (shift+1)) * sizeof(data->data_saved[0]));
  164. memset(data->data_saved + ARRAY_SIZE(data->data_saved) - 1, 0,
  165. sizeof(data->data_saved[0]));
  166. }
  167. /* This routine is invoked in interrupt context. Note: mca.c enables
  168. * interrupts before calling this code for CMC/CPE. MCA and INIT events are
  169. * not irq safe, do not call any routines that use spinlocks, they may deadlock.
  170. * MCA and INIT records are recorded, a timer event will look for any
  171. * outstanding events and wake up the user space code.
  172. *
  173. * The buffer passed from mca.c points to the output from ia64_log_get. This is
  174. * a persistent buffer but its contents can change between the interrupt and
  175. * when user space processes the record. Save the record id to identify
  176. * changes.
  177. */
  178. void
  179. salinfo_log_wakeup(int type, u8 *buffer, u64 size, int irqsafe)
  180. {
  181. struct salinfo_data *data = salinfo_data + type;
  182. struct salinfo_data_saved *data_saved;
  183. unsigned long flags = 0;
  184. int i;
  185. int saved_size = ARRAY_SIZE(data->data_saved);
  186. BUG_ON(type >= ARRAY_SIZE(salinfo_log_name));
  187. if (irqsafe)
  188. spin_lock_irqsave(&data_saved_lock, flags);
  189. for (i = 0, data_saved = data->data_saved; i < saved_size; ++i, ++data_saved) {
  190. if (!data_saved->buffer)
  191. break;
  192. }
  193. if (i == saved_size) {
  194. if (!data->saved_num) {
  195. shift1_data_saved(data, 0);
  196. data_saved = data->data_saved + saved_size - 1;
  197. } else
  198. data_saved = NULL;
  199. }
  200. if (data_saved) {
  201. data_saved->cpu = smp_processor_id();
  202. data_saved->id = ((sal_log_record_header_t *)buffer)->id;
  203. data_saved->size = size;
  204. data_saved->buffer = buffer;
  205. }
  206. if (irqsafe)
  207. spin_unlock_irqrestore(&data_saved_lock, flags);
  208. if (!test_and_set_bit(smp_processor_id(), &data->cpu_event)) {
  209. if (irqsafe)
  210. up(&data->sem);
  211. }
  212. }
  213. /* Check for outstanding MCA/INIT records every minute (arbitrary) */
  214. #define SALINFO_TIMER_DELAY (60*HZ)
  215. static struct timer_list salinfo_timer;
  216. static void
  217. salinfo_timeout_check(struct salinfo_data *data)
  218. {
  219. int i;
  220. if (!data->open)
  221. return;
  222. for (i = 0; i < NR_CPUS; ++i) {
  223. if (test_bit(i, &data->cpu_event)) {
  224. /* double up() is not a problem, user space will see no
  225. * records for the additional "events".
  226. */
  227. up(&data->sem);
  228. }
  229. }
  230. }
  231. static void
  232. salinfo_timeout (unsigned long arg)
  233. {
  234. salinfo_timeout_check(salinfo_data + SAL_INFO_TYPE_MCA);
  235. salinfo_timeout_check(salinfo_data + SAL_INFO_TYPE_INIT);
  236. salinfo_timer.expires = jiffies + SALINFO_TIMER_DELAY;
  237. add_timer(&salinfo_timer);
  238. }
  239. static int
  240. salinfo_event_open(struct inode *inode, struct file *file)
  241. {
  242. if (!capable(CAP_SYS_ADMIN))
  243. return -EPERM;
  244. return 0;
  245. }
  246. static ssize_t
  247. salinfo_event_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
  248. {
  249. struct inode *inode = file->f_dentry->d_inode;
  250. struct proc_dir_entry *entry = PDE(inode);
  251. struct salinfo_data *data = entry->data;
  252. char cmd[32];
  253. size_t size;
  254. int i, n, cpu = -1;
  255. retry:
  256. if (down_trylock(&data->sem)) {
  257. if (file->f_flags & O_NONBLOCK)
  258. return -EAGAIN;
  259. if (down_interruptible(&data->sem))
  260. return -ERESTARTSYS;
  261. }
  262. n = data->cpu_check;
  263. for (i = 0; i < NR_CPUS; i++) {
  264. if (test_bit(n, &data->cpu_event)) {
  265. cpu = n;
  266. break;
  267. }
  268. if (++n == NR_CPUS)
  269. n = 0;
  270. }
  271. if (cpu == -1)
  272. goto retry;
  273. /* events are sticky until the user says "clear" */
  274. up(&data->sem);
  275. /* for next read, start checking at next CPU */
  276. data->cpu_check = cpu;
  277. if (++data->cpu_check == NR_CPUS)
  278. data->cpu_check = 0;
  279. snprintf(cmd, sizeof(cmd), "read %d\n", cpu);
  280. size = strlen(cmd);
  281. if (size > count)
  282. size = count;
  283. if (copy_to_user(buffer, cmd, size))
  284. return -EFAULT;
  285. return size;
  286. }
  287. static struct file_operations salinfo_event_fops = {
  288. .open = salinfo_event_open,
  289. .read = salinfo_event_read,
  290. };
  291. static int
  292. salinfo_log_open(struct inode *inode, struct file *file)
  293. {
  294. struct proc_dir_entry *entry = PDE(inode);
  295. struct salinfo_data *data = entry->data;
  296. if (!capable(CAP_SYS_ADMIN))
  297. return -EPERM;
  298. spin_lock(&data_lock);
  299. if (data->open) {
  300. spin_unlock(&data_lock);
  301. return -EBUSY;
  302. }
  303. data->open = 1;
  304. spin_unlock(&data_lock);
  305. if (data->state == STATE_NO_DATA &&
  306. !(data->log_buffer = vmalloc(ia64_sal_get_state_info_size(data->type)))) {
  307. data->open = 0;
  308. return -ENOMEM;
  309. }
  310. return 0;
  311. }
  312. static int
  313. salinfo_log_release(struct inode *inode, struct file *file)
  314. {
  315. struct proc_dir_entry *entry = PDE(inode);
  316. struct salinfo_data *data = entry->data;
  317. if (data->state == STATE_NO_DATA) {
  318. vfree(data->log_buffer);
  319. vfree(data->oemdata);
  320. data->log_buffer = NULL;
  321. data->oemdata = NULL;
  322. }
  323. spin_lock(&data_lock);
  324. data->open = 0;
  325. spin_unlock(&data_lock);
  326. return 0;
  327. }
  328. static void
  329. call_on_cpu(int cpu, void (*fn)(void *), void *arg)
  330. {
  331. cpumask_t save_cpus_allowed, new_cpus_allowed;
  332. memcpy(&save_cpus_allowed, &current->cpus_allowed, sizeof(save_cpus_allowed));
  333. memset(&new_cpus_allowed, 0, sizeof(new_cpus_allowed));
  334. set_bit(cpu, &new_cpus_allowed);
  335. set_cpus_allowed(current, new_cpus_allowed);
  336. (*fn)(arg);
  337. set_cpus_allowed(current, save_cpus_allowed);
  338. }
  339. static void
  340. salinfo_log_read_cpu(void *context)
  341. {
  342. struct salinfo_data *data = context;
  343. sal_log_record_header_t *rh;
  344. data->log_size = ia64_sal_get_state_info(data->type, (u64 *) data->log_buffer);
  345. rh = (sal_log_record_header_t *)(data->log_buffer);
  346. /* Clear corrected errors as they are read from SAL */
  347. if (rh->severity == sal_log_severity_corrected)
  348. ia64_sal_clear_state_info(data->type);
  349. }
  350. static void
  351. salinfo_log_new_read(int cpu, struct salinfo_data *data)
  352. {
  353. struct salinfo_data_saved *data_saved;
  354. unsigned long flags;
  355. int i;
  356. int saved_size = ARRAY_SIZE(data->data_saved);
  357. data->saved_num = 0;
  358. spin_lock_irqsave(&data_saved_lock, flags);
  359. retry:
  360. for (i = 0, data_saved = data->data_saved; i < saved_size; ++i, ++data_saved) {
  361. if (data_saved->buffer && data_saved->cpu == cpu) {
  362. sal_log_record_header_t *rh = (sal_log_record_header_t *)(data_saved->buffer);
  363. data->log_size = data_saved->size;
  364. memcpy(data->log_buffer, rh, data->log_size);
  365. barrier(); /* id check must not be moved */
  366. if (rh->id == data_saved->id) {
  367. data->saved_num = i+1;
  368. break;
  369. }
  370. /* saved record changed by mca.c since interrupt, discard it */
  371. shift1_data_saved(data, i);
  372. goto retry;
  373. }
  374. }
  375. spin_unlock_irqrestore(&data_saved_lock, flags);
  376. if (!data->saved_num)
  377. call_on_cpu(cpu, salinfo_log_read_cpu, data);
  378. if (!data->log_size) {
  379. data->state = STATE_NO_DATA;
  380. clear_bit(cpu, &data->cpu_event);
  381. } else {
  382. data->state = STATE_LOG_RECORD;
  383. }
  384. }
  385. static ssize_t
  386. salinfo_log_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
  387. {
  388. struct inode *inode = file->f_dentry->d_inode;
  389. struct proc_dir_entry *entry = PDE(inode);
  390. struct salinfo_data *data = entry->data;
  391. u8 *buf;
  392. u64 bufsize;
  393. if (data->state == STATE_LOG_RECORD) {
  394. buf = data->log_buffer;
  395. bufsize = data->log_size;
  396. } else if (data->state == STATE_OEMDATA) {
  397. buf = data->oemdata;
  398. bufsize = data->oemdata_size;
  399. } else {
  400. buf = NULL;
  401. bufsize = 0;
  402. }
  403. return simple_read_from_buffer(buffer, count, ppos, buf, bufsize);
  404. }
  405. static void
  406. salinfo_log_clear_cpu(void *context)
  407. {
  408. struct salinfo_data *data = context;
  409. ia64_sal_clear_state_info(data->type);
  410. }
  411. static int
  412. salinfo_log_clear(struct salinfo_data *data, int cpu)
  413. {
  414. sal_log_record_header_t *rh;
  415. data->state = STATE_NO_DATA;
  416. if (!test_bit(cpu, &data->cpu_event))
  417. return 0;
  418. down(&data->sem);
  419. clear_bit(cpu, &data->cpu_event);
  420. if (data->saved_num) {
  421. unsigned long flags;
  422. spin_lock_irqsave(&data_saved_lock, flags);
  423. shift1_data_saved(data, data->saved_num - 1 );
  424. data->saved_num = 0;
  425. spin_unlock_irqrestore(&data_saved_lock, flags);
  426. }
  427. rh = (sal_log_record_header_t *)(data->log_buffer);
  428. /* Corrected errors have already been cleared from SAL */
  429. if (rh->severity != sal_log_severity_corrected)
  430. call_on_cpu(cpu, salinfo_log_clear_cpu, data);
  431. /* clearing a record may make a new record visible */
  432. salinfo_log_new_read(cpu, data);
  433. if (data->state == STATE_LOG_RECORD &&
  434. !test_and_set_bit(cpu, &data->cpu_event))
  435. up(&data->sem);
  436. return 0;
  437. }
  438. static ssize_t
  439. salinfo_log_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
  440. {
  441. struct inode *inode = file->f_dentry->d_inode;
  442. struct proc_dir_entry *entry = PDE(inode);
  443. struct salinfo_data *data = entry->data;
  444. char cmd[32];
  445. size_t size;
  446. u32 offset;
  447. int cpu;
  448. size = sizeof(cmd);
  449. if (count < size)
  450. size = count;
  451. if (copy_from_user(cmd, buffer, size))
  452. return -EFAULT;
  453. if (sscanf(cmd, "read %d", &cpu) == 1) {
  454. salinfo_log_new_read(cpu, data);
  455. } else if (sscanf(cmd, "clear %d", &cpu) == 1) {
  456. int ret;
  457. if ((ret = salinfo_log_clear(data, cpu)))
  458. count = ret;
  459. } else if (sscanf(cmd, "oemdata %d %d", &cpu, &offset) == 2) {
  460. if (data->state != STATE_LOG_RECORD && data->state != STATE_OEMDATA)
  461. return -EINVAL;
  462. if (offset > data->log_size - sizeof(efi_guid_t))
  463. return -EINVAL;
  464. data->state = STATE_OEMDATA;
  465. if (salinfo_platform_oemdata) {
  466. struct salinfo_platform_oemdata_parms parms = {
  467. .efi_guid = data->log_buffer + offset,
  468. .oemdata = &data->oemdata,
  469. .oemdata_size = &data->oemdata_size
  470. };
  471. call_on_cpu(cpu, salinfo_platform_oemdata_cpu, &parms);
  472. if (parms.ret)
  473. count = parms.ret;
  474. } else
  475. data->oemdata_size = 0;
  476. } else
  477. return -EINVAL;
  478. return count;
  479. }
  480. static struct file_operations salinfo_data_fops = {
  481. .open = salinfo_log_open,
  482. .release = salinfo_log_release,
  483. .read = salinfo_log_read,
  484. .write = salinfo_log_write,
  485. };
  486. static int __init
  487. salinfo_init(void)
  488. {
  489. struct proc_dir_entry *salinfo_dir; /* /proc/sal dir entry */
  490. struct proc_dir_entry **sdir = salinfo_proc_entries; /* keeps track of every entry */
  491. struct proc_dir_entry *dir, *entry;
  492. struct salinfo_data *data;
  493. int i, j, online;
  494. salinfo_dir = proc_mkdir("sal", NULL);
  495. if (!salinfo_dir)
  496. return 0;
  497. for (i=0; i < NR_SALINFO_ENTRIES; i++) {
  498. /* pass the feature bit in question as misc data */
  499. *sdir++ = create_proc_read_entry (salinfo_entries[i].name, 0, salinfo_dir,
  500. salinfo_read, (void *)salinfo_entries[i].feature);
  501. }
  502. for (i = 0; i < ARRAY_SIZE(salinfo_log_name); i++) {
  503. data = salinfo_data + i;
  504. data->type = i;
  505. sema_init(&data->sem, 0);
  506. dir = proc_mkdir(salinfo_log_name[i], salinfo_dir);
  507. if (!dir)
  508. continue;
  509. entry = create_proc_entry("event", S_IRUSR, dir);
  510. if (!entry)
  511. continue;
  512. entry->data = data;
  513. entry->proc_fops = &salinfo_event_fops;
  514. *sdir++ = entry;
  515. entry = create_proc_entry("data", S_IRUSR | S_IWUSR, dir);
  516. if (!entry)
  517. continue;
  518. entry->data = data;
  519. entry->proc_fops = &salinfo_data_fops;
  520. *sdir++ = entry;
  521. /* we missed any events before now */
  522. online = 0;
  523. for (j = 0; j < NR_CPUS; j++)
  524. if (cpu_online(j)) {
  525. set_bit(j, &data->cpu_event);
  526. ++online;
  527. }
  528. sema_init(&data->sem, online);
  529. *sdir++ = dir;
  530. }
  531. *sdir++ = salinfo_dir;
  532. init_timer(&salinfo_timer);
  533. salinfo_timer.expires = jiffies + SALINFO_TIMER_DELAY;
  534. salinfo_timer.function = &salinfo_timeout;
  535. add_timer(&salinfo_timer);
  536. return 0;
  537. }
  538. /*
  539. * 'data' contains an integer that corresponds to the feature we're
  540. * testing
  541. */
  542. static int
  543. salinfo_read(char *page, char **start, off_t off, int count, int *eof, void *data)
  544. {
  545. int len = 0;
  546. len = sprintf(page, (sal_platform_features & (unsigned long)data) ? "1\n" : "0\n");
  547. if (len <= off+count) *eof = 1;
  548. *start = page + off;
  549. len -= off;
  550. if (len>count) len = count;
  551. if (len<0) len = 0;
  552. return len;
  553. }
  554. module_init(salinfo_init);