Skip to content

Commit

Permalink
Merge pull request #164 from VisorFolks/development
Browse files Browse the repository at this point in the history
Release merge for Cyancore v1.3.0
  • Loading branch information
akashkollipara authored Aug 29, 2022
2 parents f8014bd + cdd402f commit 30e7b40
Show file tree
Hide file tree
Showing 74 changed files with 926 additions and 542 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</div>
</body>

> **Version (arch:2 | major:4 | minor:2): 1.2.2**
> **Version (arch:2 | major:4 | minor:2): 1.3.0**
[![GitHub CI](https://github.com/VisorFolks/cyancore/actions/workflows/github_ci.yml/badge.svg)](https://github.com/VisorFolks/cyancore/actions/workflows/github_ci.yml)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=VisorFolks_cyancore&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=VisorFolks_cyancore)
Expand Down
12 changes: 6 additions & 6 deletions mk/elf.mk
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ LD_SUPPLEMENT := $(addprefix $(OUT)/,$(LD_SUPPLEMENT:.ld.sx=.ld))

elf: $(ELF)

$(ELF): $(DEP_LIBS) $(DEP_OBJS) $(LD_SCRIPT) $(LD_SUPPLEMENT)
.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) -Map=$(@:.elf=.map) -o $@ $(filter %.o, $^) $(DEP_LIB_PATH) $(DEP_LIBS_ARG) -L $(TL) -lgcc
$(LD) -dT $(LD_SCRIPT) $(addprefix -T , $(LD_SUPPLEMENT)) $(LD_FLAGS) \
-Map=$(@:.elf=.map) -o $@ $(filter %.o, $^) $(DEP_LIB_PATH) $(DEP_LIBS_ARG) -L $(TL) -lgcc
$(OD) -Dx -h --wide $@ > $(@:.elf=.lst)
$(OC) -O binary $@ $(@:.elf=.bin)
$(OC) -O ihex $@ $(@:.elf=.hex)
@echo "=================================================="
@echo "Size of Executable:"
@cd $(@D); $(SIZE) $(@F)
@cd $(@D); $(SIZE) -f $(@F) -m Flash $(FLASH_START) $(FLASH_SIZE) \
-m RAM $(RAM_START) $(RAM_SIZE) $(MEMSIZE_ARGS)
@echo ""

.SECONDEXPANSION:
$(OUT)/%.ld: %.ld.sx
mkdir -p $(@D)
@echo "Elf: Preprocessing $(@F) ..."
Expand Down
1 change: 0 additions & 1 deletion mk/tc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ OD := $(TC)-objdump
OC := $(TC)-objcopy
STRIP := $(TC)-strip
A2L := $(TC)-addr2line
SIZE := $(TC)-size
endif

ifeq ($(realpath $(TI)),)
Expand Down
8 changes: 8 additions & 0 deletions mk/tc_get.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ T_ALLOWLIST += get_all_tc get_avr_tc get_arm_tc get_riscv_tc

# GIT REPO RECOMMENDED
# Provide git repo path for toolchains for better experience
ESIZE_REPO := https://github.com/VisorFolks/cc_elf_size.git
AVR_TC_REPO ?=
RISC_V_TC_REPO ?=
ARM_TC_REPO ?=
Expand All @@ -23,6 +24,13 @@ get_all_tc: --tc_clear get_avr_tc get_arm_tc get_riscv_tc
--tc_clear:
rm -rf $(TOOLS_ROOT)

SIZE := $(TOOLS_ROOT)/cc_elf_size/size
$(SIZE):
$(info < ! > Fetching ELF-Size utility ...)
cd $(TOOLS_ROOT); git clone $(ESIZE_REPO) --quiet;
$(MAKE) -C $(@D)
echo "< / > Done !"

get_arm_tc: $(TOOLS_ROOT)/arm-toolchain/bin/arm-none-eabi-gcc
$(TOOLS_ROOT)/arm-toolchain/bin/arm-none-eabi-gcc:
ifeq ($(ARM_TC_REPO),)
Expand Down
1 change: 0 additions & 1 deletion projects/demo_avr/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ STDLOG_MEMBUF := 0
BOOTMSGS := 0
EARLYCON_SERIAL := 1
CONSOLE_SERIAL := 1
TERRAKERN := 0
OBRDLED_ENABLE := 1
1 change: 0 additions & 1 deletion src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ This is the root directory of all the sources of this framework.
| [include](include) | Constitues of all the include/header files except for arch |
| [lib](lib) | Constitues of all the necessary libraries |
| [platform](platform) | Constitues of platform/development board specific sources |
| [projects](projects) | Constitues of project sources made using this framework |
| [visor](visor) | Constitues of terra/hyper/super - visors' sources |

---
Expand Down
27 changes: 5 additions & 22 deletions src/arch/avr/8/common_5x_6/terravisor/arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
#include <stdint.h>
#include <status.h>
#include <syslog.h>
#include <machine_call.h>
#include <terravisor/workers.h>
#include <plat_arch.h>
#include <mmio.h>
#include <arch.h>
#include <terravisor/workers.h>

/**
* arch_early_setup - This function is called in the early stages of boot
*
* @brief This function is responsible to clean reset cpu status/control registers.
*
*/
void (* const p_mcall)(unsigned int, unsigned int, unsigned int, unsigned int, mret_t *) = &machine_call;
void arch_early_setup()
{
arch_di();
Expand Down Expand Up @@ -72,30 +72,12 @@ void arch_wfi()
asm volatile("sleep");
}

/**
* arch_machine_call - perform machine call
*
* @brief This function emulates the machine
* call to maintain consistency.
*
* @param[in] code: machine call code
* @param[in] a0: first argument
* @param[in] a1: second argument
* @param[in] a2: third argument
* @param[in] *ret: return value
*/
void arch_machine_call(unsigned int code, unsigned int a0, unsigned int a1, unsigned int a2, mret_t *ret)
{
if(ret == NULL)
return;
machine_call(code, a0, a1, a2, ret);
return;
}

void _NORETURN arch_panic_handler_callback()
{
context_frame_t *frame;
frame = get_context_frame();
if(!frame)
goto panic;
syslog_stdout_enable();
sysdbg("r0=%p\tr1=%p\tr2=%p\tr3=%p\tr4=%p\tr5=%p\n",
frame->r0, frame->r1, frame->r2, frame->r3, frame->r4, frame->r5);
Expand All @@ -112,5 +94,6 @@ void _NORETURN arch_panic_handler_callback()
#if DEBUG==0
syslog(info, "SP=%p\tSREG = %p\n", frame, frame->sreg);
#endif
panic:
while(1) arch_wfi();
}
4 changes: 2 additions & 2 deletions src/arch/avr/8/common_5x_6/terravisor/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
*/
function entry
cli
ldi r18, lo8(stack_start)
ldi r18, lo8(_stack_end)
ldi r30, SPL
st Z, r18
ldi r18, hi8(stack_start)
ldi r18, hi8(_stack_end)
ldi r30, SPH
st Z, r18
eor r18, r18
Expand Down
31 changes: 22 additions & 9 deletions src/arch/avr/8/common_5x_6/terravisor/include/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <plat_arch.h>
#include <avr.h>
#include <mmio.h>
#include <machine_call.h>

/**
* arch_early_setup - This needs to be called in early stages of boot
Expand All @@ -38,15 +39,6 @@ void arch_ei_restore_state(istate_t *);
*/
void arch_panic_handler();

#ifdef _MACHINE_CALL_H_
/**
* arch_machine_call - Performs machine call
*
* Refer arch.c for more details.
*/
void arch_machine_call(call_arg_t, call_arg_t, call_arg_t, call_arg_t, mret_t *);
#endif

/**
* arch_register_interrupt_handler - Registers interrtup handler
* for arch specific interrupt vectors
Expand All @@ -62,6 +54,27 @@ static inline unsigned int arch_core_index()
return 0;
}

/**
* arch_machine_call - perform machine call
*
* @brief This function emulates the machine
* call to maintain consistency.
*
* @param[in] code: machine call code
* @param[in] a0: first argument
* @param[in] a1: second argument
* @param[in] a2: third argument
* @param[in] *ret: return value
*/
static inline void arch_machine_call(unsigned int code, unsigned int a0, unsigned int a1, unsigned int a2, mret_t *ret)
{
extern void (*const p_mcall)(unsigned int, unsigned int, unsigned int, unsigned int, mret_t*);
if(ret == NULL)
return;
p_mcall(code, a0, a1, a2, ret);
return;
}

/**
* arch_ei - arch enable global interrupts
*/
Expand Down
5 changes: 1 addition & 4 deletions src/arch/avr/8/common_5x_6/terravisor/interrupt_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,9 @@ void interrupt_handler(unsigned char id, context_frame_t *frame)
}


