Skip to content

Commit

Permalink
Merge pull request #292 from VisorFolks/development
Browse files Browse the repository at this point in the history
Bump changes into stable.
  • Loading branch information
akashkollipara authored Jun 29, 2024
2 parents 35b69a7 + 031b45d commit a07ff55
Show file tree
Hide file tree
Showing 40 changed files with 1,536 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/github_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ jobs:
make demo_riscv
make demo_helios_avr
make demo_helios_riscv
make demo_qemu_sifive_e
make demo_ibex_ss
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
Expand Down
7 changes: 5 additions & 2 deletions mk/elf.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ ELF := $(addprefix $(OUT)/,$(PROJECT).elf)
LD_SCRIPT := $(addprefix $(OUT)/,$(LD_SCRIPT:.ld.sx=.ld))
LD_SUPPLEMENT := $(addprefix $(OUT)/,$(LD_SUPPLEMENT:.ld.sx=.ld))

ifneq ($(FLASH_START),)
SIZE_ARGS := -m Flash $(FLASH_START) $(FLASH_SIZE)
endif

elf: $(ELF)

.SECONDEXPANSION:
Expand All @@ -30,8 +34,7 @@ $(ELF): $(DEP_LIBS) $(DEP_OBJS) $(LD_SCRIPT) $(LD_SUPPLEMENT) | $$(SIZE)
$(OD) -Dx -h --wide $@ > $(@:.elf=.lst)
$(OC) -O binary $@ $(@:.elf=.bin)
$(OC) -O ihex $@ $(@:.elf=.hex)
@cd $(@D); $(SIZE) -f $(@F) -m Flash $(FLASH_START) $(FLASH_SIZE) \
-m RAM $(RAM_START) $(RAM_SIZE) $(MEMSIZE_ARGS)
@cd $(@D); $(SIZE) -f $(@F) $(SIZE_ARGS) -m RAM $(RAM_START) $(RAM_SIZE) $(MEMSIZE_ARGS)
@echo ""

$(OUT)/%.ld: %.ld.sx
Expand Down
20 changes: 20 additions & 0 deletions projects/demo_ibex_ss/build.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2024, 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)

OPTIMIZATION := s

EXE_MODE := terravisor

include $(PROJECT_DIR)/config.mk

DIR := $(PROJECT_DIR)
include mk/obj.mk
18 changes: 18 additions & 0 deletions projects/demo_ibex_ss/config.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2019, 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
FAMILY := ibex
PLATFORM := simple_system
STDLOG_MEMBUF := 1
BOOTMSGS := 1
EARLYCON_SERIAL := 1
OBRDLED_ENABLE := 0
TERRAKERN := 0
43 changes: 43 additions & 0 deletions projects/demo_ibex_ss/project.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* CYANCORE LICENSE
* Copyrights (C) 2022, 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 <stdio.h>
#include <string.h>
#include <terravisor/bootstrap.h>
#include <driver.h>
#include <time.h>

void plug()
{
bootstrap();
driver_setup_all();

printf("Demo Program!\n");
return;
}


void play()
{
static unsigned char i = 0;
char progress[] = "-\\|/";
uint64_t time;
char c = progress[(i++) % strlen(progress)];
get_timestamp(&time);
time /= 1000U;

printf("[%012llu] Running Blinky ... [%c]", time, c);

mdelay(500);

printf("\r");
return;
}
2 changes: 2 additions & 0 deletions src/arch/riscv/32/i/terravisor/arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ void arch_early_setup()
arch_di_mei();
arch_di_mtime();
arch_di_msoftirq();
#ifndef RV_VEC_MODE
riscv_update_vector();
#endif
return;
}

Expand Down
7 changes: 7 additions & 0 deletions src/arch/riscv/32/i/terravisor/asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,16 @@ function exception_handler_base
EPILOGUE
mret

#ifndef RV_VEC_MODE
function riscv_update_vector
la a0, exception_handler_base
csrw mtvec, a0
mv a0, zero
fence.i
ret
#else
vectors vtors
.rept 32
j exception_handler_base
.endr
#endif
2 changes: 2 additions & 0 deletions src/arch/riscv/32/i/terravisor/include/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,13 @@ static inline void arch_nop()

static inline void arch_wfi()
{
#ifndef RV_NO_WFI
asm volatile("wfi");
#if ERRATA_CIP578
arch_nop();
arch_nop();
#endif
#endif
}

static inline void arch_isb()
Expand Down
9 changes: 9 additions & 0 deletions src/arch/riscv/32/imc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# RV32 IMC-Extension

#### Supported Extensions
* RV32I baseline
* M - Hardware multiplication
* C - Compressed instructions

