Skip to content

Commit

Permalink
Merge pull request #235 from VisorFolks/feature/akashkollipara/233-qe…
Browse files Browse the repository at this point in the history
…mu-bl
  • Loading branch information
akashkollipara authored Feb 19, 2023
2 parents d6527eb + 20c55a2 commit f743430
Show file tree
Hide file tree
Showing 28 changed files with 884 additions and 14 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ Connect with us over VisorFolks discord server: < [**JOIN**](https://discord.gg/

### Supported Platforms

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

### Programming Languages
* asm/assembly
Expand Down
20 changes: 20 additions & 0 deletions projects/demo_qemu_sifive_e/build.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2023, Cyancore Team
#
# File Name : build.mk
# Description : This file builds and gathers project properties
# Primary Author : Akash Kollipara [[email protected]]
# Organisation : Cyancore Core-Team
#

PROJECT_DIR := $(GET_PATH)

include $(PROJECT_DIR)/../demo.src/build.mk
include $(PROJECT_DIR)/config.mk

DIR := $(PROJECT_DIR)
include mk/obj.mk

aux_target:
make qemu_sifive_e_bl
20 changes: 20 additions & 0 deletions projects/demo_qemu_sifive_e/config.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2023, Cyancore Team
#
# File Name : config.mk
# Description : This file consists of project config
# Primary Author : Akash Kollipara [[email protected]]
# Organisation : Cyancore Core-Team
#

COMPILER := gcc
TC_VER := 10.2.0
FAMILY := sifive
PLATFORM := qemu-sifive-e
STDLOG_MEMBUF := 0
BOOTMSGS := 0
EARLYCON_SERIAL := 1
CONSOLE_SERIAL := 1
OBRDLED_ENABLE := 1
TERRAKERN := 0
21 changes: 21 additions & 0 deletions projects/qemu_sifive_e_bl/build.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2023, Cyancore Team
#
# File Name : build.mk
# Description : This file build project sources and specifies
# project properties
# Primary Author : Akash Kollipara [[email protected]]
# Organisation : Cyancore Core-Team
#

PROJECT_DIR := $(GET_PATH)

OPTIMIZATION := s

EXE_MODE := terravisor

include $(PROJECT_DIR)/config.mk

DIR := $(PROJECT_DIR)
include mk/obj.mk
21 changes: 21 additions & 0 deletions projects/qemu_sifive_e_bl/config.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2023, Cyancore Team
#
# File Name : config.mk
# Description : This file consists of project config
# Primary Author : Akash Kollipara [[email protected]]
# Organisation : Cyancore Core-Team
#

COMPILER := gcc
TC_VER := 10.2.0
FAMILY := sifive
PLATFORM := qemu-sifive-e-bl
USE_FLOAT := 0
STDLOG_MEMBUF := 0
BOOTMSGS := 0
EARLYCON_SERIAL := 1
CONSOLE_SERIAL := 0
OBRDLED_ENABLE := 0
TERRAKERN := 0
40 changes: 40 additions & 0 deletions projects/qemu_sifive_e_bl/project.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* CYANCORE LICENSE
* Copyrights (C) 2023, Cyancore Team
*
* File Name : project.c
* Description : This file consists of project srouces
* Primary Author : Akash Kollipara [[email protected]]
* Organisation : Cyancore Core-Team
*/

#include <status.h>
#include <syslog.h>
#include <terravisor/bootstrap.h>
#include <arch.h>
#include <driver.h>
#include <interrupt.h>
#include <platform.h>

void no_program(void);
void plug()
{
bootstrap();
driver_setup_all();
syslog_stdout_enable();
link_interrupt(int_arch, 2, no_program);
syslog(info, "Bootloader!\n");
syslog(info, "Jumping to XIP...\n");
driver_exit_all();
arch_di();
platform_jump_to_user_code();
return;
}

void no_program()
{
driver_setup_all();
syslog(fail, "No User program found!\n");
plat_panic_handler();
}

2 changes: 2 additions & 0 deletions src/driver/interrupt/plic/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
PLIC_PATH := $(GET_PATH)

ifeq ($(ARCH), riscv)
ifneq ($(N_PLAT_IRQS),0)

DIR := $(PLIC_PATH)
include mk/obj.mk

endif
endif
2 changes: 1 addition & 1 deletion src/lib/libc/malloc_lite.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static void merge()
{
chunk_t *cur;
cur = freeList;
while(cur->next != NULL)
while(cur && cur->next)
{
if(cur->free && cur->next->free)
{
Expand Down
6 changes: 4 additions & 2 deletions src/platform/sifive/common_fe310/platform/plat_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ static tvisor_timer_t *plat_timer_port;
* plat_timer_setup - Timer driver setup function
* To be exported to driver table.
*/
static status_t plat_timer_setup(void)
status_t plat_timer_setup(void)
{
status_t ret = success;
const irqs_t *irq;
Expand Down Expand Up @@ -177,7 +177,7 @@ static status_t plat_timer_setup(void)
* plat_timer_exit - Timer driver shutdown function
* To be exported to driver table.
*/
static status_t plat_timer_exit(void)
status_t plat_timer_exit(void)
{
const irqs_t *irq;
arch_di_mtime();
Expand All @@ -189,4 +189,6 @@ static status_t plat_timer_exit(void)
return timer_release_device();
}

#if USE_TIMER
INCLUDE_DRIVER(plat_timer, plat_timer_setup, plat_timer_exit, 0, 1, 1);
#endif
17 changes: 16 additions & 1 deletion src/platform/sifive/common_fe310/platform/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,35 @@ static void platform_memory_layout()

void platform_setup()
{
/*
status_t ret = success;
*/

#if PRCI_CLK
status_t ret = success;
driver_setup("sysclk_prci");
ret |= sysclk_reset();
/* This is a temporary change */
if(ret != success)
exit(EXIT_FAILURE);
#endif

driver_setup("earlycon");
bootmsgs_enable();
#ifdef BOOTLOADER
cyancore_insignia_lite();
#else
cyancore_insignia();
#endif

#if PRINT_MEMORY_LAYOUT
platform_memory_layout();
#endif

/* Uncomment this and remove above check if more conditions
* are introduced.
if(ret != success)
exit(EXIT_FAILURE);
*/
return;
}

Expand Down
12 changes: 6 additions & 6 deletions src/platform/sifive/fe310g002-bl/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
# Organisation : Cyancore Core-Team
#

FE310G002_DIR := $(GET_PATH)
FE310G002_BL_DIR := $(GET_PATH)

ARCH := riscv
BIT := 32
ARCH_VARIANT := imac
ARCH_ABI := ilp32
TARGET_FLAGS += -march=rv32imac -mabi=$(ARCH_ABI)
PLAT_INCLUDE += $(FE310G002_DIR)/include
PLAT_INCLUDE += $(FE310G002_BL_DIR)/include
OUTPUT_FORMAT := elf32-littleriscv

include $(FE310G002_DIR)/config.mk
include $(FE310G002_DIR)/../common_fe310/build.mk
$(eval $(call check_and_include,USE_DEFAULT_RESOURCES,$(FE310G002_DIR)/resources/build.mk))
include $(FE310G002_BL_DIR)/config.mk
include $(FE310G002_BL_DIR)/../common_fe310/build.mk
$(eval $(call check_and_include,USE_DEFAULT_RESOURCES,$(FE310G002_BL_DIR)/resources/build.mk))

DIR := $(FE310G002_DIR)
DIR := $(FE310G002_BL_DIR)
include mk/obj.mk
10 changes: 10 additions & 0 deletions src/platform/sifive/fe310g002-bl/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,20 @@ $(eval $(call add_define,ERRATA_CIP578))
#======================================================================
SYSCLK_ENABLE := 1
PRCI_CLK := 1
$(eval $(call add_define,SYSCLK_ENABLE))
$(eval $(call add_define,PRCI_CLK))
#======================================================================

#======================================================================
# Bootload Configuration
#======================================================================
$(eval $(call add_define,BOOTLOADER))

#======================================================================
# Bootloader
# \ Timer: Sched timer/wall clock
#======================================================================
USE_TIMER ?= 0
$(eval $(call add_define,USE_TIMER))
#======================================================================
#======================================================================
9 changes: 9 additions & 0 deletions src/platform/sifive/fe310g002/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,13 @@ $(eval $(call add_define,ERRATA_CIP578))
#======================================================================
SYSCLK_ENABLE := 1
PRCI_CLK := 1
$(eval $(call add_define,SYSCLK_ENABLE))
$(eval $(call add_define,PRCI_CLK))
#======================================================================

#======================================================================
# Timer: Sched timer/wall clock
#======================================================================
USE_TIMER ?= 1
$(eval $(call add_define,USE_TIMER))
#======================================================================
28 changes: 28 additions & 0 deletions src/platform/sifive/qemu-sifive-e-bl/build.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2023, Cyancore Team
#
# File Name : build.mk
# Description : This file accumulates the build scripts from
# all other directories that have sifive-e
# board support sources
# Primary Author : Akash Kollipara [[email protected]]
# Organisation : Cyancore Core-Team
#

QEMU_SIFIVE_E_BL_DIR := $(GET_PATH)

ARCH := riscv
BIT := 32
ARCH_VARIANT := imac
ARCH_ABI := ilp32
TARGET_FLAGS += -march=rv32imac -mabi=$(ARCH_ABI)
PLAT_INCLUDE += $(QEMU_SIFIVE_E_BL_DIR)/include
OUTPUT_FORMAT := elf32-littleriscv

include $(QEMU_SIFIVE_E_BL_DIR)/config.mk
include $(QEMU_SIFIVE_E_BL_DIR)/../common_fe310/build.mk
$(eval $(call check_and_include,USE_DEFAULT_RESOURCES,$(QEMU_SIFIVE_E_BL_DIR)/resources/build.mk))

DIR := $(QEMU_SIFIVE_E_BL_DIR)
include mk/obj.mk
Loading

0 comments on commit f743430

Please sign in to comment.