/* Fixed memory block of 33 bytes on bss */
context_frame_t snapshot_frame;

context_frame_t *get_context_frame()
{
if(local_frame)
return local_frame;
return &snapshot_frame;
return NULL;
}
27 changes: 0 additions & 27 deletions src/arch/avr/8/common_5x_6/terravisor/stack.S

This file was deleted.

27 changes: 0 additions & 27 deletions src/arch/riscv/32/i/terravisor/arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,33 +95,6 @@ void arch_ei_restore_state(istate_t *istate)
asm volatile("csrs mie, %0" : : "r" (*istate));
}

/**
* arch_machine_call - perform machine call
*
* @brief This function performs environment call
* in m mode
*
* @param[in] code: machine call code
* @param[in] a0: first argument
* @param[in] a1: second argument
* @param[in] a2: third argument
* @param[in] *ret: return struct
*/
void arch_machine_call(unsigned int code, unsigned int a0, unsigned int a1, unsigned int a2, mret_t *ret)
{
if(ret == NULL)
return;
asm volatile("mv a0, %0" : : "r" (code));
asm volatile("mv a1, %0" : : "r" (a0));
asm volatile("mv a2, %0" : : "r" (a1));
asm volatile("mv a3, %0" : : "r" (a2));
asm volatile("ecall");
asm volatile("mv %0, a0" : "=r" (ret->p));
asm volatile("mv %0, a1" : "=r" (ret->size));
asm volatile("mv %0, a2" : "=r" (ret->status));
return;
}

