Subject: how to read out NuBus ROM space to file?
To: None <port-mac68k@netbsd.org>
From: None <ngc@ff.iij4u.or.jp>
List: port-mac68k
Date: 09/24/2002 13:05:58
Hello all.
Can we read out any physical spaces to file in userland ?
"Any spaces" includes except RAM, such as NuBus and on-board I/Os.
Since /dev/mem is avaliable for memory, I modified
sys/arch/mac68k/mac68k/mem.c to remove expressions to allow
access to RAM only.
Then, I wrote the following code to read out a part of NuBus #A super
space.
if( (fdmem = open( "/dev/mem", O_RDONLY )) < 0 ){
printf("can't open /dev/mem\n");
return( 1 );
}
if( (fpfile = fopen("t1.bin", "w")) == NULL ){
return( 1 );
}
addr = mmap( 0, 0x10000, PROT_READ, MAP_SHARED, fdmem, 0xAFFF0000 );
if( addr == MAP_FAILED ){
printf("mmap() failed\n");
return( 1 );
}
fwrite( addr, 0x10000, 1, fpfile );
I ran the above codes on PowerBook 550c with PCMCIA module
(PCMCIA module is mapped NuBus #A).
However, kernel panic occurred.
Is it because of bus error?
Now I can't check since I have tested this from remote place.
-----------------------------
Hiroshi Noguchi
ngc@ff.iij4u.or.jp
http://www.ff.iij4u.or.jp/~ngc/