Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[vdr] Re: NVRAM WakeUp
Hello,
i have found a program which is the simplest way to read and (maybe)
write into bios nvram.
It is a program written by Paul Gortmaker ; the whole package is called
bios-cmos utilities
(I can't remember from where i downloaded it).
I made some little changes to simplify dump output.
The main point is that you can see nvram including the lower part that
/dev/nvram cannot manage wihout changing kernel source.
Here is the simple code :
-------------------------------------------------------------------
/*
*
* A quick hack to dump the CMOS RAM values from 0x0 to 0x7f. Note
that
* some CMOS are only 0x40 in size, so edit accordingly. Released
to
* the public under the terms and conditions of the Gnu General
Public
* License (GPL) included herein by reference.
*
* Compile with:
* gcc -s -N -Wall -O cmosdump.c -o cmosdump
*
* Paul Gortmaker 07/95
*/
#define CMOS_SIZE 0x80
#include <stdio.h>
#include <asm/io.h>
#include <unistd.h>
#include <errno.h>
/*
* <linux/rtc.h> was <linux/mc146818rtc.h> on kernels prior to 2.2.19,
so
* just define CMOS_READ/WRITE here independently and avoid the hassle.
*/
#define RTC_PORT(x) (0x70 + (x))
#define CMOS_READ(addr) ({ \
outb_p((addr),RTC_PORT(0)); \
inb_p(RTC_PORT(1)); \
})
#define CMOS_WRITE(val, addr) ({ \
outb_p((addr),RTC_PORT(0)); \
outb_p((val),RTC_PORT(1)); \
})
void main(void) {
unsigned short addr, val;
val= iopl(3);
if (val) {
perror("iopl");
exit(errno);
}
printf("Addr:\tHex\tDec.\tBinary\n");
for (addr = 0; addr < CMOS_SIZE; addr++) {
val = CMOS_READ(addr);
if ( (addr%16) == 0)
printf("\n0x%.4x:",addr);
printf(" 0x%.2x", val);
}
printf("\n");
iopl(0);
} /*end*/
-------------------------------------------------------------------
my 2 cents
Patrick.
Home |
Main Index |
Thread Index