Skip to content

Commit

Permalink
Merge branch 'development' into cc-kernel-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
pranjalchanda08 committed Jan 5, 2022
2 parents d68cfc7 + 11b98f6 commit 2e22bb3
Show file tree
Hide file tree
Showing 40 changed files with 1,303 additions and 49 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ Click the above icon to connect

| Atmel | SiFive | STMicro | TI | Raspberry Pi |
| ---------- | ----------- | ----------- | ----------- | -------------|
| ATMega328P | Coming soon | Coming soon | Coming soon | Coming soon |
| ATMega328P | FE310-G002 | Coming soon | Coming soon | Coming soon |
| ATMega2560 | | | | |

### Projects
* demo_avr
* demo_avr_cpp
* demo_avr_bit_banding
run
```
$ make list
```

### Programming Languages
* asm/assembly
* C
* Cpp/C++
* C/C++
* makefile
* linker script

### Help
run
```
make help
$ make help
```

For details about the framework, follow the README.md in each folder.
Expand All @@ -54,4 +54,4 @@ Host system requirements:
Toolchain Requirements:
* Please push your toolchains to your git repo
* Update the links in mk/tc_get.mk file
* run ```make help``` for more details
* run ```$ make help``` for more details
3 changes: 3 additions & 0 deletions jenkins.pipe
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@ pipeline {
stage('tc check') {
steps {
sh 'make get_avr_tc [email protected]:VisorFolks/avr-toolchain.git'
sh 'make get_riscv_tc [email protected]:VisorFolks/risc-v-toolchain.git'
}
}
stage('check') {
steps {
sh 'make demo_avr check'
sh 'make demo_avr_cpp check'
sh 'make demo_riscv check'
}
}
stage('build') {
steps {
sh 'make demo_avr clean default'
sh 'make demo_avr_cpp clean default'
sh 'make demo_riscv clean default'
}
}
stage('clean') {
Expand Down
16 changes: 16 additions & 0 deletions mk/copy_to_remote.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2019, Cyancore Team
#
# File Name : copy_to_target.mk
# Description : This file has build target to copy to
# remote machine if any
# Primary Author : Akash Kollipara [[email protected]]
# Organisation : Cyancore Core-Team
#

--cpremote: $(ELF)
@echo "< ! > Please add your commands here..."

--rmremote:
@echo "< ! > Please add your commands here..."
2 changes: 2 additions & 0 deletions mk/elf.mk
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ $(ELF): $(DEP_LIBS) $(DEP_OBJS) $(LD_SCRIPT) $(LD_SUPPLEMENT)
@cd $(@D); $(SIZE) $(@F)
@echo ""

.SECONDEXPANSION:
$(OUT)/%.ld: %.ld.sx
mkdir -p $(@D)
@echo "Elf: Preprocessing $(@F) ..."
$(CC) $(CFLAGS) -E -P -o $@ $<

20 changes: 10 additions & 10 deletions mk/project.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
include mk/path.mk
include mk/mk_helper.mk

T_ALLOWLIST += help list
P_TARGETS += default cyancore check version copy_to_remote clean_remote
T_ALLOWLIST += help list clean

.PHONY: aux_target

Expand All @@ -36,11 +37,12 @@ list:

check: --lint

copy_to_remote: --cpremote
clean_remote: --rmremote


ifeq ($(findstring $(MAKECMDGOALS),$(T_ALLOWLIST)),)
ifneq ($(firstword $(MAKECMDGOALS)),clean)
ifneq ($(firstword $(MAKECMDGOALS)),default)
ifneq ($(firstword $(MAKECMDGOALS)),cyancore)
ifneq ($(firstword $(MAKECMDGOALS)),check)
ifeq ($(findstring $(firstword $(MAKECMDGOALS)),$(P_TARGETS)),)
PROJECT ?= $(firstword $(MAKECMDGOALS))
CMD := $(word 2,$(MAKECMDGOALS))
ifeq ($(CMD),)
Expand All @@ -50,9 +52,6 @@ endif
.PHONY: $(PROJECT)
$(PROJECT): $(CMD)

endif
endif
endif
endif

ifeq ($(PROJECT),)
Expand All @@ -64,14 +63,15 @@ $(info < x > Invalid project name...)
$(info < ! > Run `make list` to get list of projects)
$(error < x > Build Failed!)
endif
endif

ifeq ($(findstring $(MAKECMDGOALS),$(T_ALLOWLIST)),)
include $(SRC)/sources.mk
include mk/tc.mk
include mk/copy_to_remote.mk
endif
endif

ifeq ($(findstring $(CMD),$(T_ALLOWLIST) default clean cyancore),)
ifeq ($(findstring $(CMD),$(T_ALLOWLIST) $(P_TARGETS)),)
$(CMD): $(filter %/$(CMD),$(DEP_LIBS) $(DEP_OBJS))
if [ "$<" = "" ]; then \
echo "No such target: $@"; \
Expand Down
14 changes: 13 additions & 1 deletion mk/usage_help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
Usage : make <option> <command>
option : {list | get_all_tc | get_arm_tc | get_avr_tv |
get_riscv_tc | help} or <Project Name>
command : default (implicit) | clean
command : default (implicit) | clean | check | cyancore |
copy_to_remote clean_remote
----------------------------------------------------------
> Project Name:
* The project name is the name of directory under
Expand All @@ -20,4 +21,15 @@ command : default (implicit) | clean
* This option fetches AVR-8 toolchain.
> get_riscv_tc:
* This option fetched RISC-V toolchain.

> cyancore (avoid if not needed):
* This command builds the project with 1 thread
> check:
* This command performs cppcheck on code base for
the project.
> copy_to_remote:
* This command copies the bin, elf and hex to remote
machine.
> clean_remote:
* This command removes folders from remote machine.
==========================================================
2 changes: 2 additions & 0 deletions src/arch/avr/8/common_5x_6/terravisor/arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ void (*mcall)(unsigned int, unsigned int, unsigned int, unsigned int, mret_t *);
*/
void arch_machine_call(unsigned int code, unsigned int a0, unsigned int a1, unsigned int a2, mret_t *ret)
{
if(ret == NULL)
return;
mcall(code, a0, a1, a2, ret);
return;
}
25 changes: 0 additions & 25 deletions src/arch/avr/8/common_5x_6/terravisor/include/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,28 +89,3 @@ static inline void arch_nop()
{
asm volatile("nop");
}

static inline void arch_sync()
{
arch_nop();
}

static inline void arch_msb()
{
arch_nop();
}

static inline void arch_isb()
{
arch_nop();
}

static inline void arch_dsb()
{
arch_nop();
}

static inline void arch_wfe()
{
arch_nop();
}
14 changes: 14 additions & 0 deletions src/arch/riscv/32/a/build.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2019, Cyancore Team
#
# File Name : build.mk
# Description : Build script for this directory.
# Primary Authod : Akash Kollipara [[email protected]]
# Organisation : Cyancore Core-Team
#

RV32IA_ARCH_DIR := $(GET_PATH)

DIR := $(RV32IA_ARCH_DIR)
include mk/obj.mk
35 changes: 35 additions & 0 deletions src/arch/riscv/32/a/spinlock.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* CYANCORE LICENSE
* Copyrights (C) 2019, Cyancore Team
*
* File Name : spinlock.c
* Description : This file consists of sources of spinlock
* Primary Author : Akash Kollipara [[email protected]]
* Organisation : Cyancore Core-Team
*/

#include <stdint.h>
#include <status.h>
#include <arch.h>
#include <lock/lock.h>

void spinlock_acquire(spinlock_t *key)
{
unsigned int old, new;
new = 1;
while(1)
{
if(*key)
continue;
asm volatile("amoswap.w %0, %2, %1" : "=r" (old), "+A" (*key) : "r" (new) : "memory");
fence(r, rw);
if(!old)
break;
}
}

void spinlock_release(spinlock_t *key)
{
fence(r, rw);
*key = 0;
}
91 changes: 91 additions & 0 deletions src/arch/riscv/32/i/terravisor/arch.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* CYANCORE LICENSE
* Copyrights (C) 2019, Cyancore Team
*
* File Name : arch.c
* Description : This file consists of architecture specific function that
* cannot be inlined. Hence, present in c file.
* Primary Author : Akash Kollipara [[email protected]]
* Organisation : Cyancore Core-Team
*/

#include <stdint.h>
#include <status.h>
#include <stdio.h>
#include <arch.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 arch_early_setup()
{
arch_di();
riscv_update_vector();
return;
}

/**
* arch_setup - This function is called after initial setup is done
*
* @brief This function is called after initial setup is done.
*/
void arch_setup()
{
return;
}

void arch_di_save_state()
{
}

void arch_ei_restore_state()
{
}

/**
* 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()
{
context_frame_t *frame = get_context_frame();
printf("< x > Arch Panic!\n");
printf("Info:\nCause\t: 0x%x\t Address\t: 0x%x\n", frame->mcause, frame->mepc);
while(1)
arch_wfi();
}

_WEAK void arch_unhandled_irq()
{
context_frame_t *frame = get_context_frame();
printf("< x > Arch Unhandled IRQ!\n");
printf("Info:\nIRQ ID\t: 0x%x\n", frame->mcause & ~(1U << 31));
while(1)
arch_wfi();
}
Loading

0 comments on commit 2e22bb3

Please sign in to comment.