nvram.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  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. */
  36. #define NVRAM_VERSION "1.2"
  37. #include <linux/module.h>
  38. #include <linux/smp_lock.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 others?? */
  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/slab.h>
  87. #include <linux/ioport.h>
  88. #include <linux/fcntl.h>
  89. #include <linux/mc146818rtc.h>
  90. #include <linux/init.h>
  91. #include <linux/proc_fs.h>
  92. #include <linux/spinlock.h>
  93. #include <asm/io.h>
  94. #include <asm/uaccess.h>
  95. #include <asm/system.h>
  96. static DEFINE_SPINLOCK(nvram_state_lock);
  97. static int nvram_open_cnt; /* #times opened */
  98. static int nvram_open_mode; /* special open modes */
  99. #define NVRAM_WRITE 1 /* opened for writing (exclusive) */
  100. #define NVRAM_EXCL 2 /* opened with O_EXCL */
  101. static int mach_check_checksum(void);
  102. static void mach_set_checksum(void);
  103. #ifdef CONFIG_PROC_FS
  104. static int mach_proc_infos(unsigned char *contents, char *buffer, int *len,
  105. off_t *begin, off_t offset, int size);
  106. #endif
  107. /*
  108. * These functions are provided to be called internally or by other parts of
  109. * the kernel. It's up to the caller to ensure correct checksum before reading
  110. * or after writing (needs to be done only once).
  111. *
  112. * It is worth noting that these functions all access bytes of general
  113. * purpose memory in the NVRAM - that is to say, they all add the
  114. * NVRAM_FIRST_BYTE offset. Pass them offsets into NVRAM as if you did not
  115. * know about the RTC cruft.
  116. */
  117. unsigned char
  118. __nvram_read_byte(int i)
  119. {
  120. return CMOS_READ(NVRAM_FIRST_BYTE + i);
  121. }
  122. unsigned char
  123. 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. /* This races nicely with trying to read with checksum checking (nvram_read) */
  133. void
  134. __nvram_write_byte(unsigned char c, int i)
  135. {
  136. CMOS_WRITE(c, NVRAM_FIRST_BYTE + i);
  137. }
  138. void
  139. 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. int
  147. __nvram_check_checksum(void)
  148. {
  149. return mach_check_checksum();
  150. }
  151. int
  152. 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. static void
  162. __nvram_set_checksum(void)
  163. {
  164. mach_set_checksum();
  165. }
  166. #if 0
  167. void
  168. 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
  197. nvram_read(struct file *file, char __user *buf, 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
  217. nvram_write(struct file *file, const char __user *buf, 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
  240. nvram_ioctl(struct inode *inode, struct file *file,
  241. unsigned int cmd, unsigned long arg)
  242. {
  243. int i;
  244. switch (cmd) {
  245. case NVRAM_INIT:
  246. /* initialize NVRAM contents and checksum */
  247. if (!capable(CAP_SYS_ADMIN))
  248. return -EACCES;
  249. spin_lock_irq(&rtc_lock);
  250. for (i = 0; i < NVRAM_BYTES; ++i)
  251. __nvram_write_byte(0, i);
  252. __nvram_set_checksum();
  253. spin_unlock_irq(&rtc_lock);
  254. return 0;
  255. case NVRAM_SETCKS:
  256. /* just set checksum, contents unchanged (maybe useful after
  257. * checksum garbaged somehow...) */
  258. if (!capable(CAP_SYS_ADMIN))
  259. return -EACCES;
  260. spin_lock_irq(&rtc_lock);
  261. __nvram_set_checksum();
  262. spin_unlock_irq(&rtc_lock);
  263. return 0;
  264. default:
  265. return -ENOTTY;
  266. }
  267. }
  268. static int
  269. nvram_open(struct inode *inode, struct file *file)
  270. {
  271. lock_kernel();
  272. spin_lock(&nvram_state_lock);
  273. if ((nvram_open_cnt && (file->f_flags & O_EXCL)) ||
  274. (nvram_open_mode & NVRAM_EXCL) ||
  275. ((file->f_mode & 2) && (nvram_open_mode & NVRAM_WRITE))) {
  276. spin_unlock(&nvram_state_lock);
  277. unlock_kernel();
  278. return -EBUSY;
  279. }
  280. if (file->f_flags & O_EXCL)
  281. nvram_open_mode |= NVRAM_EXCL;
  282. if (file->f_mode & 2)
  283. nvram_open_mode |= NVRAM_WRITE;
  284. nvram_open_cnt++;
  285. spin_unlock(&nvram_state_lock);
  286. unlock_kernel();
  287. return 0;
  288. }
  289. static int
  290. 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 & 2)
  298. nvram_open_mode &= ~NVRAM_WRITE;
  299. spin_unlock(&nvram_state_lock);
  300. return 0;
  301. }
  302. #ifndef CONFIG_PROC_FS
  303. static int
  304. nvram_read_proc(char *buffer, char **start, off_t offset,
  305. int size, int *eof, void *data)
  306. {
  307. return 0;
  308. }
  309. #else
  310. static int
  311. nvram_read_proc(char *buffer, char **start, off_t offset,
  312. int size, int *eof, void *data)
  313. {
  314. unsigned char contents[NVRAM_BYTES];
  315. int i, len = 0;
  316. off_t begin = 0;
  317. spin_lock_irq(&rtc_lock);
  318. for (i = 0; i < NVRAM_BYTES; ++i)
  319. contents[i] = __nvram_read_byte(i);
  320. spin_unlock_irq(&rtc_lock);
  321. *eof = mach_proc_infos(contents, buffer, &len, &begin, offset, size);
  322. if (offset >= begin + len)
  323. return 0;
  324. *start = buffer + (offset - begin);
  325. return (size < begin + len - offset) ? size : begin + len - offset;
  326. }
  327. /* This macro frees the machine specific function from bounds checking and
  328. * this like that... */
  329. #define PRINT_PROC(fmt,args...) \
  330. do { \
  331. *len += sprintf(buffer+*len, fmt, ##args); \
  332. if (*begin + *len > offset + size) \
  333. return 0; \
  334. if (*begin + *len < offset) { \
  335. *begin += *len; \
  336. *len = 0; \
  337. } \
  338. } while(0)
  339. #endif /* CONFIG_PROC_FS */
  340. static const struct file_operations nvram_fops = {
  341. .owner = THIS_MODULE,
  342. .llseek = nvram_llseek,
  343. .read = nvram_read,
  344. .write = nvram_write,
  345. .ioctl = nvram_ioctl,
  346. .open = nvram_open,
  347. .release = nvram_release,
  348. };
  349. static struct miscdevice nvram_dev = {
  350. NVRAM_MINOR,
  351. "nvram",
  352. &nvram_fops
  353. };
  354. static int __init
  355. nvram_init(void)
  356. {
  357. int ret;
  358. /* First test whether the driver should init at all */
  359. if (!CHECK_DRIVER_INIT())
  360. return -ENODEV;
  361. ret = misc_register(&nvram_dev);
  362. if (ret) {
  363. printk(KERN_ERR "nvram: can't misc_register on minor=%d\n",
  364. NVRAM_MINOR);
  365. goto out;
  366. }
  367. if (!create_proc_read_entry("driver/nvram", 0, NULL, nvram_read_proc,
  368. NULL)) {
  369. printk(KERN_ERR "nvram: can't create /proc/driver/nvram\n");
  370. ret = -ENOMEM;
  371. goto outmisc;
  372. }
  373. ret = 0;
  374. printk(KERN_INFO "Non-volatile memory driver v" NVRAM_VERSION "\n");
  375. out:
  376. return ret;
  377. outmisc:
  378. misc_deregister(&nvram_dev);
  379. goto out;
  380. }
  381. static void __exit
  382. nvram_cleanup_module(void)
  383. {
  384. remove_proc_entry("driver/nvram", NULL);
  385. misc_deregister(&nvram_dev);
  386. }
  387. module_init(nvram_init);
  388. module_exit(nvram_cleanup_module);
  389. /*
  390. * Machine specific functions
  391. */
  392. #if MACH == PC
  393. static int
  394. pc_check_checksum(void)
  395. {
  396. int i;
  397. unsigned short sum = 0;
  398. unsigned short expect;
  399. for (i = PC_CKS_RANGE_START; i <= PC_CKS_RANGE_END; ++i)
  400. sum += __nvram_read_byte(i);
  401. expect = __nvram_read_byte(PC_CKS_LOC)<<8 |
  402. __nvram_read_byte(PC_CKS_LOC+1);
  403. return ((sum & 0xffff) == expect);
  404. }
  405. static void
  406. pc_set_checksum(void)
  407. {
  408. int i;
  409. unsigned short sum = 0;
  410. for (i = PC_CKS_RANGE_START; i <= PC_CKS_RANGE_END; ++i)
  411. sum += __nvram_read_byte(i);
  412. __nvram_write_byte(sum >> 8, PC_CKS_LOC);
  413. __nvram_write_byte(sum & 0xff, PC_CKS_LOC + 1);
  414. }
  415. #ifdef CONFIG_PROC_FS
  416. static char *floppy_types[] = {
  417. "none", "5.25'' 360k", "5.25'' 1.2M", "3.5'' 720k", "3.5'' 1.44M",
  418. "3.5'' 2.88M", "3.5'' 2.88M"
  419. };
  420. static char *gfx_types[] = {
  421. "EGA, VGA, ... (with BIOS)",
  422. "CGA (40 cols)",
  423. "CGA (80 cols)",
  424. "monochrome",
  425. };
  426. static int
  427. pc_proc_infos(unsigned char *nvram, char *buffer, int *len,
  428. off_t *begin, off_t offset, int size)
  429. {
  430. int checksum;
  431. int type;
  432. spin_lock_irq(&rtc_lock);
  433. checksum = __nvram_check_checksum();
  434. spin_unlock_irq(&rtc_lock);
  435. PRINT_PROC("Checksum status: %svalid\n", checksum ? "" : "not ");
  436. PRINT_PROC("# floppies : %d\n",
  437. (nvram[6] & 1) ? (nvram[6] >> 6) + 1 : 0);
  438. PRINT_PROC("Floppy 0 type : ");
  439. type = nvram[2] >> 4;
  440. if (type < ARRAY_SIZE(floppy_types))
  441. PRINT_PROC("%s\n", floppy_types[type]);
  442. else
  443. PRINT_PROC("%d (unknown)\n", type);
  444. PRINT_PROC("Floppy 1 type : ");
  445. type = nvram[2] & 0x0f;
  446. if (type < ARRAY_SIZE(floppy_types))
  447. PRINT_PROC("%s\n", floppy_types[type]);
  448. else
  449. PRINT_PROC("%d (unknown)\n", type);
  450. PRINT_PROC("HD 0 type : ");
  451. type = nvram[4] >> 4;
  452. if (type)
  453. PRINT_PROC("%02x\n", type == 0x0f ? nvram[11] : type);
  454. else
  455. PRINT_PROC("none\n");
  456. PRINT_PROC("HD 1 type : ");
  457. type = nvram[4] & 0x0f;
  458. if (type)
  459. PRINT_PROC("%02x\n", type == 0x0f ? nvram[12] : type);
  460. else
  461. PRINT_PROC("none\n");
  462. PRINT_PROC("HD type 48 data: %d/%d/%d C/H/S, precomp %d, lz %d\n",
  463. nvram[18] | (nvram[19] << 8),
  464. nvram[20], nvram[25],
  465. nvram[21] | (nvram[22] << 8), nvram[23] | (nvram[24] << 8));
  466. PRINT_PROC("HD type 49 data: %d/%d/%d C/H/S, precomp %d, lz %d\n",
  467. nvram[39] | (nvram[40] << 8),
  468. nvram[41], nvram[46],
  469. nvram[42] | (nvram[43] << 8), nvram[44] | (nvram[45] << 8));
  470. PRINT_PROC("DOS base memory: %d kB\n", nvram[7] | (nvram[8] << 8));
  471. PRINT_PROC("Extended memory: %d kB (configured), %d kB (tested)\n",
  472. nvram[9] | (nvram[10] << 8), nvram[34] | (nvram[35] << 8));
  473. PRINT_PROC("Gfx adapter : %s\n", gfx_types[(nvram[6] >> 4) & 3]);
  474. PRINT_PROC("FPU : %sinstalled\n",
  475. (nvram[6] & 2) ? "" : "not ");
  476. return 1;
  477. }
  478. #endif
  479. #endif /* MACH == PC */
  480. #if MACH == ATARI
  481. static int
  482. atari_check_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. return (__nvram_read_byte(ATARI_CKS_LOC) == (~sum & 0xff) &&
  489. __nvram_read_byte(ATARI_CKS_LOC + 1) == (sum & 0xff));
  490. }
  491. static void
  492. atari_set_checksum(void)
  493. {
  494. int i;
  495. unsigned char sum = 0;
  496. for (i = ATARI_CKS_RANGE_START; i <= ATARI_CKS_RANGE_END; ++i)
  497. sum += __nvram_read_byte(i);
  498. __nvram_write_byte(~sum, ATARI_CKS_LOC);
  499. __nvram_write_byte(sum, ATARI_CKS_LOC + 1);
  500. }
  501. #ifdef CONFIG_PROC_FS
  502. static struct {
  503. unsigned char val;
  504. char *name;
  505. } boot_prefs[] = {
  506. { 0x80, "TOS" },
  507. { 0x40, "ASV" },
  508. { 0x20, "NetBSD (?)" },
  509. { 0x10, "Linux" },
  510. { 0x00, "unspecified" }
  511. };
  512. static char *languages[] = {
  513. "English (US)",
  514. "German",
  515. "French",
  516. "English (UK)",
  517. "Spanish",
  518. "Italian",
  519. "6 (undefined)",
  520. "Swiss (French)",
  521. "Swiss (German)"
  522. };
  523. static char *dateformat[] = {
  524. "MM%cDD%cYY",
  525. "DD%cMM%cYY",
  526. "YY%cMM%cDD",
  527. "YY%cDD%cMM",
  528. "4 (undefined)",
  529. "5 (undefined)",
  530. "6 (undefined)",
  531. "7 (undefined)"
  532. };
  533. static char *colors[] = {
  534. "2", "4", "16", "256", "65536", "??", "??", "??"
  535. };
  536. static int
  537. atari_proc_infos(unsigned char *nvram, char *buffer, int *len,
  538. off_t *begin, off_t offset, int size)
  539. {
  540. int checksum = nvram_check_checksum();
  541. int i;
  542. unsigned vmode;
  543. PRINT_PROC("Checksum status : %svalid\n", checksum ? "" : "not ");
  544. PRINT_PROC("Boot preference : ");
  545. for (i = ARRAY_SIZE(boot_prefs) - 1; i >= 0; --i) {
  546. if (nvram[1] == boot_prefs[i].val) {
  547. PRINT_PROC("%s\n", boot_prefs[i].name);
  548. break;
  549. }
  550. }
  551. if (i < 0)
  552. PRINT_PROC("0x%02x (undefined)\n", nvram[1]);
  553. PRINT_PROC("SCSI arbitration : %s\n",
  554. (nvram[16] & 0x80) ? "on" : "off");
  555. PRINT_PROC("SCSI host ID : ");
  556. if (nvram[16] & 0x80)
  557. PRINT_PROC("%d\n", nvram[16] & 7);
  558. else
  559. PRINT_PROC("n/a\n");
  560. /* the following entries are defined only for the Falcon */
  561. if ((atari_mch_cookie >> 16) != ATARI_MCH_FALCON)
  562. return 1;
  563. PRINT_PROC("OS language : ");
  564. if (nvram[6] < ARRAY_SIZE(languages))
  565. PRINT_PROC("%s\n", languages[nvram[6]]);
  566. else
  567. PRINT_PROC("%u (undefined)\n", nvram[6]);
  568. PRINT_PROC("Keyboard language: ");
  569. if (nvram[7] < ARRAY_SIZE(languages))
  570. PRINT_PROC("%s\n", languages[nvram[7]]);
  571. else
  572. PRINT_PROC("%u (undefined)\n", nvram[7]);
  573. PRINT_PROC("Date format : ");
  574. PRINT_PROC(dateformat[nvram[8] & 7],
  575. nvram[9] ? nvram[9] : '/', nvram[9] ? nvram[9] : '/');
  576. PRINT_PROC(", %dh clock\n", nvram[8] & 16 ? 24 : 12);
  577. PRINT_PROC("Boot delay : ");
  578. if (nvram[10] == 0)
  579. PRINT_PROC("default");
  580. else
  581. PRINT_PROC("%ds%s\n", nvram[10],
  582. nvram[10] < 8 ? ", no memory test" : "");
  583. vmode = (nvram[14] << 8) || nvram[15];
  584. PRINT_PROC("Video mode : %s colors, %d columns, %s %s monitor\n",
  585. colors[vmode & 7],
  586. vmode & 8 ? 80 : 40,
  587. vmode & 16 ? "VGA" : "TV", vmode & 32 ? "PAL" : "NTSC");
  588. PRINT_PROC(" %soverscan, compat. mode %s%s\n",
  589. vmode & 64 ? "" : "no ",
  590. vmode & 128 ? "on" : "off",
  591. vmode & 256 ?
  592. (vmode & 16 ? ", line doubling" : ", half screen") : "");
  593. return 1;
  594. }
  595. #endif
  596. #endif /* MACH == ATARI */
  597. MODULE_LICENSE("GPL");
  598. EXPORT_SYMBOL(__nvram_read_byte);
  599. EXPORT_SYMBOL(nvram_read_byte);
  600. EXPORT_SYMBOL(__nvram_write_byte);
  601. EXPORT_SYMBOL(nvram_write_byte);
  602. EXPORT_SYMBOL(__nvram_check_checksum);
  603. EXPORT_SYMBOL(nvram_check_checksum);
  604. MODULE_ALIAS_MISCDEV(NVRAM_MINOR);