Skip to content

Commit

Permalink
Merge pull request #287 from VisorFolks/development
Browse files Browse the repository at this point in the history
<1.4.1> Release Update
  • Loading branch information
akashkollipara authored Apr 30, 2024
2 parents e47c877 + 522e264 commit 35b69a7
Show file tree
Hide file tree
Showing 45 changed files with 1,038 additions and 364 deletions.
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@
"editor.trimAutoWhitespace": true,
"editor.autoClosingQuotes": "always",
"editor.autoClosingBrackets": "always",
"editor.wordBasedSuggestions": true,
"editor.wordBasedSuggestions": "matchingDocuments",
"editor.insertSpaces": false,
"editor.autoIndent": "advanced",
"editor.detectIndentation": true,
"editor.codeLens": true,
"editor.columnSelection": false,
"editor.colorDecorators": true,
"editor.cursorBlinking": "blink",
"editor.lightbulb.enabled": true,
"editor.lineNumbers": "on",
"editor.suggest.showFunctions": true,
"diffEditor.codeLens": true,
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</div>
</body>

> **Version (arch:2 | major:4 | minor:2): 1.4.0**
> **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)

Expand Down
4 changes: 4 additions & 0 deletions mk/mk_helper.mk
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ ifeq ($($(1)),1)
include $(2)
endif
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
5 changes: 5 additions & 0 deletions mk/tc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,23 @@ include mk/path.mk

ifeq ($(findstring arm,$(ARCH)),arm)
TC ?= $(TOOLS_ROOT)/arm-toolchain/bin/arm-none-eabi
$(eval $(call get_tc_version,$(TC))) # Sets TC_VER
TI := $(TOOLS_ROOT)/arm-toolchain/lib/gcc/arm-none-eabi/$(TC_VER)/include-fixed/
TI += $(TOOLS_ROOT)/arm-toolchain/arm-none-eabi/include/
TL := $(TOOLS_ROOT)/arm-toolchain/lib/gcc/arm-none-eabi/$(TC_VER)/$(TL_TYPE)/
endif

ifeq ($(findstring riscv,$(ARCH)),riscv)
TC ?= $(TOOLS_ROOT)/risc-v-toolchain/bin/riscv64-unknown-elf
$(eval $(call get_tc_version,$(TC))) # Sets TC_VER
TI := $(TOOLS_ROOT)/risc-v-toolchain/lib/gcc/riscv64-unknown-elf/$(TC_VER)/include-fixed/
TI += $(TOOLS_ROOT)/risc-v-toolchain/riscv64-unknown-elf/include/
TL := $(TOOLS_ROOT)/risc-v-toolchain/lib/gcc/riscv64-unknown-elf/$(TC_VER)/rv$(BIT)$(ARCH_VARIANT)/$(ARCH_ABI)/
endif

ifeq ($(findstring avr,$(ARCH)),avr)
TC ?= $(TOOLS_ROOT)/avr-toolchain/bin/avr
$(eval $(call get_tc_version,$(TC))) # Sets TC_VER
TI := $(TOOLS_ROOT)/avr-toolchain/lib/gcc/avr/$(TC_VER)/include-fixed
TL := $(TOOLS_ROOT)/avr-toolchain/lib/gcc/avr/$(TC_VER)/$(ARCH)$(ARCH_VARIANT)/
endif
Expand All @@ -47,3 +50,5 @@ $(info < ! > Toolchain is not available !)
$(info < ! > Try running 'make help' ...)
$(error < x > Build Failed !)
endif


1 change: 0 additions & 1 deletion projects/demo_avr/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#

COMPILER := gcc
TC_VER := 5.4.0
FAMILY := mega_avr
PLATFORM := atmega328p
STDLOG_MEMBUF := 0
Expand Down
1 change: 0 additions & 1 deletion projects/demo_avr_cpp/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#

COMPILER := gcc
TC_VER := 5.4.0
FAMILY := mega_avr
PLATFORM := atmega328p
STDLOG_MEMBUF := 0
Expand Down
15 changes: 14 additions & 1 deletion projects/demo_avr_cpp/gpio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,31 @@ extern "C"

#include "gpio.h"

/* Outside declaration of the member function of class onBoardLed */
/* Outside declaration of the member function of class onBoardLed: Utilized by the specific register allocation for the onboard LED */
onBoardLed::onBoardLed()
{
gpio_pin_alloc(&led13, PORTB, 5);
}

