diff --git a/README.md b/README.md index fbabdac7..037c29d6 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@
An unified software platform for embedded system projects ...
- From India with Pride!

+ From Bharat with Pride!

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/mk/tc_get.mk b/mk/tc_get.mk index cdaa630d..7548ef2d 100644 --- a/mk/tc_get.mk +++ b/mk/tc_get.mk @@ -15,9 +15,9 @@ T_ALLOWLIST += get_all_tc get_avr_tc get_arm_tc get_riscv_tc # GIT REPO RECOMMENDED # Provide git repo path for toolchains for better experience ESIZE_REPO := https://github.com/VisorFolks/cc_elf_size.git -AVR_TC_REPO ?= -RISC_V_TC_REPO ?= -ARM_TC_REPO ?= +AVR_TC_REPO ?= https://github.com/VisorFolks/avr-toolchain +RISC_V_TC_REPO ?= https://github.com/VisorFolks/risc-v-toolchain +ARM_TC_REPO ?= https://github.com/VisorFolks/arm-toolchain get_all_tc: --tc_clear get_avr_tc get_arm_tc get_riscv_tc 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-m/32/common_v6_v7/supervisor/arch.c b/src/arch/arm-m/32/common_v6_v7/supervisor/arch.c new file mode 100644 index 00000000..c74180b5 --- /dev/null +++ b/src/arch/arm-m/32/common_v6_v7/supervisor/arch.c @@ -0,0 +1,134 @@ +/* + * CYANCORE LICENSE + * Copyrights (C) 2019, Cyancore Team + * + * File Name : arch.c + * Description : This file consists of architecture specific function that + * cannot be inlined. Hence, present in c file. + * Primary Author : Mayuri Lokhande [mayurilokhande01@gmail.com] + * Organisation : Cyancore Core-Team + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +static void arch_ecall_handler() +{ + context_frame_t *frame = get_context_frame(); + vret_t vres; + machine_call(frame->r0, frame->r1, frame->r3, &vres); + frame->r0 = vres.p; + frame->r1 = vres.size; + frame->r2 = vres.status; + return; +} + +/** + *arch_early_setup - This function is called in the early stages of boot + * + * @brief This function is respinsible to clean reset cpu status/control registers. + * + */ +void arch_early_setup() +{ + arch_di(); + +} + +/** + * arch_setup - This function is called after initial setup is done + * + * @brief This function is called after initial setup is done. + */ +void arch_setup() +{ + return; +} + +void arch_di_save_state(istate_t *sreg_i_backup) +{ + * +} + +void arch_ei_restore_state(istate_t *sreg_i_backup) +{ + +} + +/** + * arch_core_index - Returns code index + */ + +_WEAK unsigned int arch_core_index() +{ + return 0; +} + +void _NORETURN arch_panic_handler_callback() +{ + context_frame_t *frame; + frame = get_context_frame(); + if(!frame) + goto panic; + syslog_stdout_enable(); + sysdbg("r0=%p\tr1=%p\tr2=%p\tr3=%p\tr4=%p\tr5=%p\n", + frame->r0, frame->r1, frame->r2, frame->r3, frame->r4, frame->r5); + sysdbg("r6=%p\tr7=%p\tr8=%p\tr9=%p\tr10=%p\tr11=%p\n", + frame->r6, frame->r7, frame->r8, frame->r9, frame->r10, frame->r11); + sysdbg("r12=%p\tr13=%p\tr14=%p\tr15=%p\tAPSR=%p\n", + frame->r12, frame->r13, frame->r14, frame->r15, frame->apsr); +#if DEBUG==0 + syslog(info, "APSR=%p\n", frame->apsr); +#endif +panic: + while(1) arch_wfi(); +} + +static cpu_sleep_t sleep_flag; + +/** + * arch_suspended_state_was + * + * @brief This function checks for the suspended state + * and returns true or flase based on arg. + * + * @param[in] state: suspended state + * @return bool: True/False + */ + +bool arch_suspended_state_was(cpu_sleep_t state) +{ + assert(state != resume); + if(!sleep_flag) + return false; + return (sleep_flag == state); +} + +/** + * arch_signal_suspend + * + * @brief This function is intended to be called before cpu enters + * suspend state. By passing the state, we store and use to check while + * exiting resume routine. + * + * @param[in] state: Suspend state of cpu + */ +void arch_signal_suspend(cpu_sleep_t state) +{ + sleep_flag = state; +} + +/** + * @brief This function signals resume of cpu. It is intended + * to be called after exiting resume routine. + */ +void arch_signal_resume(void) +{ + sleep_flag = resume; +} 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-m/32/common_v6_v7/supervisor/asm.S b/src/arch/arm-m/32/common_v6_v7/supervisor/asm.S new file mode 100644 index 00000000..ba30f7d4 --- /dev/null +++ b/src/arch/arm-m/32/common_v6_v7/supervisor/asm.S @@ -0,0 +1,53 @@ +/* + * CYANCORE LICENSE + * Copyrights (C) 2022-2023, Cyancore Team + * + * File Name : asm.S + * Description : This file consists of all the function written in asm + * like ISR, context management and panic handler + * Primary Author : Mayuri Lokhande [mayurilokhande01@gmail.com] + * Organisation : Cyancore Core-Team + */ + +#include + +.altmacro +.macro INT id + +function int_\id + push {r0} + mov r0, #\id + b isr +.endm + +/** + * isr - interrupt service routine function + * @brief This function is called from interrupt router. + * It is responsible to do context management before and after + * calling the interrupt handler function. + */ + +.weak isr +function isr + push {r1-r7, lr} + mrs r1, msp + bl exception_handler + pop {r1-r7} + pop {r0} + mov lr, r0 + pop {r0} + mov pc, lr + +/** + * Interrupt Router Declaration Table + * 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 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-m/32/common_v6_v7/supervisor/exception_handler.c b/src/arch/arm-m/32/common_v6_v7/supervisor/exception_handler.c new file mode 100644 index 00000000..92310a3f --- /dev/null +++ b/src/arch/arm-m/32/common_v6_v7/supervisor/exception_handler.c @@ -0,0 +1,109 @@ +/* + * CYANCORE LICENSE + * Copyrights (C) 2019, Cyancore Team + * + * File Name : interrupt_handler.c + * Description : This file consists of arch interrupt handler sources. + * Primary Author : Mayuri Lokhande [mayurilokhande01@gmail.com] + * Organisation : Cyancore Core-Team + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +static context_frame_t *local_frame; + +static void set_context_frame(*frame) +{ + local_frame = frame; +} + +bool in_isr(void) +{ + return (local_frame != NULL) ? true : false ; +} + +/** + * int_handler - Array of Interrupt handler pointers + * + * @brief This is a function pointer array which consists of addresses of corresponding + * interrupt handler functions. This is by default assigned as arch_panic_handler. + */ +static void (* exhandler[N_EXCEP])(void) = {{[0 ... N_EXCEP-1] = arch_panic_handler}}; + +/** + * arch_register_interrupt_handlers - Registers arch interrupt handlers + * @brief This function is responsible to registers all architectural level + * Interrupt handling functions. + * + * @param[in] id: Interrupt ID + * @param[in] *handler - function pointer of interrupt handling function. + */ + +void arch_register_interrupt_handler(unsigned int id, void(* handler)(void)) +{ + /*Check if Interrupt ID is valid*/ + assert((id > 0) && (id <= N_EXCEP)); + + /* + * Decrement ID as array indexing starts from 0. + * ID = 0 is CPU entry address. + */ + id --; + + /*Store interrupt handler*/ + exhandler[id] = handler; +} + +/** + * Exception handler - Executes Interrupt handler corresponding to int ID + * + * @brief This function is called by ISR. It executes function pointed by int_handler. + * It accepts int ID as argument, which indexes the interrupt handling function. + * + * @param[in] id: Interrupt ID + */ + +void exception_handler(unsigned int id, context_frame_t *frame) +{ + set_context_frame(frame); + + /*Check if Interrupt ID is valid*/ + if((id > 0) && (id <= N_EXCEP)) + { + /* + * Decrement ID as array indexing starts from 0. + * ID = 0 is CPU entry address. + */ + id --; + + /* Get corresponding interrupt handling function */ + void (*handler)(void) = exhandler[id] + + /* Check if the handler is valid*/ + assert(handler) + + /* Execute exception handler */ + handler(); + } + else if(id == 65535) + plat_panic_handler_callback(); + else if(id == 65536) + arch_panic_handler_callback(); + else{} + set_context_frame(NULL); + return; +} + +context_frame_t *get_context_frame() +{ + if(local_frame) + return local_frame; + return NULL; +} diff --git a/src/arch/arm-m/32/common_v6_v7/supervisor/include/arch.h b/src/arch/arm-m/32/common_v6_v7/supervisor/include/arch.h new file mode 100644 index 00000000..7e48edf3 --- /dev/null +++ b/src/arch/arm-m/32/common_v6_v7/supervisor/include/arch.h @@ -0,0 +1,119 @@ +/* + * CYANCORE LICENSE + * Copyrights (C) 2019, Cyancore Team + * + * File Name : arch.h + * Description : This file prototypes arch related functions and + * defines inline-able arch functions. + * Primary Author : Mayuri Lokhande [mayurilokhande01@gmail.com] + * Organisation : Cyancore Core-Team + */ + +#pragma once +#define _ARCH_H_ + +#include +#include + +/** + * arch_early_setup - This needs to be called in early stages of boot + */ +void arch_early_setup(); + +/** + * arch_setup - This needs to be called after intial setup is completed. + */ +void arch_setup(); + +/** + * arch_wfi - Wait for interrupt, with sleep mode + */ +void arch_wfi(); +void arch_di_save_state(istate *); +void arch_ei_restore_state(istate *); + +/** + * arch_panic_handler - Executes when arch error occurs + */ +void arch_panic_handler(); + +/** + * arch_register_interrupt_handler - Registers interrupt handler for + * arch specific interrupt vectors + */ +void arch_register_interrupt_handler(unsigned int, void(*)(void)); + +/** + * arch_super_call - perform machine call + * @brief This function performs svc call + * + * @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 + */ +#define arch_visor_call arch_super_call +static inline void arch_super_call(unsigned int code, unsigned int arg0, unsigned int arg1, unsigned int arg2, vret_t *ret) +{ + if(ret == NULL) + return; + register uint32_t r0 asm("r0") = code; + register uint32_t r1 asm("r1") = arg0; + register uint32_t r2 asm("r2") = arg1; + register uint32_t r3 asm("r3") = arg2; + asm volatile("svc" + :"+r" (r0), "+r" (r1), "+r"(r2) + :"r" (r0), "r" (r1), "r" (r2), "r" (r3) + :"memory"); + + ret->p = r0; + ret->size = r1; + ret->status = r2; + return; +} + + /** + * arch_ei - arch enable global interrupts + */ +static inline void arch_ei() +{ + asm volatile("cpsie iaf"); +} + +/** + * arch_ei - arch enable global interrupts + */ +static inline void arch_di() +{ + asm volatile("cpsid iaf"); +} + +static inline void arch_nop() +{ + asm volatile("nop"); +} + +static inline void arch_wfi() +{ + asm volatile("wfi"); +} + +static inline void arch_isb() +{ + asm volatile("isb"); +} + +static inline void arch_dsb() +{ + asm volatile("dsb"); +} + +static inline void arch_dmb() +{ + asm volatile("dmb"); +} + +bool arch_suspended_state_was(cpu_sleep_t); +void arch_signal_suspend(cpu_sleep_t); +void arch_signal_resume(void); diff --git a/src/arch/arm-m/32/common_v6_v7/supervisor/include/arm.h b/src/arch/arm-m/32/common_v6_v7/supervisor/include/arm.h new file mode 100644 index 00000000..832c0835 --- /dev/null +++ b/src/arch/arm-m/32/common_v6_v7/supervisor/include/arm.h @@ -0,0 +1,67 @@ +/* + * CYANCORE LICENSE + * Copyrights (C) 2019, Cyancore Team + * + * File Name : arch.h + * Description : This file prototypes arch related functions and + * defines inline-able arch functions. + * Primary Author : Mayuri Lokhande [mayurilokhande01@gmail.com] + * Organisation : Cyancore Core-Team + */ + +#pragma once +#define _ARM_H +#include +#include +#include + + +typedef struct context_frame +{ + uint8_t r15, r14, r13, r12, r11, r10, r9, r8, + r7, r6, r5, r4, r3, r2, r1, APSR, r0; +}context_frame_t; + +typedef uint32_t istate_t; + +static inline unsigned int arch_core_impid() +{ + unsigned int ret; + asm volatile("cpuid %0, implementer" : "=r"(ret)); + return ret; +} + +static inline unsigned int arch_core_varid() +{ + unsigned int ret; + asm volatile("cpuid %0, varid" : "=r"(ret)); + return ret; +} + +static inline unsigned int arch_core_archid() +{ + unsigned int ret; + asm volatile("cpuid %0, architecture" : "=r"(ret)); + return ret; +} + +static inline unsigned int arch_core_partno() +{ + unsigned int ret; + asm volatile("cpuid %0, partno" : "=r"(ret)); +} + +static inline unsigned int arch_core_revid() +{ + unsigned int ret; + asm volatile("cpuid %0, revision" : "=r"(ret)); +} + +static inline void arch_update_sp(uint32_t *p) +{ + asm volatile("mov sp, %0" : : "r"(p)); +} + +context_frame_t *get_context_frame(); +bool in_isr(void); +void arch_panic_handler_callback(); 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/common_v6_v7/supervisor/asm.S b/src/arch/arm/32m/common_v6_v7/supervisor/asm.S deleted file mode 100644 index e69de29b..00000000 diff --git a/src/arch/arm/32m/common_v6_v7/supervisor/exception_handler.c b/src/arch/arm/32m/common_v6_v7/supervisor/exception_handler.c deleted file mode 100644 index e69de29b..00000000 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/arch/avr/8/common_5x_6/terravisor/arch.c b/src/arch/avr/8/common_5x_6/terravisor/arch.c index 0ed970f4..b1db93e9 100644 --- a/src/arch/avr/8/common_5x_6/terravisor/arch.c +++ b/src/arch/avr/8/common_5x_6/terravisor/arch.c @@ -17,7 +17,7 @@ #include #include #include -#include +#include /** * arch_early_setup - This function is called in the early stages of boot @@ -25,7 +25,7 @@ * @brief This function is responsible to clean reset cpu status/control registers. * */ -void (* const p_mcall)(unsigned int, unsigned int, unsigned int, unsigned int, mret_t *) = &machine_call; +void (* const p_vcall)(unsigned int, unsigned int, unsigned int, unsigned int, vret_t *) = &vcall_handler; void arch_early_setup() { arch_di(); diff --git a/src/arch/avr/8/common_5x_6/terravisor/include/arch.h b/src/arch/avr/8/common_5x_6/terravisor/include/arch.h index 1b311713..5c7f212b 100644 --- a/src/arch/avr/8/common_5x_6/terravisor/include/arch.h +++ b/src/arch/avr/8/common_5x_6/terravisor/include/arch.h @@ -16,7 +16,7 @@ #include #include #include -#include +#include /** * arch_early_setup - This needs to be called in early stages of boot @@ -56,7 +56,7 @@ static inline unsigned int arch_core_index() } /** - * arch_machine_call - perform machine call + * arch_visor_call - perform machine call * * @brief This function emulates the machine * call to maintain consistency. @@ -67,12 +67,12 @@ static inline unsigned int arch_core_index() * @param[in] a2: third argument * @param[in] *ret: return value */ -static inline void arch_machine_call(unsigned int code, unsigned int a0, unsigned int a1, unsigned int a2, mret_t *ret) +static inline void arch_visor_call(unsigned int code, unsigned int a0, unsigned int a1, unsigned int a2, vret_t *ret) { - extern void (*const p_mcall)(unsigned int, unsigned int, unsigned int, unsigned int, mret_t*); + extern void (*const p_vcall)(unsigned int, unsigned int, unsigned int, unsigned int, vret_t*); if(ret == NULL) return; - p_mcall(code, a0, a1, a2, ret); + p_vcall(code, a0, a1, a2, ret); return; } diff --git a/src/arch/riscv/32/i/terravisor/arch.c b/src/arch/riscv/32/i/terravisor/arch.c index a0becfe5..5f0c286c 100644 --- a/src/arch/riscv/32/i/terravisor/arch.c +++ b/src/arch/riscv/32/i/terravisor/arch.c @@ -14,18 +14,18 @@ #include #include #include -#include +#include #include -static void arch_mcall_handler() +static void arch_vcall_handler() { context_frame_t *frame = get_context_frame(); - mret_t mres; - machine_call(frame->a0, frame->a1, frame->a2, frame->a3, &mres); + vret_t vres; + vcall_handler(frame->a0, frame->a1, frame->a2, frame->a3, &vres); fence(w, w); - frame->a0 = mres.p; - frame->a1 = mres.size; - frame->a2 = mres.status; + frame->a0 = vres.p; + frame->a1 = vres.size; + frame->a2 = vres.status; return; } @@ -72,13 +72,13 @@ void arch_early_setup() */ void arch_setup() { - link_interrupt(int_arch, 11, &arch_mcall_handler); + link_interrupt(int_arch, 11, &arch_vcall_handler); return; } void arch_setup2() { - link_interrupt(int_arch, 11, &arch_mcall_handler); + link_interrupt(int_arch, 11, &arch_vcall_handler); return; } diff --git a/src/arch/riscv/32/i/terravisor/include/arch.h b/src/arch/riscv/32/i/terravisor/include/arch.h index ad957d51..c60066f7 100644 --- a/src/arch/riscv/32/i/terravisor/include/arch.h +++ b/src/arch/riscv/32/i/terravisor/include/arch.h @@ -14,7 +14,7 @@ #include #include #include -#include +#include /** * arch_early_setup - This needs to be called in early stages of boot @@ -63,7 +63,7 @@ static inline unsigned int arch_core_index() } /** - * arch_machine_call - perform machine call + * arch_visor_call - perform machine call * * @brief This function performs environment call * in m mode @@ -74,7 +74,7 @@ static inline unsigned int arch_core_index() * @param[in] a2: 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) +static inline void arch_visor_call(unsigned int code, unsigned int arg0, unsigned int arg1, unsigned int arg2, vret_t *ret) { if(ret == NULL) return; diff --git a/src/driver/console/con_serial_mega_avr/console_serial.c b/src/driver/console/con_serial_mega_avr/console_serial.c index 5a839077..6a713907 100644 --- a/src/driver/console/con_serial_mega_avr/console_serial.c +++ b/src/driver/console/con_serial_mega_avr/console_serial.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -30,25 +30,25 @@ static void console_serial_read_irq_handler(void); static status_t console_serial_setup() { - mret_t mres; + vret_t vres; const swdev_t *sp; const module_t *dp; hw_devid_t devid; - arch_machine_call(fetch_sp, console_uart, 0, 0, &mres); - if(mres.status != success) + arch_visor_call(fetch_sp, console_uart, 0, 0, &vres); + if(vres.status != success) { sysdbg3("Console could not found!\n"); - return mres.status; + return vres.status; } - sp = (swdev_t *) mres.p; + sp = (swdev_t *) vres.p; devid = sp->hwdev_id; - arch_machine_call(fetch_dp, (devid & 0xff00), (devid & 0x00ff), 0, &mres); - if(mres.status != success) + arch_visor_call(fetch_dp, (devid & 0xff00), (devid & 0x00ff), 0, &vres); + if(vres.status != success) { sysdbg3("UART Device %d not found!\n", devid); - return mres.status; + return vres.status; } - dp = (module_t *)mres.p; + dp = (module_t *)vres.p; console_port = (uart_port_t *)malloc(sizeof(uart_port_t)); if(!console_port) return error_memory_low; diff --git a/src/driver/console/con_serial_mega_avr/earlycon_serial.c b/src/driver/console/con_serial_mega_avr/earlycon_serial.c index 05d8a527..35ce138b 100644 --- a/src/driver/console/con_serial_mega_avr/earlycon_serial.c +++ b/src/driver/console/con_serial_mega_avr/earlycon_serial.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -27,25 +27,25 @@ static uart_port_t *earlycon_port; static status_t earlycon_serial_setup() { - mret_t mres; + vret_t vres; swdev_t *sp; module_t *dp; hw_devid_t devid; - arch_machine_call(fetch_sp, console_uart, 0, 0, &mres); - if(mres.status != success) + arch_visor_call(fetch_sp, console_uart, 0, 0, &vres); + if(vres.status != success) { sysdbg3("Console could not found!\n"); - return mres.status; + return vres.status; } - sp = (swdev_t *) mres.p; + sp = (swdev_t *) vres.p; devid = sp->hwdev_id; - arch_machine_call(fetch_dp, (devid & 0xff00), (devid & 0x00ff), 0, &mres); - if(mres.status != success) + arch_visor_call(fetch_dp, (devid & 0xff00), (devid & 0x00ff), 0, &vres); + if(vres.status != success) { sysdbg3("UART Device %d not found!\n", devid); - return mres.status; + return vres.status; } - dp = (module_t *)mres.p; + dp = (module_t *)vres.p; earlycon_port = (uart_port_t *)malloc(sizeof(uart_port_t)); if(!earlycon_port) return error_memory_low; 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/driver/console/con_serial_sifive/console_serial.c b/src/driver/console/con_serial_sifive/console_serial.c index 4bd9c194..0d1f55b5 100644 --- a/src/driver/console/con_serial_sifive/console_serial.c +++ b/src/driver/console/con_serial_sifive/console_serial.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/driver/console/con_serial_sifive/earlycon_serial.c b/src/driver/console/con_serial_sifive/earlycon_serial.c index bb71d828..12792cb1 100644 --- a/src/driver/console/con_serial_sifive/earlycon_serial.c +++ b/src/driver/console/con_serial_sifive/earlycon_serial.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/driver/interrupt/plic/plic.c b/src/driver/interrupt/plic/plic.c index 96df39bc..16a17b8c 100644 --- a/src/driver/interrupt/plic/plic.c +++ b/src/driver/interrupt/plic/plic.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include @@ -33,14 +33,14 @@ static plic_port_t *port; static status_t plic_setup() { - mret_t mres; + vret_t vres; const module_t *dp; - arch_machine_call(fetch_dp, plic, 0, 0, &mres); + arch_visor_call(fetch_dp, plic, 0, 0, &vres); - if(mres.status != success) - return mres.status; - dp = (module_t *)mres.p; + if(vres.status != success) + return vres.status; + dp = (module_t *)vres.p; port = (plic_port_t *)malloc(sizeof(plic_port_t)); if(!port) return error_memory_low; diff --git a/src/driver/onboardled/onboardled.c b/src/driver/onboardled/onboardled.c index 0f619b3c..a0966ad7 100644 --- a/src/driver/onboardled/onboardled.c +++ b/src/driver/onboardled/onboardled.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include @@ -73,19 +73,19 @@ status_t onboardled_off(void) static status_t onboardled_setup(void) { - mret_t mres; + vret_t vres; status_t ret; lock_acquire(&obledlock); - arch_machine_call(fetch_sp, onboard_led, 0, 0, &mres); - if(mres.status != success) + arch_visor_call(fetch_sp, onboard_led, 0, 0, &vres); + if(vres.status != success) { sysdbg3("%p - sp node could not be found!\n", onboard_led); - ret = mres.status; + ret = vres.status; goto exit; } - obled_sp = (swdev_t *) mres.p; - ret = mres.status; + obled_sp = (swdev_t *) vres.p; + ret = vres.status; obledPort = (gpio_port_t *)malloc(sizeof(gpio_port_t) * obled_sp->pmux->npins); diff --git a/src/driver/sysclk/sysclk_prci/sysclk_prci.c b/src/driver/sysclk/sysclk_prci/sysclk_prci.c index 4d3ab45d..dfa61634 100644 --- a/src/driver/sysclk/sysclk_prci/sysclk_prci.c +++ b/src/driver/sysclk/sysclk_prci/sysclk_prci.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -31,7 +31,7 @@ static status_t sysclk_disable(); static status_t sysclk_setup() { status_t ret = success; - mret_t mres; + vret_t vres; module_t *dp; sysclk_port_t *port; istate_t ist; @@ -41,30 +41,30 @@ static status_t sysclk_setup() return error_memory_low; port = sysclk; - arch_machine_call(fetch_dp, clock, 0, 0, &mres); + arch_visor_call(fetch_dp, clock, 0, 0, &vres); - if(mres.status != success) + if(vres.status != success) { sysdbg2("Clock not found in DP!\n"); port->base_clk = 0; - ret = mres.status; + ret = vres.status; goto cleanup_exit; } - port->base_clk = *((unsigned int *)mres.p); + port->base_clk = *((unsigned int *)vres.p); - arch_machine_call(fetch_dp, prci, 0, 0, &mres); + arch_visor_call(fetch_dp, prci, 0, 0, &vres); - if(mres.status != success) + if(vres.status != success) { sysdbg2("PRCI not found in DP!\n"); - ret = mres.status; + ret = vres.status; goto cleanup_exit; } lock_acquire(&sysclk_key); arch_di_save_state(&ist); - dp = (module_t *) mres.p; + dp = (module_t *) vres.p; port->port_id = dp->id; port->baddr = dp->baddr; port->stride = dp->stride; @@ -187,7 +187,7 @@ static inline void sysclk_set_pll(unsigned int clk) return; } -static void sysclk_configure_clk(call_arg_t a0, call_arg_t a1, call_arg_t a2 _UNUSED, mret_t *ret) +static void sysclk_configure_clk(call_arg_t a0, call_arg_t a1, call_arg_t a2 _UNUSED, vret_t *ret) { sysclk_port_t *port = sysclk; istate_t ist; @@ -231,10 +231,10 @@ static void sysclk_configure_clk(call_arg_t a0, call_arg_t a1, call_arg_t a2 _UN return; } -INCLUDE_MCALL(sysclk_set, config_clk, sysclk_configure_clk); +INCLUDE_VCALL(sysclk_set, config_clk, sysclk_configure_clk); static void sysclk_get_freq(call_arg_t a0 _UNUSED, call_arg_t a1 _UNUSED, - call_arg_t a2 _UNUSED, mret_t *ret) + call_arg_t a2 _UNUSED, vret_t *ret) { sysclk_port_t *port = sysclk; istate_t ist; @@ -276,4 +276,4 @@ static void sysclk_get_freq(call_arg_t a0 _UNUSED, call_arg_t a1 _UNUSED, return; } -INCLUDE_MCALL(sysclk_get, fetch_clk, sysclk_get_freq); +INCLUDE_VCALL(sysclk_get, fetch_clk, sysclk_get_freq); diff --git a/src/include/driver/sysclk.h b/src/include/driver/sysclk.h index dc75356a..7adf4064 100644 --- a/src/include/driver/sysclk.h +++ b/src/include/driver/sysclk.h @@ -15,7 +15,7 @@ #include #include #include -#include +#include typedef struct sysclk_config_clk_callback { @@ -28,17 +28,17 @@ status_t sysclk_reset(void); static inline status_t sysclk_set_clk(clock_type_t type, unsigned int clk) { - mret_t mres; - arch_machine_call(config_clk, type, clk, 0, &mres); - return mres.status; + vret_t vres; + arch_visor_call(config_clk, type, clk, 0, &vres); + return vres.status; } static inline status_t sysclk_get_clk(unsigned int *clk) { - mret_t mres; - arch_machine_call(fetch_clk, 0, 0, 0, &mres); - *clk = (mres.status == success) ? (unsigned int) mres.p : 0; - return mres.status; + vret_t vres; + arch_visor_call(fetch_clk, 0, 0, 0, &vres); + *clk = (vres.status == success) ? (unsigned int) vres.p : 0; + return vres.status; } status_t sysclk_register_config_clk_callback(sysclk_config_clk_callback_t *); diff --git a/src/include/linker_macros.h b/src/include/linker_macros.h index a14f50b1..40fe7546 100644 --- a/src/include/linker_macros.h +++ b/src/include/linker_macros.h @@ -15,7 +15,7 @@ KEEP(*(.driver)) \ PROVIDE(_driver_table_end = .); -#define ECALL_TABLE \ - PROVIDE(_ecall_table_start = .); \ - KEEP(*(.ecall)) \ - PROVIDE(_ecall_table_end = .); +#define VCALL_TABLE \ + PROVIDE(_vcall_table_start = .); \ + KEEP(*(.vcall)) \ + PROVIDE(_vcall_table_end = .); diff --git a/src/include/machine_call.h b/src/include/machine_call.h deleted file mode 100644 index e39c3fb0..00000000 --- a/src/include/machine_call.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * CYANCORE LICENSE - * Copyrights (C) 2019-2022, Cyancore Team - * - * File Name : machine_call.h - * Description : This file consists of machine call IDs and prototypes - * Primary Author : Akash Kollipara [akashkollipara@gmail.com] - * Organisation : Cyancore Core-Team - */ - -#pragma once -#define _MACHINE_CALL_H_ - -#include -#include - -// Machine call IDs -typedef enum mcall_id -{ - fetch_sp = 0x0001, - fetch_dp = 0x0002, - set_sleep_mode = 0x0003, - fetch_clk = 0x0004, - config_clk = 0x0005, -} mcall_id_t; - -typedef struct mret -{ - uintptr_t p; - size_t size; - status_t status; -} mret_t; - -#include - -typedef struct mcall -{ - mcall_id_t id; - void (*callback)(call_arg_t a0, call_arg_t a1, call_arg_t a2, mret_t *ret); -} mcall_t; - -#define INCLUDE_MCALL(_name, _id , _callback) \ - const mcall_t _name _SECTION(".ecall") = \ - { \ - .id = _id, \ - .callback = _callback \ - } diff --git a/src/include/status.h b/src/include/status.h index 6182f784..0a334037 100644 --- a/src/include/status.h +++ b/src/include/status.h @@ -33,14 +33,9 @@ typedef enum status error_device_id_inval = -0x0201, error_device_inval = -0x0202, error_device_busy = -0x0203, -/* Machine Call related error */ - error_mcall = -0x0300, - error_mcall_code_inval = -0x0301, -/* hcall related error */ - error_hcall = -0x0400, -/* Syscall related error */ - error_scall = -0x0500, - error_scall_code_inval = -0x0501, +/* Visor Call related error */ + error_vcall = -0x0300, + error_vcall_code_inval = -0x0301, /* Memory related error */ error_memory = -0x0600, error_memory_low = -0x0601, diff --git a/src/include/supervisor_call.h b/src/include/supervisor_call.h deleted file mode 100644 index 678a5da6..00000000 --- a/src/include/supervisor_call.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * CYANCORE LICENSE - * Copyrights (C) 2019, Cyancore Team - * - * File Name : supervisor_call.h - * Description : This file consists of supervisor call IDs and prototypes - * Primary Author : Pranjal Chanda [pranjalchanda08@gmail.com] - * Organisation : Cyancore Core-Team - */ - -#pragma once -#define _SUPER_CALL_H_ - -#include -#include -#include - -// Supervisor call IDs -typedef enum scall_id -{ - scall_id_generic = 0x0000, - scall_id_is_irq, -/* pthread related */ - scall_id_pthread_barrier_destroy = 0x1000, - scall_id_pthread_barrier_init, - scall_id_pthread_barrier_wait, - scall_id_pthread_create, - scall_id_pthread_cond_broadcast, - scall_id_pthread_cond_destroy, - scall_id_pthread_cond_init, - scall_id_pthread_cond_signal, - scall_id_pthread_cond_timedwait, - scall_id_pthread_equal, - scall_id_pthread_exit, - scall_id_pthread_getschedparam, - scall_id_pthread_join, - scall_id_pthread_mutex_destroy, - scall_id_pthread_mutex_init, - scall_id_pthread_mutex_timedlock, - scall_id_pthread_mutex_unlock, - scall_id_pthread_mutexattr_destroy, - scall_id_pthread_mutexattr_gettype, - scall_id_pthread_mutexattr_init, - scall_id_pthread_mutexattr_settype, - scall_id_pthread_self, - scall_id_pthread_setschedparam, - scall_id_pthread_delay_ticks, -/* mqueue related */ - scall_id_mq_close, - scall_id_mq_setattr, - scall_id_mq_getattr, - scall_id_mq_open, - scall_id_mq_receive, - scall_id_mq_send, - scall_id_mq_unlink, -/* semaphore related */ - scall_id_sem_init, - scall_id_sem_destroy, - scall_id_sem_getvalue, - scall_id_sem_post, - scall_id_sem_wait, -/* scheduler related */ - scall_id_sched_get_max_priority, - scall_id_sched_get_min_priority, - scall_id_sched_yield, - -} scall_id_t; - -typedef struct sret -{ - uintptr_t p; - size_t size; - status_t status; -} sret_t; - -typedef struct scall -{ - scall_id_t id; - sret_t (*callback)(call_arg_t a0, call_arg_t a1, call_arg_t a2); -} scall_t; - -#define INCLUDE_SCALL(_name, _id , _callback) \ - const scall_t _name _SECTION(".scall") = \ - { \ - .id = _id, \ - .callback = _callback \ - } diff --git a/src/include/vcall_id.h b/src/include/vcall_id.h new file mode 100644 index 00000000..f7fa6c6c --- /dev/null +++ b/src/include/vcall_id.h @@ -0,0 +1,65 @@ +/* + * CYANCORE LICENSE + * Copyrights (C) 2023, Cyancore Team + * + * File Name : vcall_id.h + * Description : This file consists of visor call IDs + * Primary Author : Akash Kollipara [akashkollipara@gmail.com] + * Organisation : Cyancore Core-Team + */ + +#pragma once +#define _VCALL_ID_H_ + +// Visor call IDs +typedef enum vcall_id +{ + fetch_sp = 0x0001, + fetch_dp = 0x0002, + set_sleep_mode = 0x0003, + fetch_clk = 0x0004, + config_clk = 0x0005, +/* pthread related */ + pthread_barrier_destroy = 0x1001, + pthread_barrier_init, + pthread_barrier_wait, + pthread_create, + pthread_cond_broadcast, + pthread_cond_destroy, + pthread_cond_init, + pthread_cond_signal, + pthread_cond_timedwait, + pthread_equal, + pthread_exit, + pthread_getschedparam, + pthread_join, + pthread_mutex_destroy, + pthread_mutex_init, + pthread_mutex_timedlock, + pthread_mutex_unlock, + pthread_mutexattr_destroy, + pthread_mutexattr_gettype, + pthread_mutexattr_init, + pthread_mutexattr_settype, + pthread_self, + pthread_setschedparam, + pthread_delay_ticks, +/* mqueue related */ + mq_close = 0x2001, + mq_setattr, + mq_getattr, + mq_open, + mq_receive, + mq_send, + mq_unlink, +/* semaphore related */ + sem_init, + sem_destroy, + sem_getvalue, + sem_post, + sem_wait, +/* scheduler related */ + sched_get_max_priority, + sched_get_min_priority, + sched_yield, +} vcall_id_t; diff --git a/src/include/visor/supervisor/workers.h b/src/include/visor/supervisor/workers.h deleted file mode 100644 index e966d14d..00000000 --- a/src/include/visor/supervisor/workers.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * CYANCORE LICENSE - * Copyrights (C) 2019, Cyancore Team - * - * File Name : worker.h - * Description : This file consists of supervisor-workers - * and related prototypes - * Primary Author : Pranjal Chanda [pranjalchanda08@gmail.com] - * Organisation : Cyancore Core-Team - */ - -#pragma once - -#include - -void super_call(scall_id_t id, unsigned int a0, unsigned int a1, unsigned int a2, sret_t *ret); diff --git a/src/include/visor/terravisor/workers.h b/src/include/visor/terravisor/workers.h deleted file mode 100644 index ab9697ed..00000000 --- a/src/include/visor/terravisor/workers.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * CYANCORE LICENSE - * Copyrights (C) 2019, Cyancore Team - * - * File Name : worker.h - * Description : This file consists of terravisor-workers - * and related prototypes - * Primary Author : Akash Kollipara [akashkollipara@gmail.com] - * Organisation : Cyancore Core-Team - */ - -#pragma once - -void machine_call(unsigned int, unsigned int, unsigned int, unsigned int, mret_t *); diff --git a/src/include/visor/visor/workers.h b/src/include/visor/visor/workers.h new file mode 100644 index 00000000..dfa184b7 --- /dev/null +++ b/src/include/visor/visor/workers.h @@ -0,0 +1,13 @@ +/* + * CYANCORE LICENSE + * Copyrights (C) 2023, Cyancore Team + * + * File Name : worker.h + * Description : This file consists of visor workers prototype + * Primary Author : Akash Kollipara [akashkollipara@gmail.com] + * Organisation : Cyancore Core-Team + */ + +#pragma once + +void vcall_handler(unsigned int, unsigned int, unsigned int, unsigned int, vret_t *); diff --git a/src/include/visor_call.h b/src/include/visor_call.h new file mode 100644 index 00000000..300fe539 --- /dev/null +++ b/src/include/visor_call.h @@ -0,0 +1,39 @@ +/* + * CYANCORE LICENSE + * Copyrights (C) 2019-2023, Cyancore Team + * + * File Name : visor_call.h + * Description : This file consists of visor call utils and + * data types + * Primary Author : Akash Kollipara [akashkollipara@gmail.com] + * Organisation : Cyancore Core-Team + */ + +#pragma once +#define _VISOR_CALL_H_ + +#include +#include +#include + +typedef struct mret +{ + uintptr_t p; + size_t size; + status_t status; +} vret_t; + +#include + +typedef struct vcall +{ + vcall_id_t id; + void (*callback)(call_arg_t a0, call_arg_t a1, call_arg_t a2, vret_t *ret); +} vcall_t; + +#define INCLUDE_VCALL(_name, _id , _callback) \ + const vcall_t _name _SECTION(".vcall") = \ + { \ + .id = _id, \ + .callback = _callback \ + } diff --git a/src/lib/libposix/src/posix_mqueue.c b/src/lib/libposix/src/posix_mqueue.c index caaba26e..af0238d6 100644 --- a/src/lib/libposix/src/posix_mqueue.c +++ b/src/lib/libposix/src/posix_mqueue.c @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include @@ -44,7 +44,7 @@ static int s_queue_write(mqd_t mqdes, const void * buff, size_t size, unsigned m memcpy((void *)p_mqd_section->kernel_buff, buff, size); - super_call(scall_id_mq_send, p_mqd_section->id, size, msg_prio, &mq_sys_ret); + super_call(mq_send, p_mqd_section->id, size, msg_prio, &mq_sys_ret); RET_ERR_IF_FALSE(mq_sys_ret.status == SUCCESS, -EBADF, int); return SUCCESS; @@ -57,7 +57,7 @@ static int s_queue_read(mqd_t mqdes, void * buff, size_t size) RET_ERR_IF_FALSE((p_mqd_section->attr.mq_flags & O_WRONLY), -ENOTSUP, int); - super_call(scall_id_mq_receive, p_mqd_section->id, size, RST_VAL, &mq_sys_ret); + super_call(mq_receive, p_mqd_section->id, size, RST_VAL, &mq_sys_ret); RET_ERR_IF_FALSE(mq_sys_ret.status == SUCCESS, -EBADF, int); memcpy(buff, (void *) (p_mqd_section->kernel_buff), size); @@ -131,7 +131,7 @@ mqd_t mq_open( const char * name, p_mqd_section->attr.mq_flags = oflag; /* Perform super_call */ - super_call(scall_id_mq_open, + super_call(mq_open, (p_mqd_section->attr.mq_maxmsg * p_mqd_section->attr.mq_msgsize), RST_VAL, RST_VAL, @@ -175,7 +175,7 @@ int mq_close( mqd_t mqdes ) memset(&((mqd_section_t *) mqdes)->attr, RST_VAL, sizeof(mq_attr_t)); /* Perform Super Call */ - super_call(scall_id_mq_close, ((mqd_section_t *) mqdes)->id, RST_VAL, RST_VAL, &mq_sys_ret); + super_call(mq_close, ((mqd_section_t *) mqdes)->id, RST_VAL, RST_VAL, &mq_sys_ret); if (mq_sys_ret.status != SUCCESS) { err = -ENOTSUP; diff --git a/src/lib/libposix/src/posix_pthread.c b/src/lib/libposix/src/posix_pthread.c index 2d78dc61..b3f560a6 100644 --- a/src/lib/libposix/src/posix_pthread.c +++ b/src/lib/libposix/src/posix_pthread.c @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include @@ -132,7 +132,7 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*startr /* Grab resource access else return EBUSY */ RET_ERR_IF_FALSE(s_pthread_acquire_lock() == SUCCESS, -EBUSY, int); - super_call(scall_id_pthread_create, (call_arg_t) startroutine, (call_arg_t) arg, thread->attr->stacksize, &pthread_sys_ret); + super_call(pthread_create, (call_arg_t) startroutine, (call_arg_t) arg, thread->attr->stacksize, &pthread_sys_ret); if (pthread_sys_ret.status != SUCCESS) { err = -EAGAIN; @@ -166,7 +166,7 @@ void pthread_exit( const void *value_ptr _UNUSED) /* Grab resource access else return EBUSY */ s_pthread_acquire_lock(); - super_call(scall_id_pthread_exit, RST_VAL, RST_VAL, RST_VAL, &pthread_sys_ret); + super_call(pthread_exit, RST_VAL, RST_VAL, RST_VAL, &pthread_sys_ret); /* Release resource access else return EBUSY */ s_pthread_release_lock(); diff --git a/src/lib/libposix/src/posix_semaphore.c b/src/lib/libposix/src/posix_semaphore.c index cc0fd6fc..1b667ca0 100644 --- a/src/lib/libposix/src/posix_semaphore.c +++ b/src/lib/libposix/src/posix_semaphore.c @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include @@ -29,7 +29,7 @@ static int s_sem_wait( const sem_t * sem ) ASSERT_IF_FALSE(sem->id != RST_VAL, int); /* Perform super_call */ - super_call(scall_id_sem_wait, sem->id, RST_VAL, RST_VAL, &sem_sys_ret); + super_call(sem_wait, sem->id, RST_VAL, RST_VAL, &sem_sys_ret); return sem_sys_ret.status; } @@ -48,7 +48,7 @@ int sem_destroy( sem_t * sem ) ASSERT_IF_FALSE(sem->id != RST_VAL, int); /* Perform super_call */ - super_call(scall_id_sem_destroy, sem->id, RST_VAL, RST_VAL, &sem_sys_ret); + super_call(sem_destroy, sem->id, RST_VAL, RST_VAL, &sem_sys_ret); RET_ERR_IF_FALSE(sem_sys_ret.status == SUCCESS, sem_sys_ret.status, int); /* Reset semaphore ID */ @@ -67,7 +67,7 @@ int sem_getvalue( sem_t * sem, int * sval ) ASSERT_IF_FALSE(sem != NULL, int); /* Perform super_call */ - super_call(scall_id_sem_getvalue, sem->id, RST_VAL, RST_VAL, &sem_sys_ret); + super_call(sem_getvalue, sem->id, RST_VAL, RST_VAL, &sem_sys_ret); RET_ERR_IF_FALSE(sem_sys_ret.status == SUCCESS, sem_sys_ret.status, int); /* Copy sem value */ @@ -88,7 +88,7 @@ int sem_init( sem_t * sem, int pshared _UNUSED, unsigned value ) ASSERT_IF_FALSE(sem->id == RST_VAL, int); /* Perform super_call */ - super_call(scall_id_sem_init, value, RST_VAL, RST_VAL, &sem_sys_ret); + super_call(sem_init, value, RST_VAL, RST_VAL, &sem_sys_ret); if (sem_sys_ret.status != SUCCESS) { return sem_sys_ret.status; @@ -111,7 +111,7 @@ int sem_post( const sem_t * sem ) ASSERT_IF_FALSE(sem->id != RST_VAL, int); /* Perform super_call */ - super_call(scall_id_sem_post, sem->id, RST_VAL, RST_VAL, &sem_sys_ret); + super_call(sem_post, sem->id, RST_VAL, RST_VAL, &sem_sys_ret); return sem_sys_ret.status; } diff --git a/src/lib/libposix/src/posix_utils.c b/src/lib/libposix/src/posix_utils.c index f5f71710..5f2932b4 100644 --- a/src/lib/libposix/src/posix_utils.c +++ b/src/lib/libposix/src/posix_utils.c @@ -9,7 +9,7 @@ */ #include -#include +#include #include #include #include @@ -336,6 +336,6 @@ void os_delay_ticks( const TickType_t ticks ) { sret_t sys_ret; - super_call(scall_id_pthread_delay_ticks, ticks, RST_VAL, RST_VAL, &sys_ret); + super_call(pthread_delay_ticks, ticks, RST_VAL, RST_VAL, &sys_ret); RET_ERR_IF_FALSE(sys_ret.status == SUCCESS, EAGAIN, void); } diff --git a/src/platform/mega_avr/atmega2560/include/plat_arch.h b/src/platform/mega_avr/atmega2560/include/plat_arch.h index 542ab0c8..fe84e736 100644 --- a/src/platform/mega_avr/atmega2560/include/plat_arch.h +++ b/src/platform/mega_avr/atmega2560/include/plat_arch.h @@ -34,6 +34,6 @@ #define PRR1 0x65 #define OSCCAL 0x66 -#ifdef _MACHINE_CALL_H_ -extern void (*mcall)(unsigned int, unsigned int, unsigned int, unsigned int, mret_t *); +#ifdef _VISOR_CALL_H_ +extern void (*vcall)(unsigned int, unsigned int, unsigned int, unsigned int, vret_t *); #endif diff --git a/src/platform/mega_avr/common/hal/gpio/gpio.c b/src/platform/mega_avr/common/hal/gpio/gpio.c index 1efedb32..63906a37 100644 --- a/src/platform/mega_avr/common/hal/gpio/gpio.c +++ b/src/platform/mega_avr/common/hal/gpio/gpio.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -24,7 +24,7 @@ status_t gpio_pin_alloc(gpio_port_t *port, uint8_t portID, uint8_t pinID) { - mret_t mres; + vret_t vres; gpio_module_t *dp; unsigned char flag; @@ -46,13 +46,13 @@ status_t gpio_pin_alloc(gpio_port_t *port, uint8_t portID, uint8_t pinID) port->pin = pinID; port->port = portID; - arch_machine_call(fetch_dp, gpio, portID, 0, &mres); - if(mres.status != success) + arch_visor_call(fetch_dp, gpio, portID, 0, &vres); + if(vres.status != success) { sysdbg4("GPIO Port %d not found in DP\n", portID); - return mres.status; + return vres.status; } - dp = (gpio_module_t *)mres.p; + dp = (gpio_module_t *)vres.p; port->pbaddr = dp->baddr; sysdbg4("GPIO engine @ %p\n", dp->baddr); sysdbg4("Using GPIO Pin %d on Port %d\n", port->pin, port->port); @@ -124,7 +124,7 @@ bool gpio_pin_read(const gpio_port_t *port) status_t gpio_port_alloc(gpio_port_t *port, uint8_t portID) { - mret_t mres; + vret_t vres; gpio_module_t *dp; unsigned char flag = 0; @@ -145,13 +145,13 @@ status_t gpio_port_alloc(gpio_port_t *port, uint8_t portID) port->pin = (uint8_t)((uint16_t)(1 << BIT) - 1); port->port = portID; - arch_machine_call(fetch_dp, gpio, portID, 0, &mres); - if(mres.status != success) + arch_visor_call(fetch_dp, gpio, portID, 0, &vres); + if(vres.status != success) { sysdbg4("GPIO Port %d not found in DP\n", portID); - return mres.status; + return vres.status; } - dp = (gpio_module_t *)mres.p; + dp = (gpio_module_t *)vres.p; port->pbaddr = dp->baddr; sysdbg4("GPIO engine @ %p\n", dp->baddr); return success; diff --git a/src/platform/mega_avr/common/hal/pwm/pwm.c b/src/platform/mega_avr/common/hal/pwm/pwm.c index dc56e09a..11f18c66 100644 --- a/src/platform/mega_avr/common/hal/pwm/pwm.c +++ b/src/platform/mega_avr/common/hal/pwm/pwm.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -31,29 +31,29 @@ static void pwm_to_timer(const pwm_port_t *p, timer_port_t *t) status_t pwm_get_properties(pwm_port_t *port, sw_devid_t dev) { - mret_t mres; + vret_t vres; swdev_t *sp; module_t *dp; hw_devid_t devid; - arch_machine_call(fetch_sp, dev, 0, 0, &mres); - if(mres.status != success) + arch_visor_call(fetch_sp, dev, 0, 0, &vres); + if(vres.status != success) { sysdbg3("%p - sp node could not be found!\n", dev); - return mres.status; + return vres.status; } - sp = (swdev_t *) mres.p; + sp = (swdev_t *) vres.p; devid = sp->hwdev_id; port->pmux = sp->pmux; - arch_machine_call(fetch_dp, (devid & 0xff00), (devid & 0xf0), 0, &mres); - if(mres.status != success) + arch_visor_call(fetch_dp, (devid & 0xff00), (devid & 0xf0), 0, &vres); + if(vres.status != success) { sysdbg3("PWM (timer) Device %d not found!\n", devid); - return mres.status; + return vres.status; } - dp = (module_t *) mres.p; + dp = (module_t *) vres.p; port->port_id = dp->id; port->clk_id = dp->clk_id; port->baddr = dp->baddr; diff --git a/src/platform/mega_avr/common/hal/timer/timer.c b/src/platform/mega_avr/common/hal/timer/timer.c index 6a030ec0..9bf7892c 100644 --- a/src/platform/mega_avr/common/hal/timer/timer.c +++ b/src/platform/mega_avr/common/hal/timer/timer.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include "timer8.h" diff --git a/src/platform/mega_avr/common/hal/uart/uart.c b/src/platform/mega_avr/common/hal/uart/uart.c index f92e2f7d..7b734aab 100644 --- a/src/platform/mega_avr/common/hal/uart/uart.c +++ b/src/platform/mega_avr/common/hal/uart/uart.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include "uart_private.h" @@ -30,11 +30,11 @@ status_t uart_setup(uart_port_t *port, direction_t d, parity_t p) assert(port); MMIO8(port->baddr + UCSRA_OFFSET) = 0x00; platform_clk_en(port->clk_id); - mret_t mres; - arch_machine_call(fetch_dp, clock, 0, 0, &mres); - if(mres.status != success) - return mres.status; - unsigned long *clk = (unsigned long *)mres.p; + vret_t vres; + arch_visor_call(fetch_dp, clock, 0, 0, &vres); + if(vres.status != success) + return vres.status; + unsigned long *clk = (unsigned long *)vres.p; // Enable module based on direction diff --git a/src/platform/mega_avr/common/include/platform.h b/src/platform/mega_avr/common/include/platform.h index 1d71d867..f6388cf3 100644 --- a/src/platform/mega_avr/common/include/platform.h +++ b/src/platform/mega_avr/common/include/platform.h @@ -21,6 +21,6 @@ status_t platform_resources_setup(void); status_t platform_clk_reset(void); status_t platform_clk_en(unsigned int); status_t platform_clk_dis(unsigned int); -status_t platform_mcall_update(void *); +status_t platform_vcall_update(void *); status_t platform_wdt_reset(void); void plat_panic_handler_callback(void); diff --git a/src/platform/mega_avr/common/platform/platform.c b/src/platform/mega_avr/common/platform/platform.c index 6fefeae8..6af19823 100644 --- a/src/platform/mega_avr/common/platform/platform.c +++ b/src/platform/mega_avr/common/platform/platform.c @@ -13,9 +13,9 @@ #include #include #include -#include +#include #include -#include +#include #include #include #include diff --git a/src/platform/mega_avr/common/platform/platform_resource.c b/src/platform/mega_avr/common/platform/platform_resource.c index 4fd3d28f..23fb30db 100644 --- a/src/platform/mega_avr/common/platform/platform_resource.c +++ b/src/platform/mega_avr/common/platform/platform_resource.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include /** @@ -38,7 +38,7 @@ status_t platform_resources_setup() } /** - * platform_fetch_sp - mcall handler for fetch_sp + * platform_fetch_sp - vcall handler for fetch_sp * * @brief This function is a machine call hander for fetch_sp * access code. It is responsible to respond with hardware ID @@ -51,7 +51,7 @@ status_t platform_resources_setup() * @return status: return the function execution status */ static void platform_fetch_sp(call_arg_t a0, call_arg_t a1 _UNUSED, - call_arg_t a2 _UNUSED, mret_t *ret) + call_arg_t a2 _UNUSED, vret_t *ret) { sysdbg2("Fetch SP: Got request for %x\n", a0); ret->p = (uintptr_t) sp_terravisor_dev_info(a0); @@ -60,10 +60,10 @@ static void platform_fetch_sp(call_arg_t a0, call_arg_t a1 _UNUSED, return; } -INCLUDE_MCALL(atmega328p_fetch_sp, fetch_sp, platform_fetch_sp); +INCLUDE_VCALL(atmega328p_fetch_sp, fetch_sp, platform_fetch_sp); /** - * platform_fetch_dp - mcall handler for fetch_dp + * platform_fetch_dp - vcall handler for fetch_dp * * @brief This function is a machine call hander for fetch_dp * access code. It is responsible to respond with pointer to @@ -76,7 +76,7 @@ INCLUDE_MCALL(atmega328p_fetch_sp, fetch_sp, platform_fetch_sp); * @return status: return the function execution status */ static void platform_fetch_dp(call_arg_t a0, call_arg_t a1 _UNUSED, - call_arg_t a2 _UNUSED, mret_t *ret) + call_arg_t a2 _UNUSED, vret_t *ret) { sysdbg2("Fetch DP: Got request for %x\n", a0); switch(a0) @@ -98,4 +98,4 @@ static void platform_fetch_dp(call_arg_t a0, call_arg_t a1 _UNUSED, return; } -INCLUDE_MCALL(atmega328p_fetch_dp, fetch_dp, platform_fetch_dp); +INCLUDE_VCALL(atmega328p_fetch_dp, fetch_dp, platform_fetch_dp); diff --git a/src/platform/mega_avr/common/platform/platform_timer.c b/src/platform/mega_avr/common/platform/platform_timer.c index 84391b30..0ed3a228 100644 --- a/src/platform/mega_avr/common/platform/platform_timer.c +++ b/src/platform/mega_avr/common/platform/platform_timer.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include @@ -76,26 +76,26 @@ static void plat_timer_reg_cb(void *cb) */ static status_t plat_get_timer_prop(void) { - mret_t mres; + vret_t vres; swdev_t *sp; hw_devid_t devid; - arch_machine_call(fetch_sp, sched_timer, 0, 0, &mres); - if(mres.status != success) + arch_visor_call(fetch_sp, sched_timer, 0, 0, &vres); + if(vres.status != success) { sysdbg3("%p - sp node could not be found!\n", sched_timer); - return mres.status; + return vres.status; } - sp = (swdev_t *) mres.p; + sp = (swdev_t *) vres.p; devid = sp->hwdev_id; - arch_machine_call(fetch_dp, (devid & 0xff00), (devid & 0xff), 0, &mres); - if(mres.status != success) + arch_visor_call(fetch_dp, (devid & 0xff00), (devid & 0xff), 0, &vres); + if(vres.status != success) { sysdbg3("Timer Device %d not found!\n", devid); - return mres.status; + return vres.status; } - tm = (module_t *) mres.p; + tm = (module_t *) vres.p; return success; } diff --git a/src/platform/mega_avr/common/platform/platform_wdt.c b/src/platform/mega_avr/common/platform/platform_wdt.c index c2211611..4136e0bc 100644 --- a/src/platform/mega_avr/common/platform/platform_wdt.c +++ b/src/platform/mega_avr/common/platform/platform_wdt.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -45,16 +45,16 @@ void platform_wdt_handler(); */ static status_t platform_wdt_setup() { - mret_t mres; + vret_t vres; module_t *dp; - arch_machine_call(fetch_dp, wdt, 0, 0, &mres); + arch_visor_call(fetch_dp, wdt, 0, 0, &vres); - if(mres.status != success) + if(vres.status != success) { sysdbg2("WDT not found in DP\n"); - return mres.status; + return vres.status; } - dp = (module_t *) mres.p; + dp = (module_t *) vres.p; plat_wdt = (wdt_port_t *)malloc(sizeof(wdt_port_t)); if(!plat_wdt) return error_memory_low; diff --git a/src/platform/mega_avr/common/sections.ld.sx b/src/platform/mega_avr/common/sections.ld.sx index b8177686..7d8b3be5 100644 --- a/src/platform/mega_avr/common/sections.ld.sx +++ b/src/platform/mega_avr/common/sections.ld.sx @@ -65,7 +65,7 @@ SECTIONS *(.data.*) KEEP(*(.data)) DRIVER_TABLE - ECALL_TABLE + VCALL_TABLE } > vma_dmem AT > lma_mem .heap : diff --git a/src/platform/pico/common/sections.ld.sx b/src/platform/pico/common/sections.ld.sx deleted file mode 100644 index 7097b805..00000000 --- a/src/platform/pico/common/sections.ld.sx +++ /dev/null @@ -1,97 +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)) - *(.platvectors) - KEEP(*(.platvectors)) - . = 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 - - .stack : - { - . = ALIGN(ALIGN_BOUND); - *(.stack) - KEEP(*(.stack)) - . = . + STACK_SIZE; - } > vma_mem - - 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); - - PROVIDE(_bss_start = ADDR(.bss)); - PROVIDE(_bss_size = SIZEOF(.bss)); - PROVIDE(_flash_size = _data_size + SIZEOF(.text)); - PROVIDE(_ram_size = _bss_size + _data_size + SIZEOF(.stack)); - - 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/rpi/common_rp2/arch/platform_mem.c b/src/platform/rpi/common_rp2/arch/platform_mem.c new file mode 100644 index 00000000..b16f947f --- /dev/null +++ b/src/platform/rpi/common_rp2/arch/platform_mem.c @@ -0,0 +1,29 @@ +/* + * CYANCORE LICENSE + * Copyrights (C) 2019, Cyancore Team + * + * File Name : platform_mem.c + * Description : This file contains implementation of platform early setup APIs. + * Primary Author : Akash Kollipara [akashkollipara@gmail.com] + * Organisation : Cyancore Core-Team + */ + +#include +#include +#include +#include + +extern uintptr_t _bss_start, _bss_size, _data_start, _data_size, + _data_vstart; + +status_t platform_bss_clear() +{ + memset(&_bss_start, 0, (size_t)&_bss_size); + return success; +} + +status_t platform_copy_data() +{ + memcpy(&_data_vstart, &_data_start, (size_t)&_data_size); + return success; +} 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/rpi/common_rp2/platform/platform.c b/src/platform/rpi/common_rp2/platform/platform.c new file mode 100644 index 00000000..7cc83467 --- /dev/null +++ b/src/platform/rpi/common_rp2/platform/platform.c @@ -0,0 +1,112 @@ +/* + * CYANCORE LICENSE + * Copyrights (C) 2019, Cyancore Team + * + * File Name : platform.c + * Description : This file contains sources for platform apis + * Primary Author : Akash Kollipara [akashkollipara@gmail.com] + * Organisation : Cyancore Core-Team + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +uint32_t reset_syndrome; + +void platform_early_setup() +{ + status_t ret = success; + + /* Setup platform memories*/ + ret |= platform_copy_data(); + ret |= platform_bss_clear(); + ret |= platform_init_heap(); + ret |= platform_resources_setup(); + + /* Setup memory syslogger*/ + driver_setup("mslog"); + + reset_syndrome = MMIO32(CHIP_RESET) & 0x01110100; + MMIO32(CHIP_RESET) = 0; + + ret |= platform_clk_reset(); + + if(ret != success) + exit(EXIT_FAILURE); + return; +} + +#if PRINT_MEMORY_LAYOUT +static void platform_memory_layout() +{ + extern uint32_t _text_start, _text_size, _text_end, + _data_vstart, _data_size, _data_end, + _stack_start, _stack_size, _stack_end, + _bss_start, _bss_size, _bss_end, + _heap_start, _heap_size, _heap_end, + _flash_size, _ram_size; + + syslog(info, "Memory Info >\n"); + syslog(info, "Flash Size : %u\n", &_flash_size); + syslog(info, "RAM Size : %u\n", &_ram_size); + syslog(info, "\n"); + syslog(info, "Program Memory Layout >\n"); + syslog(info, "text Region\t: %06p - %06p : Size: %u\n", + &_text_start, &_text_end, &_text_size); + syslog(info, "bss Region\t: %06p - %06p : Size: %u\n", + &_bss_start, &_bss_end, &_bss_size); + syslog(info, "data Region\t: %06p - %06p : Size: %u\n", + &_data_vstart, &_data_vend, &_data_size); + syslog(info, "stack Region\t: %06p - %06p : Size: %u\n", + &_stack_start, &_stack_end, &_stack_size); + syslog(info, "heap Region\t: %06p - %06p : Size: %u\n", + &_heap_start, &_heap_end, &_heap_size); + syslog(info, "\n"); +} +#endif + +/** + * platform_setup - Executes functions to make platform read to init + * + * @brief This function performs calls to function which make the + * framework ready to execute. This function should be made to run on boot core only. + */ +void platform_setup() +{ + sysdbg3("In %s\n", __func__); + driver_setup("earlycon"); + bootmsgs_enable(); + cyancore_insignia_lite(); +#if PRINT_MEMORY_LAYOUT + platform_memory_layout(); +#endif + return; +} + +/** + * platform_cpu_setup - Perform platform setup calls on all cpus + * + * @brief This function performs calls to functions that should be executed + * on all cores to make the cpu ready for the platform drivers. + */ +void platform_cpu_setup() +{ + sysdbg3("In %s\n", __func__); + arch_ei(); + return; +} + +void _NAKED plat_panic_handler_callback() +{ + context_frame_t *frame; + sysdbg3("In %s\n", __func__); + frame = get_context_frame(); + syslog(info, "SP=%p \tSREG = %P\n", frame, frame->sreg); + exit(EXIT_FAILURE); +} diff --git a/src/platform/rpi/common_rp2/platform/platform_reset.c b/src/platform/rpi/common_rp2/platform/platform_reset.c new file mode 100644 index 00000000..77980f1a --- /dev/null +++ b/src/platform/rpi/common_rp2/platform/platform_reset.c @@ -0,0 +1,64 @@ +/* + * CYANCORE LICENSE + * Copyrights (C) 2019, Cyancore Team + * + * File Name : platform_reset.c + * Description : This file contains sources for platform + * reset apis + * Primary Author : Mayuri Lokhande [mayurilokhande01@gmail.com] + * Organisation : Cyancore Core-Team + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern uint32_t reset_syndrome; +/** + * platform_get_reset_syndrome - returns the cause of reset + * + * @brief This function returns the infromation related to + * the reset sources. + * + * @return reset_cause : This function returns the reset cause + */ + +reset_t platform_get_reset_syndrome() +{ + sysdbg5("Reset Syndrome = %u\n", reset_syndrome); + if(reset_syndrome & (1 << 8)) + return power_on_reset; + + if(reset_syndrome & (1 << 16)) + return external_reset; + + else + return inval_reset; +} + +/** + * platform_reset_handler - handles the reset conditions + * + * @brief This function is responsible to handle the reset + * sources like watchdog , brownout, etxernal reset, etc. + * + * @param[in] rsyn: Reset syndrome + * + * @return void + */ +void platform_reset_handler(reset_t rsyn) +{ + if(rsyn == power_on_reset) + return; + if(rsyn == external_reset) + return; + else + plat_panic_handler(); +} diff --git a/src/platform/rpi/common_rp2/platform/platform_resource.c b/src/platform/rpi/common_rp2/platform/platform_resource.c new file mode 100644 index 00000000..5ebce2bf --- /dev/null +++ b/src/platform/rpi/common_rp2/platform/platform_resource.c @@ -0,0 +1,37 @@ +/* + * CYANCORE LICENSE + * Copyrights (C) 2019-2022, Cyancore Team + * + * File Name : platform_resource.c + * Description : This file contains sources for platform + * resource apis + * Primary Author : Mayuri Lokhande [mayurilokhande01@gmail.com] + * Organisation : Cyancore Core-Team + */ + +#include +#include +#include +#include +#include +#include +#include + +/** + * platform_resources_setup - Updates platform DP and SP + * + * @brief This function is responsible to update platform DP + * and make it accessible to the system. This function needs to be called + * during platform setup. + * + * @return status: return the function execution status + */ +status_t platform_resources_setup() +{ + status_t ret = success; + extern dp_t device_prop; + extern sp_t software_prop; + ret = dp_init(&device_prop); + ret |= sp_init(&software_prop); + return ret; +} 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/platform/sifive/common_fe310/hal/clint/clint.c b/src/platform/sifive/common_fe310/hal/clint/clint.c index 6ca26ecd..bd1adf56 100644 --- a/src/platform/sifive/common_fe310/hal/clint/clint.c +++ b/src/platform/sifive/common_fe310/hal/clint/clint.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include @@ -30,19 +30,19 @@ static clint_port_t *port; static status_t clint_setup() { - mret_t mres; + vret_t vres; const module_t *dp; - arch_machine_call(fetch_dp, clint, 0, 0, &mres); + arch_visor_call(fetch_dp, clint, 0, 0, &vres); - if(mres.status != success) - return mres.status; + if(vres.status != success) + return vres.status; port = (clint_port_t *)malloc(sizeof(clint_port_t)); if(!port) return error_memory_low; - dp = (module_t *)mres.p; + dp = (module_t *)vres.p; port->baddr = dp->baddr; port->stride = dp->stride; port->port_id = clint; diff --git a/src/platform/sifive/common_fe310/hal/gpio/gpio.c b/src/platform/sifive/common_fe310/hal/gpio/gpio.c index 70dd8041..f00138ec 100644 --- a/src/platform/sifive/common_fe310/hal/gpio/gpio.c +++ b/src/platform/sifive/common_fe310/hal/gpio/gpio.c @@ -22,7 +22,7 @@ status_t gpio_pin_alloc(gpio_port_t *port, uint8_t portID, uint8_t pinID) { - mret_t mres; + vret_t vres; const gpio_module_t *dp; unsigned char flag; @@ -42,13 +42,13 @@ status_t gpio_pin_alloc(gpio_port_t *port, uint8_t portID, uint8_t pinID) port->pin = pinID; port->port = portID; - arch_machine_call(fetch_dp, gpio, portID, 0, &mres); - if(mres.status != success) + arch_visor_call(fetch_dp, gpio, portID, 0, &vres); + if(vres.status != success) { sysdbg("GPIO Port %d not found in DP\n", portID); - return mres.status; + return vres.status; } - dp = (gpio_module_t *)mres.p; + dp = (gpio_module_t *)vres.p; port->pbaddr = dp->baddr; sysdbg("GPIO engine @ %p\n", dp->baddr); sysdbg("Using GPIO Pin %d on Port %d\n", port->pin, port->port); diff --git a/src/platform/sifive/common_fe310/hal/uart/uart.c b/src/platform/sifive/common_fe310/hal/uart/uart.c index ee29c1b0..99089347 100644 --- a/src/platform/sifive/common_fe310/hal/uart/uart.c +++ b/src/platform/sifive/common_fe310/hal/uart/uart.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include @@ -26,28 +26,28 @@ status_t uart_get_properties(uart_port_t *port, sw_devid_t dev) { - mret_t mres; + vret_t vres; swdev_t *sp; module_t *dp; hw_devid_t devid; - arch_machine_call(fetch_sp, dev, 0, 0, &mres); - if(mres.status != success) + arch_visor_call(fetch_sp, dev, 0, 0, &vres); + if(vres.status != success) { sysdbg3("%p - sp node could not be found!\n", dev); - return mres.status; + return vres.status; } - sp = (swdev_t *) mres.p; + sp = (swdev_t *) vres.p; devid = sp->hwdev_id; port->pmux = sp->pmux; - arch_machine_call(fetch_dp, (devid & 0xff00), (devid & 0xff), 0, &mres); - if(mres.status != success) + arch_visor_call(fetch_dp, (devid & 0xff00), (devid & 0xff), 0, &vres); + if(vres.status != success) { sysdbg3("UART Device %d not found!\n", devid); - return mres.status; + return vres.status; } - dp = (module_t *) mres.p; + dp = (module_t *) vres.p; port->port_id = dp->id; port->clk_id = dp->clk_id; port->baddr = dp->baddr; diff --git a/src/platform/sifive/common_fe310/platform/plat_timer.c b/src/platform/sifive/common_fe310/platform/plat_timer.c index 096a752a..0e6f9ab2 100644 --- a/src/platform/sifive/common_fe310/platform/plat_timer.c +++ b/src/platform/sifive/common_fe310/platform/plat_timer.c @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include @@ -72,26 +72,26 @@ static void plat_timer_reg_cb(void *cb) */ static status_t plat_get_timer_prop(void) { - mret_t mres; + vret_t vres; swdev_t *sp; hw_devid_t devid; - arch_machine_call(fetch_sp, sched_timer, 0, 0, &mres); - if(mres.status != success) + arch_visor_call(fetch_sp, sched_timer, 0, 0, &vres); + if(vres.status != success) { sysdbg3("%p - sp node could not be found!\n", sched_timer); - return mres.status; + return vres.status; } - sp = (swdev_t *) mres.p; + sp = (swdev_t *) vres.p; devid = sp->hwdev_id; - arch_machine_call(fetch_dp, (devid & 0xff00), (devid & 0xff), 0, &mres); - if(mres.status != success) + arch_visor_call(fetch_dp, (devid & 0xff00), (devid & 0xff), 0, &vres); + if(vres.status != success) { sysdbg3("Timer Device %d not found!\n", devid); - return mres.status; + return vres.status; } - tm = (module_t *) mres.p; + tm = (module_t *) vres.p; return success; } diff --git a/src/platform/sifive/common_fe310/platform/platform.c b/src/platform/sifive/common_fe310/platform/platform.c index b2bd834d..db5f52b6 100644 --- a/src/platform/sifive/common_fe310/platform/platform.c +++ b/src/platform/sifive/common_fe310/platform/platform.c @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include void platform_early_setup() diff --git a/src/platform/sifive/common_fe310/platform/platform_reset.c b/src/platform/sifive/common_fe310/platform/platform_reset.c index 2f676eaa..41e9dd0d 100644 --- a/src/platform/sifive/common_fe310/platform/platform_reset.c +++ b/src/platform/sifive/common_fe310/platform/platform_reset.c @@ -31,15 +31,15 @@ */ reset_t platform_get_reset_syndrome() { - mret_t mres; + vret_t vres; const module_t *dp; uint32_t pmucause_val; aon_port_t aonport; - arch_machine_call(fetch_dp, aon, 0, 0, &mres); - assert(mres.status == success); + arch_visor_call(fetch_dp, aon, 0, 0, &vres); + assert(vres.status == success); - dp = (module_t *)mres.p; + dp = (module_t *)vres.p; aonport.baddr = dp->baddr; aon_pmucause(&aonport, &pmucause_val); diff --git a/src/platform/sifive/common_fe310/platform/platform_resource.c b/src/platform/sifive/common_fe310/platform/platform_resource.c index a8ad09f0..fc89e673 100644 --- a/src/platform/sifive/common_fe310/platform/platform_resource.c +++ b/src/platform/sifive/common_fe310/platform/platform_resource.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include /** @@ -37,7 +37,7 @@ status_t platform_resources_setup() } /** - * platform_fetch_sp - mcall handler for fetch_sp + * platform_fetch_sp - vcall handler for fetch_sp * * @brief This function is a machine call hander for fetch_sp * access code. It is responsible to respond with hardware ID @@ -50,7 +50,7 @@ status_t platform_resources_setup() * @return status: return the function execution status */ static void platform_fetch_sp(call_arg_t a0, call_arg_t a1 _UNUSED, - call_arg_t a2 _UNUSED, mret_t *ret) + call_arg_t a2 _UNUSED, vret_t *ret) { sysdbg5("Fetch SP: Got request for %x\n", a0); ret->p = (uintptr_t) sp_terravisor_dev_info(a0); @@ -59,10 +59,10 @@ static void platform_fetch_sp(call_arg_t a0, call_arg_t a1 _UNUSED, return; } -INCLUDE_MCALL(sifive_fe310_fetch_sp, fetch_sp, platform_fetch_sp); +INCLUDE_VCALL(sifive_fe310_fetch_sp, fetch_sp, platform_fetch_sp); /** - * platform_fetch_dp - mcall handler for fetch_dp + * platform_fetch_dp - vcall handler for fetch_dp * * @brief This function is a machine call hander for fetch_dp * access code. It is responsible to respond with pointer to @@ -75,7 +75,7 @@ INCLUDE_MCALL(sifive_fe310_fetch_sp, fetch_sp, platform_fetch_sp); * @return status: return the function execution status */ static void platform_fetch_dp(call_arg_t a0, call_arg_t a1 _UNUSED, - call_arg_t a2 _UNUSED, mret_t *ret) + call_arg_t a2 _UNUSED, vret_t *ret) { sysdbg5("Fetch DP: Got request for %x\n", a0); switch(a0) @@ -97,4 +97,4 @@ static void platform_fetch_dp(call_arg_t a0, call_arg_t a1 _UNUSED, return; } -INCLUDE_MCALL(sifive_fe310_fetch_dp, fetch_dp, platform_fetch_dp); +INCLUDE_VCALL(sifive_fe310_fetch_dp, fetch_dp, platform_fetch_dp); diff --git a/src/platform/sifive/common_fe310/sections.ld.sx b/src/platform/sifive/common_fe310/sections.ld.sx index f5650e3a..2c9c75d7 100644 --- a/src/platform/sifive/common_fe310/sections.ld.sx +++ b/src/platform/sifive/common_fe310/sections.ld.sx @@ -91,7 +91,7 @@ SECTIONS *(.data.*) KEEP(*(.data)) DRIVER_TABLE - ECALL_TABLE + VCALL_TABLE } > vma_dmem AT > lma_mem .tdata : ALIGN(4) diff --git a/src/visor/build.mk b/src/visor/build.mk index 47130f58..40820c16 100644 --- a/src/visor/build.mk +++ b/src/visor/build.mk @@ -13,6 +13,7 @@ VISOR_DIR := $(GET_PATH) INCLUDE += $(SRC)/include/visor/ +include $(VISOR_DIR)/common/build.mk ifneq ($(EXE_MODE),) include $(VISOR_DIR)/$(EXE_MODE)/build.mk endif diff --git a/src/visor/common/build.mk b/src/visor/common/build.mk new file mode 100644 index 00000000..e47070a4 --- /dev/null +++ b/src/visor/common/build.mk @@ -0,0 +1,14 @@ +# +# CYANCORE LICENSE +# Copyrights (C) 2023, Cyancore Team +# +# File Name : build.mk +# Description : This file accumulates the build scripts +# from terravisor directories +# Primary Author : Akash Kollipara [akashkollipara@gmail.com] +# Organisation : Cyancore Core-Team +# + +V_COM_PATH := $(GET_PATH) + +include $(V_COM_PATH)/workers/build.mk diff --git a/src/visor/supervisor/workers/scall/build.mk b/src/visor/common/workers/build.mk similarity index 63% rename from src/visor/supervisor/workers/scall/build.mk rename to src/visor/common/workers/build.mk index c07c5394..4029ffdd 100644 --- a/src/visor/supervisor/workers/scall/build.mk +++ b/src/visor/common/workers/build.mk @@ -1,6 +1,6 @@ # # CYANCORE LICENSE -# Copyrights (C) 2019, Cyancore Team +# Copyrights (C) 2023, Cyancore Team # # File Name : build.mk # Description : This file builds worker sources @@ -8,10 +8,10 @@ # Organisation : Cyancore Core-Team # -MCALL_DIR := $(GET_PATH) +VWORKER_DIR := $(GET_PATH) -LD_SUPPLEMENT += $(MCALL_DIR)/scall.ld.sx +include $(VWORKER_DIR)/vcall/build.mk -DIR := $(MCALL_DIR) +DIR := $(VWORKER_DIR) include mk/obj.mk diff --git a/src/visor/terravisor/workers/mcall/build.mk b/src/visor/common/workers/vcall/build.mk similarity index 72% rename from src/visor/terravisor/workers/mcall/build.mk rename to src/visor/common/workers/vcall/build.mk index 9e20c5e8..7cb37a68 100644 --- a/src/visor/terravisor/workers/mcall/build.mk +++ b/src/visor/common/workers/vcall/build.mk @@ -1,6 +1,6 @@ # # CYANCORE LICENSE -# Copyrights (C) 2019, Cyancore Team +# Copyrights (C) 2023, Cyancore Team # # File Name : build.mk # Description : This file builds worker sources @@ -8,8 +8,8 @@ # Organisation : Cyancore Core-Team # -MCALL_DIR := $(GET_PATH) +VCALL_DIR := $(GET_PATH) -DIR := $(MCALL_DIR) +DIR := $(VCALL_DIR) include mk/obj.mk diff --git a/src/visor/terravisor/workers/mcall/machine_call.c b/src/visor/common/workers/vcall/visor_call.c similarity index 50% rename from src/visor/terravisor/workers/mcall/machine_call.c rename to src/visor/common/workers/vcall/visor_call.c index 4d1572bd..d23ee3c4 100644 --- a/src/visor/terravisor/workers/mcall/machine_call.c +++ b/src/visor/common/workers/vcall/visor_call.c @@ -1,6 +1,6 @@ /* * CYANCORE LICENSE - * Copyrights (C) 2019-2022, Cyancore Team + * Copyrights (C) 2019-2023, Cyancore Team * * File Name : machine_call.c * Description : This file contains sources of machine call handler @@ -11,41 +11,41 @@ #include #include #include -#include +#include #include #include -/* mcall Table start and end defined in linker script mcall.ld.sx */ -extern mcall_t _ecall_table_start; -extern mcall_t _ecall_table_end; +/* vcall Table start and end defined in linker script using VCALL_TABLE */ +extern vcall_t _vcall_table_start; +extern vcall_t _vcall_table_end; -typedef void (*mcb_t)(call_arg_t, call_arg_t, call_arg_t, mret_t *); -static mcb_t get_callback_from_table(const mcall_t *start, const mcall_t *end, mcall_id_t id) +typedef void (*vcb_t)(call_arg_t, call_arg_t, call_arg_t, vret_t *); +static vcb_t get_callback_from_table(const vcall_t *start, const vcall_t *end, vcall_id_t id) { - mcall_t *ptr = (mcall_t *)start; + vcall_t *ptr = (vcall_t *)start; while(ptr < end) { if(ptr->id == id) return (ptr->callback != NULL) ? ptr->callback : NULL; ptr++; } - return (mcb_t) 0; + return (vcb_t) 0; } -void machine_call(mcall_id_t id, call_arg_t a0, call_arg_t a1, call_arg_t a2, mret_t *ret) +void vcall_handler(vcall_id_t id, call_arg_t a0, call_arg_t a1, call_arg_t a2, vret_t *ret) { - sysdbg4("MCall: id=%p, a0=%p, a1=%p, a2=%p\n", id, a0, a1, a2); + sysdbg4("VCall: id=%p, a0=%p, a1=%p, a2=%p\n", id, a0, a1, a2); /* Callback function pointer */ - mcb_t cb; + vcb_t cb; /* Assign "ret" parameters to default error case, * on execution of the call, the ret will updated. */ ret->p = (uintptr_t) 0; ret->size = 0; - ret->status = error_mcall_code_inval; + ret->status = error_vcall_code_inval; - cb = get_callback_from_table(&_ecall_table_start, &_ecall_table_end, id); + cb = get_callback_from_table(&_vcall_table_start, &_vcall_table_end, id); if(cb != 0) cb(a0, a1, a2, ret); return; 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/terravisor/workers/build.mk b/src/visor/supervisor/services/bootstrap/build.mk similarity index 59% rename from src/visor/terravisor/workers/build.mk rename to src/visor/supervisor/services/bootstrap/build.mk index 232b8f52..c3dc1b0f 100644 --- a/src/visor/terravisor/workers/build.mk +++ b/src/visor/supervisor/services/bootstrap/build.mk @@ -3,15 +3,11 @@ # Copyrights (C) 2019, Cyancore Team # # File Name : build.mk -# Description : This file builds worker sources +# Description : This file build bootstrap sources # Primary Author : Akash Kollipara [akashkollipara@gmail.com] # Organisation : Cyancore Core-Team # -TWORKER_DIR := $(GET_PATH) - -include $(TWORKER_DIR)/mcall/build.mk - -DIR := $(TWORKER_DIR) +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 diff --git a/src/visor/supervisor/workers/scall/scall.ld.sx b/src/visor/supervisor/workers/scall/scall.ld.sx deleted file mode 100644 index 8771727f..00000000 --- a/src/visor/supervisor/workers/scall/scall.ld.sx +++ /dev/null @@ -1,22 +0,0 @@ -/* - * CYANCORE LICENSE - * Copyrights (C) 2019, Cyancore Team - * - * File Name : scall.ld.sx - * Description : This file contains memory layout for the - * cyancore scall framework - * Primary Author : Pranjal Chanda [pranjalchanda08@gmail.com] - * Organisation : Cyancore Core-Team - */ - -SECTIONS -{ - .scall_table : - { - PROVIDE(_scall_table_start = .); - KEEP(*(.scall)) - PROVIDE(_scall_table_end = .); - } -} - -INSERT BEFORE .stack; diff --git a/src/visor/supervisor/workers/scall/supervisory_call.c b/src/visor/supervisor/workers/scall/supervisory_call.c deleted file mode 100644 index da6a44ff..00000000 --- a/src/visor/supervisor/workers/scall/supervisory_call.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * CYANCORE LICENSE - * Copyrights (C) 2019, Cyancore Team - * - * File Name : supervisory_call.c - * Description : This file contains sources of supervisory call handler - * Primary Author : Pranjal Chanda [pranjalchanda08@gmail.com] - * Organisation : Cyancore Core-Team - */ - -#include -#include -#include -#include -#include -#include - -/* mcall Table start and end defined in linker script mcall.ld.sx */ -extern scall_t _scall_table_start; -extern scall_t _scall_table_end; - -void super_call(scall_id_t id, call_arg_t a0, call_arg_t a1, call_arg_t a2, sret_t *ret) -{ - /* mcall Table pointer */ - scall_t *ptr; - - /* Assign "ret" parameters to default error case, - * on execution of the call, the ret will updated. - */ - ret->p = (uintptr_t) NULL; - ret->size = 0; - ret->status = error_scall_code_inval; - - /* Assign the pointer to start of table */ - ptr = &_scall_table_start; - - /* Run through the table till the end */ - while(ptr <= & _scall_table_end) - { - /* Check if the mcall ID matches */ - if(ptr->id == id) - { - /* Execute the callback function and update the "ret" */ - if (ptr->callback != NULL) - { - *ret = ptr->callback(a0, a1, a2); - } - /* Stop parsing the table and return */ - break; - } - /* Increament location pointer */ - ptr++; - } - return; -} diff --git a/src/visor/terravisor/build.mk b/src/visor/terravisor/build.mk index acdb3874..54b1c29f 100644 --- a/src/visor/terravisor/build.mk +++ b/src/visor/terravisor/build.mk @@ -15,4 +15,3 @@ TERRAVISOR := 1 $(eval $(call add_define,TERRAVISOR)) include $(TERRA_PATH)/services/build.mk -include $(TERRA_PATH)/workers/build.mk