littlebig
05-03-2001, 11:48 PM
the following is the code which received the message:
unsigned long*volatile reg1=(unsigned long*) 0x40800000;
reg1[0x00000c04]=0xe200d9;
anything wrong? :confused:
augur
05-04-2001, 06:54 AM
Greetings,
Originally posted by littlebig:
<STRONG>the following is the code which received the message:
unsigned long*volatile reg1=(unsigned long*) 0x40800000;
reg1[0x00000c04]=0xe200d9;
anything wrong? :confused:</STRONG>
You can't just poke memory around like that.
From the other post I figure that you're trying to write to memory that is not yours, so, you have to either map that memory into your segment, or use "/dev/mem" like a file and just fseek/fread/fwrite into it.
mmap example:
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
int main() {
FILE *f;
long *p;
if ((f=fopen("/dev/mem", "rw"))==NULL)
exit(-1);
p = (long*)mmap(NULL, <length>, PROT_READ | PROT_WRITE, MAP_SHARED, f, <offset> );
close(f);
/* Do the poking and peeking here */
*(p+0xc04) = 0xe200d9;
munmap(p, <length> );
}
I'm not sure this will work, because I'm not at my linux box, but it should be something like that, I hope. :D
Oh, just replace length with whatever suits your needs, and <offset> should be 0x40800000.