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