Date: Sun, 27 Jan 2002 17:27:47 -0700 (MST) From: Ronald G Minnich <rminnich@lanl.gov> To: Matthew Emmerton <matt@gsicomp.on.ca> Cc: <freebsd-hackers@FreeBSD.ORG> Subject: Re: Reading BIOS from userland Message-ID: <Pine.LNX.4.33.0201271726080.13349-100000@snaresland.acl.lanl.gov> In-Reply-To: <004a01c1a704$974dca50$1200a8c0@gsicomp.on.ca>
next in thread | previous in thread | raw e-mail | index | archive | help
A stupid little program you can use to dump the bios and hunt for version
strings etc.
default is to mmap the last 1MB of the 32-bit space and write it to fildes
1. optional arg 1 is the base (it gets << 16 thanks to a strtol bug that
may no longer be there); optional arg 2 is the size.
Tested on just about everything linux, I don't see any obvious gotchas for
freebsd.
ron
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
main(int argc, char *argv[])
{
int i;
volatile unsigned char *cp;
int fd;
volatile void *v;
off_t nvram = 0xfff00000;
/* avoid linux mmap bug */
size_t length = 0x100000 /*- 0x1000*/;
if (argc > 1)
nvram = (strtol(argv[1], 0, 0)) << 16;
if (argc > 2)
length = (strtol(argv[2], 0, 0)) ;
if((fd = open("/dev/mem",O_RDWR)) != -1)
{
v = mmap(0, length, PROT_READ | PROT_WRITE, MAP_SHARED,fd,nvram);
fprintf(stderr, "mmap returns %p\n", v);
if ( (int)v == -1)
{
perror("mmap");
exit(1);
}
} else {
perror("open /dev/mem");
exit(1);
}
write(1, v, length);
}
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.LNX.4.33.0201271726080.13349-100000>
