Re: ioremap_nocache(0xfffe0000, 0x00020000);

From: Jon Burgess (Jon_Burgess@eur.3com.com)
Date: Mon Aug 05 2002 - 05:29:02 EST


I used the program below to get a copy of Bios rom on a National Geode / CS5530
board. If I remember correctly this code depended on the chipset decoding the
rom at this specific address range, the 'standard' address range was
0xC0000..0xFFFFF but not all the Rom was available here. If you wanted to write
to the rom then it needed some other chipset bits set correctly as well.

You could also take a look at the
linux-2.4.19/drivers/mtd/maps/{netsc520.c,sc520cdp.c}.

You could probably acomplish the same with the right 'dd if=/dev/mem of=bios.rom
...'

     Jon Burgess

/* dumprom.c
 *
 * Dump BIOS Rom space to a file
 */
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <ctype.h>

// To read the full 4Mbit ROM it needs to be accessed at the 'high' address
range
// Only 128Kb is available at 'low' address of 0xc0000
#define START 0xfff80000
#define LENGTH 0x00080000

int main(int argc, char *argv[])
{
     void *pmem;
     int fd, fd2;

     if (argc != 2)
     {
          printf("%s: <filename>\n", argv[0]);
          printf("Writes the BIOS memory space out to the file specifed\n");
          exit(1);
     }

     fd2 = open(argv[1], O_WRONLY | O_CREAT);
     if (!fd2)
          {
         perror("Error creating file");
         exit(1);
          }

     /* Get access BIOS memory space */
     fd = open("/dev/mem", O_RDONLY);
     if(!fd)
       {
         perror("Error opening /dev/mem");
               close(fd2);
         exit(1);
       }

     pmem = mmap(0, LENGTH, PROT_READ, MAP_SHARED, fd, START);
     if (pmem == MAP_FAILED)
       {
         perror("Error mapping /dev/mem");
               close(fd2);
               close(fd);
         exit(1);
       }

     if (write(fd2, pmem, LENGTH) == -1)
          {
               perror("Error writing data");
               close(fd2);
               close(fd);
               exit(2);
          }

     munmap(pmem, LENGTH);

     close(fd);
     close(fd2);

     exit(0);
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Aug 07 2002 - 22:00:27 EST