From 15e54fcdc862cedfbc3fc4e8b7c71eae23f93c54 Mon Sep 17 00:00:00 2001 From: Bunnaroath Sou Date: Fri, 22 Feb 2019 17:23:58 -0800 Subject: Adding Standard CoreIPs forE20, E21 support --- bsp/coreip-e20/metal.h | 215 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 bsp/coreip-e20/metal.h (limited to 'bsp/coreip-e20/metal.h') diff --git a/bsp/coreip-e20/metal.h b/bsp/coreip-e20/metal.h new file mode 100644 index 0000000..e132a8e --- /dev/null +++ b/bsp/coreip-e20/metal.h @@ -0,0 +1,215 @@ +#ifndef ASSEMBLY + +#ifndef COREIP_E20__METAL_H +#define COREIP_E20__METAL_H + +#ifdef __METAL_MACHINE_MACROS + +#define __METAL_CLIC_SUBINTERRUPTS 48 + +#ifndef __METAL_CLIC_SUBINTERRUPTS +#define __METAL_CLIC_SUBINTERRUPTS 0 +#endif + +#else /* ! __METAL_MACHINE_MACROS */ + +#define METAL_MAX_CLINT_INTERRUPTS 0 + +#define METAL_MAX_PLIC_INTERRUPTS 0 + +#define __METAL_INTERRUPT_CONTROLLER_2000000_INTERRUPTS 3 + +#define __METAL_CLIC_SUBINTERRUPTS 48 + +#define METAL_MAX_CLIC_INTERRUPTS 3 + +#define __METAL_LOCAL_EXTERNAL_INTERRUPTS_0_INTERRUPTS 32 + +#define METAL_MAX_LOCAL_EXT_INTERRUPTS 32 + +#define METAL_MAX_GLOBAL_EXT_INTERRUPTS 0 + +#define METAL_MAX_GPIO_INTERRUPTS 0 + +#define METAL_MAX_UART_INTERRUPTS 0 + + +#include +#include +#include +#include +#include +#include + +/* From cpu@0 */ +asm (".weak __metal_dt_cpu_0"); +struct __metal_driver_cpu __metal_dt_cpu_0; + +/* From interrupt_controller */ +asm (".weak __metal_dt_interrupt_controller"); +struct __metal_driver_riscv_cpu_intc __metal_dt_interrupt_controller; + +asm (".weak __metal_dt_pmp_0"); +struct metal_pmp __metal_dt_pmp_0; + +/* From interrupt_controller@2000000 */ +asm (".weak __metal_dt_interrupt_controller_2000000"); +struct __metal_driver_sifive_clic0 __metal_dt_interrupt_controller_2000000; + +/* From local_external_interrupts_0 */ +asm (".weak __metal_dt_local_external_interrupts_0"); +struct __metal_driver_sifive_local_external_interrupts0 __metal_dt_local_external_interrupts_0; + +/* From teststatus@4000 */ +asm (".weak __metal_dt_teststatus_4000"); +struct __metal_driver_sifive_test0 __metal_dt_teststatus_4000; + + +/* From cpu@0 */ +struct __metal_driver_cpu __metal_dt_cpu_0 = { + .vtable = &__metal_driver_vtable_cpu, + .cpu.vtable = &__metal_driver_vtable_cpu.cpu_vtable, + .timebase = 1000000UL, + .interrupt_controller = &__metal_dt_interrupt_controller.controller, +}; + +/* From interrupt_controller */ +struct __metal_driver_riscv_cpu_intc __metal_dt_interrupt_controller = { + .vtable = &__metal_driver_vtable_riscv_cpu_intc, + .controller.vtable = &__metal_driver_vtable_riscv_cpu_intc.controller_vtable, + .init_done = 0, + .interrupt_controller = 1, +}; + +/* From pmp@0 */ +struct metal_pmp __metal_dt_pmp_0 = { + .num_regions = 8UL, +}; + +/* From interrupt_controller@2000000 */ +struct __metal_driver_sifive_clic0 __metal_dt_interrupt_controller_2000000 = { + .vtable = &__metal_driver_vtable_sifive_clic0, + .controller.vtable = &__metal_driver_vtable_sifive_clic0.clic_vtable, + .control_base = 33554432UL, + .control_size = 16777216UL, + .init_done = 0, + .num_interrupts = METAL_MAX_CLIC_INTERRUPTS, + .interrupt_parent = &__metal_dt_interrupt_controller.controller, + .interrupt_lines[0] = 3, + .interrupt_lines[1] = 7, + .interrupt_lines[2] = 11, + .num_subinterrupts = 48UL, + .num_intbits = 2UL, + .max_levels = 16UL, + .interrupt_controller = 1, +}; + +/* From local_external_interrupts_0 */ +struct __metal_driver_sifive_local_external_interrupts0 __metal_dt_local_external_interrupts_0 = { + .vtable = &__metal_driver_vtable_sifive_local_external_interrupts0, + .irc.vtable = &__metal_driver_vtable_sifive_local_external_interrupts0.local0_vtable, + .init_done = 0, +/* From interrupt_controller@2000000 */ + .interrupt_parent = &__metal_dt_interrupt_controller_2000000.controller, + .num_interrupts = METAL_MAX_LOCAL_EXT_INTERRUPTS, + .interrupt_lines[0] = 0, + .interrupt_lines[1] = 1, + .interrupt_lines[2] = 2, + .interrupt_lines[3] = 3, + .interrupt_lines[4] = 4, + .interrupt_lines[5] = 5, + .interrupt_lines[6] = 6, + .interrupt_lines[7] = 7, + .interrupt_lines[8] = 8, + .interrupt_lines[9] = 9, + .interrupt_lines[10] = 10, + .interrupt_lines[11] = 11, + .interrupt_lines[12] = 12, + .interrupt_lines[13] = 13, + .interrupt_lines[14] = 14, + .interrupt_lines[15] = 15, + .interrupt_lines[16] = 16, + .interrupt_lines[17] = 17, + .interrupt_lines[18] = 18, + .interrupt_lines[19] = 19, + .interrupt_lines[20] = 20, + .interrupt_lines[21] = 21, + .interrupt_lines[22] = 22, + .interrupt_lines[23] = 23, + .interrupt_lines[24] = 24, + .interrupt_lines[25] = 25, + .interrupt_lines[26] = 26, + .interrupt_lines[27] = 27, + .interrupt_lines[28] = 28, + .interrupt_lines[29] = 29, + .interrupt_lines[30] = 30, + .interrupt_lines[31] = 31, +}; + +/* From teststatus@4000 */ +struct __metal_driver_sifive_test0 __metal_dt_teststatus_4000 = { + .vtable = &__metal_driver_vtable_sifive_test0, + .shutdown.vtable = &__metal_driver_vtable_sifive_test0.shutdown, + .base = 16384UL, + .size = 4096UL, +}; + + +/* From cpu@0 */ +#define __METAL_DT_RISCV_CPU_HANDLE (&__metal_dt_cpu_0.cpu) + +#define __METAL_DT_CPU_0_HANDLE (&__metal_dt_cpu_0.cpu) + +#define __METAL_DT_MAX_HARTS 1 + +asm (".weak __metal_cpu_table"); +struct __metal_driver_cpu *__metal_cpu_table[] = { + &__metal_dt_cpu_0}; + +/* From interrupt_controller */ +#define __METAL_DT_RISCV_CPU_INTC_HANDLE (&__metal_dt_interrupt_controller.controller) + +#define __METAL_DT_INTERRUPT_CONTROLLER_HANDLE (&__metal_dt_interrupt_controller.controller) + +/* From pmp@0 */ +#define __METAL_DT_PMP_HANDLE (&__metal_dt_pmp_0) + +/* From interrupt_controller@2000000 */ +#define __METAL_DT_SIFIVE_CLIC0_HANDLE (&__metal_dt_interrupt_controller_2000000.controller) + +#define __METAL_DT_INTERRUPT_CONTROLLER_2000000_HANDLE (&__metal_dt_interrupt_controller_2000000.controller) + +/* From local_external_interrupts_0 */ +#define __METAL_DT_SIFIVE_LOCAL_EXINTR0_HANDLE (&__metal_dt_local_external_interrupts_0.irc) + +#define __METAL_DT_LOCAL_EXTERNAL_INTERRUPTS_0_HANDLE (&__metal_dt_local_external_interrupts_0.irc) + +#define __METAL_DT_MAX_BUTTONS 0 + +asm (".weak __metal_button_table"); +struct __metal_driver_sifive_gpio_button *__metal_button_table[] = { + NULL }; +#define __METAL_DT_MAX_LEDS 0 + +asm (".weak __metal_led_table"); +struct __metal_driver_sifive_gpio_led *__metal_led_table[] = { + NULL }; +#define __METAL_DT_MAX_SWITCHES 0 + +asm (".weak __metal_switch_table"); +struct __metal_driver_sifive_gpio_switch *__metal_switch_table[] = { + NULL }; +#define __METAL_DT_MAX_SPIS 0 + +asm (".weak __metal_spi_table"); +struct __metal_driver_sifive_spi0 *__metal_spi_table[] = { + NULL }; +/* From teststatus@4000 */ +#define __METAL_DT_SHUTDOWN_HANDLE (&__metal_dt_teststatus_4000.shutdown) + +#define __METAL_DT_TESTSTATUS_4000_HANDLE (&__metal_dt_teststatus_4000.shutdown) + + +#endif /* ! __METAL_MACHINE_MACROS */ +#endif /* COREIP_E20__METAL_H*/ +#endif /* ! ASSEMBLY */ -- cgit v1.2.1-18-gbd029