nvram.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. /*
  2. * CMOS/NV-RAM driver for Linux
  3. *
  4. * Copyright (C) 1997 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
  5. * idea by and with help from Richard Jelinek <rj@suse.de>
  6. * Portions copyright (c) 2001,2002 Sun Microsystems (thockin@sun.com)
  7. *
  8. * This driver allows you to access the contents of the non-volatile memory in
  9. * the mc146818rtc.h real-time clock. This chip is built into all PCs and into
  10. * many Atari machines. In the former it's called "CMOS-RAM", in the latter
  11. * "NVRAM" (NV stands for non-volatile).
  12. *
  13. * The data are supplied as a (seekable) character device, /dev/nvram. The
  14. * size of this file is dependent on the controller. The usual size is 114,
  15. * the number of freely available bytes in the memory (i.e., not used by the
  16. * RTC itself).
  17. *
  18. * Checksums over the NVRAM contents are managed by this driver. In case of a
  19. * bad checksum, reads and writes return -EIO. The checksum can be initialized
  20. * to a sane state either by ioctl(NVRAM_INIT) (clear whole NVRAM) or
  21. * ioctl(NVRAM_SETCKS) (doesn't change contents, just makes checksum valid
  22. * again; use with care!)
  23. *
  24. * This file also provides some functions for other parts of the kernel that
  25. * want to access the NVRAM: nvram_{read,write,check_checksum,set_checksum}.
  26. * Obviously this can be used only if this driver is always configured into
  27. * the kernel and is not a module. Since the functions are used by some Atari
  28. * drivers, this is the case on the Atari.
  29. *
  30. *
  31. * 1.1 Cesar Barros: SMP locking fixes
  32. * added changelog
  33. * 1.2 Erik Gilling: Cobalt Networks support
  34. * Tim Hockin: general cleanup, Cobalt support
  35. * 1.3 Wim Van Sebroeck: convert PRINT_PROC to seq_file
  36. */
  37. #define NVRAM_VERSION "1.3"
  38. #include <linux/module.h>
  39. #include <linux/nvram.h>
  40. #define PC 1
  41. #define ATARI 2
  42. /* select machine configuration */
  43. #if defined(CONFIG_ATARI)
  44. # define MACH ATARI
  45. #elif defined(__i386__) || defined(__x86_64__) || defined(__arm__) /* and ?? */
  46. # define MACH PC
  47. #else
  48. # error Cannot build nvram driver for this machine configuration.
  49. #endif
  50. #if MACH == PC
  51. /* RTC in a PC */
  52. #define CHECK_DRIVER_INIT() 1
  53. /* On PCs, the checksum is built only over bytes 2..31 */
  54. #define PC_CKS_RANGE_START 2
  55. #define PC_CKS_RANGE_END 31
  56. #define PC_CKS_LOC 32
  57. #define NVRAM_BYTES (128-NVRAM_FIRST_BYTE)
  58. #define mach_check_checksum pc_check_checksum
  59. #define mach_set_checksum pc_set_checksum
  60. #define mach_proc_infos pc_proc_infos
  61. #endif
  62. #if MACH == ATARI
  63. /* Special parameters for RTC in Atari machines */
  64. #include <asm/atarihw.h>
  65. #include <asm/atariints.h>
  66. #define RTC_PORT(x) (TT_RTC_BAS + 2*(x))
  67. #define CHECK_DRIVER_INIT() (MACH_IS_ATARI && ATARIHW_PRESENT(TT_CLK))
  68. #define NVRAM_BYTES 50
  69. /* On Ataris, the checksum is over all bytes except the checksum bytes
  70. * themselves; these are at the very end */
  71. #define ATARI_CKS_RANGE_START 0
  72. #define ATARI_CKS_RANGE_END 47
  73. #define ATARI_CKS_LOC 48
  74. #define mach_check_checksum atari_check_checksum
  75. #define mach_set_checksum atari_set_checksum
  76. #define mach_proc_infos atari_proc_infos
  77. #endif
  78. /* Note that *all* calls to CMOS_READ and CMOS_WRITE must be done with
  79. * rtc_lock held. Due to the index-port/data-port design of the RTC, we
  80. * don't want two different things trying to get to it at once. (e.g. the
  81. * periodic 11 min sync from kernel/time/ntp.c vs. this driver.)
  82. */
  83. #include <linux/types.h>
  84. #include <linux/errno.h>
  85. #include <linux/miscdevice.h>
  86. #include <linux/ioport.h>
  87. #include <linux/fcntl.h>
  88. #include <linux/mc146818rtc.h>
  89. #include <linux/init.h>
  90. #include <linux/proc_fs.h>
  91. #include <linux/seq_file.h>
  92. #include <linux/spinlock.h>
  93. #include <linux/io.h>
  94. #include <linux/uaccess.h>
  95. #include <linux/mutex.h>
  96. static DEFINE_MUTEX(nvram_mutex);
  97. static DEFINE_SPINLOCK(nvram_state_lock);
  98. static int nvram_open_cnt; /* #times opened */
  99. static int nvram_open_mode; /* special open modes */
  100. #define NVRAM_WRITE 1 /* opened for writing (exclusive) */
  101. #define NVRAM_EXCL 2 /* opened with O_EXCL */
  102. static int mach_check_checksum(void);
  103. static void mach_set_checksum(void);
  104. #ifdef CONFIG_PROC_FS
  105. static void mach_proc_infos(unsigned char *contents, struct seq_file *seq,
  106. void *offset);
  107. #endif
  108. /*
  109. * These functions are provided to be called internally or by other parts of
  110. * the kernel. It's up to the caller to ensure correct checksum before reading
  111. * or after writing (needs to be done only once).
  112. *
  113. * It is worth noting that these functions all access bytes of general
  114. * purpose memory in the NVRAM - that is to say, they all add the
  115. * NVRAM_FIRST_BYTE offset. Pass them offsets into NVRAM as if you did not
  116. * know about the RTC cruft.
  117. */
  118. unsigned char __nvram_read_byte(int i)
  119. {
  120. return CMOS_READ(NVRAM_FIRST_BYTE + i);
  121. }
  122. EXPORT_SYMBOL(__nvram_read_byte);
  123. unsigned char nvram_read_byte(int i)
  124. {
  125. unsigned long flags;
  126. unsigned char c;
  127. spin_lock_irqsave(&rtc_lock, flags);
  128. c = __nvram_read_byte(i);
  129. spin_unlock_irqrestore(&rtc_lock, flags);
  130. return c;
  131. }
  132. EXPORT_SYMBOL(nvram_read_byte);
  133. /* This races nicely with trying to read with checksum checking (nvram_read) */
  134. void __nvram_write_byte(unsigned char c, int i)
  135. {
  136. CMOS_WRITE(c, NVRAM_FIRST_BYTE + i);
  137. }
  138. EXPORT_SYMBOL(__nvram_write_byte);
  139. void nvram_write_byte(unsigned char c, int i)
  140. {
  141. unsigned long flags;
  142. spin_lock_irqsave(&rtc_lock, flags);
  143. __nvram_write_byte(c, i);
  144. spin_unlock_irqrestore(&rtc_lock, flags);
  145. }
  146. EXPORT_SYMBOL(nvram_write_byte);
  147. int __nvram_check_checksum(void)
  148. {
  149. return mach_check_checksum();
  150. }
  151. EXPORT_SYMBOL(__nvram_check_checksum);
  152. int nvram_check_checksum(void)
  153. {
  154. unsigned long flags;
  155. int rv;
  156. spin_lock_irqsave(&rtc_lock, flags);
  157. rv = __nvram_check_checksum();
  158. spin_unlock_irqrestore(&rtc_lock, flags);
  159. return rv;
  160. }
  161. EXPORT_SYMBOL(nvram_check_checksum);
  162. static void __nvram_set_checksum(void)
  163. {
  164. mach_set_checksum();
  165. }
  166. #if 0
  167. void nvram_set_checksum(void)
  168. {
  169. unsigned long flags;
  170. spin_lock_irqsave(&rtc_lock, flags);
  171. __nvram_set_checksum();
  172. spin_unlock_irqrestore(&rtc_lock, flags);
  173. }
  174. #endif /* 0 */
  175. /*
  176. * The are the file operation function for user access to /dev/nvram
  177. */
  178. static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
  179. {
  180. switch (origin) {
  181. case 0:
  182. /* nothing to do */
  183. break;
  184. case 1:
  185. offset += file->f_pos;
  186. break;
  187. case 2:
  188. offset += NVRAM_BYTES;
  189. break;
  190. default:
  191. return -EINVAL;
  192. }
  193. return (offset >= 0) ? (file->f_pos = offset) : -EINVAL;
  194. }
  195. static ssize_t nvram_read(struct file *file, char __user *buf,
  196. size_t count, loff_t *ppos)
  197. {
  198. unsigned char contents[NVRAM_BYTES];
  199. unsigned i = *ppos;
  200. unsigned char *tmp;
  201. spin_lock_irq(&rtc_lock);
  202. if (!__nvram_check_checksum())
  203. goto checksum_err;
  204. for (tmp = contents; count-- > 0 && i < NVRAM_BYTES; ++i, ++tmp)
  205. *tmp = __nvram_read_byte(i);
  206. spin_unlock_irq(&rtc_lock);
  207. if (copy_to_user(buf, contents, tmp - contents))
  208. return -EFAULT;
  209. *ppos = i;
  210. return tmp - contents;
  211. checksum_err:
  212. spin_unlock_irq(&rtc_lock);
  213. return -EIO;
  214. }
  215. static ssize_t nvram_write(struct file *file, const char __user *buf,
  216. size_t count, loff_t *ppos)
  217. {
  218. unsigned char contents[NVRAM_BYTES];
  219. unsigned i = *ppos;
  220. unsigned char *tmp;
  221. if (i >= NVRAM_BYTES)
  222. return 0; /* Past EOF */
  223. if (count > NVRAM_BYTES - i)
  224. count = NVRAM_BYTES - i;
  225. if (count > NVRAM_BYTES)
  226. return -EFAULT; /* Can't happen, but prove it to gcc */
  227. if (copy_from_user(contents, buf, count))
  228. return -EFAULT;
  229. spin_lock_irq(&rtc_lock);
  230. if (!__nvram_check_checksum())
  231. goto checksum_err;
  232. for (tmp = contents; count--; ++i, ++tmp)
  233. __nvram_write_byte(*tmp, i);
  234. __nvram_set_checksum();
  235. spin_unlock_irq(&rtc_lock);
  236. *ppos = i;
  237. return tmp - contents;
  238. checksum_err:
  239. spin_unlock_irq(&rtc_lock);
  240. return -EIO;
  241. }
  242. static long nvram_ioctl(struct file *file, unsigned int cmd,
  243. unsigned long arg)
  244. {
  245. int i;
  246. switch (cmd) {
  247. case NVRAM_INIT:
  248. /* initialize NVRAM contents and checksum */
  249. if (!capable(CAP_SYS_ADMIN))
  250. return -EACCES;
  251. mutex_lock(&nvram_mutex);
  252. spin_lock_irq(&rtc_lock);
  253. for (i = 0; i < NVRAM_BYTES; ++i)
  254. __nvram_write_byte(0, i);
  255. __nvram_set_checksum();
  256. spin_unlock_irq(&rtc_lock);
  257. mutex_unlock(&nvram_mutex);
  258. return 0;
  259. case NVRAM_SETCKS:
  260. /* just set checksum, contents unchanged (maybe useful after
  261. * checksum garbaged somehow...) */
  262. if (!capable(CAP_SYS_ADMIN))
  263. return -EACCES;
  264. mutex_lock(&nvram_mutex);
  265. spin_lock_irq(&rtc_lock);
  266. __nvram_set_checksum();
  267. spin_unlock_irq(&rtc_lock);
  268. mutex_unlock(&nvram_mutex);
  269. return 0;
  270. default:
  271. return -ENOTTY;
  272. }
  273. }
  274. static int nvram_open(struct inode *inode, struct file *file)
  275. {
  276. spin_lock(&nvram_state_lock);
  277. if ((nvram_open_cnt && (file->f_flags & O_EXCL)) ||
  278. (nvram_open_mode & NVRAM_EXCL) ||
  279. ((file->f_mode & FMODE_WRITE) && (nvram_open_mode & NVRAM_WRITE))) {
  280. spin_unlock(&nvram_state_lock);
  281. return -EBUSY;
  282. }
  283. if (file->f_flags & O_EXCL)
  284. nvram_open_mode |= NVRAM_EXCL;
  285. if (file->f_mode & FMODE_WRITE)
  286. nvram_open_mode |= NVRAM_WRITE;
  287. nvram_open_cnt++;
  288. spin_unlock(&nvram_state_lock);
  289. return 0;
  290. }
  291. static int nvram_release(struct inode *inode, struct file *file)
  292. {
  293. spin_lock(&nvram_state_lock);
  294. nvram_open_cnt--;
  295. /* if only one instance is open, clear the EXCL bit */
  296. if (nvram_open_mode & NVRAM_EXCL)
  297. nvram_open_mode &= ~NVRAM_EXCL;
  298. if (file->f_mode & FMODE_WRITE)
  299. nvram_open_mode &= ~NVRAM_WRITE;
  300. spin_unlock(&nvram_state_lock);
  301. return 0;
  302. }
  303. #ifndef CONFIG_PROC_FS
  304. static int nvram_add_proc_fs(void)
  305. {
  306. return 0;
  307. }
  308. #else
  309. static int nvram_proc_read(struct seq_file *seq, void *offset)
  310. {
  311. unsigned char contents[NVRAM_BYTES];
  312. int i = 0;
  313. spin_lock_irq(&rtc_lock);
  314. for (i = 0; i < NVRAM_BYTES; ++i)
  315. contents[i] = __nvram_read_byte(i);
  316. spin_unlock_irq(&rtc_lock);
  317. mach_proc_infos(contents, seq, offset);
  318. return 0;
  319. }
  320. static int nvram_proc_open(struct inode *inode, struct file *file)
  321. {
  322. return single_open(file, nvram_proc_read, NULL);
  323. }
  324. static const struct file_operations nvram_proc_fops = {
  325. .owner = THIS_MODULE,
  326. .open = nvram_proc_open,
  327. .read = seq_read,
  328. .llseek = seq_lseek,
  329. .release = single_release,
  330. };
  331. static int nvram_add_proc_fs(void)
  332. {
  333. if (!proc_create("driver/nvram", 0, NULL, &nvram_proc_fops))
  334. return -ENOMEM;
  335. return 0;
  336. }
  337. #endif /* CONFIG_PROC_FS */
  338. static const struct file_operations nvram_fops = {
  339. .owner = THIS_MODULE,
  340. .llseek = nvram_llseek,
  341. .read = nvram_read,
  342. .write = nvram_write,
  343. .unlocked_ioctl = nvram_ioctl,
  344. .open = nvram_open,
  345. .release = nvram_release,
  346. };
  347. static struct miscdevice nvram_dev = {
  348. NVRAM_MINOR,
  349. "nvram",
  350. &nvram_fops
  351. };
  352. static int __init nvram_init(void)
  353. {
  354. int ret;
  355. /* First test whether the driver should init at all */
  356. if (!CHECK_DRIVER_INIT())
  357. return -ENODEV;
  358. ret = misc_register(&nvram_dev);
  359. if (ret) {
  360. printk(KERN_ERR "nvram: can't misc_register on minor=%d\n",
  361. NVRAM_MINOR);
  362. goto out;
  363. }
  364. ret = nvram_add_proc_fs();
  365. if (ret) {
  366. printk(KERN_ERR "nvram: can't create /proc/driver/nvram\n");
  367. goto outmisc;
  368. }
  369. ret = 0;
  370. printk(KERN_INFO "Non-volatile memory driver v" NVRAM_VERSION "\n");
  371. out:
  372. return ret;
  373. outmisc:
  374. misc_deregister(&nvram_dev);
  375. goto out;
  376. }
  377. static void __exit nvram_cleanup_module(void)
  378. {
  379. remove_proc_entry("driver/nvram", NULL);
  380. misc_deregister(&nvram_dev);
  381. }
  382. module_init(nvram_init);
  383. module_exit(nvram_cleanup_module);
  384. /*
  385. * Machine specific functions
  386. */
  387. #if MACH == PC
  388. static int pc_check_checksum(void)
  389. {
  390. int i;
  391. unsigned short sum = 0;
  392. unsigned short expect;
  393. for (i = PC_CKS_RANGE_START; i <= PC_CKS_RANGE_END; ++i)
  394. sum += __nvram_read_byte(i);
  395. expect = __nvram_read_byte(PC_CKS_LOC)<<8 |
  396. __nvram_read_byte(PC_CKS_LOC+1);
  397. return (sum & 0xffff) == expect;
  398. }
  399. static void pc_set_checksum(void)
  400. {
  401. int i;
  402. unsigned short sum = 0;
  403. for (i = PC_CKS_RANGE_START; i <= PC_CKS_RANGE_END; ++i)
  404. sum += __nvram_read_byte(i);
  405. __nvram_write_byte(sum >> 8, PC_CKS_LOC);
  406. __nvram_write_byte(sum & 0xff, PC_CKS_LOC + 1);
  407. }
  408. #ifdef CONFIG_PROC_FS
  409. static char *floppy_types[] = {
  410. "none", "5.25'' 360k", "5.25'' 1.2M", "3.5'' 720k", "3.5'' 1.44M",
  411. "3.5'' 2.88M", "3.5'' 2.88M"
  412. };
  413. static char *gfx_types[] = {
  414. "EGA, VGA, ... (with BIOS)",
  415. "CGA (40 cols)",
  416. "CGA (80 cols)",
  417. "monochrome",
  418. };
  419. static void pc_proc_infos(unsigned char *nvram, struct seq_file *seq,
  420. void *offset)
  421. {
  422. int checksum;
  423. int type;
  424. spin_lock_irq(&rtc_lock);
  425. checksum = __nvram_check_checksum();
  426. spin_unlock_irq(&rtc_lock);
  427. seq_printf(seq, "Checksum status: %svalid\n", checksum ? "" : "not ");
  428. seq_printf(seq, "# floppies : %d\n",
  429. (nvram[6] & 1) ? (nvram[6] >> 6) + 1 : 0);
  430. seq_printf(seq, "Floppy 0 type : ");
  431. type = nvram[2] >> 4;
  432. if (type < ARRAY_SIZE(floppy_types))
  433. seq_printf(seq, "%s\n", floppy_types[type]);
  434. else
  435. seq_printf(seq, "%d (unknown)\n", type);
  436. seq_printf(seq, "Floppy 1 type : ");
  437. type = nvram[2] & 0x0f;
  438. if (type < ARRAY_SIZE(floppy_types))
  439. seq_printf(seq, "%s\n", floppy_types[type]);
  440. else
  441. seq_printf(seq, "%d (unknown)\n", type);
  442. seq_printf(seq, "HD 0 type : ");
  443. type = nvram[4] >> 4;
  444. if (type)
  445. seq_printf(seq, "%02x\n", type == 0x0f ? nvram[11] : type);
  446. else
  447. seq_printf(seq, "none\n");
  448. seq_printf(seq, "HD 1 type : ");
  449. type = nvram[4] & 0x0f;
  450. if (type)
  451. seq_printf(seq, "%02x\n", type == 0x0f ? nvram[12] : type);
  452. else
  453. seq_printf(seq, "none\n");
  454. seq_printf(seq, "HD type 48 data: %d/%d/%d C/H/S, precomp %d, lz %d\n",
  455. nvram[18] | (nvram[19] << 8),
  456. nvram[20], nvram[25],
  457. nvram[21] | (nvram[22] << 8), nvram[23] | (nvram[24] << 8));
  458. seq_printf(seq, "HD type 49 data: %d/%d/%d C/H/S, precomp %d, lz %d\n",
  459. nvram[39] | (nvram[40] << 8),
  460. nvram[41], nvram[46],
  461. nvram[42] | (nvram[43] << 8), nvram[44] | (nvram[45] << 8));
  462. seq_printf(seq, "DOS base memory: %d kB\n", nvram[7] | (nvram[8] << 8));
  463. seq_printf(seq, "Extended memory: %d kB (configured), %d kB (tested)\n",
  464. nvram[9] | (nvram[10] << 8), nvram[34] | (nvram[35] << 8));
  465. seq_printf(seq, "Gfx adapter : %s\n",
  466. gfx_types[(nvram[6] >> 4) & 3]);
  467. seq_printf(seq, "FPU : %sinstalled\n",
  468. (nvram[6] & 2) ? "" : "not ");
  469. return;
  470. }
  471. #endif
  472. #endif /* MACH == PC */
  473. #if MACH == ATARI
  474. static int atari_check_checksum(void)
  475. {
  476. int i;
  477. unsigned char sum = 0;
  478. for (i = ATARI_CKS_RANGE_START; i <= ATARI_CKS_RANGE_END; ++i)
  479. sum += __nvram_read_byte(i);
  480. return (__nvram_read_byte(ATARI_CKS_LOC) == (~sum & 0xff)) &&
  481. (__nvram_read_byte(ATARI_CKS_LOC + 1) == (sum & 0xff));
  482. }
  483. static void atari_set_checksum(void)
  484. {
  485. int i;
  486. unsigned char sum = 0;
  487. for (i = ATARI_CKS_RANGE_START; i <= ATARI_CKS_RANGE_END; ++i)
  488. sum += __nvram_read_byte(i);
  489. __nvram_write_byte(~sum, ATARI_CKS_LOC);
  490. __nvram_write_byte(sum, ATARI_CKS_LOC + 1);
  491. }
  492. #ifdef CONFIG_PROC_FS
  493. static struct {
  494. unsigned char val;
  495. char *name;
  496. } boot_prefs[] = {
  497. { 0x80, "TOS" },
  498. { 0x40, "ASV" },
  499. { 0x20, "NetBSD (?)" },
  500. { 0x10, "Linux" },
  501. { 0x00, "unspecified" }
  502. };
  503. static char *languages[] = {
  504. "English (US)",
  505. "German",
  506. "French",
  507. "English (UK)",
  508. "Spanish",
  509. "Italian",
  510. "6 (undefined)",
  511. "Swiss (French)",
  512. "Swiss (German)"
  513. };
  514. static char *dateformat[] = {
  515. "MM%cDD%cYY",
  516. "DD%cMM%cYY",
  517. "YY%cMM%cDD",
  518. "YY%cDD%cMM",
  519. "4 (undefined)",
  520. "5 (undefined)",
  521. "6 (undefined)",
  522. "7 (undefined)"
  523. };
  524. static char *colors[] = {
  525. "2", "4", "16", "256", "65536", "??", "??", "??"
  526. };
  527. static void atari_proc_infos(unsigned char *nvram, struct seq_file *seq,
  528. void *offset)
  529. {
  530. int checksum = nvram_check_checksum();
  531. int i;
  532. unsigned vmode;
  533. seq_printf(seq, "Checksum status : %svalid\n", checksum ? "" : "not ");
  534. seq_printf(seq, "Boot preference : ");
  535. for (i = ARRAY_SIZE(boot_prefs) - 1; i >= 0; --i) {
  536. if (nvram[1] == boot_prefs[i].val) {
  537. seq_printf(seq, "%s\n", boot_prefs[i].name);
  538. break;
  539. }
  540. }
  541. if (i < 0)
  542. seq_printf(seq, "0x%02x (undefined)\n", nvram[1]);
  543. seq_printf(seq, "SCSI arbitration : %s\n",
  544. (nvram[16] & 0x80) ? "on" : "off");
  545. seq_printf(seq, "SCSI host ID : ");
  546. if (nvram[16] & 0x80)
  547. seq_printf(seq, "%d\n", nvram[16] & 7);
  548. else
  549. seq_printf(seq, "n/a\n");
  550. /* the following entries are defined only for the Falcon */
  551. if ((atari_mch_cookie >> 16) != ATARI_MCH_FALCON)
  552. return;
  553. seq_printf(seq, "OS language : ");
  554. if (nvram[6] < ARRAY_SIZE(languages))
  555. seq_printf(seq, "%s\n", languages[nvram[6]]);
  556. else
  557. seq_printf(seq, "%u (undefined)\n", nvram[6]);
  558. seq_printf(seq, "Keyboard language: ");
  559. if (nvram[7] < ARRAY_SIZE(languages))
  560. seq_printf(seq, "%s\n", languages[nvram[7]]);
  561. else
  562. seq_printf(seq, "%u (undefined)\n", nvram[7]);
  563. seq_printf(seq, "Date format : ");
  564. seq_printf(seq, dateformat[nvram[8] & 7],
  565. nvram[9] ? nvram[9] : '/', nvram[9] ? nvram[9] : '/');
  566. seq_printf(seq, ", %dh clock\n", nvram[8] & 16 ? 24 : 12);
  567. seq_printf(seq, "Boot delay : ");
  568. if (nvram[10] == 0)
  569. seq_printf(seq, "default");
  570. else
  571. seq_printf(seq, "%ds%s\n", nvram[10],
  572. nvram[10] < 8 ? ", no memory test" : "");
  573. vmode = (nvram[14] << 8) | nvram[15];
  574. seq_printf(seq,
  575. "Video mode : %s colors, %d columns, %s %s monitor\n",
  576. colors[vmode & 7],
  577. vmode & 8 ? 80 : 40,
  578. vmode & 16 ? "VGA" : "TV", vmode & 32 ? "PAL" : "NTSC");
  579. seq_printf(seq, " %soverscan, compat. mode %s%s\n",
  580. vmode & 64 ? "" : "no ",
  581. vmode & 128 ? "on" : "off",
  582. vmode & 256 ?
  583. (vmode & 16 ? ", line doubling" : ", half screen") : "");
  584. return;
  585. }
  586. #endif
  587. #endif /* MACH == ATARI */
  588. MODULE_LICENSE("GPL");
  589. MODULE_ALIAS_MISCDEV(NVRAM_MINOR);