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/