nvram.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  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/smp_lock.h>
  40. #include <linux/nvram.h>
  41. #define PC 1
  42. #define ATARI 2
  43. /* select machine configuration */
  44. #if defined(CONFIG_ATARI)
  45. # define MACH ATARI
  46. #elif defined(__i386__) || defined(__x86_64__) || defined(__arm__) /* and ?? */
  47. # define MACH PC
  48. #else
  49. # error Cannot build nvram driver for this machine configuration.
  50. #endif
  51. #if MACH == PC
  52. /* RTC in a PC */
  53. #define CHECK_DRIVER_INIT() 1
  54. /* On PCs, the checksum is built only over bytes 2..31 */
  55. #define PC_CKS_RANGE_START 2
  56. #define PC_CKS_RANGE_END 31
  57. #define PC_CKS_LOC 32
  58. #define NVRAM_BYTES (128-NVRAM_FIRST_BYTE)
  59. #define mach_check_checksum pc_check_checksum
  60. #define mach_set_checksum pc_set_checksum
  61. #define mach_proc_infos pc_proc_infos
  62. #endif
  63. #if MACH == ATARI
  64. /* Special parameters for RTC in Atari machines */
  65. #include <asm/atarihw.h>
  66. #include <asm/atariints.h>
  67. #define RTC_PORT(x) (TT_RTC_BAS + 2*(x))
  68. #define CHECK_DRIVER_INIT() (MACH_IS_ATARI && ATARIHW_PRESENT(TT_CLK))
  69. #define NVRAM_BYTES 50
  70. /* On Ataris, the checksum is over all bytes except the checksum bytes
  71. * themselves; these are at the very end */
  72. #define ATARI_CKS_RANGE_START 0
  73. #define ATARI_CKS_RANGE_END 47
  74. #define ATARI_CKS_LOC 48
  75. #define mach_check_checksum atari_check_checksum
  76. #define mach_set_checksum atari_set_checksum
  77. #define mach_proc_infos atari_proc_infos
  78. #endif
  79. /* Note that *all* calls to CMOS_READ and CMOS_WRITE must be done with
  80. * rtc_lock held. Due to the index-port/data-port design of the RTC, we
  81. * don't want two different things trying to get to it at once. (e.g. the
  82. * periodic 11 min sync from time.c vs. this driver.)
  83. */
  84. #include <linux/types.h>
  85. #include <linux/errno.h>
  86. #include <linux/miscdevice.h>
  87. #include <linux/slab.h>
  88. #include <linux/ioport.h>
  89. #include <linux/fcntl.h>
  90. #include <linux/mc146818rtc.h>
  91. #include <linux/init.h>
  92. #include <linux/proc_fs.h>
  93. #include <linux/seq_file.h>
  94. #include <linux/spinlock.h>
  95. #include <linux/io.h>
  96. #include <linux/uaccess.h>
  97. #include <asm/system.h>
  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. lock_kernel();
  182. switch (origin) {
  183. case 0:
  184. /* nothing to do */
  185. break;
  186. case 1:
  187. offset += file->f_pos;
  188. break;
  189. case 2:
  190. offset += NVRAM_BYTES;
  191. break;
  192. }
  193. unlock_kernel();
  194. return (offset >= 0) ? (file->f_pos = offset) : -EINVAL;
  195. }
  196. static ssize_t nvram_read(struct file *file, char __user *buf,
  197. size_t count, loff_t *ppos)
  198. {
  199. unsigned char contents[NVRAM_BYTES];
  200. unsigned i = *ppos;
  201. unsigned char *tmp;
  202. spin_lock_irq(&rtc_lock);
  203. if (!__nvram_check_checksum())
  204. goto checksum_err;
  205. for (tmp = contents; count-- > 0 && i < NVRAM_BYTES; ++i, ++tmp)
  206. *tmp = __nvram_read_byte(i);
  207. spin_unlock_irq(&rtc_lock);
  208. if (copy_to_user(buf, contents, tmp - contents))
  209. return -EFAULT;
  210. *ppos = i;
  211. return tmp - contents;
  212. checksum_err:
  213. spin_unlock_irq(&rtc_lock);
  214. return -EIO;
  215. }
  216. static ssize_t nvram_write(struct file *file, const char __user *buf,
  217. size_t count, loff_t *ppos)
  218. {
  219. unsigned char contents[NVRAM_BYTES];
  220. unsigned i = *ppos;
  221. unsigned char *tmp;
  222. int len;
  223. len = (NVRAM_BYTES - i) < count ? (NVRAM_BYTES - i) : count;
  224. if (copy_from_user(contents, buf, len))
  225. return -EFAULT;
  226. spin_lock_irq(&rtc_lock);
  227. if (!__nvram_check_checksum())
  228. goto checksum_err;
  229. for (tmp = contents; count-- > 0 && i < NVRAM_BYTES; ++i, ++tmp)
  230. __nvram_write_byte(*tmp, i);
  231. __nvram_set_checksum();
  232. spin_unlock_irq(&rtc_lock);
  233. *ppos = i;
  234. return tmp - contents;
  235. checksum_err:
  236. spin_unlock_irq(&rtc_lock);
  237. return -EIO;
  238. }
  239. static int nvram_ioctl(struct inode *inode, struct file *file,
  240. unsigned int cmd, unsigned long arg)
  241. {
  242. int i;
  243. switch (cmd) {
  244. case NVRAM_INIT:
  245. /* initialize NVRAM contents and checksum */
  246. if (!capable(CAP_SYS_ADMIN))
  247. return -EACCES;
  248. spin_lock_irq(&rtc_lock);
  249. for (i = 0; i < NVRAM_BYTES; ++i)
  250. __nvram_write_byte(0, i);
  251. __nvram_set_checksum();
  252. spin_unlock_irq(&rtc_lock);
  253. return 0;
  254. case NVRAM_SETCKS:
  255. /* just set checksum, contents unchanged (maybe useful after
  256. * checksum garbaged somehow...) */
  257. if (!capable(CAP_SYS_ADMIN))
  258. return -EACCES;
  259. spin_lock_irq(&rtc_lock);
  260. __nvram_set_checksum();
  261. spin_unlock_irq(&rtc_lock);
  262. return 0;
  263. default:
  264. return -ENOTTY;
  265. }
  266. }
  267. static int nvram_open(struct inode *inode, struct file *file)
  268. {
  269. lock_kernel();
  270. spin_lock(&nvram_state_lock);
  271. if ((nvram_open_cnt && (file->f_flags & O_EXCL)) ||
  272. (nvram_open_mode & NVRAM_EXCL) ||
  273. ((file->f_mode & FMODE_WRITE) && (nvram_open_mode & NVRAM_WRITE))) {
  274. spin_unlock(&nvram_state_lock);
  275. unlock_kernel();
  276. return -EBUSY;
  277. }
  278. if (file->f_flags & O_EXCL)
  279. nvram_open_mode |= NVRAM_EXCL;
  280. if (file->f_mode & FMODE_WRITE)
  281. nvram_open_mode |= NVRAM_WRITE;
  282. nvram_open_cnt++;
  283. spin_unlock(&nvram_state_lock);
  284. unlock_kernel();
  285. return 0;
  286. }
  287. static int nvram_release(struct inode *inode, struct file *file)
  288. {
  289. spin_lock(&nvram_state_lock);
  290. nvram_open_cnt--;
  291. /* if only one instance is open, clear the EXCL bit */
  292. if (nvram_open_mode & NVRAM_EXCL)
  293. nvram_open_mode &= ~NVRAM_EXCL;
  294. if (file->f_mode & FMODE_WRITE)
  295. nvram_open_mode &= ~NVRAM_WRITE;
  296. spin_unlock(&nvram_state_lock);
  297. return 0;
  298. }
  299. #ifndef CONFIG_PROC_FS
  300. static int nvram_add_proc_fs(void)
  301. {
  302. return 0;
  303. }
  304. #else
  305. static int nvram_proc_read(struct seq_file *seq, void *offset)
  306. {
  307. unsigned char contents[NVRAM_BYTES];
  308. int i = 0;
  309. spin_lock_irq(&rtc_lock);
  310. for (i = 0; i < NVRAM_BYTES; ++i)
  311. contents[i] = __nvram_read_byte(i);
  312. spin_unlock_irq(&rtc_lock);
  313. mach_proc_infos(contents, seq, offset);
  314. return 0;
  315. }
  316. static int nvram_proc_open(struct inode *inode, struct file *file)
  317. {
  318. return single_open(file, nvram_proc_read, NULL);
  319. }
  320. static const struct file_operations nvram_proc_fops = {
  321. .owner = THIS_MODULE,
  322. .open = nvram_proc_open,
  323. .read = seq_read,
  324. .llseek = seq_lseek,
  325. .release = single_release,
  326. };
  327. static int nvram_add_proc_fs(void)
  328. {
  329. if (!proc_create("driver/nvram", 0, NULL, &nvram_proc_fops))
  330. return -ENOMEM;
  331. return 0;
  332. }
  333. #endif /* CONFIG_PROC_FS */
  334. static const struct file_operations nvram_fops = {
  335. .owner = THIS_MODULE,
  336. .llseek = nvram_llseek,
  337. .read = nvram_read,
  338. .write = nvram_write,
  339. .ioctl = nvram_ioctl,
  340. .open = nvram_open,
  341. .release = nvram_release,
  342. };
  343. static struct miscdevice nvram_dev = {
  344. NVRAM_MINOR,
  345. "nvram",
  346. &nvram_fops
  347. };
  348. static int __init nvram_init(void)
  349. {
  350. int ret;
  351. /* First test whether the driver should init at all */
  352. if (!CHECK_DRIVER_INIT())
  353. return -ENODEV;
  354. ret = misc_register(&nvram_dev);
  355. if (ret) {
  356. printk(KERN_ERR "nvram: can't misc_register on minor=%d\n",
  357. NVRAM_MINOR);
  358. goto out;
  359. }
  360. ret = nvram_add_proc_fs();
  361. if (ret) {
  362. printk(KERN_ERR "nvram: can't create /proc/driver/nvram\n");
  363. goto outmisc;
  364. }
  365. ret = 0;
  366. printk(KERN_INFO "Non-volatile memory driver v" NVRAM_VERSION "\n");
  367. out:
  368. return ret;
  369. outmisc:
  370. misc_deregister(&nvram_dev);
  371. goto out;
  372. }
  373. static void __exit nvram_cleanup_module(void)
  374. {
  375. remove_proc_entry("driver/nvram", NULL);
  376. misc_deregister(&nvram_dev);
  377. }
  378. module_init(nvram_init);
  379. module_exit(nvram_cleanup_module);
  380. /*
  381. * Machine specific functions
  382. */
  383. #if MACH == PC
  384. static int pc_check_checksum(void)
  385. {
  386. int i;
  387. unsigned short sum = 0;
  388. unsigned short expect;
  389. for (i = PC_CKS_RANGE_START; i <= PC_CKS_RANGE_END; ++i)
  390. sum += __nvram_read_byte(i);
  391. expect = __nvram_read_byte(PC_CKS_LOC)<<8 |
  392. __nvram_read_byte(PC_CKS_LOC+1);
  393. return (sum & 0xffff) == expect;
  394. }
  395. static void pc_set_checksum(void)
  396. {
  397. int i;
  398. unsigned short sum = 0;
  399. for (i = PC_CKS_RANGE_START; i <= PC_CKS_RANGE_END; ++i)
  400. sum += __nvram_read_byte(i);
  401. __nvram_write_byte(sum >> 8, PC_CKS_LOC);
  402. __nvram_write_byte(sum & 0xff, PC_CKS_LOC + 1);
  403. }
  404. #ifdef CONFIG_PROC_FS
  405. static char *floppy_types[] = {
  406. "none", "5.25'' 360k", "5.25'' 1.2M", "3.5'' 720k", "3.5'' 1.44M",
  407. "3.5'' 2.88M", "3.5'' 2.88M"
  408. };
  409. static char *gfx_types[] = {
  410. "EGA, VGA, ... (with BIOS)",
  411. "CGA (40 cols)",
  412. "CGA (80 cols)",
  413. "monochrome",
  414. };
  415. static void pc_proc_infos(unsigned char *nvram, struct seq_file *seq,
  416. void *offset)
  417. {
  418. int checksum;
  419. int type;
  420. spin_lock_irq(&rtc_lock);
  421. checksum = __nvram_check_checksum();
  422. spin_unlock_irq(&rtc_lock);
  423. seq_printf(seq, "Checksum status: %svalid\n", checksum ? "" : "not ");
  424. seq_printf(seq, "# floppies : %d\n",
  425. (nvram[6] & 1) ? (nvram[6] >> 6) + 1 : 0);
  426. seq_printf(seq, "Floppy 0 type : ");
  427. type = nvram[2] >> 4;
  428. if (type < ARRAY_SIZE(floppy_types))
  429. seq_printf(seq, "%s\n", floppy_types[type]);
  430. else
  431. seq_printf(seq, "%d (unknown)\n", type);
  432. seq_printf(seq, "Floppy 1 type : ");
  433. type = nvram[2] & 0x0f;
  434. if (type < ARRAY_SIZE(floppy_types))
  435. seq_printf(seq, "%s\n", floppy_types[type]);
  436. else
  437. seq_printf(seq, "%d (unknown)\n", type);
  438. seq_printf(seq, "HD 0 type : ");
  439. type = nvram[4] >> 4;
  440. if (type)
  441. seq_printf(seq, "%02x\n", type == 0x0f ? nvram[11] : type);
  442. else
  443. seq_printf(seq, "none\n");
  444. seq_printf(seq, "HD 1 type : ");
  445. type = nvram[4] & 0x0f;
  446. if (type)
  447. seq_printf(seq, "%02x\n", type == 0x0f ? nvram[12] : type);
  448. else
  449. seq_printf(seq, "none\n");
  450. seq_printf(seq, "HD type 48 data: %d/%d/%d C/H/S, precomp %d, lz %d\n",
  451. nvram[18] | (nvram[19] << 8),
  452. nvram[20], nvram[25],
  453. nvram[21] | (nvram[22] << 8), nvram[23] | (nvram[24] << 8));
  454. seq_printf(seq, "HD type 49 data: %d/%d/%d C/H/S, precomp %d, lz %d\n",
  455. nvram[39] | (nvram[40] << 8),
  456. nvram[41], nvram[46],
  457. nvram[42] | (nvram[43] << 8), nvram[44] | (nvram[45] << 8));
  458. seq_printf(seq, "DOS base memory: %d kB\n", nvram[7] | (nvram[8] << 8));
  459. seq_printf(seq, "Extended memory: %d kB (configured), %d kB (tested)\n",
  460. nvram[9] | (nvram[10] << 8), nvram[34] | (nvram[35] << 8));
  461. seq_printf(seq, "Gfx adapter : %s\n",
  462. gfx_types[(nvram[6] >> 4) & 3]);
  463. seq_printf(seq, "FPU : %sinstalled\n",
  464. (nvram[6] & 2) ? "" : "not ");
  465. return;
  466. }
  467. #endif
  468. #endif /* MACH == PC */
  469. #if MACH == ATARI
  470. static int atari_check_checksum(void)
  471. {
  472. int i;
  473. unsigned char sum = 0;
  474. for (i = ATARI_CKS_RANGE_START; i <= ATARI_CKS_RANGE_END; ++i)
  475. sum += __nvram_read_byte(i);
  476. return (__nvram_read_byte(ATARI_CKS_LOC) == (~sum & 0xff)) &&
  477. (__nvram_read_byte(ATARI_CKS_LOC + 1) == (sum & 0xff));
  478. }
  479. static void atari_set_checksum(void)
  480. {
  481. int i;
  482. unsigned char sum = 0;
  483. for (i = ATARI_CKS_RANGE_START; i <= ATARI_CKS_RANGE_END; ++i)
  484. sum += __nvram_read_byte(i);
  485. __nvram_write_byte(~sum, ATARI_CKS_LOC);
  486. __nvram_write_byte(sum, ATARI_CKS_LOC + 1);
  487. }
  488. #ifdef CONFIG_PROC_FS
  489. static struct {
  490. unsigned char val;
  491. char *name;
  492. } boot_prefs[] = {
  493. { 0x80, "TOS" },
  494. { 0x40, "ASV" },
  495. { 0x20, "NetBSD (?)" },
  496. { 0x10, "Linux" },
  497. { 0x00, "unspecified" }
  498. };
  499. static char *languages[] = {
  500. "English (US)",
  501. "German",
  502. "French",
  503. "English (UK)",
  504. "Spanish",
  505. "Italian",
  506. "6 (undefined)",
  507. "Swiss (French)",
  508. "Swiss (German)"
  509. };
  510. static char *dateformat[] = {
  511. "MM%cDD%cYY",
  512. "DD%cMM%cYY",
  513. "YY%cMM%cDD",
  514. "YY%cDD%cMM",
  515. "4 (undefined)",
  516. "5 (undefined)",
  517. "6 (undefined)",
  518. "7 (undefined)"
  519. };
  520. static char *colors[] = {
  521. "2", "4", "16", "256", "65536", "??", "??", "??"
  522. };
  523. static void atari_proc_infos(unsigned char *nvram, struct seq_file *seq,
  524. void *offset)
  525. {
  526. int checksum = nvram_check_checksum();
  527. int i;
  528. unsigned vmode;
  529. seq_printf(seq, "Checksum status : %svalid\n", checksum ? "" : "not ");
  530. seq_printf(seq, "Boot preference : ");
  531. for (i = ARRAY_SIZE(boot_prefs) - 1; i >= 0; --i) {
  532. if (nvram[1] == boot_prefs[i].val) {
  533. seq_printf(seq, "%s\n", boot_prefs[i].name);
  534. break;
  535. }
  536. }
  537. if (i < 0)
  538. seq_printf(seq, "0x%02x (undefined)\n", nvram[1]);
  539. seq_printf(seq, "SCSI arbitration : %s\n",
  540. (nvram[16] & 0x80) ? "on" : "off");
  541. seq_printf(seq, "SCSI host ID : ");
  542. if (nvram[16] & 0x80)
  543. seq_printf(seq, "%d\n", nvram[16] & 7);
  544. else
  545. seq_printf(seq, "n/a\n");
  546. /* the following entries are defined only for the Falcon */
  547. if ((atari_mch_cookie >> 16) != ATARI_MCH_FALCON)
  548. return;
  549. seq_printf(seq, "OS language : ");
  550. if (nvram[6] < ARRAY_SIZE(languages))
  551. seq_printf(seq, "%s\n", languages[nvram[6]]);
  552. else
  553. seq_printf(seq, "%u (undefined)\n", nvram[6]);
  554. seq_printf(seq, "Keyboard language: ");
  555. if (nvram[7] < ARRAY_SIZE(languages))
  556. seq_printf(seq, "%s\n", languages[nvram[7]]);
  557. else
  558. seq_printf(seq, "%u (undefined)\n", nvram[7]);
  559. seq_printf(seq, "Date format : ");
  560. seq_printf(seq, dateformat[nvram[8] & 7],
  561. nvram[9] ? nvram[9] : '/', nvram[9] ? nvram[9] : '/');
  562. seq_printf(seq, ", %dh clock\n", nvram[8] & 16 ? 24 : 12);
  563. seq_printf(seq, "Boot delay : ");
  564. if (nvram[10] == 0)
  565. seq_printf(seq, "default");
  566. else
  567. seq_printf(seq, "%ds%s\n", nvram[10],
  568. nvram[10] < 8 ? ", no memory test" : "");
  569. vmode = (nvram[14] << 8) || nvram[15];
  570. seq_printf(seq,
  571. "Video mode : %s colors, %d columns, %s %s monitor\n",
  572. colors[vmode & 7],
  573. vmode & 8 ? 80 : 40,
  574. vmode & 16 ? "VGA" : "TV", vmode & 32 ? "PAL" : "NTSC");
  575. seq_printf(seq, " %soverscan, compat. mode %s%s\n",
  576. vmode & 64 ? "" : "no ",
  577. vmode & 128 ? "on" : "off",
  578. vmode & 256 ?
  579. (vmode & 16 ? ", line doubling" : ", half screen") : "");
  580. return;
  581. }
  582. #endif
  583. #endif /* MACH == ATARI */
  584. MODULE_LICENSE("GPL");
  585. MODULE_ALIAS_MISCDEV(NVRAM_MINOR);