66 lines
2.1 KiB
C
66 lines
2.1 KiB
C
/**
|
|
* \file
|
|
* \brief shelly - a shell process
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include <drivers/lpuart.h>
|
|
#include <drivers/gic_dist.h>
|
|
#include <maps/imx8x_map.h>
|
|
#include <maps/qemu_map.h>
|
|
#include <aos/aos.h>
|
|
#include <aos/inthandler.h>
|
|
#include "shelly.h"
|
|
|
|
__attribute__((__used__))
|
|
static void shelly_interrupt_handler(void * arg) {
|
|
// struct shelly_st * shelly_s = (struct shelly_st *) arg;
|
|
debug_printf("[shelly_interrupt_handler]!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
|
return;
|
|
}
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
errval_t err;
|
|
debug_printf("welcome to shelly!\n");
|
|
|
|
struct shelly_st shelly_s;
|
|
//afeer: map device registers
|
|
struct capref cap_arg0 = {
|
|
.cnode = cnode_arg,
|
|
.slot = 0
|
|
};
|
|
err = paging_map_frame_attr(get_current_paging_state(),
|
|
(void **) &shelly_s.dev_base, IMX8X_UART_SIZE,
|
|
cap_arg0, VREGION_FLAGS_READ_WRITE_NOCACHE);
|
|
if (err_is_fail(err)) return err;
|
|
|
|
struct gic_dist_s * gic_s;
|
|
//TODO: map gic space
|
|
err = gic_dist_init(&gic_s, NULL);
|
|
if (err_is_fail(err)) USER_PANIC_ERR(err, "couln't init gic_dist interrupts");
|
|
|
|
struct lpuart_s * uart_s;
|
|
err = lpuart_init(&uart_s, shelly_s.dev_base);
|
|
if (err_is_fail(err)) {
|
|
USER_PANIC_ERR(err, "couldn't init lpuart");
|
|
}
|
|
|
|
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");
|
|
|
|
struct waitset * ws = get_default_waitset();
|
|
// waitset_init(&ws);
|
|
|
|
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");
|
|
|
|
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");
|
|
|
|
err = lpuart_enable_interrupt(uart_s);
|
|
if (err_is_fail(err)) USER_PANIC_ERR(err, "couln't enable lpuart interrupts");
|
|
} |