using /dev/mem to talk to peripherals on VIIP system
Dan Malek
dan at embeddedalley.com
Sat Jul 29 03:51:03 EST 2006
On Jul 28, 2006, at 1:35 PM, scott wrote:
> ptr = MAP_FAILED; // Initialize to bad value
> ptr = (int *) mmap(0, 256, PROT_READ|PROT_WRITE, MAP_SHARED, fd,
> USER_LOGIC_BASEADDR);
Well, this isn't going to detect an error, since the error code
is returned instead of an address.
>
> if(ptr==MAP_FAILED) {
if ((int)ptr == -1) {
> printf("Err: cannot access address!\n");
> return -1;
> }
>
> .... Any other thoughts?
Your mmap is failing because the size is not modulo PAGE_SIZE.
-- Dan
More information about the Linuxppc-embedded
mailing list