void timer__init(void) { DTIME("Starting init"); config.vaddr = pwm_clk; timer = pwm_get_timer(&config); gtimer = generic_timer_get_timer(); timer_int4_reg_callback(&timer_interupt_handler4, NULL); timer_int0_reg_callback(&timer_interupt_handler0, NULL); timer->start(timer); DTIME("Finished init"); }
void clock_init() { pwm_config_t config; /* * Provide hardware info to platsupport. */ config.vaddr = (void*)mem; timer_drv = pwm_get_timer(&config); if (!timer_drv) { printf("PWM timer does not exist.\n"); } }
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); }