correctly mark code segments as code in SELF
[coreboot.git] / util / resetcf / resetcf.c
1 #include <stdio.h>
2 #include <fcntl.h>
3
4 #include <unistd.h>
5 #include <sys/mman.h>
6
7 main(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 }