public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Jon Burgess" <Jon_Burgess@eur.3com.com>
To: root@chaos.analogic.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: ioremap_nocache(0xfffe0000, 0x00020000);
Date: Mon, 5 Aug 2002 11:29:02 +0100	[thread overview]
Message-ID: <80256C0C.003A0ED2.00@notesmta.eur.3com.com> (raw)



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



             reply	other threads:[~2002-08-05 13:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-05 10:29 Jon Burgess [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-08-02 15:23 ioremap_nocache(0xfffe0000, 0x00020000); Richard B. Johnson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=80256C0C.003A0ED2.00@notesmta.eur.3com.com \
    --to=jon_burgess@eur.3com.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=root@chaos.analogic.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox