From e78966691d04d6e742b8b911193d73af6e2b78ac Mon Sep 17 00:00:00 2001 From: Akash Kollipara Date: Sat, 20 Jul 2024 16:15:32 +0530 Subject: [PATCH 1/8] Cleaned up functions --- projects/demo.src/project.c | 2 +- src/driver/sysclk/sysclk_prci/sysclk_prci.c | 12 +++---- src/include/hal/adc.h | 12 +++---- src/include/hal/prci.h | 32 +++++++++---------- src/include/hal/spi.h | 6 ++-- src/lib/libc/malloc_lite.c | 2 +- src/lib/liblocks/bakerylock.c | 4 +-- src/lib/libnmath/arithmetic/arithmetic.c | 2 +- src/lib/libnmath/include/nmath.h | 2 +- src/platform/mega_avr/common/hal/adc/adc.c | 28 ++++++++-------- src/platform/mega_avr/common/hal/spi/spi.c | 8 ++--- src/platform/mega_avr/common/hal/uart/uart.c | 2 +- .../sifive/common_fe310/hal/prci/hfosc.c | 14 ++++---- .../sifive/common_fe310/hal/prci/pll.c | 20 ++++++------ 14 files changed, 73 insertions(+), 73 deletions(-) diff --git a/projects/demo.src/project.c b/projects/demo.src/project.c index ce3caee7..ed59f153 100644 --- a/projects/demo.src/project.c +++ b/projects/demo.src/project.c @@ -29,7 +29,7 @@ void plug() void play() { static unsigned char i = 0; - char progress[] = "-\\|/"; + const char progress[] = "-\\|/"; uint64_t time; char c = progress[(i++) % strlen(progress)]; get_timestamp(&time); diff --git a/src/driver/sysclk/sysclk_prci/sysclk_prci.c b/src/driver/sysclk/sysclk_prci/sysclk_prci.c index 50ffade3..a01843ae 100644 --- a/src/driver/sysclk/sysclk_prci/sysclk_prci.c +++ b/src/driver/sysclk/sysclk_prci/sysclk_prci.c @@ -108,7 +108,7 @@ INCLUDE_DRIVER(sysclk_prci, sysclk_setup, sysclk_disable, 0, 1, 1); status_t sysclk_reset() { status_t ret; - sysclk_port_t *port = sysclk; + const sysclk_port_t *port = sysclk; istate_t ist; RET_ON_FAIL(port && port->baddr && port->base_clk, @@ -133,7 +133,7 @@ status_t sysclk_reset() static inline void sysclk_set_internal(unsigned int clk _UNUSED) { status_t ret; - sysclk_port_t *port = sysclk; + const sysclk_port_t *port = sysclk; ret = prci_hfxocs_enable(port); prci_pll_bypass(port); ret |= prci_hfosc_enable(port); @@ -150,7 +150,7 @@ static inline void sysclk_set_internal(unsigned int clk _UNUSED) static inline void sysclk_set_external(void) { status_t ret; - sysclk_port_t *port = sysclk; + const sysclk_port_t *port = sysclk; ret = prci_hfosc_enable(port); ret |= prci_hfxocs_enable(port); prci_pll_select_xosc(port); @@ -165,7 +165,7 @@ static inline void sysclk_set_external(void) static inline void sysclk_set_pll(unsigned int clk) { status_t ret; - sysclk_port_t *port = sysclk; + const sysclk_port_t *port = sysclk; ret = prci_hfosc_enable(port); ret |= prci_hfxocs_enable(port); prci_pll_bypass(port); @@ -181,7 +181,7 @@ static inline void sysclk_set_pll(unsigned int clk) 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; + const sysclk_port_t *port = sysclk; istate_t ist; clock_type_t type = (clock_type_t) a0; unsigned int clk = (unsigned int) a1; @@ -227,7 +227,7 @@ 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, vret_t *ret) { - sysclk_port_t *port = sysclk; + const sysclk_port_t *port = sysclk; istate_t ist; unsigned int getclk; diff --git a/src/include/hal/adc.h b/src/include/hal/adc.h index 9755b6fc..7c8dc818 100644 --- a/src/include/hal/adc.h +++ b/src/include/hal/adc.h @@ -47,10 +47,10 @@ typedef struct adc_port } adc_port_t; status_t adc_setup(adc_port_t *); -status_t adc_shutdown(adc_port_t *); -bool adc_busy(adc_port_t *); -status_t adc_int_en(adc_port_t *); -status_t adc_int_dis(adc_port_t *); -status_t adc_config_pin(adc_port_t *, uint8_t, adc_trig_t, uint8_t, adc_ref_t); -status_t adc_read(adc_port_t *, uint16_t *); +status_t adc_shutdown(const adc_port_t *); +bool adc_busy(const adc_port_t *); +status_t adc_int_en(const adc_port_t *); +status_t adc_int_dis(const adc_port_t *); +status_t adc_config_pin(const adc_port_t *, uint8_t, adc_trig_t, uint8_t, adc_ref_t); +status_t adc_read(const adc_port_t *, uint16_t *); status_t adc_temperature_convert(uint16_t, float *); diff --git a/src/include/hal/prci.h b/src/include/hal/prci.h index 69bf41eb..1e303aea 100644 --- a/src/include/hal/prci.h +++ b/src/include/hal/prci.h @@ -2,7 +2,7 @@ * CYANCORE LICENSE * Copyrights (C) 2022, Cyancore Team * - * File Name : sysclk.h + * File Name : prci.h * Description : This file consists of SYSCLK prototypes * Primary Author : Akash Kollipara [akashkollipara@gmail.com] * Organisation : Cyancore Core-Team @@ -31,22 +31,22 @@ typedef struct sysclk_port lock_t key; } sysclk_port_t; -void prci_pll_set_clk(sysclk_port_t *port, unsigned int clk); -status_t prci_pll_get_clk(sysclk_port_t *port, unsigned int *clk); -void prci_pll_select_xosc(sysclk_port_t *port); -void prci_pll_select_rosc(sysclk_port_t *port); -void prci_pll_select_pll(sysclk_port_t *port); -void prci_pll_deselect_pll(sysclk_port_t *port); -void prci_pll_bypass(sysclk_port_t *port); -void prci_pll_inline(sysclk_port_t *port); +void prci_pll_set_clk(const sysclk_port_t *port, unsigned int clk); +status_t prci_pll_get_clk(const sysclk_port_t *port, unsigned int *clk); +void prci_pll_select_xosc(const sysclk_port_t *port); +void prci_pll_select_rosc(const sysclk_port_t *port); +void prci_pll_select_pll(const sysclk_port_t *port); +void prci_pll_deselect_pll(const sysclk_port_t *port); +void prci_pll_bypass(const sysclk_port_t *port); +void prci_pll_inline(const sysclk_port_t *port); -status_t prci_hfxocs_enable(sysclk_port_t *port); -status_t prci_hfxocs_disable(sysclk_port_t *port); +status_t prci_hfxocs_enable(const sysclk_port_t *port); +status_t prci_hfxocs_disable(const sysclk_port_t *port); -status_t prci_hfosc_enable(sysclk_port_t *port); -status_t prci_hfosc_disable(sysclk_port_t *port); -status_t prci_hfosc_set_clk(sysclk_port_t *port, unsigned int clk); -status_t prci_hfosc_get_clk(sysclk_port_t *port, unsigned int *clk); +status_t prci_hfosc_enable(const sysclk_port_t *port); +status_t prci_hfosc_disable(const sysclk_port_t *port); +status_t prci_hfosc_set_clk(const sysclk_port_t *port, unsigned int clk); +status_t prci_hfosc_get_clk(const sysclk_port_t *port, unsigned int *clk); #ifdef OEM -status_t prci_hfosc_set_trim(sysclk_port_t *port, unsigned int trim); +status_t prci_hfosc_set_trim(const sysclk_port_t *port, unsigned int trim); #endif diff --git a/src/include/hal/spi.h b/src/include/hal/spi.h index a538d6d0..23b91301 100644 --- a/src/include/hal/spi.h +++ b/src/include/hal/spi.h @@ -49,8 +49,8 @@ typedef struct spi_port status_t spi_master_setup(spi_port_t *, dataframe_format_t, clk_pol_t, clk_ph_t); status_t spi_slave_setup(spi_port_t *, dataframe_format_t, clk_pol_t, clk_ph_t); -bool spi_trx_done(spi_port_t *); +bool spi_trx_done(const spi_port_t *); status_t spi_int_en(spi_port_t *); status_t spi_int_dis(spi_port_t *); -status_t spi_tx(spi_port_t *, char); -status_t spi_rx(spi_port_t *, char *); +status_t spi_tx(const spi_port_t *, char); +status_t spi_rx(const spi_port_t *, char *); diff --git a/src/lib/libc/malloc_lite.c b/src/lib/libc/malloc_lite.c index 7118dc18..0ae83d48 100644 --- a/src/lib/libc/malloc_lite.c +++ b/src/lib/libc/malloc_lite.c @@ -161,7 +161,7 @@ void *realloc(void *p, size_t n_bytes) return NULL; } - chunk_t *header = get_header(p); + const chunk_t *header = get_header(p); void *new_p = malloc(n_bytes); if(!new_p) return NULL; diff --git a/src/lib/liblocks/bakerylock.c b/src/lib/liblocks/bakerylock.c index dfca1a61..575cc6c0 100644 --- a/src/lib/liblocks/bakerylock.c +++ b/src/lib/liblocks/bakerylock.c @@ -10,10 +10,10 @@ void bakerylock_acquire(bakerylock_t *key) key->protect[tid] = 1; arch_dmb(); - unsigned int i, n_cust, n_max = 0; + unsigned int i, n_max = 0; for(i = 0; i < N_CORES; i++) { - n_cust = key->thread_count[i]; + size_t n_cust = key->thread_count[i]; n_max = n_cust > n_max ? n_cust : n_max; } diff --git a/src/lib/libnmath/arithmetic/arithmetic.c b/src/lib/libnmath/arithmetic/arithmetic.c index 0e2aceaa..5f15c2ac 100644 --- a/src/lib/libnmath/arithmetic/arithmetic.c +++ b/src/lib/libnmath/arithmetic/arithmetic.c @@ -50,7 +50,7 @@ unsigned long gcd(unsigned long a, unsigned long b) * * @return lcm: returns the LCM of the elements in the array */ -unsigned long lcm(unsigned int *a, unsigned int n) +unsigned long lcm(const unsigned int *a, unsigned int n) { unsigned long ret = a[0]; unsigned int i; diff --git a/src/lib/libnmath/include/nmath.h b/src/lib/libnmath/include/nmath.h index 6de51482..76dc45ce 100644 --- a/src/lib/libnmath/include/nmath.h +++ b/src/lib/libnmath/include/nmath.h @@ -12,7 +12,7 @@ #include unsigned int clog2(unsigned long num); unsigned long gcd(unsigned long a, unsigned long b); -unsigned long lcd(unsigned int *a, unsigned int n); +unsigned long lcd(const unsigned int *a, unsigned int n); long mod(long a, long b); long multiplicative_inverse(long base, long subject); int abs(int x); diff --git a/src/platform/mega_avr/common/hal/adc/adc.c b/src/platform/mega_avr/common/hal/adc/adc.c index e710e907..703198d8 100644 --- a/src/platform/mega_avr/common/hal/adc/adc.c +++ b/src/platform/mega_avr/common/hal/adc/adc.c @@ -29,7 +29,7 @@ * @param[in] port: Pointer to the ADC port structure */ -static inline void _adc_enable(adc_port_t *port) +static inline void _adc_enable(const adc_port_t *port) { MMIO8(port->baddr + ADCSRA_OFFSET) |= (1 << ADEN); } @@ -42,7 +42,7 @@ static inline void _adc_enable(adc_port_t *port) * @param[in] port: Pointer to the ADC port structure */ -static inline void _adc_disable(adc_port_t *port) +static inline void _adc_disable(const adc_port_t *port) { MMIO8(port->baddr + ADCSRA_OFFSET) &= ~(1 << ADEN); } @@ -57,7 +57,7 @@ static inline void _adc_disable(adc_port_t *port) * @return status: Status of prescaler setup operation */ -static inline status_t _adc_set_prescaler(adc_port_t *port) +static inline status_t _adc_set_prescaler(const adc_port_t *port) { uint8_t pscale_value = 0; status_t ret = success; @@ -99,7 +99,7 @@ static inline status_t _adc_set_prescaler(adc_port_t *port) * @param[in] port: Pointer to the ADC port structure */ -static inline void _adc_start_conv(adc_port_t *port) +static inline void _adc_start_conv(const adc_port_t *port) { MMIO8(port->baddr + ADCSRA_OFFSET) |= (1 << ADSC); } @@ -115,7 +115,7 @@ static inline void _adc_start_conv(adc_port_t *port) * @return status: Status of trigger configuration operation */ -static inline status_t _adc_config_trigger(adc_port_t *port, adc_trig_t trigger) +static inline status_t _adc_config_trigger(const adc_port_t *port, adc_trig_t trigger) { status_t ret = success; uint8_t trig_value = (uint8_t) trigger; @@ -137,7 +137,7 @@ static inline status_t _adc_config_trigger(adc_port_t *port, adc_trig_t trigger) * @return status: Status of resolution configuration operation */ -static inline status_t _adc_config_resolution(adc_port_t *port, uint8_t resolution) +static inline status_t _adc_config_resolution(const adc_port_t *port, uint8_t resolution) { status_t ret = success; if(resolution == 8) @@ -158,7 +158,7 @@ static inline status_t _adc_config_resolution(adc_port_t *port, uint8_t resoluti * @return status: Status of voltage reference configuration operation */ -static inline status_t _adc_config_vref(adc_port_t *port, adc_ref_t vref) +static inline status_t _adc_config_vref(const adc_port_t *port, adc_ref_t vref) { status_t ret = success; uint8_t value = 0; @@ -216,7 +216,7 @@ status_t adc_setup(adc_port_t *port) * @return status: Status of shutdown operation */ -status_t adc_shutdown(adc_port_t *port) +status_t adc_shutdown(const adc_port_t *port) { status_t ret = success; STATUS_CHECK_POINTER(port); @@ -236,7 +236,7 @@ status_t adc_shutdown(adc_port_t *port) * @return state: State of ADC busy status */ -bool adc_busy(adc_port_t *port) +bool adc_busy(const adc_port_t *port) { bool ret; assert(port); @@ -254,7 +254,7 @@ bool adc_busy(adc_port_t *port) * @return status: Status of interrupt enable operation */ -status_t adc_int_en(adc_port_t *port) +status_t adc_int_en(const adc_port_t *port) { STATUS_CHECK_POINTER(port); MMIO8(port->baddr + ADCSRA_OFFSET) |= (1 << ADIE); @@ -271,7 +271,7 @@ status_t adc_int_en(adc_port_t *port) * @return status: Status of interrupt disable operation */ -status_t adc_int_dis(adc_port_t *port) +status_t adc_int_dis(const adc_port_t *port) { STATUS_CHECK_POINTER(port); MMIO8(port->baddr + ADCSRA_OFFSET) &= ~(1 << ADIE); @@ -292,7 +292,7 @@ status_t adc_int_dis(adc_port_t *port) * @return status: Status of pin configuration operation */ -status_t adc_config_pin(adc_port_t *port, uint8_t pin, adc_trig_t trigger, uint8_t resolution, adc_ref_t vref) +status_t adc_config_pin(const adc_port_t *port, uint8_t pin, adc_trig_t trigger, uint8_t resolution, adc_ref_t vref) { status_t ret = success; STATUS_CHECK_POINTER(port); @@ -317,7 +317,7 @@ status_t adc_config_pin(adc_port_t *port, uint8_t pin, adc_trig_t trigger, uint8 * @return status: Status of read operation */ -status_t adc_read(adc_port_t *port, uint16_t *adc_val) +status_t adc_read(const adc_port_t *port, uint16_t *adc_val) { status_t ret = success; STATUS_CHECK_POINTER(port); @@ -351,7 +351,7 @@ status_t adc_read(adc_port_t *port, uint16_t *adc_val) status_t adc_temperature_convert(uint16_t raw_adc, float *temperature) { status_t ret = success; - unsigned long scaled_val = raw_adc * 1000; + unsigned long scaled_val = (unsigned long)raw_adc * 1000; *temperature = ((float)(scaled_val - CTO) / CTK); return ret; } diff --git a/src/platform/mega_avr/common/hal/spi/spi.c b/src/platform/mega_avr/common/hal/spi/spi.c index 6209d361..daf467d9 100644 --- a/src/platform/mega_avr/common/hal/spi/spi.c +++ b/src/platform/mega_avr/common/hal/spi/spi.c @@ -142,7 +142,7 @@ status_t spi_slave_setup(spi_port_t *port, dataframe_format_t df_format, clk_pol * @return state: State of the write collision error (true = error, false = no error) */ -bool spi_wcol_error(spi_port_t *port) +bool spi_wcol_error(const spi_port_t *port) { assert(port); return (MMIO8(port->baddr + SPSR_OFFSET) & (1 << WCOL)) ? true : false; @@ -158,7 +158,7 @@ bool spi_wcol_error(spi_port_t *port) * @return state: State of the transaction completion (true = completed, false = not completed) */ -bool spi_trx_done(spi_port_t *port) +bool spi_trx_done(const spi_port_t *port) { assert(port); return (MMIO8(port->baddr + SPSR_OFFSET) & (1 << SPIF)) ? true : false; @@ -209,7 +209,7 @@ status_t spi_int_dis(spi_port_t * port) * @return status: Status of data transmission operation */ -status_t spi_tx(spi_port_t *port, char data) +status_t spi_tx(const spi_port_t *port, char data) { STATUS_CHECK_POINTER(port); MMIO8(port->baddr + SPDR_OFFSET) = data; @@ -227,7 +227,7 @@ status_t spi_tx(spi_port_t *port, char data) * @return status: Status of data reception operation */ -status_t spi_rx(spi_port_t *port, char *data) +status_t spi_rx(const spi_port_t *port, char *data) { STATUS_CHECK_POINTER(port); STATUS_CHECK_POINTER(data); diff --git a/src/platform/mega_avr/common/hal/uart/uart.c b/src/platform/mega_avr/common/hal/uart/uart.c index 3db3afc9..c0147f9f 100644 --- a/src/platform/mega_avr/common/hal/uart/uart.c +++ b/src/platform/mega_avr/common/hal/uart/uart.c @@ -47,7 +47,7 @@ status_t uart_setup(uart_port_t *port, direction_t d, parity_t p) arch_visor_call(fetch_dp, clock, 0, 0, &vres); if(vres.status != success) return vres.status; - unsigned long *clk = (unsigned long *)vres.p; + const unsigned long *clk = (unsigned long *)vres.p; // Enable module based on direction diff --git a/src/platform/sifive/common_fe310/hal/prci/hfosc.c b/src/platform/sifive/common_fe310/hal/prci/hfosc.c index 7ca0d5e2..a0911b6b 100644 --- a/src/platform/sifive/common_fe310/hal/prci/hfosc.c +++ b/src/platform/sifive/common_fe310/hal/prci/hfosc.c @@ -20,7 +20,7 @@ INFO(< I > Using ICLK = 72Mhz) #endif -status_t _NOINLINE prci_hfxocs_enable(sysclk_port_t *port) +status_t _NOINLINE prci_hfxocs_enable(const sysclk_port_t *port) { /* Enable External Crystal Osc (xtal) */ MMIO32(port->baddr + HFXOSCCFG_OFFSET) |= (1U << HFXOSCEN); @@ -30,7 +30,7 @@ status_t _NOINLINE prci_hfxocs_enable(sysclk_port_t *port) success : error_system; } -status_t _NOINLINE prci_hfxocs_disable(sysclk_port_t *port) +status_t _NOINLINE prci_hfxocs_disable(const sysclk_port_t *port) { /* Disable External Crystal Osc (xtal) */ MMIO32(port->baddr + HFXOSCCFG_OFFSET) &= ~(1U << HFXOSCEN); @@ -38,7 +38,7 @@ status_t _NOINLINE prci_hfxocs_disable(sysclk_port_t *port) error_system : success; } -status_t _NOINLINE prci_hfosc_enable(sysclk_port_t *port) +status_t _NOINLINE prci_hfosc_enable(const sysclk_port_t *port) { MMIO32(port->baddr + HFROSCCFG_OFFSET) |= (1U << HFROSCEN); while(!(MMIO32(port->baddr + HFROSCCFG_OFFSET) & (1U << HFROSCRDY))); @@ -46,14 +46,14 @@ status_t _NOINLINE prci_hfosc_enable(sysclk_port_t *port) success : error_system; } -status_t _NOINLINE prci_hfosc_disable(sysclk_port_t *port) +status_t _NOINLINE prci_hfosc_disable(const sysclk_port_t *port) { MMIO32(port->baddr + HFROSCCFG_OFFSET) &= ~(1U << HFROSCEN); return (MMIO32(port->baddr + HFROSCCFG_OFFSET) & (1U << HFROSCEN)) ? error_system : success; } -status_t _NOINLINE prci_hfosc_set_clk(sysclk_port_t *port, unsigned int clk) +status_t _NOINLINE prci_hfosc_set_clk(const sysclk_port_t *port, unsigned int clk) { unsigned int hfrosc; unsigned int divdr = ICLK / clk; @@ -68,7 +68,7 @@ status_t _NOINLINE prci_hfosc_set_clk(sysclk_port_t *port, unsigned int clk) divdr) ? success : error_system; } -status_t _NOINLINE prci_hfosc_get_clk(sysclk_port_t *port, unsigned int *clk) +status_t _NOINLINE prci_hfosc_get_clk(const sysclk_port_t *port, unsigned int *clk) { unsigned int hfrosc; unsigned int divdr; @@ -85,7 +85,7 @@ status_t _NOINLINE prci_hfosc_get_clk(sysclk_port_t *port, unsigned int *clk) * - Avoid calling this function * - This function is untested */ -status_t _NOINLINE prci_hfosc_set_trim(sysclk_port_t *port, unsigned int trim) +status_t _NOINLINE prci_hfosc_set_trim(const sysclk_port_t *port, unsigned int trim) { unsigned int hfrosc; diff --git a/src/platform/sifive/common_fe310/hal/prci/pll.c b/src/platform/sifive/common_fe310/hal/prci/pll.c index 0df8e98c..d202d505 100644 --- a/src/platform/sifive/common_fe310/hal/prci/pll.c +++ b/src/platform/sifive/common_fe310/hal/prci/pll.c @@ -85,7 +85,7 @@ static inline void pll_config_for_nearest_freq(unsigned int base, unsigned int c } } -status_t _NOINLINE prci_pll_get_clk(sysclk_port_t *port, unsigned int *clk) +status_t _NOINLINE prci_pll_get_clk(const sysclk_port_t *port, unsigned int *clk) { pllc_t *config = &pllc[arch_core_index()]; unsigned int pllref, refr, vco, pllout; @@ -115,7 +115,7 @@ status_t _NOINLINE prci_pll_get_clk(sysclk_port_t *port, unsigned int *clk) return success; } -static inline void prci_pll_wait_to_lock(sysclk_port_t *port) +static inline void prci_pll_wait_to_lock(const sysclk_port_t *port) { uint64_t t = clint_read_time(); while((uint32_t)(clint_read_time() - t) < 10) @@ -124,7 +124,7 @@ static inline void prci_pll_wait_to_lock(sysclk_port_t *port) arch_dsb(); } -static inline void prci_pll_write_config(sysclk_port_t *port, const pllc_t *conf) +static inline void prci_pll_write_config(const sysclk_port_t *port, const pllc_t *conf) { if(!conf->found) return; @@ -152,7 +152,7 @@ static inline void prci_pll_write_config(sysclk_port_t *port, const pllc_t *conf return; } -void _NOINLINE prci_pll_set_clk(sysclk_port_t *port, unsigned int clk) +void _NOINLINE prci_pll_set_clk(const sysclk_port_t *port, unsigned int clk) { pllc_t *conf = &pllc[arch_core_index()]; pll_config_for_nearest_freq(port->base_clk, clk, conf); @@ -161,37 +161,37 @@ void _NOINLINE prci_pll_set_clk(sysclk_port_t *port, unsigned int clk) return; } -void _NOINLINE prci_pll_select_xosc(sysclk_port_t *port) +void _NOINLINE prci_pll_select_xosc(const sysclk_port_t *port) { MMIO32(port->baddr + PLLCFG_OFFSET) |= (1 << PLLREFSEL); return; } -void _NOINLINE prci_pll_select_rosc(sysclk_port_t *port) +void _NOINLINE prci_pll_select_rosc(const sysclk_port_t *port) { MMIO32(port->baddr + PLLCFG_OFFSET) &= ~(1 << PLLREFSEL); return; } -void _NOINLINE prci_pll_select_pll(sysclk_port_t *port) +void _NOINLINE prci_pll_select_pll(const sysclk_port_t *port) { MMIO32(port->baddr + PLLCFG_OFFSET) |= (1 << PLLSEL); return; } -void _NOINLINE prci_pll_deselect_pll(sysclk_port_t *port) +void _NOINLINE prci_pll_deselect_pll(const sysclk_port_t *port) { MMIO32(port->baddr + PLLCFG_OFFSET) &= ~(1 << PLLSEL); return; } -void _NOINLINE prci_pll_bypass(sysclk_port_t *port) +void _NOINLINE prci_pll_bypass(const sysclk_port_t *port) { MMIO32(port->baddr + PLLCFG_OFFSET) |= (1 << PLLBYPASS); return; } -void _NOINLINE prci_pll_inline(sysclk_port_t *port) +void _NOINLINE prci_pll_inline(const sysclk_port_t *port) { MMIO32(port->baddr + PLLCFG_OFFSET) &= ~(1 << PLLBYPASS); return; From fb17e2ad5321a0707366e1365bed124a421b56bf Mon Sep 17 00:00:00 2001 From: Akash Kollipara Date: Sat, 20 Jul 2024 14:36:41 +0530 Subject: [PATCH 2/8] 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 3/8] 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 4/8] 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)) From 020f790e2fc3be13c2d733a6146b11e4efa05354 Mon Sep 17 00:00:00 2001 From: Akash Kollipara Date: Thu, 1 Aug 2024 10:24:25 +0530 Subject: [PATCH 5/8] Add tools build test --- .../{github_ci.yml => cyancore_build.yml} | 2 +- .github/workflows/cyancore_tools_build.yml | 38 +++++++++++++++++++ mk/ccache.mk | 8 +--- mk/picotool.mk | 14 +++---- mk/project.mk | 2 +- mk/qemu.mk | 8 +++- mk/tc_get.mk | 16 ++++++-- 7 files changed, 64 insertions(+), 24 deletions(-) rename .github/workflows/{github_ci.yml => cyancore_build.yml} (98%) create mode 100644 .github/workflows/cyancore_tools_build.yml diff --git a/.github/workflows/github_ci.yml b/.github/workflows/cyancore_build.yml similarity index 98% rename from .github/workflows/github_ci.yml rename to .github/workflows/cyancore_build.yml index b96059d9..efa78529 100644 --- a/.github/workflows/github_ci.yml +++ b/.github/workflows/cyancore_build.yml @@ -1,4 +1,4 @@ -name: GitHub CI +name: Cyancore Build on: push: diff --git a/.github/workflows/cyancore_tools_build.yml b/.github/workflows/cyancore_tools_build.yml new file mode 100644 index 00000000..7a3cf90c --- /dev/null +++ b/.github/workflows/cyancore_tools_build.yml @@ -0,0 +1,38 @@ +name: Cyancore Tools Build + +on: + pull_request: + branches: [ stable ] + +jobs: + build: + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + statuses: write + + strategy: + fail-fast: true + + steps: + - uses: actions/checkout@v4 + + - name: Configure Git + env: + TOKEN: ${{ secrets.AKASH_VF }} + run: git config --global url."https://${TOKEN}:x-oauth-basic@github.com/".insteadOf "https://github.com/" + + - name: Fetch Dependencies + run: | + make setup_workspace + + - name: Tools Build + run: | + # make get_qemu V=1 + make get_picotool V=1 + + - name: Clean Up + run: | + make clean_workspace diff --git a/mk/ccache.mk b/mk/ccache.mk index ab594f39..02f01de6 100644 --- a/mk/ccache.mk +++ b/mk/ccache.mk @@ -103,16 +103,10 @@ export CCACHE_UMASK ifeq ($(EN_BUILD_CACHE),1) -CCACHE := ccache +CCACHE := $(shell which 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 diff --git a/mk/picotool.mk b/mk/picotool.mk index 67e3476a..4ac90db1 100644 --- a/mk/picotool.mk +++ b/mk/picotool.mk @@ -8,8 +8,8 @@ # Organisation : Cyancore Core-Team # -PICO_SDK_GIT := git@github.com:raspberrypi/pico-sdk.git -PICO_TOOL_GIT := git@github.com:raspberrypi/picotool.git +PICO_SDK_GIT := https://github.com/raspberrypi/pico-sdk.git +PICO_TOOL_GIT := https://github.com/raspberrypi/picotool.git PICO_SDK_PATH := $(TOOLS_ROOT)/pico-sdk/ PICO_TOOL_PATH := $(TOOLS_ROOT)/picotool/ PICO_TOOL := $(MISC_TOOLS)/picotool @@ -18,10 +18,11 @@ ELF2UF2 := $(MISC_TOOLS)/elf2uf2 ifneq ($(V),1) SILENT_LOGS := > cbuild.log 2> /dev/null +PICOTOOL_QUIET := 2>/dev/null 1>/dev/null endif P_TARGETS += elf2uf2 -T_ALLOWLIST += get_picotool clean_picotool install_pt_dep +T_ALLOWLIST += get_picotool clean_picotool get_picotool: $(PICO_TOOL) $(ELF2UF2) @@ -41,7 +42,7 @@ $(ELF2UF2): $(PICO_SDK_PATH) @echo "< ! > Building elf2uf2 ..." mkdir -p $(MISC_TOOLS)/temp cd $(MISC_TOOLS)/temp; \ - cmake $(PICO_SDK_PATH)/tools/elf2uf2 2>/dev/null >/dev/null; \ + cmake $(PICO_SDK_PATH)/tools/elf2uf2 $(PICOTOOL_QUIET); \ make >/dev/null 2>/dev/null cp $(MISC_TOOLS)/temp/elf2uf2 $@ rm -rf $(MISC_TOOLS)/temp @@ -64,11 +65,6 @@ $(PICO_TOOL_PATH): git clone $(PICO_TOOL_GIT) --quiet $@ @echo "< / > Done!" -install_pt_dep: - @echo "< ! > Installing Dependencies ..." - @sudo apt-get install build-essential pkg-config libusb-1.0-0-dev -y -qq > /dev/null - @echo "< / > Done!" - clean_picotool: @echo "< ! > Removing picotools ..." rm -rf $(PICO_SDK_PATH) $(PICO_TOOL_PATH) $(PICO_TOOL) $(ELF2UF2) diff --git a/mk/project.mk b/mk/project.mk index 795fc940..09da769e 100644 --- a/mk/project.mk +++ b/mk/project.mk @@ -40,7 +40,7 @@ clean: $(info < ! > Removing $(PROJECT) binaries ...) rm -rf $(OUT) -setup_workspace: $(SIZE) get_qemu get_all_tc +setup_workspace: | --install_os_pkgs $(SIZE) get_all_tc clean_workspace: clean $(info < / > Cleaning up workspace ...) diff --git a/mk/qemu.mk b/mk/qemu.mk index a9a822bc..96c7645c 100644 --- a/mk/qemu.mk +++ b/mk/qemu.mk @@ -17,6 +17,10 @@ QEMU_OUT_PATH := $(TOOLS_ROOT)/cc_qemu QEMU_TLIST := avr-softmmu arm-softmmu aarch64-softmmu QEMU_TLIST += riscv32-softmmu riscv64-softmmu x86_64-softmmu +ifneq ($(V),1) +QEMU_QUIET := 2> /dev/null 1> /dev/null +endif + get_qemu: $(QEMU_OUT_PATH) $(TOOLS_ROOT)/qemu: @@ -34,8 +38,8 @@ c := , $(QEMU_OUT_PATH): $(QEMU_PATH) @echo "< ! > Building qemu ..." @echo "< ? > Please be patient as this might take a while ..." - cd $<; ./configure --prefix=$(QEMU_OUT_PATH) --target-list=$(subst $(s),$(c),$(QEMU_TLIST)) 2> /dev/null 1> /dev/null - make -j $(N_JOBS) -C $< install 2> /dev/null 1> /dev/null + cd $<; ./configure --prefix=$(QEMU_OUT_PATH) --target-list=$(subst $(s),$(c),$(QEMU_TLIST)) $(QEMU_QUIET) + make -j $(N_JOBS) -C $< install $(QEMU_QUIET) @echo "< ! > Cleaning up build space ..." rm -rf $(QEMU_PATH) @echo "< ! > Adding load_qemu alias to bashrc ..." diff --git a/mk/tc_get.mk b/mk/tc_get.mk index 7548ef2d..84e638ee 100644 --- a/mk/tc_get.mk +++ b/mk/tc_get.mk @@ -12,6 +12,10 @@ include mk/path.mk T_ALLOWLIST += get_all_tc get_avr_tc get_arm_tc get_riscv_tc +OSDEPPKGS := build-essential pkg-config libusb-1.0-0-dev cppcheck ccache +OSDEPPKGS += tree ninja-build libpixman-1-dev libcairo2-dev libpango1.0-dev +OSDEPPKGS += libjpeg8-dev libgif-dev libglib2.0-dev libgcrypt20-dev python3-venv + # GIT REPO RECOMMENDED # Provide git repo path for toolchains for better experience ESIZE_REPO := https://github.com/VisorFolks/cc_elf_size.git @@ -19,13 +23,17 @@ 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 +get_all_tc: get_avr_tc get_arm_tc get_riscv_tc ---tc_clear: - rm -rf $(TOOLS_ROOT) +--install_os_pkgs: + @echo "< ! > Installing workspace dependencies, it may take a while ..." + sudo apt-get install $(OSDEPPKGS) -y -qq > /dev/null + @echo "< / > Done!" SIZE := $(TOOLS_ROOT)/cc_elf_size/size -$(SIZE): + +.SECONDEXPANSION: +$(SIZE): | $$(@D)/ $(info < ! > Fetching ELF-Size utility ...) cd $(TOOLS_ROOT); git clone $(ESIZE_REPO) --quiet; $(MAKE) -C $(@D) From 1e3b0096a28bd8e6fcf165395b7c7f4372266933 Mon Sep 17 00:00:00 2001 From: Akash Kollipara Date: Thu, 1 Aug 2024 11:31:36 +0530 Subject: [PATCH 6/8] Updated cyancore build CI --- .github/workflows/cyancore_build.yml | 4 +--- .github/workflows/cyancore_tools_build.yml | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cyancore_build.yml b/.github/workflows/cyancore_build.yml index efa78529..ae2b3f3a 100644 --- a/.github/workflows/cyancore_build.yml +++ b/.github/workflows/cyancore_build.yml @@ -31,9 +31,7 @@ jobs: - name: Fetch Dependencies run: | - sudo apt install cppcheck ccache -y - make get_avr_tc - make get_riscv_tc + make setup_workspace - name: Init CodeQL uses: github/codeql-action/init@v3 diff --git a/.github/workflows/cyancore_tools_build.yml b/.github/workflows/cyancore_tools_build.yml index 7a3cf90c..175e0f5b 100644 --- a/.github/workflows/cyancore_tools_build.yml +++ b/.github/workflows/cyancore_tools_build.yml @@ -30,7 +30,7 @@ jobs: - name: Tools Build run: | - # make get_qemu V=1 + make get_qemu V=1 make get_picotool V=1 - name: Clean Up From 7c8831e0d34fa1ff0f6f8ab774082746057e6db8 Mon Sep 17 00:00:00 2001 From: Akash Kollipara Date: Thu, 1 Aug 2024 11:51:04 +0530 Subject: [PATCH 7/8] Updated README Badges --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 205ef404..cfcdbb26 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ > **Version (arch:2 | major:4 | minor:2): 1.4.1** -> -[![GitHub CI](https://github.com/VisorFolks/cyancore/actions/workflows/github_ci.yml/badge.svg)](https://github.com/VisorFolks/cyancore/actions/workflows/github_ci.yml) [![Discord](https://img.shields.io/discord/859140196498014238?style=flat&logo=discord&logoSize=auto&label=VF%20Server)](https://discord.gg/gxUQr77MT2) + +[![CC Build](https://github.com/VisorFolks/cyancore/actions/workflows/cyancore_build.yml/badge.svg)](https://github.com/VisorFolks/cyancore/actions/workflows/cyancore_build.yml) [![CC Tools Build](https://github.com/VisorFolks/cyancore/actions/workflows/cyancore_tools_build.yml/badge.svg)](https://github.com/VisorFolks/cyancore/actions/workflows/cyancore_tools_build.yml) [![Discord](https://img.shields.io/discord/859140196498014238?style=flat&logo=discord&logoSize=auto&label=VF%20Server)](https://discord.gg/gxUQr77MT2) Cyancore is an open source unified software platform for embedded system projects. VisorFolks is motivated to develope a framework which enables a developer/user to write a portable project which can run on any of the target. It is designed to be a goto framework for almost all projects, be it an Embedded applications, IoT, firmware, OS, etc. It provides flexibility, tighter integration of features and abilities by utilizing the hardware and software resources better and boost various KPIs of the final product. From 68c9e202fac55b117728212821a2778b9158ac01 Mon Sep 17 00:00:00 2001 From: Akash Kollipara Date: Thu, 1 Aug 2024 12:24:48 +0530 Subject: [PATCH 8/8] Upgraded builder - `make clean` is no longer a valid target - `make clean` is valid target, this change is made to keep other build safe. - Add new target to clean up workspace `make clean_workspace` - Upgraded project builder to validate targets more effectively --- mk/help.mk | 4 ++-- mk/path.mk | 2 +- mk/project.mk | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mk/help.mk b/mk/help.mk index 4d26033f..35a07689 100644 --- a/mk/help.mk +++ b/mk/help.mk @@ -16,7 +16,7 @@ Usage: make [|default|...] (V=|PP=|...)\n\ \n\ Examples:\n\ $$ make demo_avr \# Builds project demo_avr\n\ -$$ make clean \# Cleans the build out folder \n\ +$$ make demo_avr clean \# Cleans demo_avr build\n\ $$ make demo_avr V=1 \# Builds demo_avr with verbose\n\ $$ make list \# Displays all the available projects\n\ $$ make get_all_tc \# Fetches all toolchains\n\ @@ -54,7 +54,7 @@ passed. This uses multi threaded build.\n\ Use this for debug as it will be slow than default.\n\ ~ clean: Cleans the project build artifacts.\n\ ~ check: Perform static analysis.\n\ -clean: Cleans all the build artifacts.\n\ +clean_workspace: Cleans workspace to new checkout state.\n\ list: Displays all the projects available for build.\n\ get_all_tc: Fetches all Toolchains.\n\ get_avr_tc: Fetches AVR Toolchain.\n\ diff --git a/mk/path.mk b/mk/path.mk index 2e3383a6..215b78f4 100644 --- a/mk/path.mk +++ b/mk/path.mk @@ -23,5 +23,5 @@ OUT ?= $(OUT_PATH)/$(PROJECT) GET_PATH = $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) -./%/: +%/: mkdir -p $@ diff --git a/mk/project.mk b/mk/project.mk index 09da769e..de5c4196 100644 --- a/mk/project.mk +++ b/mk/project.mk @@ -17,8 +17,8 @@ include mk/mk_helper.mk 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 clean_workspace setup_workspace +P_TARGETS += default cyancore check version copy_to_remote clean_remote clean +T_ALLOWLIST += list all_projects clean_workspace setup_workspace PROJECT_LIST := $(shell ls projects/ -I *.template -I *.src) .PHONY: aux_target @@ -44,7 +44,7 @@ setup_workspace: | --install_os_pkgs $(SIZE) get_all_tc clean_workspace: clean $(info < / > Cleaning up workspace ...) - rm -rf $(CCACHE_DIR) $(TOOLS_ROOT) + rm -rf $(OUT_PATH) $(CCACHE_DIR) $(TOOLS_ROOT) list: $(info Available projects are :) @@ -56,8 +56,8 @@ copy_to_remote: --cpremote clean_remote: --rmremote -ifeq ($(findstring $(MAKECMDGOALS),$(T_ALLOWLIST)),) -ifeq ($(findstring $(firstword $(MAKECMDGOALS)),$(P_TARGETS)),) +ifeq ($(filter $(MAKECMDGOALS),$(T_ALLOWLIST)),) +ifeq ($(filter $(firstword $(MAKECMDGOALS)),$(P_TARGETS)),) PROJECT ?= $(firstword $(MAKECMDGOALS)) CMD := $(word 2,$(MAKECMDGOALS)) ifeq ($(CMD),)