commit 042b01bf1eb4597412a52b4aafb2b134e996dce9 parent 56bf7c4de1cc9ca20f73d26b2f5d24f7394e5f88 Author: Roberto Vargas <roberto.vargas@arm.com> Date: Thu, 22 Nov 2018 17:08:56 +0000 [target] Change the arch layout to target layout Change-Id: Ifd7f99e00012e4cd02afa9280e3f71f1d5f771ea Diffstat:
93 files changed, 136 insertions(+), 524 deletions(-)
diff --git a/Makefile b/Makefile @@ -3,28 +3,26 @@ PROJECTDIR = . include scripts/rules.mk TESTS = functional fuzzing integration model unit +DIRS = src target drivers test -all: arch/$(ARCH) +all: target test $(TESTS): all FORCE @+cd test/ && $(MAKE) $@ -arch/$(ARCH): src +target: src src: lib bin bin lib: mkdir $@ -drivers src arch/$(ARCH): FORCE +drivers src target: FORCE +@cd $@ && $(MAKE) gen: FORCE +@cd src && $(MAKE) gen clean: - +@cd src && $(MAKE) clean - +@cd arch && $(MAKE) clean - +@cd drivers && $(MAKE) clean - +@cd test && $(MAKE) clean + $(FORALL) rm -rf lib bin diff --git a/arch/Makefile b/arch/Makefile @@ -1,11 +0,0 @@ -.POSIX: -PROJECTDIR=.. -include $(PROJECTDIR)/scripts/rules.mk - -DIRS=arm32 arm64 amd64 - -all: - +@cd $(ARCH) && $(MAKE) - -clean: - $(FORALL) diff --git a/arch/amd64/Makefile b/arch/amd64/Makefile @@ -1,34 +0,0 @@ -.POSIX: -PROJECTDIR = ../.. -include $(PROJECTDIR)/scripts/rules.mk - -ROMOBJS = arch.o \ - rom.o \ - bss.o \ - sys/$(SYS)/builtin.o \ - $(SRCDIR)/romfw/builtin.o \ - -RAMOBJS = arch.o \ - ram.o \ - bss.o \ - sys/$(SYS)/builtin.o \ - $(SRCDIR)/ramfw/builtin.o \ - -TARGET = $(BINDIR)/romfw.elf $(BINDIR)/ramfw.elf -DIRS = sys - -all: $(TARGET) - -sys/$(SYS)/builtin.o: sys/$(SYS) - -sys/$(SYS): FORCE - cd $@ && $(MAKE) - -$(BINDIR)/romfw.elf: $(ROMOBJS) $(LIBDEP) - $(LD) $(RCODE_LDFLAGS) $(ROMOBJS) $(RCODE_LDLIBS) -o $@ - -$(BINDIR)/ramfw.elf: $(RAMOBJS) $(LIBDEP) - $(LD) $(RCODE_LDFLAGS) $(RAMOBJS) $(RCODE_LDLIBS) -o $@ - -clean: - $(FORALL) diff --git a/arch/amd64/arch.c b/arch/amd64/arch.c @@ -1,28 +0,0 @@ -#include <setjmp.h> -#include <stdio.h> -#include <stdlib.h> - -#include <rcode.h> - -jmp_buf recover; - -noreturn void abort(void); -noreturn void longjmp(jmp_buf env, int val); - -void -dohalt(void) -{ - abort(); -} - -void -doswtch(struct trapframe *fp) -{ - longjmp(recover, 1); -} - -void -dopanic(void) -{ - trap(NULL); -} diff --git a/arch/amd64/bss.c b/arch/amd64/bss.c @@ -1 +0,0 @@ -#include "../sys/bss.c" diff --git a/arch/amd64/sys/Makefile b/arch/amd64/sys/Makefile @@ -1,8 +0,0 @@ -.POSIX: -PROJECTDIR=../../.. -include $(PROJECTDIR)/scripts/rules.mk - -DIRS = dragonfly linux netbsd openbsd - -clean: - $(FORALL) diff --git a/arch/amd64/sys/dragonfly/Makefile b/arch/amd64/sys/dragonfly/Makefile @@ -1,13 +0,0 @@ -.POSIX: -PROJECTDIR=../../../.. -include $(PROJECTDIR)/scripts/rules.mk - -OBJS = crt.o \ - putenv.o \ - -all: builtin.o - -builtin.o: $(OBJS) - $(LD) $(RCODE_LDFLAGS) -r -o $@ $(OBJS) - -crt.o: ../crt-posix.s diff --git a/arch/amd64/sys/dragonfly/crt.s b/arch/amd64/sys/dragonfly/crt.s @@ -1 +0,0 @@ - .include "../crt-posix.s" diff --git a/arch/amd64/sys/dragonfly/putenv.c b/arch/amd64/sys/dragonfly/putenv.c @@ -1 +0,0 @@ -#include "../../../sys/putenv-posix.c" diff --git a/arch/amd64/sys/linux/Makefile b/arch/amd64/sys/linux/Makefile @@ -1,13 +0,0 @@ -.POSIX: -PROJECTDIR=../../../.. -include $(PROJECTDIR)/scripts/rules.mk - -OBJS = crt.o \ - putenv.o \ - -all: builtin.o - -builtin.o: $(OBJS) - $(LD) $(RCODE_LDFLAGS) -r -o $@ $(OBJS) - -crt.o: ../crt-posix.s diff --git a/arch/amd64/sys/linux/crt.s b/arch/amd64/sys/linux/crt.s @@ -1 +0,0 @@ - .include "../crt-posix.s" diff --git a/arch/amd64/sys/linux/putenv.c b/arch/amd64/sys/linux/putenv.c @@ -1 +0,0 @@ -#include "../../../sys/putenv-posix.c" diff --git a/arch/amd64/sys/netbsd/Makefile b/arch/amd64/sys/netbsd/Makefile @@ -1,13 +0,0 @@ -.POSIX: -PROJECTDIR=../../../.. -include $(PROJECTDIR)/scripts/rules.mk - -OBJS = crt.o \ - putenv.o \ - -all: builtin.o - -builtin.o: $(OBJS) - $(LD) $(RCODE_LDFLAGS) -r -o $@ $(OBJS) - -crt.o: ../crt-posix.s diff --git a/arch/amd64/sys/netbsd/crt.s b/arch/amd64/sys/netbsd/crt.s @@ -1,9 +0,0 @@ - .section ".note.netbsd.ident", "a" - .p2align 2 - - .long 7 - .long 4 - .long 1 - .ascii "NetBSD\0\0" - .long 800000000 - .include "../crt-posix.s" diff --git a/arch/amd64/sys/netbsd/putenv.c b/arch/amd64/sys/netbsd/putenv.c @@ -1 +0,0 @@ -#include "../../../sys/putenv-posix.c" diff --git a/arch/amd64/sys/openbsd/Makefile b/arch/amd64/sys/openbsd/Makefile @@ -1,13 +0,0 @@ -.POSIX: -PROJECTDIR=../../../.. -include $(PROJECTDIR)/scripts/rules.mk - -OBJS = crt.o \ - putenv.o \ - -all: builtin.o - -builtin.o: $(OBJS) - $(LD) $(RCODE_LDFLAGS) -r -o $@ $(OBJS) - -crt.o: ../crt-posix.s diff --git a/arch/amd64/sys/openbsd/crt.s b/arch/amd64/sys/openbsd/crt.s @@ -1,9 +0,0 @@ - .section ".note.openbsd.ident", "a" - .p2align 2 - .long 8 - .long 4 - .long 1 - .ascii "OpenBSD\0" - .long 0 - .p2align 2 - .include "../crt-posix.s" diff --git a/arch/amd64/sys/openbsd/putenv.c b/arch/amd64/sys/openbsd/putenv.c @@ -1 +0,0 @@ -#include "../../../sys/putenv-posix.c" diff --git a/arch/arm32/Makefile b/arch/arm32/Makefile @@ -1,34 +0,0 @@ -.POSIX: -PROJECTDIR = ../.. -include $(PROJECTDIR)/scripts/rules.mk - -ROMOBJS = arch.o \ - rom.o \ - bss.o \ - sys/$(SYS)/builtin.o \ - $(SRCDIR)/romfw/builtin.o \ - -RAMOBJS = arch.o \ - ram.o \ - bss.o \ - sys/$(SYS)/builtin.o \ - $(SRCDIR)/ramfw/builtin.o \ - -TARGET = $(BINDIR)/romfw.elf $(BINDIR)/ramfw.elf -DIRS = sys - -all: $(TARGET) - -sys/$(SYS)/builtin.o: sys/$(SYS) - -sys/$(SYS): FORCE - cd $@ && $(MAKE) - -$(BINDIR)/romfw.elf: $(ROMOBJS) $(LIBDEP) - $(LD) $(RCODE_LDFLAGS) $(ROMOBJS) $(RCODE_LDLIBS) -o $@ - -$(BINDIR)/ramfw.elf: $(RAMOBJS) $(LIBDEP) - $(LD) $(RCODE_LDFLAGS) $(RAMOBJS) $(RCODE_LDLIBS) -o $@ - -clean: - $(FORALL) diff --git a/arch/arm32/arch.c b/arch/arm32/arch.c @@ -1,28 +0,0 @@ -#include <setjmp.h> -#include <stdio.h> -#include <stdlib.h> - -#include <rcode.h> - -jmp_buf recover; - -noreturn void abort(void); -noreturn void longjmp(jmp_buf env, int val); - -void -dohalt(void) -{ - abort(); -} - -void -doswtch(struct trapframe *fp) -{ - longjmp(recover, 1); -} - -void -dopanic(void) -{ - trap(NULL); -} diff --git a/arch/arm32/bss.c b/arch/arm32/bss.c @@ -1 +0,0 @@ -#include "../sys/bss.c" diff --git a/arch/arm32/ram.c b/arch/arm32/ram.c @@ -1,7 +0,0 @@ -#include <rcode.h> - -int -main(int argc, char *argv[]) -{ - return 0; -} diff --git a/arch/arm32/rom.c b/arch/arm32/rom.c @@ -1,20 +0,0 @@ -#include <string.h> - -#include <rcode.h> - -struct tree tree[] = { - {"/dev", FSDIR | FSCREATE | FSREAD}, - {"/dev/uart", FSDIR | FSREAD}, - {"/realms", FSDIR | FSREAD}, - {NULL} -}; - -int -main(int argc, char *argv[]) -{ - memset(bss, 0, sizeof(struct bssmap)); - bss->fp = &(struct trapframe) {0}; - - initfs(tree); - return debug(); -} diff --git a/arch/arm32/sys/Makefile b/arch/arm32/sys/Makefile @@ -1,8 +0,0 @@ -.POSIX: -PROJECTDIR=../../.. -include $(PROJECTDIR)/scripts/rules.mk - -DIRS = dragonfly linux netbsd openbsd - -clean: - $(FORALL) diff --git a/arch/arm32/sys/dragonfly/Makefile b/arch/arm32/sys/dragonfly/Makefile @@ -1,13 +0,0 @@ -.POSIX: -PROJECTDIR=../../../.. -include $(PROJECTDIR)/scripts/rules.mk - -OBJS = crt.o \ - putenv.o \ - -all: builtin.o - -builtin.o: $(OBJS) - $(LD) $(RCODE_LDFLAGS) -r -o $@ $(OBJS) - -crt.o: ../crt-posix.s diff --git a/arch/arm32/sys/dragonfly/crt.s b/arch/arm32/sys/dragonfly/crt.s @@ -1 +0,0 @@ - .include "../crt-posix.s" diff --git a/arch/arm32/sys/dragonfly/putenv.c b/arch/arm32/sys/dragonfly/putenv.c @@ -1 +0,0 @@ -#include "../../../sys/putenv-posix.c" diff --git a/arch/arm32/sys/linux/Makefile b/arch/arm32/sys/linux/Makefile @@ -1,13 +0,0 @@ -.POSIX: -PROJECTDIR=../../../.. -include $(PROJECTDIR)/scripts/rules.mk - -OBJS = crt.o \ - putenv.o \ - -all: builtin.o - -builtin.o: $(OBJS) - $(LD) $(RCODE_LDFLAGS) -r -o $@ $(OBJS) - -crt.o: ../crt-posix.s diff --git a/arch/arm32/sys/linux/crt.s b/arch/arm32/sys/linux/crt.s @@ -1 +0,0 @@ - .include "../crt-posix.s" diff --git a/arch/arm32/sys/linux/putenv.c b/arch/arm32/sys/linux/putenv.c @@ -1 +0,0 @@ -#include "../../../sys/putenv-posix.c" diff --git a/arch/arm32/sys/netbsd/Makefile b/arch/arm32/sys/netbsd/Makefile @@ -1,13 +0,0 @@ -.POSIX: -PROJECTDIR=../../../.. -include $(PROJECTDIR)/scripts/rules.mk - -OBJS = crt.o \ - putenv.o \ - -all: builtin.o - -builtin.o: $(OBJS) - $(LD) $(RCODE_LDFLAGS) -r -o $@ $(OBJS) - -crt.o: ../crt-posix.s diff --git a/arch/arm32/sys/netbsd/crt.s b/arch/arm32/sys/netbsd/crt.s @@ -1,9 +0,0 @@ - .section ".note.netbsd.ident", "a" - .p2align 2 - - .long 7 - .long 4 - .long 1 - .ascii "NetBSD\0\0" - .long 800000000 - .include "../crt-posix.s" diff --git a/arch/arm32/sys/netbsd/putenv.c b/arch/arm32/sys/netbsd/putenv.c @@ -1 +0,0 @@ -#include "../../../sys/putenv-posix.c" diff --git a/arch/arm32/sys/openbsd/Makefile b/arch/arm32/sys/openbsd/Makefile @@ -1,13 +0,0 @@ -.POSIX: -PROJECTDIR=../../../.. -include $(PROJECTDIR)/scripts/rules.mk - -OBJS = crt.o \ - putenv.o \ - -all: builtin.o - -builtin.o: $(OBJS) - $(LD) $(RCODE_LDFLAGS) -r -o $@ $(OBJS) - -crt.o: ../crt-posix.s diff --git a/arch/arm32/sys/openbsd/crt.s b/arch/arm32/sys/openbsd/crt.s @@ -1,9 +0,0 @@ - .section ".note.openbsd.ident", "a" - .p2align 2 - .long 8 - .long 4 - .long 1 - .ascii "OpenBSD\0" - .long 0 - .p2align 2 - .include "../crt-posix.s" diff --git a/arch/arm32/sys/openbsd/putenv.c b/arch/arm32/sys/openbsd/putenv.c @@ -1 +0,0 @@ -#include "../../../sys/putenv-posix.c" diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile @@ -1,34 +0,0 @@ -.POSIX: -PROJECTDIR = ../.. -include $(PROJECTDIR)/scripts/rules.mk - -ROMOBJS = arch.o \ - rom.o \ - bss.o \ - sys/$(SYS)/builtin.o \ - $(SRCDIR)/romfw/builtin.o \ - -RAMOBJS = arch.o \ - ram.o \ - bss.o \ - sys/$(SYS)/builtin.o \ - $(SRCDIR)/ramfw/builtin.o \ - -TARGET = $(BINDIR)/romfw.elf $(BINDIR)/ramfw.elf -DIRS = sys - -all: $(TARGET) - -sys/$(SYS)/builtin.o: sys/$(SYS) - -sys/$(SYS): FORCE - cd $@ && $(MAKE) - -$(BINDIR)/romfw.elf: $(ROMOBJS) $(LIBDEP) - $(LD) $(RCODE_LDFLAGS) $(ROMOBJS) $(RCODE_LDLIBS) -o $@ - -$(BINDIR)/ramfw.elf: $(RAMOBJS) $(LIBDEP) - $(LD) $(RCODE_LDFLAGS) $(RAMOBJS) $(RCODE_LDLIBS) -o $@ - -clean: - $(FORALL) diff --git a/arch/arm64/arch.c b/arch/arm64/arch.c @@ -1,28 +0,0 @@ -#include <setjmp.h> -#include <stdio.h> -#include <stdlib.h> - -#include <rcode.h> - -jmp_buf recover; - -noreturn void abort(void); -noreturn void longjmp(jmp_buf env, int val); - -void -dohalt(void) -{ - abort(); -} - -void -doswtch(struct trapframe *fp) -{ - longjmp(recover, 1); -} - -void -dopanic(void) -{ - trap(NULL); -} diff --git a/arch/arm64/bss.c b/arch/arm64/bss.c @@ -1 +0,0 @@ -#include "../sys/bss.c" diff --git a/arch/arm64/ram.c b/arch/arm64/ram.c @@ -1,7 +0,0 @@ -#include <rcode.h> - -int -main(int argc, char *argv[]) -{ - return 0; -} diff --git a/arch/arm64/rom.c b/arch/arm64/rom.c @@ -1,20 +0,0 @@ -#include <string.h> - -#include <rcode.h> - -struct tree tree[] = { - {"/dev", FSDIR | FSCREATE | FSREAD}, - {"/dev/uart", FSDIR | FSREAD}, - {"/realms", FSDIR | FSREAD}, - {NULL} -}; - -int -main(int argc, char *argv[]) -{ - memset(bss, 0, sizeof(struct bssmap)); - bss->fp = &(struct trapframe) {0}; - - initfs(tree); - return debug(); -} diff --git a/arch/arm64/sys/Makefile b/arch/arm64/sys/Makefile @@ -1,8 +0,0 @@ -.POSIX: -PROJECTDIR=../../.. -include $(PROJECTDIR)/scripts/rules.mk - -DIRS = dragonfly linux netbsd openbsd - -clean: - $(FORALL) diff --git a/arch/arm64/sys/dragonfly/Makefile b/arch/arm64/sys/dragonfly/Makefile @@ -1,13 +0,0 @@ -.POSIX: -PROJECTDIR=../../../.. -include $(PROJECTDIR)/scripts/rules.mk - -OBJS = crt.o \ - putenv.o \ - -all: builtin.o - -builtin.o: $(OBJS) - $(LD) $(RCODE_LDFLAGS) -r -o $@ $(OBJS) - -crt.o: ../crt-posix.s diff --git a/arch/arm64/sys/dragonfly/crt.s b/arch/arm64/sys/dragonfly/crt.s @@ -1 +0,0 @@ - .include "../crt-posix.s" diff --git a/arch/arm64/sys/dragonfly/putenv.c b/arch/arm64/sys/dragonfly/putenv.c @@ -1 +0,0 @@ -#include "../../../sys/putenv-posix.c" diff --git a/arch/arm64/sys/linux/Makefile b/arch/arm64/sys/linux/Makefile @@ -1,13 +0,0 @@ -.POSIX: -PROJECTDIR=../../../.. -include $(PROJECTDIR)/scripts/rules.mk - -OBJS = crt.o \ - putenv.o \ - -all: builtin.o - -builtin.o: $(OBJS) - $(LD) $(RCODE_LDFLAGS) -r -o $@ $(OBJS) - -crt.o: ../crt-posix.s diff --git a/arch/arm64/sys/linux/crt.s b/arch/arm64/sys/linux/crt.s @@ -1 +0,0 @@ - .include "../crt-posix.s" diff --git a/arch/arm64/sys/linux/putenv.c b/arch/arm64/sys/linux/putenv.c @@ -1 +0,0 @@ -#include "../../../sys/putenv-posix.c" diff --git a/arch/arm64/sys/netbsd/Makefile b/arch/arm64/sys/netbsd/Makefile @@ -1,13 +0,0 @@ -.POSIX: -PROJECTDIR=../../../.. -include $(PROJECTDIR)/scripts/rules.mk - -OBJS = crt.o \ - putenv.o \ - -all: builtin.o - -builtin.o: $(OBJS) - $(LD) $(RCODE_LDFLAGS) -r -o $@ $(OBJS) - -crt.o: ../crt-posix.s diff --git a/arch/arm64/sys/netbsd/crt.s b/arch/arm64/sys/netbsd/crt.s @@ -1,9 +0,0 @@ - .section ".note.netbsd.ident", "a" - .p2align 2 - - .long 7 - .long 4 - .long 1 - .ascii "NetBSD\0\0" - .long 800000000 - .include "../crt-posix.s" diff --git a/arch/arm64/sys/netbsd/putenv.c b/arch/arm64/sys/netbsd/putenv.c @@ -1 +0,0 @@ -#include "../../../sys/putenv-posix.c" diff --git a/arch/arm64/sys/openbsd/Makefile b/arch/arm64/sys/openbsd/Makefile @@ -1,13 +0,0 @@ -.POSIX: -PROJECTDIR=../../../.. -include $(PROJECTDIR)/scripts/rules.mk - -OBJS = crt.o \ - putenv.o \ - -all: builtin.o - -builtin.o: $(OBJS) - $(LD) $(RCODE_LDFLAGS) -r -o $@ $(OBJS) - -crt.o: ../crt-posix.s diff --git a/arch/arm64/sys/openbsd/crt.s b/arch/arm64/sys/openbsd/crt.s @@ -1,9 +0,0 @@ - .section ".note.openbsd.ident", "a" - .p2align 2 - .long 8 - .long 4 - .long 1 - .ascii "OpenBSD\0" - .long 0 - .p2align 2 - .include "../crt-posix.s" diff --git a/arch/arm64/sys/openbsd/putenv.c b/arch/arm64/sys/openbsd/putenv.c @@ -1 +0,0 @@ -#include "../../../sys/putenv-posix.c" diff --git a/arch/sys/bss.c b/arch/sys/bss.c @@ -1,11 +0,0 @@ -#include <rcode.h> - -#undef bss - -struct bssmap * -bss(void) -{ - static struct bssmap bssmap; - - return &bssmap; -} diff --git a/config/amd64-dragonfly.mk b/config/amd64-dragonfly.mk @@ -1,5 +1,7 @@ ARCH = amd64 SYS = dragonfly +ABI = amd64-posix +MODE = hosted SYSCFLAGS = -g -static -nostdinc -ffreestanding -std=c99 -fno-stack-protector -MD -Wall SYSLDFLAGS = -static -z nodefaultlib COMP = gcc diff --git a/config/amd64-linux-clang.mk b/config/amd64-linux-clang.mk @@ -1,5 +1,7 @@ ARCH = amd64 SYS = linux +ABI = amd64-posix +MODE = hosted SYSASFLAGS = -fintegrated-as -c SYSCFLAGS = -g -static -nostdinc -ffreestanding -std=c99 -fno-stack-protector -MD -Wall SYSLDFLAGS = -static -z nodefaultlib diff --git a/config/amd64-linux.mk b/config/amd64-linux.mk @@ -1,5 +1,7 @@ ARCH = amd64 SYS = linux +ABI = amd64-posix +MODE = hosted SYSCFLAGS = -g -static -nostdinc -ffreestanding -std=c99 -fno-stack-protector -MD -Wall SYSLDFLAGS = -static -z nodefaultlib COMP = gcc diff --git a/config/amd64-netbsd.mk b/config/amd64-netbsd.mk @@ -1,5 +1,7 @@ ARCH = amd64 SYS = netbsd +ABI = amd64-posix +MODE = hosted SYSCFLAGS = -g -static -nostdinc -ffreestanding -std=c99 -fno-stack-protector -MD -Wall SYSLDFLAGS = -static -z nodefaultlib COMP = gcc diff --git a/config/amd64-openbsd.mk b/config/amd64-openbsd.mk @@ -1,5 +1,7 @@ ARCH = amd64 SYS = openbsd +ABI = amd64-posix +MODE = hosted SYSCFLAGS = -g -static -nostdinc -ffreestanding -std=c99 -fno-stack-protector -MD -Wall -nopie SYSLDFLAGS = -static -z nodefaultlib -nopie COMP = gcc diff --git a/config/arm32-linux.mk b/config/arm32-linux.mk @@ -7,6 +7,8 @@ ARCH = arm32 SYS = linux +ABI = arm32-posix +MODE = hosted SYSCFLAGS = -g -static -nostdinc -ffreestanding -std=c99 -fno-stack-protector -MD -Wall -marm SYSLDFLAGS = -static -z nodefaultlib SYSLDLIBS = -lgcc diff --git a/config/arm64-linux.mk b/config/arm64-linux.mk @@ -1,5 +1,7 @@ ARCH = arm64 SYS = linux +ABI = arm64-posix +MODE = hosted SYSCFLAGS = -g -static -nostdinc -ffreestanding -std=c99 -fno-stack-protector -MD -Wall SYSLDFLAGS = -static -z nodefaultlib COMP = gcc diff --git a/config/rmode-rcode-clang.mk b/config/rmode-rcode-clang.mk @@ -1,5 +1,6 @@ ARCH = rmode SYS = rcode +MODE = native SYSASFLAGS = -fintegrated-as -c -target aarch64-elf SYSCFLAGS = -g -static -nostdinc -ffreestanding -std=c99 -mgeneral-regs-only -fno-stack-protector -MD -Wall -target aarch64-elf SYSLDFLAGS = -static -z nodefaultlib -T $(CONFDIR)/rmode-rcode.ld diff --git a/config/rmode-rcode.mk b/config/rmode-rcode.mk @@ -1,5 +1,6 @@ ARCH = rmode SYS = rcode +MODE = native SYSCFLAGS = -g -static -nostdinc -ffreestanding -std=c99 -mgeneral-regs-only -fno-stack-protector -MD -Wall SYSLDFLAGS = -static -z nodefaultlib -T $(CONFDIR)/rmode-rcode.ld COMP = gcc diff --git a/target/Makefile b/target/Makefile @@ -0,0 +1,11 @@ +.POSIX: +PROJECTDIR=.. +include $(PROJECTDIR)/scripts/rules.mk + +DIRS=hosted native + +all: + +@cd $(MODE) && $(MAKE) + +clean: + $(FORALL) diff --git a/target/hosted/Makefile b/target/hosted/Makefile @@ -0,0 +1,34 @@ +.POSIX: +PROJECTDIR = ../.. +include $(PROJECTDIR)/scripts/rules.mk + +ROMOBJS = arch.o \ + rom.o \ + putenv.o \ + crt/crt.o \ + $(SRCDIR)/romfw/builtin.o \ + +RAMOBJS = arch.o \ + ram.o \ + putenv.o \ + crt/crt.o \ + $(SRCDIR)/ramfw/builtin.o \ + +TARGET = $(BINDIR)/romfw.elf $(BINDIR)/ramfw.elf +DIRS = crt + +all: $(TARGET) + +crt/crt.o: crt + +$(DIRS): FORCE + cd $@ && $(MAKE) + +$(BINDIR)/romfw.elf: $(ROMOBJS) $(LIBDEP) + $(LD) $(RCODE_LDFLAGS) $(ROMOBJS) $(RCODE_LDLIBS) -o $@ + +$(BINDIR)/ramfw.elf: $(RAMOBJS) $(LIBDEP) + $(LD) $(RCODE_LDFLAGS) $(RAMOBJS) $(RCODE_LDLIBS) -o $@ + +clean: + $(FORALL) diff --git a/target/hosted/arch.c b/target/hosted/arch.c @@ -0,0 +1,37 @@ +#include <setjmp.h> +#include <stdio.h> +#include <stdlib.h> + +#include <rcode.h> +#undef bss + +jmp_buf recover; + +noreturn void abort(void); +noreturn void longjmp(jmp_buf env, int val); + +struct bssmap * +bss(void) +{ + static struct bssmap bssmap; + + return &bssmap; +} + +void +dohalt(void) +{ + abort(); +} + +void +doswtch(struct trapframe *fp) +{ + longjmp(recover, 1); +} + +void +dopanic(void) +{ + trap(NULL); +} diff --git a/target/hosted/crt/Makefile b/target/hosted/crt/Makefile @@ -0,0 +1,10 @@ +.POSIX: +PROJECTDIR=../../.. +include $(PROJECTDIR)/scripts/rules.mk + +OBJS = crt-$(SYS).o crt-$(ABI).o + +all: crt.o + +crt.o: $(OBJS) + $(LD) $(RCODE_LDFLAGS) -r -o $@ $(OBJS) diff --git a/arch/amd64/sys/crt-posix.s b/target/hosted/crt/crt-amd64-posix.s diff --git a/arch/arm32/sys/crt-posix.s b/target/hosted/crt/crt-arm32-posix.s diff --git a/arch/arm64/sys/crt-posix.s b/target/hosted/crt/crt-arm64-posix.s diff --git a/target/hosted/crt/crt-dragonfly.s b/target/hosted/crt/crt-dragonfly.s @@ -0,0 +1 @@ + .file "crt-dragonfly.s" diff --git a/target/hosted/crt/crt-linux.s b/target/hosted/crt/crt-linux.s @@ -0,0 +1 @@ + .file "crt-linux.s" diff --git a/target/hosted/crt/crt-netbsd.s b/target/hosted/crt/crt-netbsd.s @@ -0,0 +1,9 @@ + .file "crt-netbsd.s" + .section ".note.netbsd.ident", "a" + .p2align 2 + + .long 7 + .long 4 + .long 1 + .ascii "NetBSD\0\0" + .long 800000000 diff --git a/target/hosted/crt/crt-openbsd.s b/target/hosted/crt/crt-openbsd.s @@ -0,0 +1,9 @@ + .file "crt-openbsd.s" + .section ".note.openbsd.ident", "a" + .p2align 2 + .long 8 + .long 4 + .long 1 + .ascii "OpenBSD\0" + .long 0 + .p2align 2 diff --git a/arch/sys/putenv-posix.c b/target/hosted/putenv.c diff --git a/arch/amd64/ram.c b/target/hosted/ram.c diff --git a/arch/amd64/rom.c b/target/hosted/rom.c diff --git a/arch/rmode/.gitignore b/target/native/.gitignore diff --git a/arch/rmode/Makefile b/target/native/Makefile diff --git a/arch/rmode/arch.h b/target/native/arch.h diff --git a/arch/rmode/arch.s b/target/native/arch.s diff --git a/arch/rmode/cache.c b/target/native/cache.c diff --git a/arch/rmode/crt.s b/target/native/crt.s diff --git a/arch/rmode/mksysreg b/target/native/mksysreg diff --git a/arch/rmode/mktst b/target/native/mktst diff --git a/arch/rmode/putenv.c b/target/native/putenv.c diff --git a/arch/rmode/ram-crt.s b/target/native/ram-crt.s diff --git a/arch/rmode/ram.c b/target/native/ram.c diff --git a/target/native/rcode b/target/native/rcode @@ -0,0 +1,3 @@ +dev + root + uart diff --git a/arch/rmode/rom-crt.s b/target/native/rom-crt.s diff --git a/arch/rmode/rom.c b/target/native/rom.c diff --git a/arch/rmode/sysreg.lst b/target/native/sysreg.lst