commit b2219f39d23ed29f4a05a2e3ca28692b30b6fbbb
parent 241c85d64803e46c909f4fa120d09dd7ba8fff9e
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Sun, 12 Jul 2020 00:15:05 +0200
build: Change RCODE to 9os
Remove tests
Change-Id: Ibeede183bc0e7f3467b2bf98ebdb3835f0a18bc2
Diffstat:
24 files changed, 196 insertions(+), 409 deletions(-)
diff --git a/Makefile b/Makefile
@@ -2,7 +2,7 @@
PROJECTDIR = .
include scripts/rules.mk
-DIRS = src target drivers test
+DIRS = src target drivers
all: target
diff --git a/src/kernel/Makefile b/src/kernel/Makefile
@@ -2,14 +2,15 @@
PROJECTDIR=../..
include $(PROJECTDIR)/scripts/rules.mk
-OBJS = rmc.o \
- ecstr.o \
- dlang.o \
+OBJS =\
+ svc.o\
+ ecstr.o\
+ dlang.o\
all: builtin.o
builtin.o: $(OBJS)
- $(LD) $(RCODE_LDFLAGS) -r -o $@ $(OBJS)
+ $(LD) $(PROJ_LDFLAGS) -r -o $@ $(OBJS)
ecstr.c: ec.h
mkecstr ec.h
diff --git a/src/kernel/dlang.c b/src/kernel/dlang.c
@@ -139,17 +139,14 @@ do_trap(const struct cmd *cmd, struct args *args)
}
static int
-do_rmc(const struct cmd *cmd, struct args *args)
+do_svc(const struct cmd *cmd, struct args *args)
{
- unsigned char class;
- unsigned char func;
+ unsigned num;
- class = estrtoull(args->argv[1], 0);
- func = estrtoull(args->argv[2], 0);
+ num = estrtoull(args->argv[1], 0);
- framep->r[ESR] = (unsigned long long) RMC << 26;
- framep->r[ESR] |= class;
- framep->r[ESR] |= (func << 8);
+ framep->r[ESR] = (unsigned long long) SVC << 26;
+ framep->r[ESR] |= num;
trap(framep);
return 0;
}
@@ -383,11 +380,11 @@ static const struct cmd cmds[] = {
.helpmsg = "Call trap handler: trap",
},
{
- .name = "rmc",
- .eval = do_rmc,
+ .name = "svc",
+ .eval = do_svc,
.min = 3,
.max = 3,
- .helpmsg = "Call RMC handler: rmc imm1 imm2",
+ .helpmsg = "Call SVC handler: svc imm",
},
{
.name = "exit",
diff --git a/src/kernel/ec.h b/src/kernel/ec.h
@@ -29,7 +29,6 @@ enum ecvals {
FPE32 = 0x28, /* Floating-point exception in AArch32 */
FPE = 0x2c, /* Floating-point exception in AArch64 */
SOFTRES = 0x2d, /* Software defined fault syndrome */
- RMC = 0x2e, /* RMC */
SERROR = 0x2f, /* Serror interrupt */
BREAKL = 0x30, /* Breakpoint exception from lower level */
BREAK = 0x31, /* Breakpoint exception from current level */
diff --git a/src/kernel/rmc.c b/src/kernel/rmc.c
@@ -1,190 +0,0 @@
-#include <setjmp.h>
-#include <stdint.h>
-
-#include <libk.h>
-#include <9os/9os.h>
-#include <9os/kernel.h>
-
-#include "ec.h"
-
-struct rmctab *rmctab;
-
-static unsigned in_panic;
-static unsigned in_dumpstack;
-static unsigned in_backtrace;
-static struct rmucmd *rmucmd;
-static char *errstr;
-
-const char *const regnames[] = {
- [X0] = "x0",
- [X1] = "x1",
- [X2] = "x2",
- [X3] = "x3",
- [X4] = "x4",
- [X5] = "x5",
- [X6] = "x6",
- [X7] = "x7",
- [X8] = "x8",
- [X9] = "x9",
- [X10] = "x10",
- [X11] = "x11",
- [X12] = "x12",
- [X13] = "x13",
- [X14] = "x14",
- [X15] = "x15",
- [X16] = "x16",
- [X17] = "x17",
- [X18] = "x18",
- [X19] = "x19",
- [X20] = "x20",
- [X21] = "x21",
- [X22] = "x22",
- [X23] = "x23",
- [X24] = "x24",
- [X25] = "x25",
- [X26] = "x26",
- [X27] = "x27",
- [X28] = "x28",
- [X29] = "x29",
- [ELR] = "elr",
- [X30] = "x30",
- [SPSR] = "spsr",
- [ESR] = "esr",
- [SP] = "sp",
- [FAR] = "far",
- [SCR] = "scr",
- [UNUSED] = "unused",
- NULL
-};
-
-void
-dumpregs(struct trapframe *fp, int fd)
-{
- int i;
-
- for (i = 0; i < NR_REGS; i++)
- kprint(fd, "%s=0x%llx%c", regnames[i], fp->r[i],
- (i > 0 && i % 3 == 0) ? '\n' : ' ');
- if (i % 4 != 3)
- kputc(fd, '\n');
-}
-
-static void
-backtrace(struct trapframe *fp)
-{
- void **bp;
-
- if (!in_backtrace)
- return;
- kprint(kerr, "backtrace:\n");
- kprint(kerr, "%0llx\n", fp->r[X30]);
- for (bp = (void **) fp->r[X29]; *bp; bp = (void **) *bp)
- kprint(kerr, "%p\n", bp[1]);
-}
-
-static void
-dumpstack(struct trapframe *fp)
-{
- long long *sp, i;
-
- if (!in_dumpstack)
- return;
- kprint(kerr, "stack dump:\n");
- sp = (long long *)fp->r[SP];
- for (i = 1; i <= 16; i++)
- kprint(kerr, "%0llx%c", *sp++, (i % 4 == 0) ? '\n' : ' ');
-}
-
-static void
-panicfmt(const char *msg, struct trapframe *fp)
-{
- /*
- * check against 1 to be more robust
- * against memory corruptions
- */
- if (in_panic == 1) {
- for (;;)
- ;
- }
-
- in_panic = 1;
- kprint(kerr, "panic: %s\n", msg);
-
- dumpregs(fp, kerr);
- backtrace(fp);
- dumpstack(fp);
-}
-
-void
-halt(void)
-{
- if (in_debug)
- longjmp(dbgrecover, 1);
- dohalt();
-}
-
-void
-panic(const char *msg)
-{
- if (in_debug) {
- kprint(kerr, "panic: %s\n", msg);
- longjmp(dbgrecover, 1);
- }
-
- errstr = msg;
- dopanic();
-}
-
-void
-swtch(struct trapframe *fp)
-{
- if (in_debug)
- longjmp(dbgrecover, 1);
- doswtch(fp);
-}
-
-void
-trap(struct trapframe *fp)
-{
- Rmucmd cmd;
- enum ecvals ec;
- const char *msg;
-
- if (errstr) {
- panicfmt(errstr, fp);
- halt();
- }
- dbg(kerr, "exception handler\n");
-
- ec = (fp->r[ESR] >> 26) & 0x3f;
-
- if (ec != RMC) {
- msg = (ec < NR_EC_VALS) ? ecstr[ec] : "unknown reason";
- panicfmt(msg, fp);
- halt();
- }
-
- cmd.class = fp->r[ESR] & 0xff;
- cmd.func = (fp->r[ESR] >> 8) & 0xff;
- framep = cmd.fp = fp;
- rmucmd = &cmd;
-
- rmc(&cmd);
- swtch(fp);
-}
-
-void
-badcmd(int error)
-{
- Rmucmd *cmd = rmucmd;
-
- dbg(kerr, "bad RMC: %d, %d = %d\n", cmd->class, cmd->func, error);
- framep->r[X0] = error;
- swtch(framep);
-}
-
-void
-rmc(Rmucmd *cmd)
-{
- cmd->fp->r[X0] = -1;
-}
diff --git a/src/kernel/svc.c b/src/kernel/svc.c
@@ -0,0 +1,182 @@
+#include <setjmp.h>
+#include <stdint.h>
+
+#include <libk.h>
+#include <9os/9os.h>
+#include <9os/kernel.h>
+
+#include "ec.h"
+
+static unsigned in_panic;
+static unsigned in_dumpstack;
+static unsigned in_backtrace;
+static char *errstr;
+
+const char *const regnames[] = {
+ [X0] = "x0",
+ [X1] = "x1",
+ [X2] = "x2",
+ [X3] = "x3",
+ [X4] = "x4",
+ [X5] = "x5",
+ [X6] = "x6",
+ [X7] = "x7",
+ [X8] = "x8",
+ [X9] = "x9",
+ [X10] = "x10",
+ [X11] = "x11",
+ [X12] = "x12",
+ [X13] = "x13",
+ [X14] = "x14",
+ [X15] = "x15",
+ [X16] = "x16",
+ [X17] = "x17",
+ [X18] = "x18",
+ [X19] = "x19",
+ [X20] = "x20",
+ [X21] = "x21",
+ [X22] = "x22",
+ [X23] = "x23",
+ [X24] = "x24",
+ [X25] = "x25",
+ [X26] = "x26",
+ [X27] = "x27",
+ [X28] = "x28",
+ [X29] = "x29",
+ [ELR] = "elr",
+ [X30] = "x30",
+ [SPSR] = "spsr",
+ [ESR] = "esr",
+ [SP] = "sp",
+ [FAR] = "far",
+ [SCR] = "scr",
+ [UNUSED] = "unused",
+ NULL
+};
+
+void
+dumpregs(struct trapframe *fp, int fd)
+{
+ int i;
+
+ for (i = 0; i < NR_REGS; i++)
+ kprint(fd, "%s=0x%llx%c", regnames[i], fp->r[i],
+ (i > 0 && i % 3 == 0) ? '\n' : ' ');
+ if (i % 4 != 3)
+ kputc(fd, '\n');
+}
+
+static void
+backtrace(struct trapframe *fp)
+{
+ void **bp;
+
+ if (!in_backtrace)
+ return;
+ kprint(kerr, "backtrace:\n");
+ kprint(kerr, "%0llx\n", fp->r[X30]);
+ for (bp = (void **) fp->r[X29]; *bp; bp = (void **) *bp)
+ kprint(kerr, "%p\n", bp[1]);
+}
+
+static void
+dumpstack(struct trapframe *fp)
+{
+ long long *sp, i;
+
+ if (!in_dumpstack)
+ return;
+ kprint(kerr, "stack dump:\n");
+ sp = (long long *)fp->r[SP];
+ for (i = 1; i <= 16; i++)
+ kprint(kerr, "%0llx%c", *sp++, (i % 4 == 0) ? '\n' : ' ');
+}
+
+static void
+panicfmt(const char *msg, struct trapframe *fp)
+{
+ /*
+ * check against 1 to be more robust
+ * against memory corruptions
+ */
+ if (in_panic == 1) {
+ for (;;)
+ ;
+ }
+
+ in_panic = 1;
+ kprint(kerr, "panic: %s\n", msg);
+
+ dumpregs(fp, kerr);
+ backtrace(fp);
+ dumpstack(fp);
+}
+
+void
+halt(void)
+{
+ if (in_debug)
+ longjmp(dbgrecover, 1);
+ dohalt();
+}
+
+void
+panic(const char *msg)
+{
+ if (in_debug) {
+ kprint(kerr, "panic: %s\n", msg);
+ longjmp(dbgrecover, 1);
+ }
+
+ errstr = msg;
+ dopanic();
+}
+
+void
+swtch(struct trapframe *fp)
+{
+ if (in_debug)
+ longjmp(dbgrecover, 1);
+ doswtch(fp);
+}
+
+void
+trap(struct trapframe *fp)
+{
+ enum ecvals ec;
+ const char *msg;
+ int numsvc;
+
+ if (errstr) {
+ panicfmt(errstr, fp);
+ halt();
+ }
+ dbg(kerr, "exception handler\n");
+
+ ec = (fp->r[ESR] >> 26) & 0x3f;
+
+ if (ec != SVC) {
+ msg = (ec < NR_EC_VALS) ? ecstr[ec] : "unknown reason";
+ panicfmt(msg, fp);
+ halt();
+ }
+
+ numsvc = fp->r[ESR] & 0xff;
+ framep = fp;
+
+ svc(numsvc);
+ swtch(fp);
+}
+
+void
+badcmd(int error)
+{
+ framep->r[X0] = error;
+ swtch(framep);
+}
+
+void
+svc(int numsvc)
+{
+ framep->r[X0] = -1;
+}
diff --git a/test/Makefile b/test/Makefile
@@ -1,13 +0,0 @@
-.POSIX:
-PROJECTDIR = ..
-include $(PROJECTDIR)/scripts/rules.mk
-
-DIRS = unit functional fuzzing integration model
-
-all: $(DIRS)
-
-$(DIRS): FORCE
- +@cd $@ && $(MAKE) test
-
-clean test:
- $(FORALL)
diff --git a/test/functional/Makefile b/test/functional/Makefile
@@ -1,7 +0,0 @@
-.POSIX:
-PROJECTDIR = ../..
-include $(PROJECTDIR)/scripts/rules.mk
-
-all: test
-
-test:
diff --git a/test/fuzzing/Makefile b/test/fuzzing/Makefile
@@ -1,7 +0,0 @@
-.POSIX:
-PROJECTDIR = ../..
-include $(PROJECTDIR)/scripts/rules.mk
-
-all: test
-
-test:
diff --git a/test/integration/Makefile b/test/integration/Makefile
@@ -1,7 +0,0 @@
-.POSIX:
-PROJECTDIR = ../..
-include $(PROJECTDIR)/scripts/rules.mk
-
-all: test
-
-test:
diff --git a/test/model/Makefile b/test/model/Makefile
@@ -1,7 +0,0 @@
-.POSIX:
-PROJECTDIR = ../..
-include $(PROJECTDIR)/scripts/rules.mk
-
-all: test
-
-test:
diff --git a/test/unit/.gitignore b/test/unit/.gitignore
@@ -1,2 +0,0 @@
-test.log
-run
diff --git a/test/unit/001/Makefile b/test/unit/001/Makefile
@@ -1,17 +0,0 @@
-.POSIX:
-PROJECTDIR = ../../..
-include $(PROJECTDIR)/scripts/rules.mk
-include ../rules.mk
-
-OBJS = $(LIBDIR)/crt.o \
- $(TARGETDIR)/arch.o \
- $(SRCDIR)/romfw/builtin.o \
- $(DRVDIR)/builtin.o \
- test.o \
-
-TARGET = run
-
-all: $(TARGET)
-
-$(TARGET): $(OBJS) $(LIBDEP)
- $(LD) $(PROJ_LDFLAGS) $(OBJS) $(PROJ_LDLIBS) -o $@
diff --git a/test/unit/001/descr b/test/unit/001/descr
@@ -1 +0,0 @@
-Test RMU_System_InterfaceVersion()
diff --git a/test/unit/001/test.c b/test/unit/001/test.c
@@ -1,26 +0,0 @@
-#include <assert.h>
-#include <setjmp.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <9os/9os.h>
-
-#include "../../../src/romfw/ec.h"
-#include "../../../target/hosted/hosted.h"
-
-struct trapframe frame;
-
-int
-main(void)
-{
- frame.r[ESR] = RMC << 26; /* class = func = 0 */
-
- if (!setjmp(recover))
- trap(&frame);
-
- assert(frame.r[X0] == 0);
- assert(frame.r[X1] == 0);
- assert(frame.r[X2] == 1);
-
- return 0;
-}
diff --git a/test/unit/001/test.sh b/test/unit/001/test.sh
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-set -e
-
-$EMUCMD ./run
diff --git a/test/unit/002/Makefile b/test/unit/002/Makefile
@@ -1,17 +0,0 @@
-.POSIX:
-PROJECTDIR = ../../..
-include $(PROJECTDIR)/scripts/rules.mk
-include ../rules.mk
-
-OBJS = $(LIBDIR)/crt.o \
- $(TARGETDIR)/arch.o \
- $(SRCDIR)/romfw/builtin.o \
- $(DRVDIR)/builtin.o \
- test.o \
-
-TARGET = run
-
-all: $(TARGET)
-
-$(TARGET): $(OBJS) $(LIBDEP)
- $(LD) $(PROJ_LDFLAGS) $(OBJS) $(PROJ_LDLIBS) -o $@
diff --git a/test/unit/002/descr b/test/unit/002/descr
@@ -1 +0,0 @@
-Test panic()
diff --git a/test/unit/002/test.c b/test/unit/002/test.c
@@ -1,40 +0,0 @@
-#include <signal.h>
-#include <stdlib.h>
-#include <9os/9os.h>
-
-#include "../../../target/hosted/hosted.h"
-
-void
-cleanup(int signum)
-{
- extern int halted;
-
- if (halted)
- exit(0);
-}
-
-static struct trapframe *
-mockframe(void)
-{
- int i;
- static struct trapframe frame;
-
- for (i = 0; i < NR_REGS; i++)
- frame.r[i] = i;
- frame.r[ELR] = 0xdeadbeef;
- frame.r[SP] = 0xdeadbabe;
-
- return &frame;
-}
-
-int
-main(void)
-{
- if (setjmp(recover))
- return -1;
- signal(SIGABRT, cleanup);
- getframe = mockframe;
-
- panic("oops");
- return 0;
-}
diff --git a/test/unit/002/test.exp b/test/unit/002/test.exp
@@ -1,11 +0,0 @@
-panic: oops
-x0=0 x1=1 x2=2 x3=3
-x4=4 x5=5 x6=6 x7=7
-x8=8 x9=9 x10=A x11=B
-x12=C x13=D x14=E x15=F
-x16=10 x17=11 x18=12 x19=13
-x20=14 x21=15 x22=16 x23=17
-x24=18 x25=19 x26=1A x27=1B
-x28=1C x29=1D x30=1E elr=DEADBEEF
-spsr=20 esr=21 far=22
-sp=DEADBABE
diff --git a/test/unit/002/test.sh b/test/unit/002/test.sh
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-set -e
-
-tmp1=tmp.$$
-trap 'r=$?;rm -f $tmp1;exit $r' EXIT HUP INT QUIT TERM
-
-$EMUCMD ./run > $tmp1
-diff -u $tmp1 test.exp
diff --git a/test/unit/Makefile b/test/unit/Makefile
@@ -1,17 +0,0 @@
-.POSIX:
-PROJECTDIR = ../..
-include $(PROJECTDIR)/scripts/rules.mk
-
-DIRS = 001 002
-
-all: $(DIRS)
-
-test: FORCE
- @chktest.sh
-
-$(DIRS): FORCE
- +@cd $@ && $(MAKE)
-
-clean:
- $(FORALL)
- rm -f test.log
diff --git a/test/unit/chktest.sh b/test/unit/chktest.sh
@@ -1,13 +0,0 @@
-#!/bin/sh
-
-rm -f test.log
-pwd=$PWD
-
-for i in [0-9]*
-do
- cd $i &&
- $MAKE run_test >> ../test.log 2>&1 &&
- printf '[PASS]' || printf '[FAIL]'
- printf "\t%s - $(cat descr)\n" $i
- cd $pwd
-done
diff --git a/test/unit/rules.mk b/test/unit/rules.mk
@@ -1,2 +0,0 @@
-run_test: run FORCE
- EMUCMD='$(EMUCMD)' SCRIPTDIR=$(SCRIPTDIR) ./test.sh