2 * CMOS/NV-RAM driver for Linux
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)
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).
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
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!)
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.
31 * 1.1 Cesar Barros: SMP locking fixes
33 * 1.2 Erik Gilling: Cobalt Networks support
34 * Tim Hockin: general cleanup, Cobalt support
37 #define NVRAM_VERSION "1.2"
39 #include <linux/module.h>
40 #include <linux/sched.h>
41 #include <linux/smp_lock.h>
42 #include <linux/nvram.h>
48 /* select machine configuration */
49 #if defined(CONFIG_ATARI)
51 #elif defined(__i386__) || defined(__x86_64__) || defined(__arm__) /* and others?? */
53 # if defined(CONFIG_COBALT)
54 # include <linux/cobalt-nvram.h>
60 # error Cannot build nvram driver for this machine configuration.
66 #define CHECK_DRIVER_INIT() 1
68 /* On PCs, the checksum is built only over bytes 2..31 */
69 #define PC_CKS_RANGE_START 2
70 #define PC_CKS_RANGE_END 31
72 #define NVRAM_BYTES (128-NVRAM_FIRST_BYTE)
74 #define mach_check_checksum pc_check_checksum
75 #define mach_set_checksum pc_set_checksum
76 #define mach_proc_infos pc_proc_infos
82 #define CHECK_DRIVER_INIT() 1
84 #define NVRAM_BYTES (128-NVRAM_FIRST_BYTE)
86 #define mach_check_checksum cobalt_check_checksum
87 #define mach_set_checksum cobalt_set_checksum
88 #define mach_proc_infos cobalt_proc_infos
94 /* Special parameters for RTC in Atari machines */
95 #include <asm/atarihw.h>
96 #include <asm/atariints.h>
97 #define RTC_PORT(x) (TT_RTC_BAS + 2*(x))
98 #define CHECK_DRIVER_INIT() (MACH_IS_ATARI && ATARIHW_PRESENT(TT_CLK))
100 #define NVRAM_BYTES 50
102 /* On Ataris, the checksum is over all bytes except the checksum bytes
103 * themselves; these are at the very end */
104 #define ATARI_CKS_RANGE_START 0
105 #define ATARI_CKS_RANGE_END 47
106 #define ATARI_CKS_LOC 48
108 #define mach_check_checksum atari_check_checksum
109 #define mach_set_checksum atari_set_checksum
110 #define mach_proc_infos atari_proc_infos
114 /* Note that *all* calls to CMOS_READ and CMOS_WRITE must be done with
115 * rtc_lock held. Due to the index-port/data-port design of the RTC, we
116 * don't want two different things trying to get to it at once. (e.g. the
117 * periodic 11 min sync from time.c vs. this driver.)
120 #include <linux/types.h>
121 #include <linux/errno.h>
122 #include <linux/miscdevice.h>
123 #include <linux/slab.h>
124 #include <linux/ioport.h>
125 #include <linux/fcntl.h>
126 #include <linux/mc146818rtc.h>
127 #include <linux/init.h>
128 #include <linux/proc_fs.h>
129 #include <linux/spinlock.h>
132 #include <asm/uaccess.h>
133 #include <asm/system.h>
135 static DEFINE_SPINLOCK(nvram_state_lock
);
136 static int nvram_open_cnt
; /* #times opened */
137 static int nvram_open_mode
; /* special open modes */
138 #define NVRAM_WRITE 1 /* opened for writing (exclusive) */
139 #define NVRAM_EXCL 2 /* opened with O_EXCL */
141 static int mach_check_checksum(void);
142 static void mach_set_checksum(void);
144 #ifdef CONFIG_PROC_FS
145 static int mach_proc_infos(unsigned char *contents
, char *buffer
, int *len
,
146 off_t
*begin
, off_t offset
, int size
);
150 * These functions are provided to be called internally or by other parts of
151 * the kernel. It's up to the caller to ensure correct checksum before reading
152 * or after writing (needs to be done only once).
154 * It is worth noting that these functions all access bytes of general
155 * purpose memory in the NVRAM - that is to say, they all add the
156 * NVRAM_FIRST_BYTE offset. Pass them offsets into NVRAM as if you did not
157 * know about the RTC cruft.
161 __nvram_read_byte(int i
)
163 return CMOS_READ(NVRAM_FIRST_BYTE
+ i
);
167 nvram_read_byte(int i
)
172 spin_lock_irqsave(&rtc_lock
, flags
);
173 c
= __nvram_read_byte(i
);
174 spin_unlock_irqrestore(&rtc_lock
, flags
);
178 /* This races nicely with trying to read with checksum checking (nvram_read) */
180 __nvram_write_byte(unsigned char c
, int i
)
182 CMOS_WRITE(c
, NVRAM_FIRST_BYTE
+ i
);
186 nvram_write_byte(unsigned char c
, int i
)
190 spin_lock_irqsave(&rtc_lock
, flags
);
191 __nvram_write_byte(c
, i
);
192 spin_unlock_irqrestore(&rtc_lock
, flags
);
196 __nvram_check_checksum(void)
198 return mach_check_checksum();
202 nvram_check_checksum(void)
207 spin_lock_irqsave(&rtc_lock
, flags
);
208 rv
= __nvram_check_checksum();
209 spin_unlock_irqrestore(&rtc_lock
, flags
);
214 __nvram_set_checksum(void)
221 nvram_set_checksum(void)
225 spin_lock_irqsave(&rtc_lock
, flags
);
226 __nvram_set_checksum();
227 spin_unlock_irqrestore(&rtc_lock
, flags
);
232 * The are the file operation function for user access to /dev/nvram
235 static loff_t
nvram_llseek(struct file
*file
,loff_t offset
, int origin
)
243 offset
+= file
->f_pos
;
246 offset
+= NVRAM_BYTES
;
250 return (offset
>= 0) ? (file
->f_pos
= offset
) : -EINVAL
;
254 nvram_read(struct file
*file
, char __user
*buf
, size_t count
, loff_t
*ppos
)
256 unsigned char contents
[NVRAM_BYTES
];
260 spin_lock_irq(&rtc_lock
);
262 if (!__nvram_check_checksum())
265 for (tmp
= contents
; count
-- > 0 && i
< NVRAM_BYTES
; ++i
, ++tmp
)
266 *tmp
= __nvram_read_byte(i
);
268 spin_unlock_irq(&rtc_lock
);
270 if (copy_to_user(buf
, contents
, tmp
- contents
))
275 return tmp
- contents
;
278 spin_unlock_irq(&rtc_lock
);
283 nvram_write(struct file
*file
, const char __user
*buf
, size_t count
, loff_t
*ppos
)
285 unsigned char contents
[NVRAM_BYTES
];
290 len
= (NVRAM_BYTES
- i
) < count
? (NVRAM_BYTES
- i
) : count
;
291 if (copy_from_user(contents
, buf
, len
))
294 spin_lock_irq(&rtc_lock
);
296 if (!__nvram_check_checksum())
299 for (tmp
= contents
; count
-- > 0 && i
< NVRAM_BYTES
; ++i
, ++tmp
)
300 __nvram_write_byte(*tmp
, i
);
302 __nvram_set_checksum();
304 spin_unlock_irq(&rtc_lock
);
308 return tmp
- contents
;
311 spin_unlock_irq(&rtc_lock
);
316 nvram_ioctl(struct inode
*inode
, struct file
*file
,
317 unsigned int cmd
, unsigned long arg
)
324 /* initialize NVRAM contents and checksum */
325 if (!capable(CAP_SYS_ADMIN
))
328 spin_lock_irq(&rtc_lock
);
330 for (i
= 0; i
< NVRAM_BYTES
; ++i
)
331 __nvram_write_byte(0, i
);
332 __nvram_set_checksum();
334 spin_unlock_irq(&rtc_lock
);
338 /* just set checksum, contents unchanged (maybe useful after
339 * checksum garbaged somehow...) */
340 if (!capable(CAP_SYS_ADMIN
))
343 spin_lock_irq(&rtc_lock
);
344 __nvram_set_checksum();
345 spin_unlock_irq(&rtc_lock
);
354 nvram_open(struct inode
*inode
, struct file
*file
)
356 spin_lock(&nvram_state_lock
);
358 if ((nvram_open_cnt
&& (file
->f_flags
& O_EXCL
)) ||
359 (nvram_open_mode
& NVRAM_EXCL
) ||
360 ((file
->f_mode
& 2) && (nvram_open_mode
& NVRAM_WRITE
))) {
361 spin_unlock(&nvram_state_lock
);
365 if (file
->f_flags
& O_EXCL
)
366 nvram_open_mode
|= NVRAM_EXCL
;
367 if (file
->f_mode
& 2)
368 nvram_open_mode
|= NVRAM_WRITE
;
371 spin_unlock(&nvram_state_lock
);
377 nvram_release(struct inode
*inode
, struct file
*file
)
379 spin_lock(&nvram_state_lock
);
383 /* if only one instance is open, clear the EXCL bit */
384 if (nvram_open_mode
& NVRAM_EXCL
)
385 nvram_open_mode
&= ~NVRAM_EXCL
;
386 if (file
->f_mode
& 2)
387 nvram_open_mode
&= ~NVRAM_WRITE
;
389 spin_unlock(&nvram_state_lock
);
394 #ifndef CONFIG_PROC_FS
396 nvram_read_proc(char *buffer
, char **start
, off_t offset
,
397 int size
, int *eof
, void *data
)
404 nvram_read_proc(char *buffer
, char **start
, off_t offset
,
405 int size
, int *eof
, void *data
)
407 unsigned char contents
[NVRAM_BYTES
];
411 spin_lock_irq(&rtc_lock
);
412 for (i
= 0; i
< NVRAM_BYTES
; ++i
)
413 contents
[i
] = __nvram_read_byte(i
);
414 spin_unlock_irq(&rtc_lock
);
416 *eof
= mach_proc_infos(contents
, buffer
, &len
, &begin
, offset
, size
);
418 if (offset
>= begin
+ len
)
420 *start
= buffer
+ (offset
- begin
);
421 return (size
< begin
+ len
- offset
) ? size
: begin
+ len
- offset
;
425 /* This macro frees the machine specific function from bounds checking and
426 * this like that... */
427 #define PRINT_PROC(fmt,args...) \
429 *len += sprintf(buffer+*len, fmt, ##args); \
430 if (*begin + *len > offset + size) \
432 if (*begin + *len < offset) { \
438 #endif /* CONFIG_PROC_FS */
440 static const struct file_operations nvram_fops
= {
441 .owner
= THIS_MODULE
,
442 .llseek
= nvram_llseek
,
444 .write
= nvram_write
,
445 .ioctl
= nvram_ioctl
,
447 .release
= nvram_release
,
450 static struct miscdevice nvram_dev
= {
461 /* First test whether the driver should init at all */
462 if (!CHECK_DRIVER_INIT())
465 ret
= misc_register(&nvram_dev
);
467 printk(KERN_ERR
"nvram: can't misc_register on minor=%d\n",
471 if (!create_proc_read_entry("driver/nvram", 0, NULL
, nvram_read_proc
,
473 printk(KERN_ERR
"nvram: can't create /proc/driver/nvram\n");
478 printk(KERN_INFO
"Non-volatile memory driver v" NVRAM_VERSION
"\n");
482 misc_deregister(&nvram_dev
);
487 nvram_cleanup_module(void)
489 remove_proc_entry("driver/nvram", NULL
);
490 misc_deregister(&nvram_dev
);
493 module_init(nvram_init
);
494 module_exit(nvram_cleanup_module
);
497 * Machine specific functions
503 pc_check_checksum(void)
506 unsigned short sum
= 0;
507 unsigned short expect
;
509 for (i
= PC_CKS_RANGE_START
; i
<= PC_CKS_RANGE_END
; ++i
)
510 sum
+= __nvram_read_byte(i
);
511 expect
= __nvram_read_byte(PC_CKS_LOC
)<<8 |
512 __nvram_read_byte(PC_CKS_LOC
+1);
513 return ((sum
& 0xffff) == expect
);
517 pc_set_checksum(void)
520 unsigned short sum
= 0;
522 for (i
= PC_CKS_RANGE_START
; i
<= PC_CKS_RANGE_END
; ++i
)
523 sum
+= __nvram_read_byte(i
);
524 __nvram_write_byte(sum
>> 8, PC_CKS_LOC
);
525 __nvram_write_byte(sum
& 0xff, PC_CKS_LOC
+ 1);
528 #ifdef CONFIG_PROC_FS
530 static char *floppy_types
[] = {
531 "none", "5.25'' 360k", "5.25'' 1.2M", "3.5'' 720k", "3.5'' 1.44M",
532 "3.5'' 2.88M", "3.5'' 2.88M"
535 static char *gfx_types
[] = {
536 "EGA, VGA, ... (with BIOS)",
543 pc_proc_infos(unsigned char *nvram
, char *buffer
, int *len
,
544 off_t
*begin
, off_t offset
, int size
)
549 spin_lock_irq(&rtc_lock
);
550 checksum
= __nvram_check_checksum();
551 spin_unlock_irq(&rtc_lock
);
553 PRINT_PROC("Checksum status: %svalid\n", checksum
? "" : "not ");
555 PRINT_PROC("# floppies : %d\n",
556 (nvram
[6] & 1) ? (nvram
[6] >> 6) + 1 : 0);
557 PRINT_PROC("Floppy 0 type : ");
558 type
= nvram
[2] >> 4;
559 if (type
< ARRAY_SIZE(floppy_types
))
560 PRINT_PROC("%s\n", floppy_types
[type
]);
562 PRINT_PROC("%d (unknown)\n", type
);
563 PRINT_PROC("Floppy 1 type : ");
564 type
= nvram
[2] & 0x0f;
565 if (type
< ARRAY_SIZE(floppy_types
))
566 PRINT_PROC("%s\n", floppy_types
[type
]);
568 PRINT_PROC("%d (unknown)\n", type
);
570 PRINT_PROC("HD 0 type : ");
571 type
= nvram
[4] >> 4;
573 PRINT_PROC("%02x\n", type
== 0x0f ? nvram
[11] : type
);
575 PRINT_PROC("none\n");
577 PRINT_PROC("HD 1 type : ");
578 type
= nvram
[4] & 0x0f;
580 PRINT_PROC("%02x\n", type
== 0x0f ? nvram
[12] : type
);
582 PRINT_PROC("none\n");
584 PRINT_PROC("HD type 48 data: %d/%d/%d C/H/S, precomp %d, lz %d\n",
585 nvram
[18] | (nvram
[19] << 8),
586 nvram
[20], nvram
[25],
587 nvram
[21] | (nvram
[22] << 8), nvram
[23] | (nvram
[24] << 8));
588 PRINT_PROC("HD type 49 data: %d/%d/%d C/H/S, precomp %d, lz %d\n",
589 nvram
[39] | (nvram
[40] << 8),
590 nvram
[41], nvram
[46],
591 nvram
[42] | (nvram
[43] << 8), nvram
[44] | (nvram
[45] << 8));
593 PRINT_PROC("DOS base memory: %d kB\n", nvram
[7] | (nvram
[8] << 8));
594 PRINT_PROC("Extended memory: %d kB (configured), %d kB (tested)\n",
595 nvram
[9] | (nvram
[10] << 8), nvram
[34] | (nvram
[35] << 8));
597 PRINT_PROC("Gfx adapter : %s\n", gfx_types
[(nvram
[6] >> 4) & 3]);
599 PRINT_PROC("FPU : %sinstalled\n",
600 (nvram
[6] & 2) ? "" : "not ");
606 #endif /* MACH == PC */
610 /* the cobalt CMOS has a wider range of its checksum */
611 static int cobalt_check_checksum(void)
614 unsigned short sum
= 0;
615 unsigned short expect
;
617 for (i
= COBT_CMOS_CKS_START
; i
<= COBT_CMOS_CKS_END
; ++i
) {
618 if ((i
== COBT_CMOS_CHECKSUM
) || (i
== (COBT_CMOS_CHECKSUM
+1)))
621 sum
+= __nvram_read_byte(i
);
623 expect
= __nvram_read_byte(COBT_CMOS_CHECKSUM
) << 8 |
624 __nvram_read_byte(COBT_CMOS_CHECKSUM
+1);
625 return ((sum
& 0xffff) == expect
);
628 static void cobalt_set_checksum(void)
631 unsigned short sum
= 0;
633 for (i
= COBT_CMOS_CKS_START
; i
<= COBT_CMOS_CKS_END
; ++i
) {
634 if ((i
== COBT_CMOS_CHECKSUM
) || (i
== (COBT_CMOS_CHECKSUM
+1)))
637 sum
+= __nvram_read_byte(i
);
640 __nvram_write_byte(sum
>> 8, COBT_CMOS_CHECKSUM
);
641 __nvram_write_byte(sum
& 0xff, COBT_CMOS_CHECKSUM
+1);
644 #ifdef CONFIG_PROC_FS
646 static int cobalt_proc_infos(unsigned char *nvram
, char *buffer
, int *len
,
647 off_t
*begin
, off_t offset
, int size
)
650 unsigned int checksum
;
653 char *key
= "cNoEbTaWlOtR!";
654 unsigned char bto_csum
;
656 spin_lock_irq(&rtc_lock
);
657 checksum
= __nvram_check_checksum();
658 spin_unlock_irq(&rtc_lock
);
660 PRINT_PROC("Checksum status: %svalid\n", checksum
? "" : "not ");
662 flags
= nvram
[COBT_CMOS_FLAG_BYTE_0
] << 8
663 | nvram
[COBT_CMOS_FLAG_BYTE_1
];
665 PRINT_PROC("Console: %s\n",
666 flags
& COBT_CMOS_CONSOLE_FLAG
? "on": "off");
668 PRINT_PROC("Firmware Debug Messages: %s\n",
669 flags
& COBT_CMOS_DEBUG_FLAG
? "on": "off");
671 PRINT_PROC("Auto Prompt: %s\n",
672 flags
& COBT_CMOS_AUTO_PROMPT_FLAG
? "on": "off");
674 PRINT_PROC("Shutdown Status: %s\n",
675 flags
& COBT_CMOS_CLEAN_BOOT_FLAG
? "clean": "dirty");
677 PRINT_PROC("Hardware Probe: %s\n",
678 flags
& COBT_CMOS_HW_NOPROBE_FLAG
? "partial": "full");
680 PRINT_PROC("System Fault: %sdetected\n",
681 flags
& COBT_CMOS_SYSFAULT_FLAG
? "": "not ");
683 PRINT_PROC("Panic on OOPS: %s\n",
684 flags
& COBT_CMOS_OOPSPANIC_FLAG
? "yes": "no");
686 PRINT_PROC("Delayed Cache Initialization: %s\n",
687 flags
& COBT_CMOS_DELAY_CACHE_FLAG
? "yes": "no");
689 PRINT_PROC("Show Logo at Boot: %s\n",
690 flags
& COBT_CMOS_NOLOGO_FLAG
? "no": "yes");
692 PRINT_PROC("Boot Method: ");
693 switch (nvram
[COBT_CMOS_BOOT_METHOD
]) {
694 case COBT_CMOS_BOOT_METHOD_DISK
:
695 PRINT_PROC("disk\n");
698 case COBT_CMOS_BOOT_METHOD_ROM
:
702 case COBT_CMOS_BOOT_METHOD_NET
:
707 PRINT_PROC("unknown\n");
711 PRINT_PROC("Primary Boot Device: %d:%d\n",
712 nvram
[COBT_CMOS_BOOT_DEV0_MAJ
],
713 nvram
[COBT_CMOS_BOOT_DEV0_MIN
] );
714 PRINT_PROC("Secondary Boot Device: %d:%d\n",
715 nvram
[COBT_CMOS_BOOT_DEV1_MAJ
],
716 nvram
[COBT_CMOS_BOOT_DEV1_MIN
] );
717 PRINT_PROC("Tertiary Boot Device: %d:%d\n",
718 nvram
[COBT_CMOS_BOOT_DEV2_MAJ
],
719 nvram
[COBT_CMOS_BOOT_DEV2_MIN
] );
721 PRINT_PROC("Uptime: %d\n",
722 nvram
[COBT_CMOS_UPTIME_0
] << 24 |
723 nvram
[COBT_CMOS_UPTIME_1
] << 16 |
724 nvram
[COBT_CMOS_UPTIME_2
] << 8 |
725 nvram
[COBT_CMOS_UPTIME_3
]);
727 PRINT_PROC("Boot Count: %d\n",
728 nvram
[COBT_CMOS_BOOTCOUNT_0
] << 24 |
729 nvram
[COBT_CMOS_BOOTCOUNT_1
] << 16 |
730 nvram
[COBT_CMOS_BOOTCOUNT_2
] << 8 |
731 nvram
[COBT_CMOS_BOOTCOUNT_3
]);
733 /* 13 bytes of serial num */
734 for (i
=0 ; i
<13 ; i
++) {
735 sernum
[i
] = nvram
[COBT_CMOS_SYS_SERNUM_0
+ i
];
740 for (i
=0 ; i
<13 ; i
++) {
741 checksum
+= sernum
[i
] ^ key
[i
];
743 checksum
= ((checksum
& 0x7f) ^ (0xd6)) & 0xff;
745 PRINT_PROC("Serial Number: %s", sernum
);
746 if (checksum
!= nvram
[COBT_CMOS_SYS_SERNUM_CSUM
]) {
747 PRINT_PROC(" (invalid checksum)");
751 PRINT_PROC("Rom Revison: %d.%d.%d\n", nvram
[COBT_CMOS_ROM_REV_MAJ
],
752 nvram
[COBT_CMOS_ROM_REV_MIN
], nvram
[COBT_CMOS_ROM_REV_REV
]);
754 PRINT_PROC("BTO Server: %d.%d.%d.%d", nvram
[COBT_CMOS_BTO_IP_0
],
755 nvram
[COBT_CMOS_BTO_IP_1
], nvram
[COBT_CMOS_BTO_IP_2
],
756 nvram
[COBT_CMOS_BTO_IP_3
]);
757 bto_csum
= nvram
[COBT_CMOS_BTO_IP_0
] + nvram
[COBT_CMOS_BTO_IP_1
]
758 + nvram
[COBT_CMOS_BTO_IP_2
] + nvram
[COBT_CMOS_BTO_IP_3
];
759 if (bto_csum
!= nvram
[COBT_CMOS_BTO_IP_CSUM
]) {
760 PRINT_PROC(" (invalid checksum)");
764 if (flags
& COBT_CMOS_VERSION_FLAG
765 && nvram
[COBT_CMOS_VERSION
] >= COBT_CMOS_VER_BTOCODE
) {
766 PRINT_PROC("BTO Code: 0x%x\n",
767 nvram
[COBT_CMOS_BTO_CODE_0
] << 24 |
768 nvram
[COBT_CMOS_BTO_CODE_1
] << 16 |
769 nvram
[COBT_CMOS_BTO_CODE_2
] << 8 |
770 nvram
[COBT_CMOS_BTO_CODE_3
]);
775 #endif /* CONFIG_PROC_FS */
777 #endif /* MACH == COBALT */
782 atari_check_checksum(void)
785 unsigned char sum
= 0;
787 for (i
= ATARI_CKS_RANGE_START
; i
<= ATARI_CKS_RANGE_END
; ++i
)
788 sum
+= __nvram_read_byte(i
);
789 return (__nvram_read_byte(ATARI_CKS_LOC
) == (~sum
& 0xff) &&
790 __nvram_read_byte(ATARI_CKS_LOC
+ 1) == (sum
& 0xff));
794 atari_set_checksum(void)
797 unsigned char sum
= 0;
799 for (i
= ATARI_CKS_RANGE_START
; i
<= ATARI_CKS_RANGE_END
; ++i
)
800 sum
+= __nvram_read_byte(i
);
801 __nvram_write_byte(~sum
, ATARI_CKS_LOC
);
802 __nvram_write_byte(sum
, ATARI_CKS_LOC
+ 1);
805 #ifdef CONFIG_PROC_FS
813 { 0x20, "NetBSD (?)" },
815 { 0x00, "unspecified" }
818 static char *languages
[] = {
830 static char *dateformat
[] = {
841 static char *colors
[] = {
842 "2", "4", "16", "256", "65536", "??", "??", "??"
846 atari_proc_infos(unsigned char *nvram
, char *buffer
, int *len
,
847 off_t
*begin
, off_t offset
, int size
)
849 int checksum
= nvram_check_checksum();
853 PRINT_PROC("Checksum status : %svalid\n", checksum
? "" : "not ");
855 PRINT_PROC("Boot preference : ");
856 for (i
= ARRAY_SIZE(boot_prefs
) - 1; i
>= 0; --i
) {
857 if (nvram
[1] == boot_prefs
[i
].val
) {
858 PRINT_PROC("%s\n", boot_prefs
[i
].name
);
863 PRINT_PROC("0x%02x (undefined)\n", nvram
[1]);
865 PRINT_PROC("SCSI arbitration : %s\n",
866 (nvram
[16] & 0x80) ? "on" : "off");
867 PRINT_PROC("SCSI host ID : ");
868 if (nvram
[16] & 0x80)
869 PRINT_PROC("%d\n", nvram
[16] & 7);
873 /* the following entries are defined only for the Falcon */
874 if ((atari_mch_cookie
>> 16) != ATARI_MCH_FALCON
)
877 PRINT_PROC("OS language : ");
878 if (nvram
[6] < ARRAY_SIZE(languages
))
879 PRINT_PROC("%s\n", languages
[nvram
[6]]);
881 PRINT_PROC("%u (undefined)\n", nvram
[6]);
882 PRINT_PROC("Keyboard language: ");
883 if (nvram
[7] < ARRAY_SIZE(languages
))
884 PRINT_PROC("%s\n", languages
[nvram
[7]]);
886 PRINT_PROC("%u (undefined)\n", nvram
[7]);
887 PRINT_PROC("Date format : ");
888 PRINT_PROC(dateformat
[nvram
[8] & 7],
889 nvram
[9] ? nvram
[9] : '/', nvram
[9] ? nvram
[9] : '/');
890 PRINT_PROC(", %dh clock\n", nvram
[8] & 16 ? 24 : 12);
891 PRINT_PROC("Boot delay : ");
893 PRINT_PROC("default");
895 PRINT_PROC("%ds%s\n", nvram
[10],
896 nvram
[10] < 8 ? ", no memory test" : "");
898 vmode
= (nvram
[14] << 8) || nvram
[15];
899 PRINT_PROC("Video mode : %s colors, %d columns, %s %s monitor\n",
902 vmode
& 16 ? "VGA" : "TV", vmode
& 32 ? "PAL" : "NTSC");
903 PRINT_PROC(" %soverscan, compat. mode %s%s\n",
904 vmode
& 64 ? "" : "no ",
905 vmode
& 128 ? "on" : "off",
907 (vmode
& 16 ? ", line doubling" : ", half screen") : "");
913 #endif /* MACH == ATARI */
915 MODULE_LICENSE("GPL");
917 EXPORT_SYMBOL(__nvram_read_byte
);
918 EXPORT_SYMBOL(nvram_read_byte
);
919 EXPORT_SYMBOL(__nvram_write_byte
);
920 EXPORT_SYMBOL(nvram_write_byte
);
921 EXPORT_SYMBOL(__nvram_check_checksum
);
922 EXPORT_SYMBOL(nvram_check_checksum
);
923 MODULE_ALIAS_MISCDEV(NVRAM_MINOR
);