C
CptDondo
I'm trying to write what should be a simple program, and it keeps
hanging if I use volatile....
The program, stripped of its error checking, is this:
unsigned short * start;
unsigned short * ctl;
int fd = open("/dev/mem", O_RDWR);
start = mmap(0, getpagesize()*2, PROT_READ|PROT_WRITE, MAP_SHARED, fd,
0x72000000);
ctl = (volatile unsigned short *)(start + 0x0410);
printf("got my pointer %p\n",ctl);
sleep(1);
printf("got ctl reg: 0x%02x\n",*ctl);
The program hangs as soon as it hits the last printf - it prints the
"got my pointer" message but hard-locks before printing the "got ctl
reg" message.
Before I start digging into various other issues, is this a proper use
of volatile?
--Yan
hanging if I use volatile....
The program, stripped of its error checking, is this:
unsigned short * start;
unsigned short * ctl;
int fd = open("/dev/mem", O_RDWR);
start = mmap(0, getpagesize()*2, PROT_READ|PROT_WRITE, MAP_SHARED, fd,
0x72000000);
ctl = (volatile unsigned short *)(start + 0x0410);
printf("got my pointer %p\n",ctl);
sleep(1);
printf("got ctl reg: 0x%02x\n",*ctl);
The program hangs as soon as it hits the last printf - it prints the
"got my pointer" message but hard-locks before printing the "got ctl
reg" message.
Before I start digging into various other issues, is this a proper use
of volatile?
--Yan