blob: 1977f7dbcb3e8b93b3b822e1a53f5453aff8143d [file] [log] [blame]
Ronald G. Minnich02fa3b22004-10-06 17:33:54 +00001#include <stdio.h>
2#include <fcntl.h>
3
4#include <unistd.h>
5#include <sys/mman.h>
6
7main(int argc, char *argv[])
8{
9 int i;
10 volatile unsigned char *cp;
11 int fd;
12 void *v;
13 off_t nvram;
14 size_t length = 0x1000;
15
16 fd = open("/proc/bus/pci/00/0a.1",O_RDONLY);
17 lseek(fd,0x10,0);
18 read(fd,&nvram,sizeof(nvram));
19 close(fd);
20 //printf("Star %x\n",nvram);
21
22 if((fd = open("/dev/mem",O_RDWR)) != -1)
23 {
24 v = mmap(0, length, PROT_READ | PROT_WRITE, MAP_SHARED,fd,nvram);
25 fprintf(stderr, "mmap returns %p\n", v);
26
27 if ( v == (void *) -1)
28 {
29 perror("mmap");
30 exit(1);
31 }
32 } else {
33 perror("open /dev/mem");
34 exit(1);
35 }
36
37 for( i = 0x836 ; i < 0x840 ; i++){
38 *(unsigned char *)(v+i) = 0;
39 }
40
41
42}