void UnwrappedHardwareScheduler::makeMaps() {
    memfd = open("/dev/mem", O_RDWR | O_SYNC);
    if (memfd < 0) {
        LOGE("Failed to open /dev/mem (did you remember to run as root?)\n");
        exit(1);
    }
    pagemapfd = open("/proc/self/pagemap", O_RDONLY);
    //now map /dev/mem into memory, but only map specific peripheral sections:
    //gpioBaseMem = mapPeripheral(GPIO_BASE);
    dmaBaseMem = mapPeripheral(DMA_BASE);
    pwmBaseMem = mapPeripheral(PWM_BASE);
    clockBaseMem = mapPeripheral(CLOCK_BASE);
}
Example #2
0
/* Module initialization and release */
static int __init piScopinatorModuleInit(void)
{
    int retval;

    dbg("");
    piscoperator_kobj = kobject_create_and_add("piscopinator", kernel_kobj);
    if (!piscoperator_kobj) {
        err("Cannot create kobject!");
        goto crap_error;
    }

    retval = sysfs_create_group(piscoperator_kobj, &pisc_attr_group);
    if (retval)
        kobject_put(piscoperator_kobj);

    mutex_init(&piScopinatorDeviceMutex);
    /* This device uses a Kernel FIFO for its read operation */

    // need to map the memory of the gpio registers
    mapPeripheral(&gpio);

    return retval;

crap_error:
    return -1;

}