/**
* @brief the setting up of the onboard-LED
*
* This function configures the specific GPIO pin for the onboard-LED as an output
* This function also sets the LED state to low (off)
*/

void onBoardLed::setup()
{
gpio_pin_mode(&led13, out);
gpio_pin_clear(&led13);
}

/**
* @brief The toggling of the onboard LED
*
* This function toggles the state of the onboard LED on and off
*/

void onBoardLed::toggle()
{
gpio_pin_toggle(&led13);
Expand Down
7 changes: 7 additions & 0 deletions projects/demo_avr_cpp/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@

#pragma once

/**
* @brief Class representing an on-board LED controlled via GPIO.
*
* This class provides methods to initialize the LED, set it up as an output,
* and toggle its state.
*/

class onBoardLed
{
private:
Expand Down
12 changes: 6 additions & 6 deletions projects/demo_avr_cpp/project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ extern "C"
#include <hal/gpio.h>
}

#include "gpio.h"
#include "gpio.h" // This has custom GPIO header functions


class onBoardLed led;
class onBoardLed led;

/* Use EXPORT_C macro for calling cpp function in c file */
EXPORT_C(void plug())
{
bootstrap();
bootstrap(); // calls the system initial bootstrap
driver_setup_all();

/* call the constructor and setup member of led object */
Expand All @@ -47,13 +47,13 @@ void delay(unsigned long d)
{
unsigned long c;
for(c = 0; c < d; c++)
asm volatile("nop");
asm volatile("nop"); // provides the assembly instructions to create a general delay
}

static unsigned char i = 0;
EXPORT_C(void play())
EXPORT_C(void play()) // the calling of the continues function check
{
wdog_guard(WDT_64MS, true, NULL);
wdog_guard(WDT_64MS, true, NULL); // safety feature if the core hangs or creates interruptions

/* call the toggle member of led object */
led.toggle();
Expand Down
1 change: 0 additions & 1 deletion projects/demo_helios_avr/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#

COMPILER := gcc
TC_VER := 5.4.0
FAMILY := mega_avr
PLATFORM := atmega328p
HEAP_SIZE := 500
Expand Down
1 change: 0 additions & 1 deletion projects/demo_helios_riscv/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#

COMPILER := gcc
TC_VER := 10.2.0
FAMILY := sifive
PLATFORM := fe310g002
HEAP_SIZE := 3K
Expand Down
1 change: 0 additions & 1 deletion projects/demo_qemu_sifive_e/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#

COMPILER := gcc
TC_VER := 10.2.0
FAMILY := sifive
PLATFORM := qemu-sifive-e
STDLOG_MEMBUF := 0
Expand Down
1 change: 0 additions & 1 deletion projects/demo_riscv/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#

COMPILER := gcc
TC_VER := 10.2.0
FAMILY := sifive
PLATFORM := fe310g002
STDLOG_MEMBUF := 0
Expand Down
1 change: 0 additions & 1 deletion projects/hifive1b_bl/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#

COMPILER := gcc
TC_VER := 10.2.0
FAMILY := sifive
PLATFORM := fe310g002-bl
STDLOG_MEMBUF := 0
Expand Down
1 change: 0 additions & 1 deletion projects/qemu_sifive_e_bl/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#

COMPILER := gcc
TC_VER := 10.2.0
FAMILY := sifive
PLATFORM := qemu-sifive-e-bl
USE_FLOAT := 0
Expand Down
84 changes: 68 additions & 16 deletions src/arch/arm-m/32/common_v6_v7/supervisor/arch.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/*
* CYANCORE LICENSE
* Copyrights (C) 2019, Cyancore Team
* Copyrights (C) 2024, Cyancore Team
*
* File Name : arch.c
* Description : This file consists of architecture specific function that
* cannot be inlined. Hence, present in c file.
* Primary Author : Mayuri Lokhande [[email protected]]
* Primary Author : Mayuri Lokhande [[email protected]],
* Akash Kollipara [[email protected]]
* Organisation : Cyancore Core-Team
*/

Expand All @@ -14,21 +15,50 @@
#include <assert.h>
#include <status.h>
#include <syslog.h>
#include <mmio.h>
#include <arch.h>
#include <interrupt.h>
#include <visor/workers.h>
#include <rand.h>
#include <lock/lock.h>

static void arch_ecall_handler()
/**
* arch_vcall_handler
*
* @brief This function handles svc calls. In Cyancore all exception calls
* will be called as visor-calls.
*/
static void arch_vcall_handler()
{
context_frame_t *frame = get_context_frame();
vret_t vres;
machine_call(frame->r0, frame->r1, frame->r3, &vres);
vcall_handler(frame->r0, frame->r1, frame->r2, frame->r3, &vres);
frame->r0 = vres.p;
frame->r1 = vres.size;
frame->r2 = vres.status;
return;
}

/* This the key for boot lock */
static lock_t boot_key = LOCK_INITAL_VALUE;
void arch_early_signal_boot_start()
{
boot_key = LOCK_INITAL_VALUE;
return;
}

void arch_wait_till_boot_done()
{
lock_acquire(&boot_key);
lock_release(&boot_key);
return;
}

void arch_signal_boot_done()
{
lock_release(&boot_key);
return;
}

/**
*arch_early_setup - This function is called in the early stages of boot
*
Expand All @@ -38,7 +68,6 @@ static void arch_ecall_handler()
void arch_early_setup()
{
arch_di();

}

/**
Expand All @@ -48,15 +77,15 @@ void arch_early_setup()
*/
void arch_setup()
{
link_interrupt(int_arch, 10 ,&arch_vcall_handler);
return;
}

void arch_di_save_state(istate_t *sreg_i_backup)
void arch_di_save_state(istate_t *istate _UNUSED)
{
*
}

void arch_ei_restore_state(istate_t *sreg_i_backup)
void arch_ei_restore_state(istate_t *istate _UNUSED)
{

}
Expand All @@ -77,14 +106,12 @@ void _NORETURN arch_panic_handler_callback()
if(!frame)
goto panic;
syslog_stdout_enable();
sysdbg("r0=%p\tr1=%p\tr2=%p\tr3=%p\tr4=%p\tr5=%p\n",
frame->r0, frame->r1, frame->r2, frame->r3, frame->r4, frame->r5);
sysdbg("r6=%p\tr7=%p\tr8=%p\tr9=%p\tr10=%p\tr11=%p\n",
frame->r6, frame->r7, frame->r8, frame->r9, frame->r10, frame->r11);
sysdbg("r12=%p\tr13=%p\tr14=%p\tr15=%p\tAPSR=%p\n",
frame->r12, frame->r13, frame->r14, frame->r15, frame->apsr);
sysdbg("r0=%p\tr1=%p\tr2=%p\tr3=%p\n",
frame->r0, frame->r1, frame->r2, frame->r3);
sysdbg("r12=%p\tLR=%p\tPSR=%p\tReturns To=%p\n",
frame->r12, frame->lr, frame->psr, frame->ret_addr);
#if DEBUG==0
syslog(info, "APSR=%p\n", frame->apsr);
syslog(info, "PSR=%p\n", frame->psr);
#endif
panic:
while(1) arch_wfi();
Expand Down Expand Up @@ -132,3 +159,28 @@ void arch_signal_resume(void)
{
sleep_flag = resume;
}

/**
* arch_rseed_capture
*
* @brief This function is intended to capture unique seed value
*/
void arch_rseed_capture()
{
extern uintptr_t *_bss_start;
srand((size_t)_bss_start);
}

_WEAK void arch_panic_handler()
{
syslog_stdout_enable();
syslog(fail, "Arch Panic!\n");
arch_panic_handler_callback();
}

_WEAK void arch_unhandled_irq()
{
syslog_stdout_enable();
syslog(fail, "Arch Unhandled IRQ!\n");
arch_panic_handler_callback();
}
22 changes: 22 additions & 0 deletions src/arch/arm-m/32/common_v6_v7/supervisor/arch_vectors.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* CYANCORE LICENSE
* Copyrights (C) 2024, Cyancore Team
*
* File Name : arch_verctors.S
* Description : This file consists of array of vector table
* specific to arm-m proile.
* Primary Author : Akash Kollipara [[email protected]]
* Organisation : Cyancore Core-Team
*/

#include <asm.inc>

object arch_vectors
.word _stack_start
.word init

.set i, 1
.rept (N_EXCEP + N_IRQ)
.word isr
.set i, i+1
.endr
Loading

0 comments on commit 35b69a7

Please sign in to comment.