From b235f49f31d11e68019c42f48b6641c37e4c986e Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sun, 22 Aug 2021 20:38:48 +0300 Subject: Integrated libfdt + Added new common/ directory, into which code that should be shared with init and kernel is to be added. Currently string.c and bytes.c. Code in common/ should be marked with __weak, so as to allow the arch to implement a better, more optimised version of the function if possible/required. + Created include/apos/types.h with macros essentially providing the libc limits.h and stdint.h. At the moment I use gcc/clang predefined macros for most things. --- arch/riscv/conf/mkimage.sh | 3 +++ arch/riscv/init/init.c | 2 +- arch/riscv/sbi.c | 27 --------------------------- arch/riscv/source.mk | 6 +++++- 4 files changed, 9 insertions(+), 29 deletions(-) delete mode 100644 arch/riscv/sbi.c (limited to 'arch') diff --git a/arch/riscv/conf/mkimage.sh b/arch/riscv/conf/mkimage.sh index 31abb8e..5a22d01 100755 --- a/arch/riscv/conf/mkimage.sh +++ b/arch/riscv/conf/mkimage.sh @@ -13,6 +13,9 @@ SSIZE=$(fdisk -l rootfs.img | awk '$1=="Units:" {print $8}') OFFSET=$(fdisk -l rootfs.img | awk '$1=="rootfs.img1" {print $2}') mount -o loop,offset=$((${SSIZE}*${OFFSET})) rootfs.img fs +# not entirely pleased with this solution, although eventually I should probably +# move `run` out of the kernel repo and into some `aposos` repo with a runtime +# and proper initrd etc. so this is good enough for now ../u-boot-apos/tools/mkimage -f arch/riscv/conf/apos.its fs/apos.itb ../u-boot-apos/tools/mkimage -A riscv -O apos -T script \ -d arch/riscv/conf/boot.cmd fs/boot.scr diff --git a/arch/riscv/init/init.c b/arch/riscv/init/init.c index 69dbc0a..30c60ac 100644 --- a/arch/riscv/init/init.c +++ b/arch/riscv/init/init.c @@ -1,6 +1,6 @@ -#include #include #include +#include #include #include #include diff --git a/arch/riscv/sbi.c b/arch/riscv/sbi.c deleted file mode 100644 index e255ecf..0000000 --- a/arch/riscv/sbi.c +++ /dev/null @@ -1,27 +0,0 @@ -#include - -struct sbiret sbi_ecall(int ext, int fid, - unsigned long arg0, unsigned long arg1, unsigned long arg2, - unsigned long arg3, unsigned long arg4, unsigned long arg5) -{ - struct sbiret ret; - - register unsigned long a0 asm("a0") = arg0; - register unsigned long a1 asm("a1") = arg1; - register unsigned long a2 asm("a2") = arg2; - register unsigned long a3 asm("a3") = arg3; - register unsigned long a4 asm("a4") = arg4; - register unsigned long a5 asm("a5") = arg5; - register unsigned long a6 asm("a6") = fid; - register unsigned long a7 asm("a7") = ext; - - asm volatile ("ecall" - : "+r" (a0), "+r" (a1) - : "r" (a2), "r" (a3), "r" (a4), "r" (a5), "r" (a6), "r" (a7) - : "memory"); - - ret.error = a0; - ret.value = a1; - - return ret; -} diff --git a/arch/riscv/source.mk b/arch/riscv/source.mk index fb645f7..cf8edd7 100644 --- a/arch/riscv/source.mk +++ b/arch/riscv/source.mk @@ -2,8 +2,12 @@ KERNEL_LOCAL != echo arch/riscv/*.[cS] KERNEL_SOURCES += $(KERNEL_LOCAL) INIT_LOCAL != echo arch/riscv/init/*.[cS] -INIT_SOURCES += $(INIT_LOCAL) +INIT_FDT != echo lib/fdt*.c +INIT_SOURCES += $(INIT_LOCAL) $(INIT_FDT) CLEANUP_CMD := ./arch/riscv/conf/rmimage.sh + +USE_FDT := y + run: ./arch/riscv/conf/mkimage.sh -- cgit v1.3