diff --git a/README.md b/README.md index deb685d..fce4cf8 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ Finally, initialize the repo and all the submodules by running: To build the bare-metal guest for the cva6: `cd bao-baremetal-guest`\ +`cp -r ../guest/platform/* ./src/platform`\ `make CROSS_COMPILE=riscv64-unknown-elf- PLATFORM=cva6` ## 1.2) CVA6 SDK Linux diff --git a/guest/platform/cva6/cva6.c b/guest/platform/cva6/cva6.c new file mode 100644 index 0000000..740366a --- /dev/null +++ b/guest/platform/cva6/cva6.c @@ -0,0 +1,37 @@ +#include +#include <8250_uart.h> + +#define CVA6_DEFAULT_UART_ADDR 0x10000000 +#define CVA6_DEFAULT_UART_FREQ 50000000 +#define CVA6_DEFAULT_UART_BAUDRATE 115200 +#define CVA6_DEFAULT_UART_REG_SHIFT 2 +#define CVA6_DEFAULT_UART_REG_WIDTH 4 + + +void uart_init(){ + uart8250_init(CVA6_DEFAULT_UART_ADDR, + CVA6_DEFAULT_UART_FREQ, + CVA6_DEFAULT_UART_BAUDRATE, + CVA6_DEFAULT_UART_REG_SHIFT, + CVA6_DEFAULT_UART_REG_WIDTH); +} + +void uart_putc(char c) +{ + uart8250_putc(c); +} + +char uart_getchar(void) +{ + return uart8250_getc(); +} + +void uart_enable_rxirq() +{ + uart8250_enable_rx_int(); +} + +void uart_clear_rxirq() +{ + uart8250_interrupt_handler(); +} diff --git a/guest/platform/cva6/inc/plat.h b/guest/platform/cva6/inc/plat.h new file mode 100644 index 0000000..0a7f81e --- /dev/null +++ b/guest/platform/cva6/inc/plat.h @@ -0,0 +1,10 @@ +#ifndef PLAT_H +#define PLAT_H + +#define PLAT_MEM_BASE 0x80200000 +#define PLAT_MEM_SIZE 0x4000000 + +#define PLAT_TIMER_FREQ (1000000ull) +#define UART_IRQ_ID (1) + +#endif diff --git a/guest/platform/cva6/plat.mk b/guest/platform/cva6/plat.mk new file mode 100644 index 0000000..1620d66 --- /dev/null +++ b/guest/platform/cva6/plat.mk @@ -0,0 +1,2 @@ +ARCH:=riscv +drivers:=8250_uart \ No newline at end of file diff --git a/guest/platform/cva6/sources.mk b/guest/platform/cva6/sources.mk new file mode 100644 index 0000000..1612bae --- /dev/null +++ b/guest/platform/cva6/sources.mk @@ -0,0 +1,2 @@ +plat_c_srcs:=cva6.c +plat_s_srcs:=