#### Supported execution level
* Terravisor
7 changes: 7 additions & 0 deletions src/arch/riscv/32/imc/terravisor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# RV32 IMAC [Terravisor]

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.
16 changes: 16 additions & 0 deletions src/arch/riscv/32/imc/terravisor/build.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2024, Cyancore Team
#
# File Name : build.mk
# Description : Build script for this directory.
# Primary Authod : Akash Kollipara [[email protected]]
# Organisation : Cyancore Core-Team
#

RV32IMC_T_ARCH_DIR := $(GET_PATH)

include $(RV32IMC_T_ARCH_DIR)/../../i/terravisor/build.mk

DIR := $(RV32IMC_T_ARCH_DIR)
include mk/obj.mk
20 changes: 20 additions & 0 deletions src/driver/console/con_serial_ibex/build.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2019, Cyancore Team
#
# File Name : build.mk
# Description : This file accumulates sources of console serial
# Primary Author : Akash Kollipara [[email protected]]
# Organisation : Cyancore Core-Team
#

DIR := $(GET_PATH)

EARLYCON_SERIAL ?= 0
CONSOLE_SERIAL := 0

$(eval $(call add_define,EARLYCON_SERIAL))

ifeq ($(filter $(CONSOLE_SERIAL) $(EARLYCON_SERIAL),1),1)
include mk/obj.mk
endif
92 changes: 92 additions & 0 deletions src/driver/console/con_serial_ibex/earlycon_serial.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* CYANCORE LICENSE
* Copyrights (C) 2019, Cyancore Team
*
* File Name : earlycon_serial.c
* Description : This file contains sources of uart earlycon
* Primary Author : Akash Kollipara [[email protected]]
* Organisation : Cyancore Core-Team
*/

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <status.h>
#include <stdlib.h>
#include <syslog.h>
#include <lock/spinlock.h>
#include <resource.h>
#include <visor_call.h>
#include <arch.h>
#include <driver.h>
#include <interrupt.h>
#include <hal/uart.h>
#include <driver/console.h>
#include <driver/sysclk.h>

static uart_port_t *earlycon_port;

static status_t earlycon_serial_setup()
{
uart_get_properties(earlycon_port, console_uart);

sysdbg2("UART engine @ %p\n", earlycon_port->baddr);
/*
* If memory mapping is applicable,
* put it in mmu supported guide.
*/
return success;
}

static status_t earlycon_serial_write(const char c)
{
status_t ret;
ret = uart_tx(earlycon_port, c);
return ret;
}

static console_t *earlycon_serial_driver;

status_t earlycon_serial_driver_exit()
{
status_t ret;
ret = console_release_device();
free(earlycon_port);
free(earlycon_serial_driver);
return ret;
}

status_t earlycon_serial_driver_setup()
{
status_t ret;

earlycon_port = (uart_port_t *)malloc(sizeof(uart_port_t));
if(!earlycon_port)
{
ret = error_memory_low;
goto cleanup_1;
}

earlycon_serial_driver = (console_t *)malloc(sizeof(console_t));
if(!earlycon_serial_driver)
{
ret = error_memory_low;
goto cleanup_1;
}
earlycon_serial_driver->write = &earlycon_serial_write;

ret = earlycon_serial_setup();
if(ret)
goto cleanup_1;
ret = console_attach_device(ret, earlycon_serial_driver);
if(!ret)
goto exit;
cleanup_1:
earlycon_serial_driver_exit();
exit:
return ret;
}

#if EARLYCON_SERIAL==1
INCLUDE_DRIVER(earlycon, earlycon_serial_driver_setup, earlycon_serial_driver_exit, 0, 2, 2);
#endif
2 changes: 2 additions & 0 deletions src/lib/libc/include/stdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ extern FILE stddev[];

int __printf(const char *fmt, ...);
int __eprintf(const char *fmt, ...);
int scanf(const char *fmt, ...);
int fputs(const FILE *, const char *);
int fputc(const FILE *, const char);
int fgetc(const FILE *, char *);
Expand All @@ -39,6 +40,7 @@ char getchar();
#ifdef _STDBOOL_H_
int fprintf(const FILE *, bool, const char *fmt, ...);
#ifdef _STDARG_H_
int vscanf(const FILE *, const char *fmt, va_list args);
int vprintf(const FILE *, bool, const char *fmt, va_list args);
#endif
#endif
Expand Down
4 changes: 3 additions & 1 deletion src/lib/libc/printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ static int fltprint(const FILE *dev, bool en_stdout, double flt,
{
frac *= 10.0;
padf--;
d = (long) frac;
if (!d)
__fputc(dev, en_stdout, '0');
}
d = (long) frac;
ret += unumprint(dev, en_stdout, d,10, '0', 0);

return ret;
Expand Down
Loading

0 comments on commit a07ff55

Please sign in to comment.