-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2bdfe5
commit 0121dd3
Showing
41 changed files
with
718 additions
and
851 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,24 @@ | ||
.POSIX: | ||
|
||
export ROOT=${abspath .} | ||
|
||
.SECONDARY: | ||
|
||
PROJECTS:=projects/hello \ | ||
projects/trapped \ | ||
projects/ping-pong \ | ||
projects/demonstrator | ||
PLATFORM?=qemu_virt | ||
|
||
include tools.mk | ||
include common/plat/${PLATFORM}.mk | ||
|
||
all: ${PROJECTS} | ||
|
||
${PROJECTS}: common | ||
|
||
common ${PROJECTS}: | ||
make -C $@ all PLATFORM=${PLATFORM} | ||
@${MAKE} -C $@ all | ||
|
||
clean: | ||
for i in ${PROJECTS}; do \ | ||
make -C $$i clean PLATFORM=${PLATFORM}; \ | ||
@for i in common ${PROJECTS}; do \ | ||
${MAKE} -C $$i clean; \ | ||
done | ||
|
||
format: | ||
clang-format -i $$(find * -type f -name '*.[hc]') | ||
|
||
.PHONY: all docs clean common ${PROJECTS} | ||
.PHONY: all clean format common ${PROJECTS} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,15 @@ | ||
.POSIX: | ||
.SECONDARY: | ||
|
||
include plat/${PLATFORM}.mk | ||
PLATFORM?=${patsubst plat/%.mk, %, ${wildcard plat/*.mk}} | ||
|
||
include ${ROOT}/tools.mk | ||
all: ${addsuffix .all, ${PLATFORM}} | ||
clean: ${addsuffix .clean, ${PLATFORM}} | ||
|
||
# CFLAGS | ||
CFLAGS:=-march=${ARCH} -mabi=${ABI} -mcmodel=${CMODEL} \ | ||
-DPLATFORM_${PLATFORM} \ | ||
-Os -flto -ffat-lto-objects \ | ||
-nostdlib -Iinc \ | ||
%.all: | ||
${MAKE} -f build.mk PLATFORM=${@:.all=} all | ||
|
||
BUILD :=build/${PLATFORM} | ||
SRCS2OBJS=${patsubst src/%.S, ${BUILD}/%.o, ${filter %.S, ${1}}} \ | ||
${patsubst src/%.c, ${BUILD}/%.o, ${filter %.c, ${1}}} | ||
|
||
ALTC_SRCS :=${wildcard src/altc/*.[cS]} | ||
S3K_SRCS :=${wildcard src/s3k/*.[cS]} | ||
START_SRCS:=${wildcard src/start/*.S} | ||
|
||
PLAT_OBJS :=${call SRCS2OBJS, ${PLAT_SRCS}} | ||
ALTC_OBJS :=${call SRCS2OBJS, ${ALTC_SRCS}} | ||
S3K_OBJS :=${call SRCS2OBJS, ${S3K_SRCS}} | ||
START_OBJS:=${call SRCS2OBJS, ${START_SRCS}} | ||
|
||
TARGETS:=${BUILD}/libplat.a \ | ||
${BUILD}/libaltc.a \ | ||
${BUILD}/libs3k.a \ | ||
${START_OBJS} | ||
|
||
|
||
all: ${TARGETS} | ||
|
||
clean: | ||
rm -rf ${TARGETS} | ||
|
||
${BUILD}/libplat.a: ${PLAT_OBJS} | ||
@mkdir -p ${@D} | ||
${AR} cr $@ $^ | ||
|
||
${BUILD}/libaltc.a: ${ALTC_OBJS} | ||
@mkdir -p ${@D} | ||
${AR} cr $@ $^ | ||
|
||
${BUILD}/libs3k.a: ${S3K_OBJS} | ||
@mkdir -p ${@D} | ||
${AR} cr $@ $^ | ||
|
||
${BUILD}/%.o: src/%.c | ||
@mkdir -p ${@D} | ||
${CC} -o $@ $< -c ${CFLAGS} | ||
|
||
${BUILD}/%.o: src/%.S | ||
@mkdir -p ${@D} | ||
${CC} -o $@ $< -c ${CFLAGS} | ||
%.clean: | ||
${MAKE} -f build.mk PLATFORM=${@:.clean=} clean | ||
|
||
.PHONY: all clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
.POSIX: | ||
|
||
ROOT:=${abspath ..} | ||
|
||
include plat/${PLATFORM}.mk | ||
|
||
include ${ROOT}/tools.mk | ||
|
||
# CFLAGS | ||
CFLAGS:=-march=${ARCH} -mabi=${ABI} -mcmodel=${CMODEL} \ | ||
-DPLATFORM_${PLATFORM} \ | ||
-Os -flto -ffat-lto-objects \ | ||
-nostdlib -Iinc \ | ||
|
||
BUILD :=build/${PLATFORM} | ||
SRCS2OBJS=${patsubst src/%.S, ${BUILD}/%.o, ${filter %.S, ${1}}} \ | ||
${patsubst src/%.c, ${BUILD}/%.o, ${filter %.c, ${1}}} | ||
|
||
ALTC_SRCS :=${wildcard src/altc/*.[cS]} | ||
S3K_SRCS :=${wildcard src/s3k/*.[cS]} | ||
START_SRCS:=${wildcard src/start/*.S} | ||
|
||
PLAT_OBJS :=${call SRCS2OBJS, ${PLAT_SRCS}} | ||
ALTC_OBJS :=${call SRCS2OBJS, ${ALTC_SRCS}} | ||
S3K_OBJS :=${call SRCS2OBJS, ${S3K_SRCS}} | ||
START_OBJS:=${call SRCS2OBJS, ${START_SRCS}} | ||
|
||
TARGETS:=${BUILD}/libplat.a \ | ||
${BUILD}/libaltc.a \ | ||
${BUILD}/libs3k.a \ | ||
${START_OBJS} | ||
|
||
|
||
all: ${TARGETS} | ||
|
||
clean: | ||
rm -rf ${BUILD} | ||
|
||
${BUILD}/libplat.a: ${PLAT_OBJS} | ||
@mkdir -p ${@D} | ||
@${AR} cr $@ $^ | ||
@printf "AR\t$@\n" | ||
|
||
${BUILD}/libaltc.a: ${ALTC_OBJS} | ||
@mkdir -p ${@D} | ||
@${AR} cr $@ $^ | ||
@printf "AR\t$@\n" | ||
|
||
${BUILD}/libs3k.a: ${S3K_OBJS} | ||
@mkdir -p ${@D} | ||
@${AR} cr $@ $^ | ||
@printf "AR\t$@\n" | ||
|
||
${BUILD}/%.o: src/%.c | ||
@mkdir -p ${@D} | ||
@${CC} -o $@ $< -c ${CFLAGS} | ||
@printf "CC\t$@\n" | ||
|
||
${BUILD}/%.o: src/%.S | ||
@mkdir -p ${@D} | ||
@${CC} -o $@ $< -c ${CFLAGS} | ||
@printf "CC\t$@\n" | ||
|
||
.PHONY: all clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
#pragma once | ||
|
||
#if defined(PLATFORM_qemu_virt) || defined(PLATFORM_qemu_virt4) | ||
#if defined(PLATFORM_qemu_virt) | ||
#include "plat/qemu_virt.h" | ||
#elif defined(PLATFORM_qemu_virt4) | ||
#include "plat/qemu_virt4.h" | ||
#elif defined(PLATFORM_sifive_unleashed) | ||
#include "plat/sifive_unleashed.h" | ||
#elif defined(PLATFORM_sifive_unleashed4) | ||
#include "plat/sifive_unleashed4.h" | ||
#else | ||
#error "Unsupported platform or platform not found" | ||
#endif | ||
|
||
#if S3K_HART_CNT > 1 | ||
#define SMP | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Platform configuration for QEMU virt | ||
*/ | ||
#pragma once | ||
|
||
#define UART_NS16550A | ||
#define UART0_BASE_ADDR (0x10000000ull) | ||
|
||
#define MTIME_BASE_ADDR 0x200bff8ull | ||
#define MTIMECMP_BASE_ADDR 0x2004000ull | ||
|
||
// Min and max usable hart ID. | ||
#define S3K_MIN_HART 0 | ||
#define S3K_MAX_HART 3 | ||
|
||
// Total number of usable harts. | ||
#define S3K_HART_CNT (S3K_MAX_HART - S3K_MIN_HART + 1ul) | ||
|
||
// Number of PMP slots. | ||
#define S3K_PMP_CNT 8 | ||
|
||
// RTC ticks per second | ||
#define S3K_RTC_HZ 1000000ull | ||
|
||
/// Stack size of 1024 KiB | ||
#define S3K_LOG_STACK_SIZE 10 | ||
|
||
#define INIT_CAPS \ | ||
{ \ | ||
[0] = cap_mk_pmp(0x20005fff, MEM_RWX), \ | ||
[1] = cap_mk_memory(0x80020000, 0x88000000, MEM_RWX), \ | ||
[2] = cap_mk_memory(0x10000000, 0x10001000, MEM_RW), \ | ||
[3] = cap_mk_memory(0x200b000, 0x200c000, MEM_R), \ | ||
[4] = cap_mk_time(0, 0, S3K_SLOT_CNT), \ | ||
[5] = cap_mk_time(1, 0, S3K_SLOT_CNT), \ | ||
[6] = cap_mk_time(2, 0, S3K_SLOT_CNT), \ | ||
[7] = cap_mk_time(3, 0, S3K_SLOT_CNT), \ | ||
[8] = cap_mk_monitor(0, S3K_PROC_CNT), \ | ||
[9] = cap_mk_channel(0, S3K_CHAN_CNT), \ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
#define UART_SIFIVE | ||
#define UART0_BASE_ADDR (0x10010000ull) | ||
|
||
#define MTIME_BASE_ADDR 0x200bff8ull | ||
#define MTIMECMP_BASE_ADDR 0x2004000ull | ||
|
||
// Min and max usable hart ID. | ||
#define S3K_MIN_HART 1 | ||
#define S3K_MAX_HART 4 | ||
|
||
// Total number of usable harts. | ||
#define S3K_HART_CNT (S3K_MAX_HART - S3K_MIN_HART + 1ul) | ||
|
||
// Number of PMP slots. | ||
#define S3K_PMP_CNT 8 | ||
|
||
// RTC ticks per second | ||
#define S3K_RTC_HZ 1000000ull | ||
|
||
/// Stack size of 1024 KiB | ||
#define S3K_LOG_STACK_SIZE 10 | ||
|
||
#define UART_SIFIVE | ||
|
||
#define INIT_CAPS \ | ||
{ \ | ||
[0] = cap_mk_pmp(0x20005fff, MEM_RWX), \ | ||
[1] = cap_mk_memory(0x80020000, 0x88000000, MEM_RWX), \ | ||
[2] = cap_mk_memory(0x10010000, 0x10011000, MEM_RW), \ | ||
[3] = cap_mk_memory(0x200b000, 0x200c000, MEM_R), \ | ||
[4] = cap_mk_time(1, 0, S3K_SLOT_CNT), \ | ||
[5] = cap_mk_time(2, 0, S3K_SLOT_CNT), \ | ||
[6] = cap_mk_time(3, 0, S3K_SLOT_CNT), \ | ||
[7] = cap_mk_time(4, 0, S3K_SLOT_CNT), \ | ||
[8] = cap_mk_monitor(0, S3K_PROC_CNT), \ | ||
[9] = cap_mk_channel(0, S3K_CHAN_CNT), \ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export ARCH=rv64imac_zicsr_zifencei | ||
export ABI=lp64 | ||
export CMODEL=medany | ||
export COMMON_INC:=${ROOT}/common/inc | ||
export COMMON_LIB:=${ROOT}/common/build/${PLATFORM} | ||
export STARTFILES:=${ROOT}/common/build/${PLATFORM}/start | ||
PLAT_SRCS=src/drivers/uart/sifive.c src/drivers/time.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.