From fb17e2ad5321a0707366e1365bed124a421b56bf Mon Sep 17 00:00:00 2001 From: Akash Kollipara Date: Sat, 20 Jul 2024 14:36:41 +0530 Subject: [PATCH 1/3] Moved all visor programs to common folder Issue: #315 --- mk/mk_helper.mk | 12 +++- projects/bl.src/project.c | 2 +- projects/demo.src/project.c | 2 +- projects/demo_avr/config.mk | 1 - projects/demo_avr_cpp/config.mk | 1 - projects/demo_avr_cpp/project.cpp | 4 +- projects/demo_helios.src/project.c | 4 +- projects/demo_helios_avr/config.mk | 2 +- projects/demo_helios_riscv/config.mk | 2 +- projects/demo_ibex_ss/config.mk | 1 - projects/demo_ibex_ss/project.c | 2 +- projects/demo_qemu_sifive_e/config.mk | 1 - projects/demo_riscv/config.mk | 1 - projects/hifive1b_bl/config.mk | 1 - projects/project.template/config.mk | 1 - projects/qemu_sifive_e_bl/config.mk | 1 - projects/qemu_sifive_e_bl/project.c | 2 +- src/arch/README.md | 2 +- src/arch/riscv/32/README.md | 1 + src/driver/build.mk | 3 +- src/driver/console/build.mk | 4 +- src/driver/schedclk/build.mk | 16 +++++ .../timer.c => driver/schedclk/schedclk.c} | 66 +++++++++---------- .../schedclk/schedclk_ibex}/build.mk | 4 +- .../schedclk/schedclk_ibex/schedclk_ibex.c} | 12 ++-- .../schedclk/schedclk_mega_avr/build.mk | 13 ++++ .../schedclk_mega_avr/schedclk_mega_avr.c} | 30 +++++---- src/driver/schedclk/schedclk_sifive/build.mk | 13 ++++ .../schedclk_sifive/schedclk_sifive.c} | 14 ++-- src/include/driver/schedclk.h | 25 +++++++ .../visor/{terravisor => }/bootstrap.h | 2 +- .../visor/{terravisor => }/helios/helios.h | 8 +-- .../{terravisor => }/helios/helios_mutex.h | 2 +- .../{terravisor => }/helios/helios_sem.h | 2 +- .../{terravisor => }/helios/helios_tasks.h | 2 +- .../helios/utils/helios_heap.h | 2 +- .../helios/utils/helios_sched.h | 0 src/include/visor/{terravisor => }/platform.h | 2 +- src/include/visor/terravisor/timer.h | 26 -------- src/include/visor/{visor => }/workers.h | 0 src/platform/build.mk | 10 +-- .../ibex/simple_system/hal/clint/clint.c | 10 ++- .../ibex/simple_system/platform/platform.c | 2 +- .../simple_system/platform/platform_reset.c | 2 +- .../mega_avr/common/platform/platform.c | 2 +- .../mega_avr/common/platform/platform_reset.c | 2 +- .../rpi/common_rp2/flash/w25q/config.mk} | 0 .../rpi/common_rp2/platform/platform.c | 2 +- .../sifive/common_fe310/hal/clint/clint.c | 10 ++- .../sifive/common_fe310/platform/platform.c | 2 +- .../common_fe310/platform/platform_reset.c | 2 +- src/visor/build.mk | 8 +-- .../services/bootstrap/bootstrap.c | 6 +- .../services/bootstrap/build.mk | 0 src/visor/{supervisor => }/services/build.mk | 11 ++-- .../{common => services/kernel}/build.mk | 8 +-- .../services/kernel/helios/build.mk | 0 .../services/kernel/helios/helios_heap.c | 2 +- .../services/kernel/helios/helios_mutex.c | 2 +- .../services/kernel/helios/helios_sched.c | 2 +- .../services/kernel/helios/helios_sem.c | 2 +- .../services/kernel/helios/helios_task_idle.c | 2 +- .../services/kernel/helios/helios_tasks.c | 2 +- src/visor/supervisor/build.mk | 0 src/visor/terravisor/README.md | 0 src/visor/terravisor/build.mk | 17 ----- .../terravisor/services/bootstrap/bootstrap.c | 49 -------------- src/visor/terravisor/services/build.mk | 22 ------- src/visor/terravisor/services/driver/build.mk | 15 ----- src/visor/{common => }/workers/build.mk | 0 src/visor/{common => }/workers/vcall/build.mk | 0 .../{common => }/workers/vcall/visor_call.c | 0 72 files changed, 218 insertions(+), 263 deletions(-) create mode 100644 src/driver/schedclk/build.mk rename src/{visor/terravisor/services/driver/timer.c => driver/schedclk/schedclk.c} (61%) rename src/{visor/terravisor/services/bootstrap => driver/schedclk/schedclk_ibex}/build.mk (66%) rename src/{platform/ibex/simple_system/platform/plat_timer.c => driver/schedclk/schedclk_ibex/schedclk_ibex.c} (93%) create mode 100644 src/driver/schedclk/schedclk_mega_avr/build.mk rename src/{platform/mega_avr/common/platform/platform_timer.c => driver/schedclk/schedclk_mega_avr/schedclk_mega_avr.c} (87%) create mode 100644 src/driver/schedclk/schedclk_sifive/build.mk rename src/{platform/sifive/common_fe310/platform/plat_timer.c => driver/schedclk/schedclk_sifive/schedclk_sifive.c} (92%) create mode 100644 src/include/driver/schedclk.h rename src/include/visor/{terravisor => }/bootstrap.h (84%) rename src/include/visor/{terravisor => }/helios/helios.h (69%) rename src/include/visor/{terravisor => }/helios/helios_mutex.h (98%) rename src/include/visor/{terravisor => }/helios/helios_sem.h (98%) rename src/include/visor/{terravisor => }/helios/helios_tasks.h (99%) rename src/include/visor/{terravisor => }/helios/utils/helios_heap.h (90%) rename src/include/visor/{terravisor => }/helios/utils/helios_sched.h (100%) rename src/include/visor/{terravisor => }/platform.h (88%) delete mode 100644 src/include/visor/terravisor/timer.h rename src/include/visor/{visor => }/workers.h (100%) rename src/{visor/hypervisor/build.mk => platform/rpi/common_rp2/flash/w25q/config.mk} (100%) rename src/visor/{supervisor => }/services/bootstrap/bootstrap.c (86%) rename src/visor/{supervisor => }/services/bootstrap/build.mk (100%) rename src/visor/{supervisor => }/services/build.mk (54%) rename src/visor/{common => services/kernel}/build.mk (56%) rename src/visor/{terravisor => }/services/kernel/helios/build.mk (100%) rename src/visor/{terravisor => }/services/kernel/helios/helios_heap.c (95%) rename src/visor/{terravisor => }/services/kernel/helios/helios_mutex.c (99%) rename src/visor/{terravisor => }/services/kernel/helios/helios_sched.c (99%) rename src/visor/{terravisor => }/services/kernel/helios/helios_sem.c (98%) rename src/visor/{terravisor => }/services/kernel/helios/helios_task_idle.c (98%) rename src/visor/{terravisor => }/services/kernel/helios/helios_tasks.c (99%) delete mode 100644 src/visor/supervisor/build.mk delete mode 100644 src/visor/terravisor/README.md delete mode 100644 src/visor/terravisor/build.mk delete mode 100644 src/visor/terravisor/services/bootstrap/bootstrap.c delete mode 100644 src/visor/terravisor/services/build.mk delete mode 100644 src/visor/terravisor/services/driver/build.mk rename src/visor/{common => }/workers/build.mk (100%) rename src/visor/{common => }/workers/vcall/build.mk (100%) rename src/visor/{common => }/workers/vcall/visor_call.c (100%) diff --git a/mk/mk_helper.mk b/mk/mk_helper.mk index b9bc74c2..fa6d2c19 100644 --- a/mk/mk_helper.mk +++ b/mk/mk_helper.mk @@ -1,6 +1,6 @@ # # CYANCORE LICENSE -# Copyrights (C) 2019, Cyancore Team +# Copyrights (C) 2024, Cyancore Team # # File Name : mk_helper.mk # Description : This file defines make helper utilities @@ -25,7 +25,7 @@ define add_cflag endef define add_ldflag - LD_FLAGS += $(1) + LD_FLAGS+= $(1) endef define check_and_include @@ -37,3 +37,11 @@ endef define get_tc_version TC_VER := $(firstword $(strip $(shell $(1)-gcc --version | grep -m 1 -Po '\s(\d{1,}\.\d{1,}\.\d{1,})'))) endef + +define check_config_and_include +ifeq ($(realpath $(1)),) +$$(info < ! > Invalid $(2) ...) +else +include $(realpath $(1)) +endif +endef diff --git a/projects/bl.src/project.c b/projects/bl.src/project.c index bdb50001..0b369acc 100644 --- a/projects/bl.src/project.c +++ b/projects/bl.src/project.c @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include diff --git a/projects/demo.src/project.c b/projects/demo.src/project.c index ed59f153..e59204bb 100644 --- a/projects/demo.src/project.c +++ b/projects/demo.src/project.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/projects/demo_avr/config.mk b/projects/demo_avr/config.mk index 2448f096..96e54b1e 100644 --- a/projects/demo_avr/config.mk +++ b/projects/demo_avr/config.mk @@ -16,4 +16,3 @@ BOOTMSGS := 0 EARLYCON_SERIAL := 1 CONSOLE_SERIAL := 1 OBRDLED_ENABLE := 1 -TERRAKERN := 0 diff --git a/projects/demo_avr_cpp/config.mk b/projects/demo_avr_cpp/config.mk index 05f673c8..f2f0d193 100644 --- a/projects/demo_avr_cpp/config.mk +++ b/projects/demo_avr_cpp/config.mk @@ -15,4 +15,3 @@ STDLOG_MEMBUF := 0 BOOTMSGS := 0 EARLYCON_SERIAL := 1 CONSOLE_SERIAL := 1 -TERRAKERN := 0 diff --git a/projects/demo_avr_cpp/project.cpp b/projects/demo_avr_cpp/project.cpp index 05edd261..b37836e5 100644 --- a/projects/demo_avr_cpp/project.cpp +++ b/projects/demo_avr_cpp/project.cpp @@ -13,8 +13,8 @@ extern "C" { #include #include - #include - #include + #include + #include #include #include #include diff --git a/projects/demo_helios.src/project.c b/projects/demo_helios.src/project.c index 5a77a309..984de456 100644 --- a/projects/demo_helios.src/project.c +++ b/projects/demo_helios.src/project.c @@ -9,9 +9,9 @@ */ #include #include -#include +#include #include -#include +#include #define TASK_WAIT_TICKS 10 diff --git a/projects/demo_helios_avr/config.mk b/projects/demo_helios_avr/config.mk index 720633ae..1a62f965 100644 --- a/projects/demo_helios_avr/config.mk +++ b/projects/demo_helios_avr/config.mk @@ -18,4 +18,4 @@ BOOTMSGS := 0 EARLYCON_SERIAL := 0 CONSOLE_SERIAL := 0 OBRDLED_ENABLE := 1 -TERRAKERN := helios +KHELIOS := 1 diff --git a/projects/demo_helios_riscv/config.mk b/projects/demo_helios_riscv/config.mk index 80a63301..b4d9f693 100644 --- a/projects/demo_helios_riscv/config.mk +++ b/projects/demo_helios_riscv/config.mk @@ -18,4 +18,4 @@ BOOTMSGS := 1 EARLYCON_SERIAL := 1 CONSOLE_SERIAL := 1 OBRDLED_ENABLE := 1 -TERRAKERN := helios +KHELIOS := 1 diff --git a/projects/demo_ibex_ss/config.mk b/projects/demo_ibex_ss/config.mk index 5a7b1385..27beca34 100644 --- a/projects/demo_ibex_ss/config.mk +++ b/projects/demo_ibex_ss/config.mk @@ -15,4 +15,3 @@ STDLOG_MEMBUF := 1 BOOTMSGS := 1 EARLYCON_SERIAL := 1 OBRDLED_ENABLE := 0 -TERRAKERN := 0 diff --git a/projects/demo_ibex_ss/project.c b/projects/demo_ibex_ss/project.c index 9388dc2c..d903572f 100644 --- a/projects/demo_ibex_ss/project.c +++ b/projects/demo_ibex_ss/project.c @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/projects/demo_qemu_sifive_e/config.mk b/projects/demo_qemu_sifive_e/config.mk index b57312e5..5cd2cddb 100644 --- a/projects/demo_qemu_sifive_e/config.mk +++ b/projects/demo_qemu_sifive_e/config.mk @@ -16,4 +16,3 @@ BOOTMSGS := 0 EARLYCON_SERIAL := 1 CONSOLE_SERIAL := 1 OBRDLED_ENABLE := 1 -TERRAKERN := 0 diff --git a/projects/demo_riscv/config.mk b/projects/demo_riscv/config.mk index c93ab91c..5e39b8e1 100644 --- a/projects/demo_riscv/config.mk +++ b/projects/demo_riscv/config.mk @@ -16,4 +16,3 @@ BOOTMSGS := 0 EARLYCON_SERIAL := 1 CONSOLE_SERIAL := 1 OBRDLED_ENABLE := 1 -TERRAKERN := 0 diff --git a/projects/hifive1b_bl/config.mk b/projects/hifive1b_bl/config.mk index 493b4a09..41150720 100644 --- a/projects/hifive1b_bl/config.mk +++ b/projects/hifive1b_bl/config.mk @@ -16,4 +16,3 @@ BOOTMSGS := 1 EARLYCON_SERIAL := 1 CONSOLE_SERIAL := 0 OBRDLED_ENABLE := 1 -TERRAKERN := 0 diff --git a/projects/project.template/config.mk b/projects/project.template/config.mk index f0d4c172..f3de5783 100644 --- a/projects/project.template/config.mk +++ b/projects/project.template/config.mk @@ -15,4 +15,3 @@ PLATFORM := SYSLOG_MEMBUF := EARLYCON_SERIAL := CONSOLE_SERIAL := -TERRAKERN := diff --git a/projects/qemu_sifive_e_bl/config.mk b/projects/qemu_sifive_e_bl/config.mk index 2e019580..4cee0674 100644 --- a/projects/qemu_sifive_e_bl/config.mk +++ b/projects/qemu_sifive_e_bl/config.mk @@ -17,4 +17,3 @@ BOOTMSGS := 0 EARLYCON_SERIAL := 1 CONSOLE_SERIAL := 0 OBRDLED_ENABLE := 0 -TERRAKERN := 0 diff --git a/projects/qemu_sifive_e_bl/project.c b/projects/qemu_sifive_e_bl/project.c index 681f6290..1168f9c5 100644 --- a/projects/qemu_sifive_e_bl/project.c +++ b/projects/qemu_sifive_e_bl/project.c @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/arch/README.md b/src/arch/README.md index b6d84521..32ad0816 100644 --- a/src/arch/README.md +++ b/src/arch/README.md @@ -7,4 +7,4 @@ Home directory for CPU architecture specific sources. #### Supported Architectures * AVR * RISCV -* ARM [Coming Soon] +* ARM-M diff --git a/src/arch/riscv/32/README.md b/src/arch/riscv/32/README.md index 84d5e823..b986b26e 100644 --- a/src/arch/riscv/32/README.md +++ b/src/arch/riscv/32/README.md @@ -4,4 +4,5 @@ Home directory for RV32 CPU #### Supported Variants * RV32I +* RV32IMC * RV32IMAC diff --git a/src/driver/build.mk b/src/driver/build.mk index 572b7f87..03c1c01a 100644 --- a/src/driver/build.mk +++ b/src/driver/build.mk @@ -1,6 +1,6 @@ # # CYANCORE LICENSE -# Copyrights (C) 2019, Cyancore Team +# Copyrights (C) 2024, Cyancore Team # # File Name : build.mk # Description : This file accumulates the build scripts from @@ -15,6 +15,7 @@ DRIVER_PATH := $(GET_PATH) include $(DRIVER_PATH)/interrupt/build.mk include $(DRIVER_PATH)/watchdog/build.mk include $(DRIVER_PATH)/console/build.mk +include $(DRIVER_PATH)/schedclk/build.mk #==========< User Config Drivers >==========# $(eval $(call check_and_include,SYSCLK_ENABLE,$(DRIVER_PATH)/sysclk/build.mk)) diff --git a/src/driver/console/build.mk b/src/driver/console/build.mk index 49d82aff..c4dfc7f2 100644 --- a/src/driver/console/build.mk +++ b/src/driver/console/build.mk @@ -11,7 +11,9 @@ CONSOLE_PATH := $(GET_PATH) include $(CONSOLE_PATH)/stdlog_membuf/build.mk -include $(CONSOLE_PATH)/con_serial_$(FAMILY)/build.mk + +$(eval $(call check_config_and_include,$(CONSOLE_PATH)/con_serial_$(FAMILY)/build.mk,Family: $(FAMILY))) + DIR := $(CONSOLE_PATH) include mk/obj.mk diff --git a/src/driver/schedclk/build.mk b/src/driver/schedclk/build.mk new file mode 100644 index 00000000..d9b62b04 --- /dev/null +++ b/src/driver/schedclk/build.mk @@ -0,0 +1,16 @@ +# +# CYANCORE LICENSE +# Copyrights (C) 2024, Cyancore Team +# +# File Name : build.mk +# Description : This file builds timer driver and related sources. +# Primary Author : Akash Kollipara [akashkollipara@gmail.com] +# Organisation : Cyancore Core-Team +# + +SCHEDCLK_DIR := $(GET_PATH) + +$(eval $(call check_config_and_include,$(SCHEDCLK_DIR)/schedclk_$(FAMILY)/build.mk,Family: $(FAMILY))) + +DIR := $(SCHEDCLK_DIR) +include mk/obj.mk diff --git a/src/visor/terravisor/services/driver/timer.c b/src/driver/schedclk/schedclk.c similarity index 61% rename from src/visor/terravisor/services/driver/timer.c rename to src/driver/schedclk/schedclk.c index f722e61b..c552637d 100644 --- a/src/visor/terravisor/services/driver/timer.c +++ b/src/driver/schedclk/schedclk.c @@ -1,9 +1,9 @@ /* * CYANCORE LICENSE - * Copyrights (C) 2022, Cyancore Team + * Copyrights (C) 2024, Cyancore Team * - * File Name : timer.c - * Description : This file contains sources of terravisor timer + * File Name : schedclk.c + * Description : This file contains sources of visor schedclk * Primary Author : Akash Kollipara [akashkollipara@gmail.com] * Organisation : Cyancore Core-Team */ @@ -15,20 +15,20 @@ #include #include #include -#include +#include /** * *port - Timer driver pointer * - * This variable is updated by the timer_attach_device + * This variable is updated by the schedclk_attach_device * when the device driver is initialised */ -static tvisor_timer_t *port[N_CORES]; +static schedclk_t *port[N_CORES]; /** - * timer_attached - Flag to indicate the initialization status + * schedclk_attached - Flag to indicate the initialization status */ -static bool timer_attached[N_CORES] = {[0 ... N_CORES-1] = false}; +static bool schedclk_attached[N_CORES] = {[0 ... N_CORES-1] = false}; /** * tlock - Locks for sync in multi thread env @@ -36,18 +36,18 @@ static bool timer_attached[N_CORES] = {[0 ... N_CORES-1] = false}; static lock_t tlock[N_CORES]; /** - * timer_attach_device - This function links hardware driver + * schedclk_attach_device - This function links hardware driver * and device driver. * - * @brief This function links the hardware driver and timer device. + * @brief This function links the hardware driver and schedclk device. * On successful linking, it updates the status flag so that - * other functions know timer is attached. + * other functions know schedclk is attached. * * @param[in] dev_status: device init status - * @param[in] *ptmr: device timer port + * @param[in] *ptmr: device schedclk port * @return status: status of device/hardware driver */ -status_t timer_attach_device(status_t dev_status, tvisor_timer_t *ptmr) +status_t schedclk_attach_device(status_t dev_status, schedclk_t *ptmr) { status_t ret; size_t cpu_index = arch_core_index(); @@ -60,7 +60,7 @@ status_t timer_attach_device(status_t dev_status, tvisor_timer_t *ptmr) if(port[cpu_index] != NULL) { ret = dev_status; - timer_attached[cpu_index] = true; + schedclk_attached[cpu_index] = true; } else ret = error_device_inval; @@ -69,43 +69,43 @@ status_t timer_attach_device(status_t dev_status, tvisor_timer_t *ptmr) } /** - * timer_release_device - This function delinks hardware driver + * schedclk_release_device - This function delinks hardware driver * and device driver. * * @brief This function simply clear hardware driver pointer and updates - * timer status flag + * schedclk status flag * * @return status: status of device/hardware driver */ -status_t timer_release_device() +status_t schedclk_release_device() { size_t cpu_index = arch_core_index(); lock_t *lock = &tlock[cpu_index]; lock_acquire(lock); port[cpu_index] = NULL; - timer_attached[cpu_index] = false; + schedclk_attached[cpu_index] = false; lock_release(lock); return success; } /** - * timer_link_callback - This is a helper function which lets other - * programs to link timer event call back functions. + * schedclk_link_callback - This is a helper function which lets other + * programs to link schedclk event call back functions. * * @brief This is a helper function which lets other programs to link - * timer event call back functions. It allows to link only 1 callback - * which will be executed as part of timer ISR handler. + * schedclk event call back functions. It allows to link only 1 callback + * which will be executed as part of schedclk ISR handler. * - * @param[in] p: period of timer irq + * @param[in] p: period of schedclk irq * @param[in] cb: call back function pointer * @return status */ -status_t timer_link_callback(unsigned int p, void *cb) +status_t schedclk_link_callback(unsigned int p, void *cb) { size_t cpu_index = arch_core_index(); lock_t *lock = &tlock[cpu_index]; - tvisor_timer_t *ptr = port[cpu_index]; - if(!timer_attached[cpu_index]) + schedclk_t *ptr = port[cpu_index]; + if(!schedclk_attached[cpu_index]) return error_driver_init_failed; lock_acquire(lock); ptr->set_period(p); @@ -117,7 +117,7 @@ status_t timer_link_callback(unsigned int p, void *cb) /** * get_timestamp - This funtion reads timestamp * - * @brief This function reads time from lower level timer + * @brief This function reads time from lower level schedclk * functions and updates the input potiner. If the driver * is not initialised, then pointer is updated to 0. * @@ -130,8 +130,8 @@ status_t get_timestamp(uint64_t *t) { size_t cpu_index = arch_core_index(); lock_t *lock = &tlock[cpu_index]; - tvisor_timer_t *ptr = port[cpu_index]; - if(!timer_attached[cpu_index]) + schedclk_t *ptr = port[cpu_index]; + if(!schedclk_attached[cpu_index]) { *t = 0; return error_driver_init_failed; @@ -143,9 +143,9 @@ status_t get_timestamp(uint64_t *t) } /** - * get_timeticks - This funtion reads timer ticks + * get_timeticks - This funtion reads schedclk ticks * - * @brief This function reads ticks from lower level timer + * @brief This function reads ticks from lower level schedclk * functions and updates the input potiner. If the driver * is not initialised, then pointer is updated to 0. * @@ -158,8 +158,8 @@ status_t get_timeticks(uint64_t *t) { size_t cpu_index = arch_core_index(); lock_t *lock = &tlock[cpu_index]; - tvisor_timer_t *ptr = port[cpu_index]; - if(!timer_attached[cpu_index]) + schedclk_t *ptr = port[cpu_index]; + if(!schedclk_attached[cpu_index]) { *t = 0; return error_driver_init_failed; diff --git a/src/visor/terravisor/services/bootstrap/build.mk b/src/driver/schedclk/schedclk_ibex/build.mk similarity index 66% rename from src/visor/terravisor/services/bootstrap/build.mk rename to src/driver/schedclk/schedclk_ibex/build.mk index c3dc1b0f..afff9c5e 100644 --- a/src/visor/terravisor/services/bootstrap/build.mk +++ b/src/driver/schedclk/schedclk_ibex/build.mk @@ -1,9 +1,9 @@ # # CYANCORE LICENSE -# Copyrights (C) 2019, Cyancore Team +# Copyrights (C) 2024, Cyancore Team # # File Name : build.mk -# Description : This file build bootstrap sources +# Description : This file accumulates sources of schedclk # Primary Author : Akash Kollipara [akashkollipara@gmail.com] # Organisation : Cyancore Core-Team # diff --git a/src/platform/ibex/simple_system/platform/plat_timer.c b/src/driver/schedclk/schedclk_ibex/schedclk_ibex.c similarity index 93% rename from src/platform/ibex/simple_system/platform/plat_timer.c rename to src/driver/schedclk/schedclk_ibex/schedclk_ibex.c index 230f29c3..8e4b4fbb 100644 --- a/src/platform/ibex/simple_system/platform/plat_timer.c +++ b/src/driver/schedclk/schedclk_ibex/schedclk_ibex.c @@ -21,7 +21,7 @@ #include #include #include -#include +#include /** * tmr_cb - Timer event call back @@ -154,7 +154,7 @@ static uint64_t plat_read_time(void) /** * Driver ops for linking timer */ -static tvisor_timer_t *plat_timer_port; +static schedclk_t *plat_timer_port; /** * plat_timer_setup - Timer driver setup function @@ -166,7 +166,7 @@ status_t plat_timer_setup(void) const irqs_t *irq; arch_di_mtime(); - plat_timer_port = (tvisor_timer_t *)malloc(sizeof(tvisor_timer_t)); + plat_timer_port = (schedclk_t *)malloc(sizeof(schedclk_t)); if(!plat_timer_port) return error_memory_low; plat_timer_port->read_ticks = &clint_read_time; @@ -181,7 +181,7 @@ status_t plat_timer_setup(void) /* Link timer isr handle */ ret |= link_interrupt(irq->module, irq->id, &plat_tmr_isr); - ret |= timer_attach_device(ret, plat_timer_port); + ret |= schedclk_attach_device(ret, plat_timer_port); plat_timer_set_period(1); return ret; } @@ -199,9 +199,9 @@ status_t plat_timer_exit(void) irq = &tm->interrupt[0]; unlink_interrupt(irq->module, irq->id); free(plat_timer_port); - return timer_release_device(); + return schedclk_release_device(); } #if USE_TIMER -INCLUDE_DRIVER(plat_timer, plat_timer_setup, plat_timer_exit, 0, 1, 1); +INCLUDE_DRIVER(schedclk, plat_timer_setup, plat_timer_exit, 0, 1, 1); #endif diff --git a/src/driver/schedclk/schedclk_mega_avr/build.mk b/src/driver/schedclk/schedclk_mega_avr/build.mk new file mode 100644 index 00000000..afff9c5e --- /dev/null +++ b/src/driver/schedclk/schedclk_mega_avr/build.mk @@ -0,0 +1,13 @@ +# +# CYANCORE LICENSE +# Copyrights (C) 2024, Cyancore Team +# +# File Name : build.mk +# Description : This file accumulates sources of schedclk +# Primary Author : Akash Kollipara [akashkollipara@gmail.com] +# Organisation : Cyancore Core-Team +# + +DIR := $(GET_PATH) + +include mk/obj.mk diff --git a/src/platform/mega_avr/common/platform/platform_timer.c b/src/driver/schedclk/schedclk_mega_avr/schedclk_mega_avr.c similarity index 87% rename from src/platform/mega_avr/common/platform/platform_timer.c rename to src/driver/schedclk/schedclk_mega_avr/schedclk_mega_avr.c index 0ed3a228..211cebed 100644 --- a/src/platform/mega_avr/common/platform/platform_timer.c +++ b/src/driver/schedclk/schedclk_mega_avr/schedclk_mega_avr.c @@ -1,6 +1,6 @@ /* * CYANCORE LICENSE - * Copyrights (C) 2022, Cyancore Team + * Copyrights (C) 2024, Cyancore Team * * File Name : platform_timer.c * Description : This file contains sources for platform timer apis @@ -18,7 +18,7 @@ #include #include #include -#include +#include #define PS 4 #define PSVALUE 256 @@ -152,13 +152,7 @@ static uint64_t plat_read_time(void) /** * Driver ops for linking timer */ -static tvisor_timer_t plat_timer_port = -{ - .read_ticks = &plat_read_ticks, - .read_time = &plat_read_time, - .set_period = &plat_timer_set_period, - .reg_cb = &plat_timer_reg_cb, -}; +static schedclk_t *plat_timer_port; static status_t plat_timer_exit(void); @@ -174,6 +168,11 @@ static status_t plat_timer_setup() tport = (timer_port_t *)malloc(sizeof(timer_port_t)); if(!tport) return error_memory_low; + + plat_timer_port = (schedclk_t *)malloc(sizeof(schedclk_t)); + if(!plat_timer_port) + return error_memory_low; + if(!tm->clk) { ret = error_system_clk_caliberation; @@ -191,7 +190,13 @@ static status_t plat_timer_setup() if(ret) goto cleanup_exit2; plat_timer_set_period(1); - ret = timer_attach_device(ret, &plat_timer_port); + + plat_timer_port->read_ticks = &plat_read_ticks; + plat_timer_port->read_time = &plat_read_time; + plat_timer_port->set_period = &plat_timer_set_period; + plat_timer_port->reg_cb = &plat_timer_reg_cb; + + ret = schedclk_attach_device(ret, plat_timer_port); if(!ret) goto exit; cleanup_exit2: @@ -213,9 +218,10 @@ static status_t plat_timer_exit(void) ticks = 0; tmr_cb = (void *) 0; memset(tport, 0, sizeof(timer_port_t)); - ret |= timer_release_device(); + ret |= schedclk_release_device(); free(tport); + free(plat_timer_port); return ret; } -INCLUDE_DRIVER(plat_timer, plat_timer_setup, plat_timer_exit, 0, 1, 1); +INCLUDE_DRIVER(schedclk, plat_timer_setup, plat_timer_exit, 0, 1, 1); diff --git a/src/driver/schedclk/schedclk_sifive/build.mk b/src/driver/schedclk/schedclk_sifive/build.mk new file mode 100644 index 00000000..afff9c5e --- /dev/null +++ b/src/driver/schedclk/schedclk_sifive/build.mk @@ -0,0 +1,13 @@ +# +# CYANCORE LICENSE +# Copyrights (C) 2024, Cyancore Team +# +# File Name : build.mk +# Description : This file accumulates sources of schedclk +# Primary Author : Akash Kollipara [akashkollipara@gmail.com] +# Organisation : Cyancore Core-Team +# + +DIR := $(GET_PATH) + +include mk/obj.mk diff --git a/src/platform/sifive/common_fe310/platform/plat_timer.c b/src/driver/schedclk/schedclk_sifive/schedclk_sifive.c similarity index 92% rename from src/platform/sifive/common_fe310/platform/plat_timer.c rename to src/driver/schedclk/schedclk_sifive/schedclk_sifive.c index 40bbc91d..8e4b4fbb 100644 --- a/src/platform/sifive/common_fe310/platform/plat_timer.c +++ b/src/driver/schedclk/schedclk_sifive/schedclk_sifive.c @@ -1,6 +1,6 @@ /* * CYANCORE LICENSE - * Copyrights (C) 2022, Cyancore Team + * Copyrights (C) 2024, Cyancore Team * * File Name : plat_timer.c * Description : This file contains sources for platform @@ -21,7 +21,7 @@ #include #include #include -#include +#include /** * tmr_cb - Timer event call back @@ -154,7 +154,7 @@ static uint64_t plat_read_time(void) /** * Driver ops for linking timer */ -static tvisor_timer_t *plat_timer_port; +static schedclk_t *plat_timer_port; /** * plat_timer_setup - Timer driver setup function @@ -166,7 +166,7 @@ status_t plat_timer_setup(void) const irqs_t *irq; arch_di_mtime(); - plat_timer_port = (tvisor_timer_t *)malloc(sizeof(tvisor_timer_t)); + plat_timer_port = (schedclk_t *)malloc(sizeof(schedclk_t)); if(!plat_timer_port) return error_memory_low; plat_timer_port->read_ticks = &clint_read_time; @@ -181,7 +181,7 @@ status_t plat_timer_setup(void) /* Link timer isr handle */ ret |= link_interrupt(irq->module, irq->id, &plat_tmr_isr); - ret |= timer_attach_device(ret, plat_timer_port); + ret |= schedclk_attach_device(ret, plat_timer_port); plat_timer_set_period(1); return ret; } @@ -199,9 +199,9 @@ status_t plat_timer_exit(void) irq = &tm->interrupt[0]; unlink_interrupt(irq->module, irq->id); free(plat_timer_port); - return timer_release_device(); + return schedclk_release_device(); } #if USE_TIMER -INCLUDE_DRIVER(plat_timer, plat_timer_setup, plat_timer_exit, 0, 1, 1); +INCLUDE_DRIVER(schedclk, plat_timer_setup, plat_timer_exit, 0, 1, 1); #endif diff --git a/src/include/driver/schedclk.h b/src/include/driver/schedclk.h new file mode 100644 index 00000000..11e97890 --- /dev/null +++ b/src/include/driver/schedclk.h @@ -0,0 +1,25 @@ +/* + * CYANCORE LICENSE + * Copyrights (C) 2024, Cyancore Team + * + * File Name : schedclk.h + * Description : This file consists of prototypes for schedclk driver + * Primary Author : Akash Kollipara [akashkollipara@gmail.com] + * Organisation : Cyancore Core-Team + */ + +#pragma once + +#define _VISOR_TIMER_T_ + +typedef struct schedclk +{ + uint64_t (*read_ticks)(void); + uint64_t (*read_time)(void); + void (*set_period)(unsigned int); + void (*reg_cb)(void *); +} schedclk_t; + +status_t schedclk_attach_device(status_t, schedclk_t *); +status_t schedclk_release_device(); +status_t schedclk_link_callback(unsigned int, void *); diff --git a/src/include/visor/terravisor/bootstrap.h b/src/include/visor/bootstrap.h similarity index 84% rename from src/include/visor/terravisor/bootstrap.h rename to src/include/visor/bootstrap.h index 8dbd12c6..96ff1f40 100644 --- a/src/include/visor/terravisor/bootstrap.h +++ b/src/include/visor/bootstrap.h @@ -3,7 +3,7 @@ * Copyrights (C) 2019, Cyancore Team * * File Name : bootstrap.h - * Description : This file consists of terravisor-bootstrap + * Description : This file consists of bootstrap * and related prototypes * Primary Author : Akash Kollipara [akashkollipara@gmail.com] * Organisation : Cyancore Core-Team diff --git a/src/include/visor/terravisor/helios/helios.h b/src/include/visor/helios/helios.h similarity index 69% rename from src/include/visor/terravisor/helios/helios.h rename to src/include/visor/helios/helios.h index ed3b8c21..7f9db4ac 100644 --- a/src/include/visor/terravisor/helios/helios.h +++ b/src/include/visor/helios/helios.h @@ -14,9 +14,9 @@ /***************************************************** * INCLUDES *****************************************************/ -#include -#include -#include -#include +#include +#include +#include +#include #endif /* __HELIOS__ */ diff --git a/src/include/visor/terravisor/helios/helios_mutex.h b/src/include/visor/helios/helios_mutex.h similarity index 98% rename from src/include/visor/terravisor/helios/helios_mutex.h rename to src/include/visor/helios/helios_mutex.h index 67ed3fb2..9ff345b7 100644 --- a/src/include/visor/terravisor/helios/helios_mutex.h +++ b/src/include/visor/helios/helios_mutex.h @@ -12,7 +12,7 @@ /***************************************************** * DEFINES *****************************************************/ -#include +#include /***************************************************** * TYPEDEFS *****************************************************/ diff --git a/src/include/visor/terravisor/helios/helios_sem.h b/src/include/visor/helios/helios_sem.h similarity index 98% rename from src/include/visor/terravisor/helios/helios_sem.h rename to src/include/visor/helios/helios_sem.h index 0c25d690..d38eb29c 100644 --- a/src/include/visor/terravisor/helios/helios_sem.h +++ b/src/include/visor/helios/helios_sem.h @@ -12,7 +12,7 @@ /***************************************************** * DEFINES *****************************************************/ -#include +#include /***************************************************** * TYPEDEFS *****************************************************/ diff --git a/src/include/visor/terravisor/helios/helios_tasks.h b/src/include/visor/helios/helios_tasks.h similarity index 99% rename from src/include/visor/terravisor/helios/helios_tasks.h rename to src/include/visor/helios/helios_tasks.h index b848913b..8f86a497 100644 --- a/src/include/visor/terravisor/helios/helios_tasks.h +++ b/src/include/visor/helios/helios_tasks.h @@ -16,7 +16,7 @@ #include "status.h" #include "stdlib.h" #include "stdint.h" -#include +#include /***************************************************** * TYPEDEFS diff --git a/src/include/visor/terravisor/helios/utils/helios_heap.h b/src/include/visor/helios/utils/helios_heap.h similarity index 90% rename from src/include/visor/terravisor/helios/utils/helios_heap.h rename to src/include/visor/helios/utils/helios_heap.h index 14dc7506..50496717 100644 --- a/src/include/visor/terravisor/helios/utils/helios_heap.h +++ b/src/include/visor/helios/utils/helios_heap.h @@ -11,7 +11,7 @@ #include #include #include -#include +#include void * helios_malloc(size_t size); void helios_free(void *addr); diff --git a/src/include/visor/terravisor/helios/utils/helios_sched.h b/src/include/visor/helios/utils/helios_sched.h similarity index 100% rename from src/include/visor/terravisor/helios/utils/helios_sched.h rename to src/include/visor/helios/utils/helios_sched.h diff --git a/src/include/visor/terravisor/platform.h b/src/include/visor/platform.h similarity index 88% rename from src/include/visor/terravisor/platform.h rename to src/include/visor/platform.h index 6719c301..6d9a0dd2 100644 --- a/src/include/visor/terravisor/platform.h +++ b/src/include/visor/platform.h @@ -3,7 +3,7 @@ * Copyrights (C) 2019, Cyancore Team * * File Name : platform.h - * Description : This file consists of terravisor-platform + * Description : This file consists of platform * and related prototypes * Primary Author : Akash Kollipara [akashkollipara@gmail.com] * Organisation : Cyancore Core-Team diff --git a/src/include/visor/terravisor/timer.h b/src/include/visor/terravisor/timer.h deleted file mode 100644 index 6ba4dca1..00000000 --- a/src/include/visor/terravisor/timer.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * CYANCORE LICENSE - * Copyrights (C) 2022, Cyancore Team - * - * File Name : timer.h - * Description : This file consists of prototypes for terravisor - * timer drivers - * Primary Author : Akash Kollipara [akashkollipara@gmail.com] - * Organisation : Cyancore Core-Team - */ - -#pragma once - -#define _TVISOR_TIMER_T_ - -typedef struct tvisor_timer -{ - uint64_t (*read_ticks)(void); - uint64_t (*read_time)(void); - void (*set_period)(unsigned int); - void (*reg_cb)(void *); -} tvisor_timer_t; - -status_t timer_attach_device(status_t, tvisor_timer_t *); -status_t timer_release_device(); -status_t timer_link_callback(unsigned int, void *); diff --git a/src/include/visor/visor/workers.h b/src/include/visor/workers.h similarity index 100% rename from src/include/visor/visor/workers.h rename to src/include/visor/workers.h diff --git a/src/platform/build.mk b/src/platform/build.mk index f20d35bf..6e97c29a 100644 --- a/src/platform/build.mk +++ b/src/platform/build.mk @@ -10,13 +10,15 @@ # PLAT_DIR := $(GET_PATH) +FAM_PATH := $(PLAT_DIR)/$(FAMILY) +PLAT_PATH := $(FAM_PATH)/$(PLATFORM) -ifeq ($(FAMILY),) -$(info < ! > Family of chip used in project is not defined !) +ifeq ($(realpath $(FAM_PATH)),) +$(info < ! > Family of chip used in project is not suppoted !) $(error < x > Build Failed !) endif -ifeq ($(PLATFORM),) -$(info < ! > Platform for project is not defined !) +ifeq ($(realpath $(PLAT_PATH)),) +$(info < ! > Platform for project is not supported !) $(error < x > Build Failed !) endif diff --git a/src/platform/ibex/simple_system/hal/clint/clint.c b/src/platform/ibex/simple_system/hal/clint/clint.c index 5ea4c3f8..f7a4061d 100644 --- a/src/platform/ibex/simple_system/hal/clint/clint.c +++ b/src/platform/ibex/simple_system/hal/clint/clint.c @@ -61,9 +61,13 @@ status_t clint_config_tcmp(size_t core_id, uint64_t value) uint64_t clint_read_time() { - uint64_t time_stamp; - time_stamp = MMIO64(port->baddr + MTIME_OFFSET); - return time_stamp; + uint32_t temp, tl, th; + do { + temp = MMIO32(port->baddr + MTIME_OFFSET + 4); + tl = MMIO32(port->baddr + MTIME_OFFSET); + th = MMIO32(port->baddr + MTIME_OFFSET + 4); + } while(temp != th); + return ((uint64_t)th << 32) | (uint64_t)(tl); } INCLUDE_DRIVER(plat_clint, clint_setup, clint_exit, 0, 0, 0); diff --git a/src/platform/ibex/simple_system/platform/platform.c b/src/platform/ibex/simple_system/platform/platform.c index d2f58be4..1882c749 100644 --- a/src/platform/ibex/simple_system/platform/platform.c +++ b/src/platform/ibex/simple_system/platform/platform.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/platform/ibex/simple_system/platform/platform_reset.c b/src/platform/ibex/simple_system/platform/platform_reset.c index 888e7721..52f80f05 100644 --- a/src/platform/ibex/simple_system/platform/platform_reset.c +++ b/src/platform/ibex/simple_system/platform/platform_reset.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include /** * platform_get_reset_syndrome - returns the cause of reset diff --git a/src/platform/mega_avr/common/platform/platform.c b/src/platform/mega_avr/common/platform/platform.c index 4bc99ff2..3e168529 100644 --- a/src/platform/mega_avr/common/platform/platform.c +++ b/src/platform/mega_avr/common/platform/platform.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/platform/mega_avr/common/platform/platform_reset.c b/src/platform/mega_avr/common/platform/platform_reset.c index 0bcb8092..105b073f 100644 --- a/src/platform/mega_avr/common/platform/platform_reset.c +++ b/src/platform/mega_avr/common/platform/platform_reset.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include extern uint8_t reset_syndrome; diff --git a/src/visor/hypervisor/build.mk b/src/platform/rpi/common_rp2/flash/w25q/config.mk similarity index 100% rename from src/visor/hypervisor/build.mk rename to src/platform/rpi/common_rp2/flash/w25q/config.mk diff --git a/src/platform/rpi/common_rp2/platform/platform.c b/src/platform/rpi/common_rp2/platform/platform.c index 863e017c..5fbd4f5f 100644 --- a/src/platform/rpi/common_rp2/platform/platform.c +++ b/src/platform/rpi/common_rp2/platform/platform.c @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/platform/sifive/common_fe310/hal/clint/clint.c b/src/platform/sifive/common_fe310/hal/clint/clint.c index b62971c9..405d8fe0 100644 --- a/src/platform/sifive/common_fe310/hal/clint/clint.c +++ b/src/platform/sifive/common_fe310/hal/clint/clint.c @@ -74,9 +74,13 @@ status_t clint_config_tcmp(size_t core_id, uint64_t value) uint64_t clint_read_time() { - uint64_t time_stamp; - time_stamp = MMIO64(port->baddr + MTIME_OFFSET); - return time_stamp; + uint32_t th, tl, temp; + do { + temp = MMIO32(port->baddr + MTIME_OFFSET + 4); + tl = MMIO32(port->baddr + MTIME_OFFSET); + th = MMIO32(port->baddr + MTIME_OFFSET + 4); + } while(temp != th); + return ((uint64_t)th << 32) | (uint64_t)(tl); } INCLUDE_DRIVER(plat_clint, clint_setup, clint_exit, 0, 0, 0); diff --git a/src/platform/sifive/common_fe310/platform/platform.c b/src/platform/sifive/common_fe310/platform/platform.c index c743a714..487fedfc 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 #include diff --git a/src/platform/sifive/common_fe310/platform/platform_reset.c b/src/platform/sifive/common_fe310/platform/platform_reset.c index 41e9dd0d..421e3efb 100644 --- a/src/platform/sifive/common_fe310/platform/platform_reset.c +++ b/src/platform/sifive/common_fe310/platform/platform_reset.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include /** * platform_get_reset_syndrome - returns the cause of reset diff --git a/src/visor/build.mk b/src/visor/build.mk index 40820c16..d5ab821c 100644 --- a/src/visor/build.mk +++ b/src/visor/build.mk @@ -11,9 +11,5 @@ 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 +include $(VISOR_DIR)/workers/build.mk +include $(VISOR_DIR)/services/build.mk diff --git a/src/visor/supervisor/services/bootstrap/bootstrap.c b/src/visor/services/bootstrap/bootstrap.c similarity index 86% rename from src/visor/supervisor/services/bootstrap/bootstrap.c rename to src/visor/services/bootstrap/bootstrap.c index bbf24dad..509653a8 100644 --- a/src/visor/supervisor/services/bootstrap/bootstrap.c +++ b/src/visor/services/bootstrap/bootstrap.c @@ -1,6 +1,6 @@ /* * CYANCORE LICENSE - * Copyrights (C) 2019, Cyancore Team + * Copyrights (C) 2024, Cyancore Team * * File Name : bootstrap.c * Description : This file contains sources of bootstrap routine @@ -12,8 +12,8 @@ #include #include #include -#include -#include +#include +#include status_t bootstrap() diff --git a/src/visor/supervisor/services/bootstrap/build.mk b/src/visor/services/bootstrap/build.mk similarity index 100% rename from src/visor/supervisor/services/bootstrap/build.mk rename to src/visor/services/bootstrap/build.mk diff --git a/src/visor/supervisor/services/build.mk b/src/visor/services/build.mk similarity index 54% rename from src/visor/supervisor/services/build.mk rename to src/visor/services/build.mk index 52a497f9..04ba4d08 100644 --- a/src/visor/supervisor/services/build.mk +++ b/src/visor/services/build.mk @@ -1,17 +1,18 @@ # # CYANCORE LICENSE -# Copyrights (C) 2023, Cyancore Team +# Copyrights (C) 2024, Cyancore Team # # File Name : build.mk # Description : This file accumulates the build scripts -# from supervisor services +# from visor services # Primary Author : Akash Kollipara [akashkollipara@gmail.com] # Organisation : Cyancore Core-Team # -S_SERVICES := $(GET_PATH) +V_SERVICES := $(GET_PATH) -include $(S_SERVICES)/bootstrap/build.mk +include $(V_SERVICES)/bootstrap/build.mk +include $(V_SERVICES)/kernel/build.mk -DIR := $(S_SERVICES) +DIR := $(V_SERVICES) include mk/obj.mk diff --git a/src/visor/common/build.mk b/src/visor/services/kernel/build.mk similarity index 56% rename from src/visor/common/build.mk rename to src/visor/services/kernel/build.mk index e47070a4..41d0f45f 100644 --- a/src/visor/common/build.mk +++ b/src/visor/services/kernel/build.mk @@ -1,14 +1,14 @@ # # CYANCORE LICENSE -# Copyrights (C) 2023, Cyancore Team +# Copyrights (C) 2024, Cyancore Team # # File Name : build.mk # Description : This file accumulates the build scripts -# from terravisor directories +# from various kernel # Primary Author : Akash Kollipara [akashkollipara@gmail.com] # Organisation : Cyancore Core-Team # -V_COM_PATH := $(GET_PATH) +KERNEL_DIR := $(GET_PATH) -include $(V_COM_PATH)/workers/build.mk +$(eval $(call check_and_include KHELIOS,$(KERNEL_DIR)/helios/build.mk)) diff --git a/src/visor/terravisor/services/kernel/helios/build.mk b/src/visor/services/kernel/helios/build.mk similarity index 100% rename from src/visor/terravisor/services/kernel/helios/build.mk rename to src/visor/services/kernel/helios/build.mk diff --git a/src/visor/terravisor/services/kernel/helios/helios_heap.c b/src/visor/services/kernel/helios/helios_heap.c similarity index 95% rename from src/visor/terravisor/services/kernel/helios/helios_heap.c rename to src/visor/services/kernel/helios/helios_heap.c index 6942085e..80f33538 100644 --- a/src/visor/terravisor/services/kernel/helios/helios_heap.c +++ b/src/visor/services/kernel/helios/helios_heap.c @@ -11,7 +11,7 @@ /***************************************************** * INCLUDES *****************************************************/ -#include +#include /***************************************************** * GLOBAL/STATIC VARIABLE DECLARATIONS diff --git a/src/visor/terravisor/services/kernel/helios/helios_mutex.c b/src/visor/services/kernel/helios/helios_mutex.c similarity index 99% rename from src/visor/terravisor/services/kernel/helios/helios_mutex.c rename to src/visor/services/kernel/helios/helios_mutex.c index 6c22c647..1fc9e953 100644 --- a/src/visor/terravisor/services/kernel/helios/helios_mutex.c +++ b/src/visor/services/kernel/helios/helios_mutex.c @@ -11,7 +11,7 @@ /***************************************************** * INCLUDES *****************************************************/ -#include +#include /***************************************************** * DEFINE diff --git a/src/visor/terravisor/services/kernel/helios/helios_sched.c b/src/visor/services/kernel/helios/helios_sched.c similarity index 99% rename from src/visor/terravisor/services/kernel/helios/helios_sched.c rename to src/visor/services/kernel/helios/helios_sched.c index 4618948f..df652dde 100644 --- a/src/visor/terravisor/services/kernel/helios/helios_sched.c +++ b/src/visor/services/kernel/helios/helios_sched.c @@ -11,7 +11,7 @@ /***************************************************** * INCLUDES *****************************************************/ -#include +#include #include #include diff --git a/src/visor/terravisor/services/kernel/helios/helios_sem.c b/src/visor/services/kernel/helios/helios_sem.c similarity index 98% rename from src/visor/terravisor/services/kernel/helios/helios_sem.c rename to src/visor/services/kernel/helios/helios_sem.c index 1f198da8..91cdbe5a 100644 --- a/src/visor/terravisor/services/kernel/helios/helios_sem.c +++ b/src/visor/services/kernel/helios/helios_sem.c @@ -11,7 +11,7 @@ /***************************************************** * INCLUDES *****************************************************/ -#include +#include /***************************************************** * GLOBAL/STATIC VARIABLE DECLARATIONS diff --git a/src/visor/terravisor/services/kernel/helios/helios_task_idle.c b/src/visor/services/kernel/helios/helios_task_idle.c similarity index 98% rename from src/visor/terravisor/services/kernel/helios/helios_task_idle.c rename to src/visor/services/kernel/helios/helios_task_idle.c index e3ca613d..c9b4b1cd 100644 --- a/src/visor/terravisor/services/kernel/helios/helios_task_idle.c +++ b/src/visor/services/kernel/helios/helios_task_idle.c @@ -11,7 +11,7 @@ /***************************************************** * INCLUDES *****************************************************/ -#include +#include #include /***************************************************** diff --git a/src/visor/terravisor/services/kernel/helios/helios_tasks.c b/src/visor/services/kernel/helios/helios_tasks.c similarity index 99% rename from src/visor/terravisor/services/kernel/helios/helios_tasks.c rename to src/visor/services/kernel/helios/helios_tasks.c index d06fb61a..908ab639 100644 --- a/src/visor/terravisor/services/kernel/helios/helios_tasks.c +++ b/src/visor/services/kernel/helios/helios_tasks.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include /***************************************************** * DEFINES diff --git a/src/visor/supervisor/build.mk b/src/visor/supervisor/build.mk deleted file mode 100644 index e69de29b..00000000 diff --git a/src/visor/terravisor/README.md b/src/visor/terravisor/README.md deleted file mode 100644 index e69de29b..00000000 diff --git a/src/visor/terravisor/build.mk b/src/visor/terravisor/build.mk deleted file mode 100644 index 54b1c29f..00000000 --- a/src/visor/terravisor/build.mk +++ /dev/null @@ -1,17 +0,0 @@ -# -# CYANCORE LICENSE -# Copyrights (C) 2019, 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 -# - -TERRA_PATH := $(GET_PATH) - -TERRAVISOR := 1 -$(eval $(call add_define,TERRAVISOR)) - -include $(TERRA_PATH)/services/build.mk diff --git a/src/visor/terravisor/services/bootstrap/bootstrap.c b/src/visor/terravisor/services/bootstrap/bootstrap.c deleted file mode 100644 index bbf24dad..00000000 --- a/src/visor/terravisor/services/bootstrap/bootstrap.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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/services/build.mk b/src/visor/terravisor/services/build.mk deleted file mode 100644 index deed033a..00000000 --- a/src/visor/terravisor/services/build.mk +++ /dev/null @@ -1,22 +0,0 @@ -# -# CYANCORE LICENSE -# Copyrights (C) 2022, Cyancore Team -# -# File Name : build.mk -# Description : This file accumulates the build scripts -# from terravisor services -# Primary Author : Akash Kollipara [akashkollipara@gmail.com] -# Organisation : Cyancore Core-Team -# - -T_SERVICES := $(GET_PATH) - -include $(T_SERVICES)/bootstrap/build.mk -include $(T_SERVICES)/driver/build.mk - -ifneq ($(TERRAKERN),0) -include $(T_SERVICES)/kernel/$(TERRAKERN)/build.mk -endif - -DIR := $(T_SERVICES) -include mk/obj.mk diff --git a/src/visor/terravisor/services/driver/build.mk b/src/visor/terravisor/services/driver/build.mk deleted file mode 100644 index 7d4538c2..00000000 --- a/src/visor/terravisor/services/driver/build.mk +++ /dev/null @@ -1,15 +0,0 @@ -# -# CYANCORE LICENSE -# Copyrights (C) 2022, Cyancore Team -# -# File Name : build.mk -# Description : This file builds all the drivers associated -# with terravisor -# Primary Author : Akash Kollipara [akashkollipara@gmail.com] -# Organisation : Cyancore Core-Team -# - -T_DRIVER_DIR := $(GET_PATH) - -DIR := $(T_DRIVER_DIR) -include mk/obj.mk diff --git a/src/visor/common/workers/build.mk b/src/visor/workers/build.mk similarity index 100% rename from src/visor/common/workers/build.mk rename to src/visor/workers/build.mk diff --git a/src/visor/common/workers/vcall/build.mk b/src/visor/workers/vcall/build.mk similarity index 100% rename from src/visor/common/workers/vcall/build.mk rename to src/visor/workers/vcall/build.mk diff --git a/src/visor/common/workers/vcall/visor_call.c b/src/visor/workers/vcall/visor_call.c similarity index 100% rename from src/visor/common/workers/vcall/visor_call.c rename to src/visor/workers/vcall/visor_call.c From daa6ba92c4389b8f42cfbf8fbb14bcbaf2dc1e94 Mon Sep 17 00:00:00 2001 From: Akash Kollipara Date: Mon, 29 Jul 2024 22:54:01 +0530 Subject: [PATCH 2/3] Updated documentation of folders --- src/arch/README.md | 1 - src/arch/avr/8/5/terravisor/README.md | 2 -- src/arch/avr/8/6/terravisor/README.md | 2 -- src/arch/avr/8/common_5x_6/README.md | 4 ++++ src/arch/riscv/32/i/README.md | 5 +---- src/arch/riscv/32/i/terravisor/README.md | 4 ++-- src/arch/riscv/32/imac/terravisor/README.md | 2 -- src/arch/riscv/32/imc/terravisor/README.md | 4 +--- src/driver/README.md | 9 +++++++++ src/driver/console/README.md | 17 +++++++++++++++++ src/visor/README.md | 7 +++++++ src/visor/services/README.md | 3 +++ src/visor/services/bootstrap/README.md | 3 +++ src/visor/services/kernel/README.md | 6 ++++++ 14 files changed, 53 insertions(+), 16 deletions(-) create mode 100644 src/arch/avr/8/common_5x_6/README.md create mode 100644 src/driver/README.md create mode 100644 src/driver/console/README.md create mode 100644 src/visor/README.md create mode 100644 src/visor/services/README.md create mode 100644 src/visor/services/bootstrap/README.md create mode 100644 src/visor/services/kernel/README.md diff --git a/src/arch/README.md b/src/arch/README.md index 32ad0816..ad3de354 100644 --- a/src/arch/README.md +++ b/src/arch/README.md @@ -7,4 +7,3 @@ Home directory for CPU architecture specific sources. #### Supported Architectures * AVR * RISCV -* ARM-M diff --git a/src/arch/avr/8/5/terravisor/README.md b/src/arch/avr/8/5/terravisor/README.md index 01564453..2a40c72c 100644 --- a/src/arch/avr/8/5/terravisor/README.md +++ b/src/arch/avr/8/5/terravisor/README.md @@ -2,6 +2,4 @@ Home directory for avr5 terravisor sources. -For terravisor documentation please read [Terravisor README](../../../../../visor/terravisor/README.md) - Please refer [README.md](../../common_5x_6/terravisor/README.md) in common_5x_6 directory. diff --git a/src/arch/avr/8/6/terravisor/README.md b/src/arch/avr/8/6/terravisor/README.md index d358fe9e..d8cf732b 100644 --- a/src/arch/avr/8/6/terravisor/README.md +++ b/src/arch/avr/8/6/terravisor/README.md @@ -2,6 +2,4 @@ Home directory for avr5 terravisor sources. -For terravisor documentation please read [Terravisor README](../../../../../visor/terravisor/README.md) - Please refer [README.md](../../common_5x_6/terravisor/README.md) in common_5x_6 directory. diff --git a/src/arch/avr/8/common_5x_6/README.md b/src/arch/avr/8/common_5x_6/README.md new file mode 100644 index 00000000..99b199f9 --- /dev/null +++ b/src/arch/avr/8/common_5x_6/README.md @@ -0,0 +1,4 @@ +# AVR-8 Common v5 and v6 + +* Supports Terravisor only. + diff --git a/src/arch/riscv/32/i/README.md b/src/arch/riscv/32/i/README.md index 4522fde5..6e621a48 100644 --- a/src/arch/riscv/32/i/README.md +++ b/src/arch/riscv/32/i/README.md @@ -1,7 +1,4 @@ # RV32 I-Extension (baseline) -* Supports machine, supervisor and undermode as of the commit date. -* Hypervisor aka background supervisor spec is still under development. +* Supports Terravisor (machine mode according to risc-v priv spec). -#### Supported execution levels -* Terravisor (machine layer) diff --git a/src/arch/riscv/32/i/terravisor/README.md b/src/arch/riscv/32/i/terravisor/README.md index 96d3a604..614814c1 100644 --- a/src/arch/riscv/32/i/terravisor/README.md +++ b/src/arch/riscv/32/i/terravisor/README.md @@ -1,10 +1,10 @@ # RV32 I [Terravisor] -* Home directory for RV32 Terravisor sources. +* Home directory for RV32I Terravisor sources. * I being baseline for RV cores, this is a common directory. -* For terravisor documentation please read [Terravisor README](../../../../../visor/terravisor/README.md) #### Highlights * Bootstrap routine is mostly in C * Reduced use of ASM * Exception handling is unified by updated "mtvec" reg with handler address +* In few platforms, mtvec is hard coded to be used in vector mode, to enable that mode just define "RV_VEC_MODE" in build defines. diff --git a/src/arch/riscv/32/imac/terravisor/README.md b/src/arch/riscv/32/imac/terravisor/README.md index 34a1b42f..785608eb 100644 --- a/src/arch/riscv/32/imac/terravisor/README.md +++ b/src/arch/riscv/32/imac/terravisor/README.md @@ -2,6 +2,4 @@ Home directory for RV32imac Terravisor -For terravisor documentation please read [Terravisor README](../../../../../visor/terravisor/README.md) - Please refer [README.md](../../i/terravisor/README.md) in i/terravisor directory. diff --git a/src/arch/riscv/32/imc/terravisor/README.md b/src/arch/riscv/32/imc/terravisor/README.md index 34a1b42f..570b4903 100644 --- a/src/arch/riscv/32/imc/terravisor/README.md +++ b/src/arch/riscv/32/imc/terravisor/README.md @@ -1,7 +1,5 @@ # RV32 IMAC [Terravisor] -Home directory for RV32imac Terravisor - -For terravisor documentation please read [Terravisor README](../../../../../visor/terravisor/README.md) +Home directory for RV32imc Terravisor Please refer [README.md](../../i/terravisor/README.md) in i/terravisor directory. diff --git a/src/driver/README.md b/src/driver/README.md new file mode 100644 index 00000000..df953e06 --- /dev/null +++ b/src/driver/README.md @@ -0,0 +1,9 @@ +# Driver +_This folder houses all the driver directories_ + +Cyancore driver framework requires the platform to provide a memory segment in ram to store driver table. This table consists of all driver entries which are enabled by user during compiler time. These drivers should ideally be started in the startup routine. Driver framework provides other apis which will let user start driver with the help of name of driver. _Refer to driver.c for more info_ + +## Build +- There are 2 types of driver, essential and user-config driver. +- Essential drivers are those which is absolute must to enable minimal functionality of the platform to execute basic code, usually system programs. +- User Config driver are those which can be enabled and can be called in the user programs. diff --git a/src/driver/console/README.md b/src/driver/console/README.md new file mode 100644 index 00000000..d0c67538 --- /dev/null +++ b/src/driver/console/README.md @@ -0,0 +1,17 @@ +# Console Driver + +Console driver provides interfaces to stdout, stdin, stderr and stdlog. The 3 standard devices std(out/in/err) are linked with console device that will be linked with the console driver stars. But for stdlog, the device is linked when the driver calls logger attach routine. _Essentially this directory houses the drivers for consoles._ + +#### Console (L1 Driver) +- This devices connects to std(out/in/err) +- std-devices are used by libc stdio functions +- The underlying hardware is getting linked with the L2 Driver which is present under `con_serial_` folder + +#### Stdlog (L1 Driver) +- This devices connects to stdlog +- stdlog is a system standard logger provided by libsyslog +- By default syslog uses membuf to log system logs + +## Build +- Maitri (cc build engine) requires a unique L2 driver folder which is represented with `con_serial_`, where **family** is Family of Platform/Controller +- If in case the family is absent, a warning will be displayed during build, but the compilation will not fail. diff --git a/src/visor/README.md b/src/visor/README.md new file mode 100644 index 00000000..ee40108b --- /dev/null +++ b/src/visor/README.md @@ -0,0 +1,7 @@ +# Visor + +This folder will contain all the sources for workers and services that can be provided by a visor. + +Its upto user's imagination to use the api's in such a way that they can craft out the visor as per their liking. + +User's are free to write their own OS, hypervisor, terravisor and user space apps based on their requriements. To do this, the user needs to specify the execution mode in the build.mk of the project file. This is necessary to assist visor's sources to integrate correct arch functions. _Note: Onus is on cyancore's developer to be careful regaring naming convention and backward compatibilty of such functions_. Going further, to enable access control, users/developers should make best use of libresources. This can be a powerful tool to build a robust software stack. diff --git a/src/visor/services/README.md b/src/visor/services/README.md new file mode 100644 index 00000000..31a38b03 --- /dev/null +++ b/src/visor/services/README.md @@ -0,0 +1,3 @@ +# Visor - Services + +This folder houses all the sources for kernels, bootstrap routines, etc. Using these api's user must create the software they desire. diff --git a/src/visor/services/bootstrap/README.md b/src/visor/services/bootstrap/README.md new file mode 100644 index 00000000..d4b02022 --- /dev/null +++ b/src/visor/services/bootstrap/README.md @@ -0,0 +1,3 @@ +# Bootstrap + +This is a service provided by visor to enable system to setup the whole platform before it can execute user code. diff --git a/src/visor/services/kernel/README.md b/src/visor/services/kernel/README.md new file mode 100644 index 00000000..65f52af5 --- /dev/null +++ b/src/visor/services/kernel/README.md @@ -0,0 +1,6 @@ +# Kernel + +This directory houses several kernels that cyancore can offer to develop software stack as per user's requirement. + +### Supported Kernels +- Helios From e7584ce9d2c09bd6bdb75192dad6d3f206fffd5a Mon Sep 17 00:00:00 2001 From: Akash Kollipara Date: Tue, 30 Jul 2024 20:20:16 +0530 Subject: [PATCH 3/3] Add build cache to speed up builds --- .github/workflows/github_ci.yml | 13 ++- .gitignore | 1 + Makefile | 2 + mk/ccache.mk | 141 +++++++++++++++++++++++++++++ mk/elf.mk | 4 +- mk/lib.mk | 2 +- mk/lobj.mk | 12 +-- mk/obj.mk | 12 +-- mk/path.mk | 2 +- mk/project.mk | 10 +- mk/slib.mk | 2 +- src/visor/services/kernel/build.mk | 2 +- 12 files changed, 178 insertions(+), 25 deletions(-) create mode 100644 mk/ccache.mk diff --git a/.github/workflows/github_ci.yml b/.github/workflows/github_ci.yml index fcf059dd..b96059d9 100644 --- a/.github/workflows/github_ci.yml +++ b/.github/workflows/github_ci.yml @@ -31,12 +31,12 @@ jobs: - name: Fetch Dependencies run: | - sudo apt install cppcheck -y + sudo apt install cppcheck ccache -y make get_avr_tc make get_riscv_tc - name: Init CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} debug: true @@ -51,10 +51,13 @@ jobs: make demo_qemu_sifive_e make demo_ibex_ss + - name: Build Cache Stats + run: | + make show_ccache_stats + - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 - name: Clean Up run: | - make clean - rm -rf toolchain + make clean_workspace diff --git a/.gitignore b/.gitignore index 07daea91..a1d1fe4e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ tools/ backup/ bkp/ projects/ +.buildcache/ *.elf *.bin *.d diff --git a/Makefile b/Makefile index 6c93a73f..e1416d47 100644 --- a/Makefile +++ b/Makefile @@ -15,11 +15,13 @@ SHELL := /bin/bash N_JOBS ?= $(shell grep -c ^processor /proc/cpuinfo) HOST_ARCH := $(shell lscpu | grep -Po '(?<='Architecture:' )[^"]*') +EN_BUILD_CACHE ?= 1 V ?= 0 PP ?= 0 include mk/help.mk include mk/path.mk +include mk/ccache.mk include mk/tc_get.mk include mk/project.mk diff --git a/mk/ccache.mk b/mk/ccache.mk new file mode 100644 index 00000000..ab594f39 --- /dev/null +++ b/mk/ccache.mk @@ -0,0 +1,141 @@ +# +# CYANCORE LICENSE +# Copyrights (C) 2024, Cyancore Team +# +# File Name : ccache.mk +# Description : This file provides recipes for build cache +# Primary Author : Akash Kollipara [akashkollipara@gmail.com] +# Organisation : Cyancore Core-Team +# + +#*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*# +#--------------< Build Cache >--------------# +#*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*# + +CCACHE_DIR := $(CC_ROOT)/.buildcache + +# For Flags read ccache documentation +CCACHE_ABSSTDERR := true +export CCACHE_ABSSTDERR +CCACHE_BASEDIR := +export CCACHE_BASEDIR +CCACHE_DIR := $(CCACHE_DIR)/cache +export CCACHE_DIR +CCACHE_COMPILER := +export CCACHE_COMPILER +CCACHE_COMPILERCHECK := mtime +export CCACHE_COMPILERCHECK +CCACHE_COMPILERTYPE := auto +export CCACHE_COMPILERTYPE +export CCACHE_COMPRESS +CCACHE_COMPRESSLEVEL := 0 +export CCACHE_COMPRESSLEVEL +CCACHE_EXTENSION := +export CCACHE_EXTENSION +# export CCACHE_DEBUG +export CCACHE_NODEBUG +CCACHE_DEBUGDIR := $(CCACHE_DIR)/dbg +export CCACHE_DEBUGDIR +CCACHE_DEBUGLEVEL := 2 +export CCACHE_DEBUGLEVEL +# export CCACHE_DEPEND +export CCACHE_NODEPEND +export CCACHE_DIRECT +# export CCACHE_NODIRECT +# export CCACHE_DISABLE +export CCACHE_NODISABLE +CCACHE_EXTRAFILES := +export CCACHE_EXTRAFILES +# export CCACHE_FILECLONE +export CCACHE_NOFILECLONE +# export CCACHE_HARDLINK +export CCACHE_NOHARDLINK +export CCACHE_HASHDIR +# export CCACHE_NOHASHDIR +CCACHE_IGNOREHEADERS := +export CCACHE_IGNOREHEADERS +CCACHE_IGNOREOPTIONS := +export CCACHE_IGNOREOPTIONS +# export CCACHE_INODECACHE +export CCACHE_NOINODECACHE +# export CCACHE_COMMENTS +export CCACHE_NOCOMMENTS +CCACHE_LOGFILE := $(CCACHE_DIR)/log +export CCACHE_LOGFILE +CCACHE_MAXFILES := 0 +export CCACHE_MAXFILES +CCACHE_MAXSIZE := 1.0 GiB +export CCACHE_MAXSIZE +CCACHE_MSVC_DEP_PREFIX := Note: including file: +export CCACHE_MSVC_DEP_PREFIX +CCACHE_NAMESPACE := cyancore +export CCACHE_NAMESPACE +CCACHE_PATH := +export CCACHE_PATH +# export CCACHE_PCH_EXTSUM +export CCACHE_NOPCH_EXTSUM +CCACHE_PREFIX := +export CCACHE_PREFIX +CCACHE_PREFIX_CPP := +export CCACHE_PREFIX_CPP +# export CCACHE_READONLY +export CCACHE_NOREADONLY +# export CCACHE_READONLY_DIRECT +export CCACHE_NOREADONLY_DIRECT +# export CCACHE_RECACHE +export CCACHE_NORECACHE +# export CCACHE_REMOTE_ONLY +export CCACHE_NOREMOTE_ONLY +CCACHE_REMOTE_STORAGE := +export CCACHE_REMOTE_STORAGE +# export CCACHE_RESHARE +export CCACHE_NORESHARE +export CCACHE_CPP2 +# export CCACHE_NOCPP2 +CCACHE_SLOPPINESS := +export CCACHE_SLOPPINESS +# export CCACHE_NOSTATS +export CCACHE_STATS +export CCACHE_STATSLOG := $(CCACHE_DIR)/stats +export CCACHE_TEMPDIR := $(CCACHE_DIR)/ +CCACHE_UMASK := +export CCACHE_UMASK + + +ifeq ($(EN_BUILD_CACHE),1) +CCACHE := ccache + +T_ALLOWLIST += show_ccache_config show_ccache_stats clean_ccache + +CHECK_CCACHE := $(shell which $(CCACHE)) +ifeq ($(CHECK_CCACHE),) +$(info < ! > ccache is not installed!) +$(error < x > Stopping build.) +endif + +show_ccache_stats: +ifneq ($(realpath $(CCACHE_LOGFILE)),) + $(CCACHE) -s -x -v +else + $(info < ! > No log file present, try to perform build and try!) +endif + +show_ccache_config: --prepare-cache + $(CCACHE) -p + +clean_ccache: +ifneq ($(realpath $(CCACHE_LOGFILE)),) + $(CCACHE) -c -C -z +else + $(info < ! > No log file present, try to perform build and try!) +endif + + +.PHONY: --prepare-cache +--prepare-cache: $(CCACHE_LOGFILE) + +.SECONDEXPANSION: +$(CCACHE_LOGFILE): | $$(@D)/ + touch $@ +endif + diff --git a/mk/elf.mk b/mk/elf.mk index 0ce895d0..a847e263 100644 --- a/mk/elf.mk +++ b/mk/elf.mk @@ -29,7 +29,7 @@ elf: $(ELF) .SECONDEXPANSION: $(ELF): $(DEP_LIBS) $(DEP_OBJS) $(LD_SCRIPT) $(LD_SUPPLEMENT) | $$(SIZE) @echo "Elf: Generating $(@F) ..." - $(LD) -dT $(LD_SCRIPT) $(addprefix -T , $(LD_SUPPLEMENT)) $(LD_FLAGS) \ + $(CCACHE) $(LD) -dT $(LD_SCRIPT) $(addprefix -T , $(LD_SUPPLEMENT)) $(LD_FLAGS) \ -Map=$(@:.elf=.map) -o $@ $(filter %.o, $^) $(DEP_LIB_PATH) $(DEP_LIBS_ARG) $(EXLIB_ARGS) -L $(TL) -lgcc $(OD) -Dx -h --wide $@ > $(@:.elf=.lst) $(OC) -O binary $@ $(@:.elf=.bin) @@ -40,5 +40,5 @@ $(ELF): $(DEP_LIBS) $(DEP_OBJS) $(LD_SCRIPT) $(LD_SUPPLEMENT) | $$(SIZE) $(OUT)/%.ld: %.ld.sx mkdir -p $(@D) @echo "Elf: Preprocessing $(@F) ..." - $(CC) $(CFLAGS) -E -P -o $@ $< + $(CCACHE) $(CC) $(CFLAGS) -E -P -o $@ $< diff --git a/mk/lib.mk b/mk/lib.mk index 05278625..e94493c1 100644 --- a/mk/lib.mk +++ b/mk/lib.mk @@ -22,7 +22,7 @@ AR_FLAGS ?= rcs $(LIB): $(LIB_OBJS) | $$(@D)/ @echo "Lib: Generating $(@F) ..." - $(AR) $(AR_FLAGS) $@ $^ + $(CCACHE) $(AR) $(AR_FLAGS) $@ $^ LIB_INCLUDE_PATH:= LIB_OBJS := diff --git a/mk/lobj.mk b/mk/lobj.mk index 95f50be1..2df808a6 100644 --- a/mk/lobj.mk +++ b/mk/lobj.mk @@ -28,21 +28,21 @@ DEP_SRCS += $(C_SRCS) $(CPP_SRCS) $(CPP_OBJS): $(OUT)/%.o: %.cpp | $$(@D)/ @echo "Elf: Compiling $(@F:.o=.cpp) ..." ifeq ($(PP),1) - $(CCP) $(CPPFLAGS) $(CFLAGS) -E -p $< -o $(@:.o=.pre.cpp) + $(CCACHE) $(CCP) $(CPPFLAGS) $(CFLAGS) -E -p $< -o $(@:.o=.pre.cpp) endif - $(CCP) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ + $(CCACHE) $(CCP) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ $(C_OBJS): $(OUT)/%.o: %.c | $$(@D)/ @echo "Lib: Compiling $(@F:.o=.c) ..." ifeq ($(PP),1) - $(CC) $(CCFLAGS) $(CFLAGS) -E -p $< -o $(@:.o=.pre.c) + $(CCACHE) $(CC) $(CCFLAGS) $(CFLAGS) -E -p $< -o $(@:.o=.pre.c) endif - $(CC) $(CCFLAGS) $(CFLAGS) -c $< -o $@ + $(CCACHE) $(CC) $(CCFLAGS) $(CFLAGS) -c $< -o $@ $(S_OBJS): $(OUT)/%.o: %.S | $$(@D)/ @echo "Lib: Assembling $(@F:.o=.S) ..." - $(CC) -E $(CCFLAGS) $(CFLAGS) -c $< -o $(@:.o=.pre.S) - $(AS) $(ASFLAGS) $(@:.o=.pre.S) -o $@ + $(CCACHE) $(CC) -E $(CCFLAGS) $(CFLAGS) -c $< -o $(@:.o=.pre.S) + $(CCACHE) $(AS) $(ASFLAGS) $(@:.o=.pre.S) -o $@ ifneq ($(PP),1) rm $(@:.o=.pre.S) endif diff --git a/mk/obj.mk b/mk/obj.mk index 11a9a856..89a12000 100644 --- a/mk/obj.mk +++ b/mk/obj.mk @@ -28,21 +28,21 @@ DEP_SRCS += $(C_SRCS) $(CPP_SRCS) $(CPP_OBJS): $(OUT)/%.o: %.cpp | $$(@D)/ @echo "Elf: Compiling $(@F:.o=.cpp) ..." ifeq ($(PP),1) - $(CCP) $(CPPFLAGS) $(CFLAGS) -E -p $< -o $(@:.o=.pre.cpp) + $(CCACHE) $(CCP) $(CPPFLAGS) $(CFLAGS) -E -p $< -o $(@:.o=.pre.cpp) endif - $(CCP) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ + $(CCACHE) $(CCP) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ $(C_OBJS): $(OUT)/%.o: %.c | $$(@D)/ @echo "Elf: Compiling $(@F:.o=.c) ..." ifeq ($(PP),1) - $(CC) $(CCFLAGS) $(CFLAGS) -E -p $< -o $(@:.o=.pre.c) + $(CCACHE) $(CC) $(CCFLAGS) $(CFLAGS) -E -p $< -o $(@:.o=.pre.c) endif - $(CC) $(CCFLAGS) $(CFLAGS) -c $< -o $@ + $(CCACHE) $(CC) $(CCFLAGS) $(CFLAGS) -c $< -o $@ $(S_OBJS): $(OUT)/%.o: %.S | $$(@D)/ @echo "Elf: Assembling $(@F:.o=.S) ..." - $(CC) -E $(CCFLAGS) $(CFLAGS) -c $< -o $(@:.o=.pre.S) - $(AS) $(ASFLAGS) $(@:.o=.pre.S) -o $@ + $(CCACHE) $(CC) -E $(CCFLAGS) $(CFLAGS) -c $< -o $(@:.o=.pre.S) + $(CCACHE) $(AS) $(ASFLAGS) $(@:.o=.pre.S) -o $@ ifneq ($(PP),1) rm $(@:.o=.pre.S) endif diff --git a/mk/path.mk b/mk/path.mk index 24318b40..2e3383a6 100644 --- a/mk/path.mk +++ b/mk/path.mk @@ -23,5 +23,5 @@ OUT ?= $(OUT_PATH)/$(PROJECT) GET_PATH = $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) -$(OUT)/%/: +./%/: mkdir -p $@ diff --git a/mk/project.mk b/mk/project.mk index f9148fdc..795fc940 100644 --- a/mk/project.mk +++ b/mk/project.mk @@ -18,7 +18,7 @@ include mk/qemu.mk include mk/picotool.mk P_TARGETS += default cyancore check version copy_to_remote clean_remote -T_ALLOWLIST += list clean all_projects +T_ALLOWLIST += list clean all_projects clean_workspace setup_workspace PROJECT_LIST := $(shell ls projects/ -I *.template -I *.src) .PHONY: aux_target @@ -33,13 +33,19 @@ all_projects: make $$project; \ done -cyancore: version elf +cyancore: --prepare-cache version elf $(info < / > Done !) clean: $(info < ! > Removing $(PROJECT) binaries ...) rm -rf $(OUT) +setup_workspace: $(SIZE) get_qemu get_all_tc + +clean_workspace: clean + $(info < / > Cleaning up workspace ...) + rm -rf $(CCACHE_DIR) $(TOOLS_ROOT) + list: $(info Available projects are :) echo $(PROJECT_LIST) diff --git a/mk/slib.mk b/mk/slib.mk index 3382b067..ede8f6b5 100644 --- a/mk/slib.mk +++ b/mk/slib.mk @@ -22,7 +22,7 @@ slib: $(SLIB) $(SLIB): $(HEADER) $(LIB_OBJS) echo "Generating $(notdir $@) ..." - $(LD) --shared -Wl,-soname,$(notdir $@) -o $@ $< + $(CCACHE) $(LD) --shared -Wl,-soname,$(notdir $@) -o $@ $< $(HEADER): --dependency cp $@ $(OUT) diff --git a/src/visor/services/kernel/build.mk b/src/visor/services/kernel/build.mk index 41d0f45f..58f18c55 100644 --- a/src/visor/services/kernel/build.mk +++ b/src/visor/services/kernel/build.mk @@ -11,4 +11,4 @@ KERNEL_DIR := $(GET_PATH) -$(eval $(call check_and_include KHELIOS,$(KERNEL_DIR)/helios/build.mk)) +$(eval $(call check_and_include,KHELIOS,$(KERNEL_DIR)/helios/build.mk))