/** * \file * \brief shelly - a shell process */ #include #include #include #include #include #include #include #include #include "shelly.h" __attribute__((__used__)) static void shelly_interrupt_handler(void * arg) { // struct shelly_st * shelly_s = (struct shelly_st *) arg; SHELLY_DEBUG("[shelly_interrupt_handler]\n"); return; } int main(int argc, char *argv[]) { errval_t err; debug_printf("welcome to shelly!\n"); struct shelly_st shelly_s; //afeer: map lpuart registers struct capref cap_arg0 = { .cnode = cnode_arg, .slot = 0 }; err = paging_map_frame_attr(get_current_paging_state(), (void **) &shelly_s.lpuart_base, IMX8X_UART_SIZE, cap_arg0, VREGION_FLAGS_READ_WRITE_NOCACHE); if (err_is_fail(err)) USER_PANIC_ERR(err, "while mapping lpuart registers"); SHELLY_DEBUG("mapped lpuart\n"); //afeer: map gic registers struct capref cap_arg1 = { .cnode = cnode_arg, .slot = 1 }; err = paging_map_frame_attr(get_current_paging_state(), (void**) &shelly_s.gic_base, IMX8X_GIC_DIST_SIZE, cap_arg1, VREGION_FLAGS_READ_WRITE_NOCACHE); if (err_is_fail(err)) USER_PANIC_ERR(err, "while mapping gic registers"); SHELLY_DEBUG("mapped gic\n"); //afeer: init gic driver struct gic_dist_s * gic_s; err = gic_dist_init(&gic_s, shelly_s.gic_base); if (err_is_fail(err)) USER_PANIC_ERR(err, "couln't init gic_dist interrupts"); SHELLY_DEBUG("initialized gic driver\n"); //afeer: init lpuart driver struct lpuart_s * uart_s; err = lpuart_init(&uart_s, shelly_s.lpuart_base); if (err_is_fail(err)) { USER_PANIC_ERR(err, "couldn't init lpuart"); } SHELLY_DEBUG("initialized lpuart driver\n"); struct capref inter_cap; err = inthandler_alloc_dest_irq_cap(IMX8X_UART3_INT, &inter_cap); if (err_is_fail(err)) USER_PANIC_ERR(err, "couln't alloc dest cap"); SHELLY_DEBUG("created interrupt cap\n"); char buf[256]; debug_print_cap_at_capref(buf, 256, inter_cap); debug_printf(buf); struct waitset * ws = get_default_waitset(); err = inthandler_setup(inter_cap, ws, MKCLOSURE(shelly_interrupt_handler, (void *) &shelly_s)); if (err_is_fail(err)) USER_PANIC_ERR(err, "couln't setup interrupt handler"); SHELLY_DEBUG("setup interrupt handler\n"); err = gic_dist_enable_interrupt(gic_s, IMX8X_UART3_INT, 0b11111111, 0); if (err_is_fail(err)) USER_PANIC_ERR(err, "couln't enable gic interrupts"); SHELLY_DEBUG("enabled gic interrupt\n"); err = lpuart_enable_interrupt(uart_s); if (err_is_fail(err)) USER_PANIC_ERR(err, "couln't enable lpuart interrupts"); SHELLY_DEBUG("enabled lpuart interrupt\n"); while (true) { err = event_dispatch(ws); if (err_is_fail(err)) { DEBUG_ERR(err, "in event_dispatch"); abort(); } } }