On Thu, 15 Mar 2001, Francis Reader wrote:

> We have picked an ECS sis630 based combo mobo for developing an internet
> appliance, and were
> about to just start tinkering with Linuxbios.
> 
> Ollie Lho's tools are great for flashing an image into a system, however I
> would like to backup
> the bios image prior to reflashing. I know that I can get dros utils to
> backup (awdflash), but I'd
> rather use Linux throughout.
> 
> Any ideas on backing up the bios? As you can gather its award based.
> 
> Thanks

the following program will dump the last xxyy Mbytes of the 32-bit address
space to stdout. 

You run it as follows:

a.out [0xxxxx [0xllll]]

0xxxxx is the upper 16-bits of the address (e.g. 0xfffe) and 0xllll is the 
length (e.g. 0x40000 for 256KB)

On old linuxes you can't mmap that last page of memory (silly bug). I hear
this is fixed. See 'linux mmap bug' comment.

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);
}






Reply via email to