_WEAK void arch_panic_handler()
{
const context_frame_t *frame = get_context_frame();
Expand Down
37 changes: 30 additions & 7 deletions src/arch/riscv/32/i/terravisor/include/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@ void arch_early_signal_boot_start();
void arch_wait_till_boot_done();
void arch_signal_boot_done();

/**
* arch_machine_call - Performs machine call
*
* Refer arch.c for more details.
*/
void arch_machine_call(unsigned int, unsigned int, unsigned int, unsigned int, mret_t *);

/**
* arch_register_interrupt_handler - Registers interrtup handler
* for arch specific exception vectors
Expand All @@ -67,6 +60,36 @@ static inline unsigned int arch_core_index()
return id;
}

/**
* arch_machine_call - perform machine call
*
* @brief This function performs environment call
* in m mode
*
* @param[in] code: machine call code
* @param[in] a0: first argument
* @param[in] a1: second argument
* @param[in] a2: third argument
* @param[in] *ret: return struct
*/
static inline void arch_machine_call(unsigned int code, unsigned int arg0, unsigned int arg1, unsigned int arg2, mret_t *ret)
{
if(ret == NULL)
return;
register uint32_t a0 asm("a0") = code;
register uint32_t a1 asm("a1") = arg0;
register uint32_t a2 asm("a2") = arg1;
register uint32_t a3 asm("a3") = arg2;
asm volatile("ecall"
: "+r" (a0), "+r" (a1), "+r"(a2)
: "r" (a0), "r" (a1), "r" (a2), "r" (a3)
: "memory");
ret->p = a0;
ret->size = a1;
ret->status = a2;
return;
}

/**
* arch_ei - arch enable global interrupts
*/
Expand Down
2 changes: 0 additions & 2 deletions src/driver/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

DRIVER_PATH := $(GET_PATH)

LD_SUPPLEMENT += $(DRIVER_PATH)/driver.ld.sx

#==========< Essentials Drivers >==========#
include $(DRIVER_PATH)/interrupt/build.mk
include $(DRIVER_PATH)/watchdog/build.mk
Expand Down
Loading

0 comments on commit 30e7b40

Please sign in to comment.