Esempio n. 1
0
seL4_timer_t *
sel4platsupport_get_timer(enum timer_id id, vka_t *vka, vspace_t *vspace,
                          simple_t *simple, seL4_CPtr notification)
{
    switch (id) {
    case DMTIMER2:
    case DMTIMER3:
    case DMTIMER4:
    case DMTIMER5:
    case DMTIMER6:
    case DMTIMER7:
        break;
    default:
        ZF_LOGE("Bad timer ID %d\n", id);
        return NULL;
    }

    seL4_timer_t *timer = calloc(1, sizeof(seL4_timer_t));
    if (timer == NULL) {
        ZF_LOGE("Failed to allocate object of size %u\n", sizeof(seL4_timer_t));
        return NULL;
    }

    timer->handle_irq = timer_common_handle_irq;
    timer_common_data_t *data = timer_common_init(vspace, simple, vka, notification,
                                                  dm_timer_irqs[id], (void*)dm_timer_paddrs[id]);
    timer->data = data;
    if (timer->data == NULL) {
        free(timer);
        return NULL;
    }

    timer_config_t config = {
        .vaddr = data->vaddr,
        .irq = dm_timer_irqs[id],
    };
    timer->timer = ps_get_timer(id, &config);
    if (timer->timer == NULL) {
        timer_common_destroy(timer->data, vka, vspace);
        free(timer);
        return NULL;
    }

    /* success */
    return timer;
}

seL4_timer_t *
sel4platsupport_get_default_timer(vka_t *vka, vspace_t *vspace, simple_t *simple,
                                  seL4_CPtr notification)
{
    return sel4platsupport_get_timer(TMR_DEFAULT, vka, vspace, simple, notification);
}
Esempio n. 2
0
seL4_timer_t *
sel4platsupport_get_pwm(vspace_t *vspace, simple_t *simple, vka_t *vka, seL4_CPtr aep)
{

    seL4_timer_t *timer = calloc(1, sizeof(seL4_timer_t));
    if (timer == NULL) {
        LOG_ERROR("Failed to allocate object of size %u\n", sizeof(seL4_timer_t));
        goto error;
    }

    timer_common_data_t *data = timer_common_init(vspace, simple, vka, aep, PWM_T4_INTERRUPT,
            (void *) PWM_TIMER_PADDR);
    timer->data = data;
    
    if (timer->data == NULL) {
         goto error;
    }

    timer->handle_irq = timer_common_handle_irq;

    /* do hardware init */
    pwm_config_t config = {
        .vaddr = data->vaddr,
    };

    timer->timer = pwm_get_timer(&config);
    if (timer->timer == NULL) {
        goto error;
    }

    /* success */
    return timer;
error:
    if (timer != NULL) {
        timer_common_destroy(timer->data, vka, vspace);
        free(timer);
    }

    return NULL;
}

void 
sel4platsupport_destroy_pwm(seL4_timer_t *timer, vka_t *vka, vspace_t *vspace) 
{
    timer_stop(timer->timer);
    timer_common_destroy(timer->data, vka, vspace);
    free(timer);
}
Esempio n. 3
0
seL4_timer_t *
sel4platsupport_get_timer(enum timer_id id, vka_t *vka, vspace_t *vspace,
                          simple_t *simple, seL4_CPtr notification)
{
    timer_common_data_t *data;
    seL4_timer_t *timer;
    /* Allocate the timer structure */
    timer = calloc(1, sizeof(*timer));
    if (timer == NULL) {
        ZF_LOGE("Failed to allocate object of size %u\n", sizeof(seL4_timer_t));
        return NULL;
    }
    /* init seL4 resources */
    timer->handle_irq = timer_common_handle_irq;
    data = timer_common_init(vspace, simple, vka, notification,
                             zynq_timer_irqs[id],
                             (void*)zynq_timer_paddrs[id]);
    timer->data = data;
    if (timer->data == NULL) {
        free(timer);
        return NULL;
    }

    /* do hardware init */
    timer_config_t config = {
        .vaddr = data->vaddr,
    };

    timer->timer = ps_get_timer(id, &config);
    if (timer->timer == NULL) {
        timer_common_destroy(timer->data, vka, vspace);
        free(timer);
        return NULL;
    }

    /* success */
    return timer;
}

seL4_timer_t *
sel4platsupport_get_default_timer(vka_t *vka, vspace_t *vspace, simple_t *simple,
                                  seL4_CPtr notification)
{
    return sel4platsupport_get_timer(TMR_DEFAULT, vka, vspace, simple, notification);
}
Esempio n. 4
0
seL4_timer_t *
sel4platsupport_get_timer(enum timer_id id, vka_t *vka, vspace_t *vspace,
                          simple_t *simple, seL4_CPtr aep)
{
    if (id != DMTIMER0) {
        LOG_ERROR("Bad timer ID %d\n", id);
        return NULL;
    }

    seL4_timer_t *timer = calloc(1, sizeof(seL4_timer_t));
    if (timer == NULL) {
        LOG_ERROR("Failed to allocate object of size %u\n", sizeof(seL4_timer_t));
        return NULL;
    }

    timer->handle_irq = timer_common_handle_irq;
    timer_common_data_t *data = timer_common_init(vspace, simple, vka, aep,
                                                  dm_timer_irqs[id], (void*)dm_timer_paddrs[id]);
    timer->data = data;
    if (timer->data == NULL) {
        free(timer);
        return NULL;
    }

    timer_config_t config = {
        .vaddr = data->vaddr,
        .irq = dm_timer_irqs[id],
    };
    timer->timer = ps_get_timer(id, &config);
    if (timer->timer == NULL) {
        timer_common_destroy(timer->data, vka, vspace);
        free(timer);
        return NULL;
    }

    /* success */
    return timer;
}

seL4_timer_t *
sel4platsupport_get_default_timer(vka_t *vka, vspace_t *vspace, simple_t *simple,
                                  seL4_CPtr aep)
{
    return sel4platsupport_get_timer(TMR_DEFAULT, vka, vspace, simple, aep);
}
Esempio n. 5
0
static seL4_timer_t *get_a20t(vspace_t *vspace, simple_t *simple, vka_t *vka, seL4_CPtr aep, int id, uint32_t prescaler)
{

    void *paddr;
    uint32_t irq;

    seL4_timer_t *timer = calloc(1, sizeof(seL4_timer_t));
    if (timer == NULL) {
        LOG_ERROR("Failed to allocate object of size %u\n", sizeof(seL4_timer_t));
        goto error;
    }

    paddr = (void *)0x01c20000;
    switch (id) {
        case 0:
            irq = TIMER_0;
            break;
        case 1:
            irq = TIMER_1;
            break;
        case 2:
            irq = TIMER_2;
            break;
        case 3:
            irq = TIMER_3;
            break;
        case 4:
            irq = TIMER_4;
            break;
        case 5:
            irq = TIMER_5;
            break;
        default:
            LOG_ERROR("Wrong id %d\n", id);
            goto error;
    }

    timer_common_data_t *data = timer_common_init(vspace, simple, vka, aep, irq, paddr);
    timer->data = data;

    if (timer->data == NULL) {
         goto error;
    }

    timer->handle_irq = timer_common_handle_irq;

    timer->timer = a20t_get_timer(data->vaddr, prescaler);
    if (timer->timer == NULL) {
        goto error;
    }

    /* success */
    return timer;
error:
    if (timer != NULL) {
        timer_common_destroy(timer->data, vka, vspace);
        free(timer);
    }

    return NULL;
}