From 93ace41eb4f643b763ba868e4b6f8fba460934af Mon Sep 17 00:00:00 2001 From: Akash Kollipara Date: Tue, 28 Feb 2023 19:57:35 +0530 Subject: [PATCH] Add arch & plat support Issue: #87 --- mk/tc.mk | 7 +- src/arch/{arm/32m => arm-m/32}/README.md | 0 .../32}/common_v6_v7/supervisor/arch.c | 14 +- .../common_v6_v7/supervisor/arch_vectors.c | 9 +- .../32}/common_v6_v7/supervisor/asm.S | 66 +++------- .../arm-m/32/common_v6_v7/supervisor/build.mk | 16 +++ .../supervisor/exception_handler.c | 0 .../common_v6_v7/supervisor/include/arch.h | 30 +---- .../32}/common_v6_v7/supervisor/include/arm.h | 0 .../32}/common_v6_v7/supervisor/init.c | 0 .../32}/common_v6_v7/supervisor/systick.c | 0 .../32/common_v7}/supervisor/build.mk | 0 .../32/m0}/supervisor/build.mk | 0 src/arch/arm-m/32/m0p/supervisor/build.mk | 16 +++ .../m0 => arm-m/32/m4}/supervisor/build.mk | 0 src/arch/arm/32m/m0p/supervisor/build.mk | 0 src/arch/arm/32m/m4/supervisor/build.mk | 0 src/driver/console/con_serial_rpi/build.mk | 21 +++ src/platform/pico/common/sections.ld.sx | 113 ---------------- src/platform/pico/r2040/include/plat_arch.h | 18 --- .../common_rp2}/arch/platform_mem.c | 0 src/platform/rpi/common_rp2/build.mk | 26 ++++ .../common_rp2/platform}/platform.c | 0 .../common_rp2/platform}/platform_reset.c | 0 .../common_rp2}/platform/platform_resource.c | 0 src/platform/rpi/common_rp2/sections.ld.sx | 123 ++++++++++++++++++ src/platform/{pico => rpi}/rp2040/build.mk | 13 +- src/platform/rpi/rp2040/config.mk | 79 +++++++++++ .../{pico => rpi}/rp2040/include/plat_mem.h | 12 +- .../rp2040/include/platform_sio.h | 0 .../supervisor/services/bootstrap/bootstrap.c | 49 +++++++ .../supervisor/services/bootstrap/build.mk | 13 ++ src/visor/supervisor/services/build.mk | 17 +++ 33 files changed, 405 insertions(+), 237 deletions(-) rename src/arch/{arm/32m => arm-m/32}/README.md (100%) rename src/arch/{arm/32m => arm-m/32}/common_v6_v7/supervisor/arch.c (90%) rename src/arch/{arm/32m => arm-m/32}/common_v6_v7/supervisor/arch_vectors.c (93%) rename src/arch/{arm/32m => arm-m/32}/common_v6_v7/supervisor/asm.S (56%) create mode 100644 src/arch/arm-m/32/common_v6_v7/supervisor/build.mk rename src/arch/{arm/32m => arm-m/32}/common_v6_v7/supervisor/exception_handler.c (100%) rename src/arch/{arm/32m => arm-m/32}/common_v6_v7/supervisor/include/arch.h (78%) rename src/arch/{arm/32m => arm-m/32}/common_v6_v7/supervisor/include/arm.h (100%) rename src/arch/{arm/32m => arm-m/32}/common_v6_v7/supervisor/init.c (100%) rename src/arch/{arm/32m => arm-m/32}/common_v6_v7/supervisor/systick.c (100%) rename src/arch/{arm/32m/common_v6_v7 => arm-m/32/common_v7}/supervisor/build.mk (100%) rename src/arch/{arm/32m/common_v7 => arm-m/32/m0}/supervisor/build.mk (100%) create mode 100644 src/arch/arm-m/32/m0p/supervisor/build.mk rename src/arch/{arm/32m/m0 => arm-m/32/m4}/supervisor/build.mk (100%) delete mode 100644 src/arch/arm/32m/m0p/supervisor/build.mk delete mode 100644 src/arch/arm/32m/m4/supervisor/build.mk create mode 100644 src/driver/console/con_serial_rpi/build.mk delete mode 100644 src/platform/pico/common/sections.ld.sx delete mode 100644 src/platform/pico/r2040/include/plat_arch.h rename src/platform/{pico/common => rpi/common_rp2}/arch/platform_mem.c (100%) create mode 100644 src/platform/rpi/common_rp2/build.mk rename src/platform/{pico/common => rpi/common_rp2/platform}/platform.c (100%) rename src/platform/{pico/common => rpi/common_rp2/platform}/platform_reset.c (100%) rename src/platform/{pico/common => rpi/common_rp2}/platform/platform_resource.c (100%) create mode 100644 src/platform/rpi/common_rp2/sections.ld.sx rename src/platform/{pico => rpi}/rp2040/build.mk (68%) create mode 100644 src/platform/rpi/rp2040/config.mk rename src/platform/{pico => rpi}/rp2040/include/plat_mem.h (62%) rename src/platform/{pico => rpi}/rp2040/include/platform_sio.h (100%) create mode 100644 src/visor/supervisor/services/bootstrap/bootstrap.c create mode 100644 src/visor/supervisor/services/bootstrap/build.mk create mode 100644 src/visor/supervisor/services/build.mk diff --git a/mk/tc.mk b/mk/tc.mk index 7abd3e42..9e920770 100644 --- a/mk/tc.mk +++ b/mk/tc.mk @@ -10,10 +10,11 @@ include mk/path.mk -ifeq ($(findstring arm-v7,$(ARCH)),arm) +ifeq ($(findstring arm,$(ARCH)),arm) TC ?= $(TOOLS_ROOT)/arm-toolchain/bin/arm-none-eabi -TI := $(TOOLS_ROOT)/arm-toolchain/arm-none-eabi/include -TL := $(TOOLS_ROOT)/arm-toolchain/arm-none-eabi/lib +TI := $(TOOLS_ROOT)/arm-toolchain/lib/gcc/arm-none-eabi/$(TC_VER)/include-fixed/ +TI += $(TOOLS_ROOT)/arm-toolchain/arm-none-eabi/include/ +TL := $(TOOLS_ROOT)/arm-toolchain/lib/gcc/arm-none-eabi/$(TC_VER)/$(TL_TYPE)/ endif ifeq ($(findstring riscv,$(ARCH)),riscv) diff --git a/src/arch/arm/32m/README.md b/src/arch/arm-m/32/README.md similarity index 100% rename from src/arch/arm/32m/README.md rename to src/arch/arm-m/32/README.md diff --git a/src/arch/arm/32m/common_v6_v7/supervisor/arch.c b/src/arch/arm-m/32/common_v6_v7/supervisor/arch.c similarity index 90% rename from src/arch/arm/32m/common_v6_v7/supervisor/arch.c rename to src/arch/arm-m/32/common_v6_v7/supervisor/arch.c index 8be4539c..8acf8e7e 100644 --- a/src/arch/arm/32m/common_v6_v7/supervisor/arch.c +++ b/src/arch/arm-m/32/common_v6_v7/supervisor/arch.c @@ -14,12 +14,11 @@ #include #include #include -#include #include #include #include -static void arch_mcall_handler() +static void arch_ecall_handler() { context_frame_t *frame = get_context_frame(); mret_t mres; @@ -71,17 +70,6 @@ _WEAK unsigned int arch_core_index() return 0; } -/** - * arch_wfi - wait for interrupt - * - * @brief This function should be called when the program needs to - * wait for interrupt. This also ensures low power consumption when compared to busy wait. - */ -void arch_wfi() -{ - asm volatile("wfi"); -} - void _NORETURN arch_panic_handler_callback() { context_frame_t *frame; diff --git a/src/arch/arm/32m/common_v6_v7/supervisor/arch_vectors.c b/src/arch/arm-m/32/common_v6_v7/supervisor/arch_vectors.c similarity index 93% rename from src/arch/arm/32m/common_v6_v7/supervisor/arch_vectors.c rename to src/arch/arm-m/32/common_v6_v7/supervisor/arch_vectors.c index f02f765c..6fafacf9 100644 --- a/src/arch/arm/32m/common_v6_v7/supervisor/arch_vectors.c +++ b/src/arch/arm-m/32/common_v6_v7/supervisor/arch_vectors.c @@ -10,8 +10,9 @@ */ #include +#include -extern uint8_t _start_start; +extern void _stack_start(); extern void init(void); #define proto_irq_func(x) extern void int_##x(void) proto_irq_func(1); @@ -37,8 +38,8 @@ proto_irq_func(14); * deref based on irq id and call respective handler. */ -const void (*arch_vectors[N_IRQ+1](void)) _SECTION(".archvectors") = -[ +void (*arch_vectors[N_IRQ+1])(void) _SECTION(".archvectors") = +{ &_stack_start, // Stack start value has higher address of stack // with as assumption that stack grows towards // lower address @@ -58,4 +59,4 @@ const void (*arch_vectors[N_IRQ+1](void)) _SECTION(".archvectors") = &int_12, // IRQ 12 -> N/A &int_13, // IRQ 13 -> PendSV &int_14, // IRQ 14 -> SysTick -]; +}; diff --git a/src/arch/arm/32m/common_v6_v7/supervisor/asm.S b/src/arch/arm-m/32/common_v6_v7/supervisor/asm.S similarity index 56% rename from src/arch/arm/32m/common_v6_v7/supervisor/asm.S rename to src/arch/arm-m/32/common_v6_v7/supervisor/asm.S index b6ecf287..ba30f7d4 100644 --- a/src/arch/arm/32m/common_v6_v7/supervisor/asm.S +++ b/src/arch/arm-m/32/common_v6_v7/supervisor/asm.S @@ -1,6 +1,6 @@ -* +/* * CYANCORE LICENSE - * Copyrights (C) 2022, Cyancore Team + * Copyrights (C) 2022-2023, Cyancore Team * * File Name : asm.S * Description : This file consists of all the function written in asm @@ -10,47 +10,15 @@ */ #include -#include -/** - * PROLOGUE - A macro that defines context save operation. Saving only argument registers (r0 - r7) - **/ - -.macro PROLOGUE - push r0 - push r1 - MRS r1, APSR - push r1 - push r2 - push r3 - push r4 - push r5 - push r6 - push r7 -.endm - -/** - * EPILOGUE - A macro that defines context restore operation -**/ +.altmacro +.macro INT id -.macro EPILOGUE - pop r7 - pop r6 - pop r5 - pop r4 - pop r3 - pop r2 - pop r1 - MSR APSR, r1 - pop r1 - pop r0 -.endm - - -function int_ /id - push r0 - mov r0, #/id +function int_\id + push {r0} + mov r0, #\id b isr +.endm /** * isr - interrupt service routine function @@ -59,23 +27,27 @@ function int_ /id * calling the interrupt handler function. */ +.weak isr function isr - PROLOGUE - MRS r1, MPS - add r1, #1 + push {r1-r7, lr} + mrs r1, msp bl exception_handler - EPILOGUE - pop r0 + pop {r1-r7} + pop {r0} + mov lr, r0 + pop {r0} + mov pc, lr /** * Interrupt Router Declaration Table - * 1-15 Interrupt routers are define as of now. If possible more can + * 1-14 Interrupt routers are define as of now. If possible more can * be added. But during compile time only necessary interrupt router * functions will be retained and others are cleaned up. */ /*==========< Interrupt router functions >==========*/ .set i, 1 -.rept 15 +.rept 14 INT %i .set i, i+1 .endr + diff --git a/src/arch/arm-m/32/common_v6_v7/supervisor/build.mk b/src/arch/arm-m/32/common_v6_v7/supervisor/build.mk new file mode 100644 index 00000000..badef973 --- /dev/null +++ b/src/arch/arm-m/32/common_v6_v7/supervisor/build.mk @@ -0,0 +1,16 @@ +# +# CYANCORE LICENSE +# Copyrights (C) 2023, Cyancore Team +# +# File Name : build.mk +# Description : Build script for this directory. +# Primary Authod : Akash Kollipara [akashkollipara@gmail.com] +# Organisation : Cyancore Core-Team +# + +ARM32_M_S_ARCH_DIR := $(GET_PATH) + +$(eval $(call add_include,$(ARM32_M_S_ARCH_DIR)/include/)) + +DIR := $(ARM32_M_S_ARCH_DIR) +include mk/obj.mk diff --git a/src/arch/arm/32m/common_v6_v7/supervisor/exception_handler.c b/src/arch/arm-m/32/common_v6_v7/supervisor/exception_handler.c similarity index 100% rename from src/arch/arm/32m/common_v6_v7/supervisor/exception_handler.c rename to src/arch/arm-m/32/common_v6_v7/supervisor/exception_handler.c diff --git a/src/arch/arm/32m/common_v6_v7/supervisor/include/arch.h b/src/arch/arm-m/32/common_v6_v7/supervisor/include/arch.h similarity index 78% rename from src/arch/arm/32m/common_v6_v7/supervisor/include/arch.h rename to src/arch/arm-m/32/common_v6_v7/supervisor/include/arch.h index e3122399..f42cec65 100644 --- a/src/arch/arm/32m/common_v6_v7/supervisor/include/arch.h +++ b/src/arch/arm-m/32/common_v6_v7/supervisor/include/arch.h @@ -12,10 +12,7 @@ #pragma once #define _ARCH_H_ -#include #include -#include -#include #include /** @@ -47,34 +44,17 @@ void arch_panic_handler(); void arch_register_interrupt_handler(unsigned int, void(*)(void)); /** - * arch_core_index - Returns code index - */ -static inline unsigned int arch_core_index() -{ - unsigned int id; - status_t status; - status = platform_sio_read(0x000 , &id); - if (status == success) - return id; - else - return 0; - -} - -unsigned int arch_core_index(); - -/** - * arch_machine_call - perform machine call - * @brief This function performs environment call + * arch_super_call - perform machine call + * @brief This function performs svc call * - * @param[in] code: machine call code + * @param[in] code: universal call code * @param[in] r0: first argument * @param[in] r1: second argument * @param[in] r2: third argument * @param[in] *ret: return struct */ - -static inline void arch_machine_call(unsigned int code, unsigned int arg0, unsigned int arg1, unsigned int arg2, mret_t *ret) +#define arch_machine_call arch_super_call +static inline void arch_super_call(unsigned int code, unsigned int arg0, unsigned int arg1, unsigned int arg2, mret_t *ret) { if(ret == NULL) return; diff --git a/src/arch/arm/32m/common_v6_v7/supervisor/include/arm.h b/src/arch/arm-m/32/common_v6_v7/supervisor/include/arm.h similarity index 100% rename from src/arch/arm/32m/common_v6_v7/supervisor/include/arm.h rename to src/arch/arm-m/32/common_v6_v7/supervisor/include/arm.h diff --git a/src/arch/arm/32m/common_v6_v7/supervisor/init.c b/src/arch/arm-m/32/common_v6_v7/supervisor/init.c similarity index 100% rename from src/arch/arm/32m/common_v6_v7/supervisor/init.c rename to src/arch/arm-m/32/common_v6_v7/supervisor/init.c diff --git a/src/arch/arm/32m/common_v6_v7/supervisor/systick.c b/src/arch/arm-m/32/common_v6_v7/supervisor/systick.c similarity index 100% rename from src/arch/arm/32m/common_v6_v7/supervisor/systick.c rename to src/arch/arm-m/32/common_v6_v7/supervisor/systick.c diff --git a/src/arch/arm/32m/common_v6_v7/supervisor/build.mk b/src/arch/arm-m/32/common_v7/supervisor/build.mk similarity index 100% rename from src/arch/arm/32m/common_v6_v7/supervisor/build.mk rename to src/arch/arm-m/32/common_v7/supervisor/build.mk diff --git a/src/arch/arm/32m/common_v7/supervisor/build.mk b/src/arch/arm-m/32/m0/supervisor/build.mk similarity index 100% rename from src/arch/arm/32m/common_v7/supervisor/build.mk rename to src/arch/arm-m/32/m0/supervisor/build.mk diff --git a/src/arch/arm-m/32/m0p/supervisor/build.mk b/src/arch/arm-m/32/m0p/supervisor/build.mk new file mode 100644 index 00000000..90e91f64 --- /dev/null +++ b/src/arch/arm-m/32/m0p/supervisor/build.mk @@ -0,0 +1,16 @@ +# +# CYANCORE LICENSE +# Copyrights (C) 2023, Cyancore Team +# +# File Name : build.mk +# Description : Build script for this directory. +# Primary Authod : Akash Kollipara [akashkollipara@gmail.com] +# Organisation : Cyancore Core-Team +# + +ARM32_M0P_T_ARCH_DIR := $(GET_PATH) + +include $(ARM32_M0P_T_ARCH_DIR)/../../common_v6_v7/supervisor/build.mk + +DIR := $(ARM32_M0P_T_ARCH_DIR) +include mk/obj.mk diff --git a/src/arch/arm/32m/m0/supervisor/build.mk b/src/arch/arm-m/32/m4/supervisor/build.mk similarity index 100% rename from src/arch/arm/32m/m0/supervisor/build.mk rename to src/arch/arm-m/32/m4/supervisor/build.mk diff --git a/src/arch/arm/32m/m0p/supervisor/build.mk b/src/arch/arm/32m/m0p/supervisor/build.mk deleted file mode 100644 index e69de29b..00000000 diff --git a/src/arch/arm/32m/m4/supervisor/build.mk b/src/arch/arm/32m/m4/supervisor/build.mk deleted file mode 100644 index e69de29b..00000000 diff --git a/src/driver/console/con_serial_rpi/build.mk b/src/driver/console/con_serial_rpi/build.mk new file mode 100644 index 00000000..52f3a081 --- /dev/null +++ b/src/driver/console/con_serial_rpi/build.mk @@ -0,0 +1,21 @@ +# +# CYANCORE LICENSE +# Copyrights (C) 2019, Cyancore Team +# +# File Name : build.mk +# Description : This file accumulates sources of console serial +# Primary Author : Akash Kollipara [akashkollipara@gmail.com] +# Organisation : Cyancore Core-Team +# + +DIR := $(GET_PATH) + +EARLYCON_SERIAL ?= 0 +CONSOLE_SERIAL ?= 0 + +$(eval $(call add_define,EARLYCON_SERIAL)) +$(eval $(call add_define,CONSOLE_SERIAL)) + +ifeq ($(filter $(CONSOLE_SERIAL) $(EARLYCON_SERIAL),1),1) +include mk/obj.mk +endif diff --git a/src/platform/pico/common/sections.ld.sx b/src/platform/pico/common/sections.ld.sx deleted file mode 100644 index c7acb9a6..00000000 --- a/src/platform/pico/common/sections.ld.sx +++ /dev/null @@ -1,113 +0,0 @@ -/* - * CYANCORE LICENSE - * Copyrights (C) 2022, Cyancore Team - * - * File Name : sections.ld.sx - * Description : This file contains memory layout for the - * cyancore framework - * Primary Author : Mayuri Lokhande [mayurilokhande01@gmail.com] - * Organisation : Cyancore Core-Team - */ - - #include - - - #ifndef L_MEM_START - #define L_MEM_START - #endif - - MEMORY - { - /* VM Addresses */ - vma_mem : ORIGIN = V_DMEM_START, LENGTH = DMEM_LENGTH - - /* LM Addresses */ - lma_mem : ORIGIN = L_MEM_START, LENGTH = IMEM_LENGTH - - /* Stack Addresses */ - v_smem : ORIGIN = V_SMEM_START, LENGTH = SMEM_LENGTH - - } - - SECTIONS - { - .text : - { - . = ALIGN(ALIGN_BOUND); - *(.archvectors) - KEEP(*(.archvectors)) - . = ALIGN(ALIGN_BOUND); - (*.text) - (*.text.*) - KEEP(*(.text)) - } > vma_mem AT > lma_mem - - .bss : - { - . = ALIGN(ALIGN_BOUND) - *(.bss) - *(.bss.*) - KEEP(*(.bss)) - *(COMMON) - } > vma_mem - - .data : - { - . = ALIGN(ALIGN_BOUND) - *(.version) - KEEP(*(.version)) - *(.rodata) - *(.rodata.*) - KEEP(*(.rodata)) - *(.data) - *(.data.*) - KEEP(*(.data)) - } > vma_mem - - .driver_table : {} > vma_mem AT > lma_mem - .mcall_table : {} > vma_mem AT > lma_mem - - .heap : - { - . = ALIGN(ALIGN_BOUND); - *(.heap) - KEEP(*(.heap)) - . = . + HEAP_SIZE; - } > vma_mem - - .stack : - { - . = ALIGN(ALIGN_BOUND); - *(.stack) - KEEP(*(.stack)) - . = . + STACK_SIZE; - } > vma_smem - - PROVIDE(_text_start = ADDR(.text)); - PROVIDE(_text_size = SIZEOF(.text)); - PROVIDE(_text_end = _text_start + _text_size - 1); - - PROVIDE(_data_start = LOADADDR(.data)); - PROVIDE(_data_size = SIZEOF(.data) + SIZEOF(.driver_table) + SIZEOF(.mcall_table)); - PROVIDE(_data_vstart = ADDR(.data)); - PROVIDE(_data_vend = _data_vstart + _data_size - 1); - - PROVIDE(_bss_start = ADDR(.bss)); - PROVIDE(_bss_size = SIZEOF(.bss)); - PROVIDE(_bss_end = _bss_start + _bss_size - 1); - - PROVIDE(_heap_start = ADDR(.heap)); - PROVIDE(_heap_size = SIZEOF(.heap)); - PROVIDE(_heap_end = _heap_start + _heap_size -1); - - PROVIDE(_flash_size = _data_size + SIZEOF(.text)); - PROVIDE(_ram_size = _bss_size + _data_size + SIZEOF(.stack) + SIZEOF(.heap)); - - ASSERT((_flash_size < FLASH_SIZE), "< x > Flash size exceeded ...") - ASSERT((_ram_size < RAM_SIZE), "< x > RAM size exceeded ...") - - /DISCARD/ : { *(.comment .trampolines) } -} - - - } diff --git a/src/platform/pico/r2040/include/plat_arch.h b/src/platform/pico/r2040/include/plat_arch.h deleted file mode 100644 index e402fb79..00000000 --- a/src/platform/pico/r2040/include/plat_arch.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * CYANCORE LICENSE - * Copyrights (C) 2019, Cyancore Team - * - * File Name : plat_arch.h - * Description : This file contains arch specific defines and - * prototypes - * Primary Author : Mayuri Lokhande[mayurilokhande01@gmail.com] - * Organisation : Cyancore Core-Team - */ - -#pragma once -#define _PLAT_ARCH_H_ - -#define _ARM_RP2040_ -#define ARCH_ARM - -#define CHIP_RESET 0x8 diff --git a/src/platform/pico/common/arch/platform_mem.c b/src/platform/rpi/common_rp2/arch/platform_mem.c similarity index 100% rename from src/platform/pico/common/arch/platform_mem.c rename to src/platform/rpi/common_rp2/arch/platform_mem.c diff --git a/src/platform/rpi/common_rp2/build.mk b/src/platform/rpi/common_rp2/build.mk new file mode 100644 index 00000000..abc3f18a --- /dev/null +++ b/src/platform/rpi/common_rp2/build.mk @@ -0,0 +1,26 @@ +# +# CYANCORE LICENSE +# Copyrights (C) 2023, Cyancore Team +# +# File Name : build.mk +# Description : This file accumulates sources from RP2 +# common directory +# Primary Author : Akash Kollipara [akashkollipara@gmail.com] +# Organisation : Cyancore Core-Team +# + +RP2_COMMON_DIR := $(GET_PATH) + +LD_SCRIPT := $(RP2_COMMON_DIR)/sections.ld.sx + +PLAT_INCLUDE += $(RP2_COMMON_DIR)/include + +LINT_FLAGS += --platform=unix32 + +USE_DEFAULT_RESOURCES ?= 1 +LOCAL_INTERRUPT_DEVICE ?= 0 +PLAT_INTERRUPT_DEVICE ?= 0 + +#include $(RP2_COMMON_DIR)/arch/build.mk +#include $(RP2_COMMON_DIR)/hal/build.mk +#include $(RP2_COMMON_DIR)/platform/build.mk diff --git a/src/platform/pico/common/platform.c b/src/platform/rpi/common_rp2/platform/platform.c similarity index 100% rename from src/platform/pico/common/platform.c rename to src/platform/rpi/common_rp2/platform/platform.c diff --git a/src/platform/pico/common/platform_reset.c b/src/platform/rpi/common_rp2/platform/platform_reset.c similarity index 100% rename from src/platform/pico/common/platform_reset.c rename to src/platform/rpi/common_rp2/platform/platform_reset.c diff --git a/src/platform/pico/common/platform/platform_resource.c b/src/platform/rpi/common_rp2/platform/platform_resource.c similarity index 100% rename from src/platform/pico/common/platform/platform_resource.c rename to src/platform/rpi/common_rp2/platform/platform_resource.c diff --git a/src/platform/rpi/common_rp2/sections.ld.sx b/src/platform/rpi/common_rp2/sections.ld.sx new file mode 100644 index 00000000..ae9b4ceb --- /dev/null +++ b/src/platform/rpi/common_rp2/sections.ld.sx @@ -0,0 +1,123 @@ +/* + * CYANCORE LICENSE + * Copyrights (C) 2023, Cyancore Team + * + * File Name : sections.ld.sx + * Description : This file contains memory layout for the + * cyancore framework + * Primary Author : Akash Kollipara [akashkollipara@gmail.com] + * Organisation : Cyancore Core-Team + */ + +#include +#include + +#ifndef L_MEM_START +#define L_MEM_START 0 +#endif + +MEMORY +{ + /* VM Addresses */ + vma_imem (irx!aw) : ORIGIN = V_IMEM_START, LENGTH = IMEM_LENGTH + vma_dmem (arw!xi) : ORIGIN = V_DMEM_START, LENGTH = DMEM_LENGTH + + /* LM Addresses */ + lma_mem : ORIGIN = L_MEM_START, LENGTH = L_MEM_LENGTH +} + +ENTRY(entry) + +SECTIONS +{ + .text : ALIGN(4) + { + KEEP(*(.text.entry)) + *(.text) + *(.text.*) + . = ALIGN(8); + } > vma_imem AT > lma_mem + + .rodata : ALIGN(4) + { + *(.version) + KEEP(*(.version)) + KEEP(*(.rdata)) + KEEP(*(.rodata)) + *(.rodata.*) + *(.srodata) + *(.srodata.*) + KEEP(*(.srodata)) + . = ALIGN(8); + } > vma_imem AT > lma_mem + + .bss : ALIGN(4) + { + *(.sbss) + *(.sbss.*) + KEEP(*(.sbss)) + *(.bss) + *(.bss.*) + KEEP(*(.bss)) + *(COMMON) + } > vma_dmem + + .data : ALIGN(4) + { + *(.sdata) + *(.sdata.*) + KEEP(*(.sdata)) + *(.data) + *(.data.*) + KEEP(*(.data)) + DRIVER_TABLE + ECALL_TABLE + } > vma_dmem AT > lma_mem + + .heap : ALIGN(HEAP_ALIGN) + { + *(.heap) + KEEP(*(.heap)) + . = . + HEAP_SIZE; + } > vma_dmem + + .stack : ALIGN(4) + { + *(.stack) + KEEP(*(.stack)) + . = . + STACK_SIZE; + } > vma_dmem + + PROVIDE(_text_start = ADDR(.text)); + PROVIDE(_text_size = SIZEOF(.text)); + PROVIDE(_text_end = _text_start + _text_size - 1); + + PROVIDE(_rodata_start = ADDR(.rodata)); + PROVIDE(_rodata_size = SIZEOF(.rodata)); + PROVIDE(_rodata_end = _rodata_start + _rodata_size - 1); + + PROVIDE(_data_start = LOADADDR(.data)); + PROVIDE(_data_size = SIZEOF(.data)); + PROVIDE(_data_vstart = ADDR(.data)); + PROVIDE(_data_vend = _data_vstart + _data_size - 1); + + PROVIDE(_stack_size = SIZEOF(.stack)); + PROVIDE(_stack_end = ADDR(.stack)); + PROVIDE(_stack_start = _stack_end + _stack_size); + + PROVIDE(_bss_start = ADDR(.bss)); + PROVIDE(_bss_size = SIZEOF(.bss)); + PROVIDE(_bss_end = _bss_start + _bss_size - 1); + + PROVIDE(_heap_start = ADDR(.heap)); + PROVIDE(_heap_size = SIZEOF(.heap)); + PROVIDE(_heap_end = _heap_start + _heap_size - 1); + + PROVIDE(_flash_size = _data_size + SIZEOF(.text) + _itim_size + SIZEOF(.rodata)); + PROVIDE(_ram_size = _bss_size + _data_size + SIZEOF(.stack) + SIZEOF(.heap)); + + ASSERT((_flash_size < FLASH_SIZE), "< x > Flash size exceeded ...") + ASSERT((_ram_size < RAM_SIZE), "< x > RAM size exceeded ...") + + /DISCARD/ : { *(.comment .trampolines) } +} diff --git a/src/platform/pico/rp2040/build.mk b/src/platform/rpi/rp2040/build.mk similarity index 68% rename from src/platform/pico/rp2040/build.mk rename to src/platform/rpi/rp2040/build.mk index 1ff98e92..76f19b91 100644 --- a/src/platform/pico/rp2040/build.mk +++ b/src/platform/rpi/rp2040/build.mk @@ -14,13 +14,12 @@ RP2040_DIR := $(GET_PATH) ARCH := arm-m BIT := 32 -ARCH_VARIANT := v6 -TARGET_FLAGS += +ARCH_VARIANT := m0p +TL_TYPE := thumb/v6-m +TARGET_FLAGS += -mcpu=cortex-m0plus -mfloat-abi=softfp PLAT_INCLUDE += $(RP2040_DIR)/include -OUTPUT_FORMAT := +OUTPUT_FORMAT := elf32-littlearm -#include $(RP2040_DIR)/config.mk -#include $(RP2040_DIR)/arch/build.mk -#include $(RP2040_DIR)/platform/build.mk +include $(RP2040_DIR)/config.mk #include $(RP2040_DIR)/resources/build.mk -#include $(RP2040_DIR)/../common_fe310/build.mk +include $(RP2040_DIR)/../common_rp2/build.mk diff --git a/src/platform/rpi/rp2040/config.mk b/src/platform/rpi/rp2040/config.mk new file mode 100644 index 00000000..020448b2 --- /dev/null +++ b/src/platform/rpi/rp2040/config.mk @@ -0,0 +1,79 @@ +# +# CYANCORE LICENSE +# Copyrights (C) 2023, Cyancore Team +# +# File Name : config.mk +# Description : This file defines configuration for RP2040 +# Primary Author : Akash Kollipara [akashkollipara@gmail.com] +# Organisation : Cyancore Core-Team +# + +#====================================================================== +# Configuration file for Platforms +#====================================================================== + +#====================================================================== +# Platform Configuration +# Do not alter below FLAGS unless explicitly mentioned +#====================================================================== +N_CORES := 2 +$(eval $(call add_define,N_CORES)) + +CCSMP ?= 1 +$(eval $(call add_define,CCSMP)) + +$(eval $(call add_define,BIT)) + +BOOT_CORE_ID:= 0 +$(eval $(call add_define,BOOT_CORE_ID)) + +FLASH_START := 0x10000000 +FLASH_SIZE := 0x1000000 # 16M +RAM_START := 0x20000000 +RAM_SIZE := 0x42000 # 264K +HEAP_SIZE ?= 16K +STACK_SIZE ?= 16K +STACK_SIZE_PCPU ?= 8K + +$(eval $(call add_define,HEAP_SIZE)) +$(eval $(call add_define,STACK_SIZE)) +$(eval $(call add_define,STACK_SIZE_PCPU)) + +# Call this FLAG from Project config file if needed +XCLK ?= 12000000 +ICLK ?= 12000000 +$(eval $(call add_define,XCLK)) +$(eval $(call add_define,ICLK)) + +N_EXCEP := 15 +$(eval $(call add_define,N_EXCEP)) + +N_PLAT_IRQS := 32 +$(eval $(call add_define,N_PLAT_IRQS)) + +MAX_INTERRUPTS_PER_DEVICE := 1 +$(eval $(call add_define,MAX_INTERRUPTS_PER_DEVICE)) + +USE_SPINLOCK ?= 1 +$(eval $(call add_define,USE_SPINLOCK)) + +#====================================================================== +# MEMBUF Configuration +#====================================================================== +MEMBUF_SIZE ?= 1024 +$(eval $(call add_define,MEMBUF_SIZE)) +#====================================================================== + +#====================================================================== +# GPIO Configuration +#====================================================================== +N_PORT := 1 +$(eval $(call add_define,N_PORT)) +#====================================================================== + +#====================================================================== +# Timer: Sched timer/wall clock +#====================================================================== +USE_TIMER ?= 1 +$(eval $(call add_define,USE_TIMER)) +#====================================================================== diff --git a/src/platform/pico/rp2040/include/plat_mem.h b/src/platform/rpi/rp2040/include/plat_mem.h similarity index 62% rename from src/platform/pico/rp2040/include/plat_mem.h rename to src/platform/rpi/rp2040/include/plat_mem.h index 3b8d287f..deea16e7 100644 --- a/src/platform/pico/rp2040/include/plat_mem.h +++ b/src/platform/rpi/rp2040/include/plat_mem.h @@ -1,10 +1,10 @@ /* * CYANCORE LICENSE - * Copyrights (C) 2019, Cyancore Team + * Copyrights (C) 2023, Cyancore Team * * File Name : plat_mem.h * Description : This file contains memory config of fe310-g002 - * Primary Author : Akash Kollipara [akashkollipara@gmail.com] + * Primary Author : Mayuri Lokhande [mayurilokhande01@gmail.com] * Organisation : Cyancore Core-Team */ @@ -15,16 +15,14 @@ #define V_IMEM_START 0x10000000 #define V_DMEM_START 0x20000000 -#define V_SMEM_START 0x20040000 #define L_MEM_START 0x10000000 #define L_MEM_LENGTH 16M -#define DMEM_LENGTH 256K -#define SMEM_LENGTH 8K +#define DMEM_LENGTH 264K #define IMEM_LENGTH 16M #define ALIGN_BOUND 4 -#define STACK_SIZE 0xc00 -#define STACK_SIZE_PCPU 4K +#define STACK_SIZE 16K +#define STACK_SIZE_PCPU 8K diff --git a/src/platform/pico/rp2040/include/platform_sio.h b/src/platform/rpi/rp2040/include/platform_sio.h similarity index 100% rename from src/platform/pico/rp2040/include/platform_sio.h rename to src/platform/rpi/rp2040/include/platform_sio.h diff --git a/src/visor/supervisor/services/bootstrap/bootstrap.c b/src/visor/supervisor/services/bootstrap/bootstrap.c new file mode 100644 index 00000000..bbf24dad --- /dev/null +++ b/src/visor/supervisor/services/bootstrap/bootstrap.c @@ -0,0 +1,49 @@ +/* + * CYANCORE LICENSE + * Copyrights (C) 2019, Cyancore Team + * + * File Name : bootstrap.c + * Description : This file contains sources of bootstrap routine + * Primary Author : Akash Kollipara [akashkollipara@gmail.com] + * Organisation : Cyancore Core-Team + */ + +#include +#include +#include +#include +#include +#include + + +status_t bootstrap() +{ + reset_t resetSyndrome; + + arch_early_setup(); + + platform_early_setup(); + + arch_setup(); + + platform_setup(); + + resetSyndrome = platform_get_reset_syndrome(); + platform_reset_handler(resetSyndrome); + + platform_cpu_setup(); + + return success; +} + +#if CCSMP +status_t bootstrap_secondary() +{ + arch_early_setup(); + + arch_setup2(); + + platform_cpu_setup(); + return success; +} +#endif diff --git a/src/visor/supervisor/services/bootstrap/build.mk b/src/visor/supervisor/services/bootstrap/build.mk new file mode 100644 index 00000000..c3dc1b0f --- /dev/null +++ b/src/visor/supervisor/services/bootstrap/build.mk @@ -0,0 +1,13 @@ +# +# CYANCORE LICENSE +# Copyrights (C) 2019, Cyancore Team +# +# File Name : build.mk +# Description : This file build bootstrap sources +# Primary Author : Akash Kollipara [akashkollipara@gmail.com] +# Organisation : Cyancore Core-Team +# + +DIR := $(GET_PATH) + +include mk/obj.mk diff --git a/src/visor/supervisor/services/build.mk b/src/visor/supervisor/services/build.mk new file mode 100644 index 00000000..52a497f9 --- /dev/null +++ b/src/visor/supervisor/services/build.mk @@ -0,0 +1,17 @@ +# +# CYANCORE LICENSE +# Copyrights (C) 2023, Cyancore Team +# +# File Name : build.mk +# Description : This file accumulates the build scripts +# from supervisor services +# Primary Author : Akash Kollipara [akashkollipara@gmail.com] +# Organisation : Cyancore Core-Team +# + +S_SERVICES := $(GET_PATH) + +include $(S_SERVICES)/bootstrap/build.mk + +DIR := $(S_SERVICES) +include mk/obj.mk