/* * JZ47xx GPIO lines * * Written 2010 by Andres Calderon andres.calderon@emqbit.com */ #include #include #include #include #include #include #include void * jz_mmap (off_t address) { int fd; void *pio; if ((fd = open ("/dev/mem", O_RDWR | O_SYNC)) == -1) { fprintf (stderr, "Cannot open /dev/mem.\n"); return 0; } pio = (void *) mmap (0, getpagesize (), PROT_READ | PROT_WRITE, MAP_SHARED, fd, address); if (pio == (void *) -1) { fprintf (stderr, "Cannot mmap.\n"); return 0; } return pio; }