duskos

dusk os fork
git clone git://git.alexwennerberg.com/duskos
Log | Files | Refs | README | LICENSE

commit d0393d67ff1954ed1af81fdef842e0f1b61e6c10
parent 4688305ea6f7ec6752384500c82a36f459d4b3e6
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Sun, 19 Mar 2023 10:00:41 -0400

hal posix: add "high HAL" directly in kernel

Diffstat:
MMakefile | 2+-
Dposix/hal.fs | 12------------
Mposix/vm.c | 35++++++++++++++++++++++++++++++++++-
3 files changed, 35 insertions(+), 14 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,5 +1,5 @@ TARGETS = dusk dis -BOOTFS_SRC = fs/xcomp/bootlo.fs posix/hal.fs posix/glue.fs fs/xcomp/boothi.fs +BOOTFS_SRC = fs/xcomp/bootlo.fs posix/glue.fs fs/xcomp/boothi.fs ALLSRCS = $(shell find fs) QEMU_FLAGS = -accel kvm -accel tcg -rtc base=utc QEMU_DRVOPTS = format=raw,index=0,if=ide diff --git a/posix/hal.fs b/posix/hal.fs @@ -1,12 +0,0 @@ -\ POSIX HAL -\ The POSIX VM doesn't have an assembler, but it still needs a HAL. This is -\ what provides it (in an inefficient manner). It is included after bootlo. -\ Everything related to conditional branching is directly in vm.c - -create _tmp 0 , -: >tmp _tmp m) !, ; -: tmp> _tmp m) @, ; -: -, ( operand -- ) >tmp @, dup, tmp> compile -^ ; -: *, ( operand -- ) >tmp @, dup, tmp> compile * ; -: <<, ( operand -- ) >tmp @, dup, tmp> PSP) @!, compile lshift ; -: >>, ( operand -- ) >tmp @, dup, tmp> PSP) @!, compile rshift ; diff --git a/posix/vm.c b/posix/vm.c @@ -500,6 +500,27 @@ static void WCHECKZ() { vm.Z = !vm.W; } static void STOREZ() { vm.W = vm.Z; } static void ACHECKZ() { vm.Z = !vm.A; } +static void WSUB() { vm.W -= gd(readop()); } // 0x68 +static void WMUL() { vm.W *= gd(readop()); } +static void WDIV() { vm.W /= gd(readop()); } +static void WMOD() { vm.W &= gd(readop()); } +static void WSHL() { vm.W <<= gd(readop()); } +static void WSHR() { vm.W >>= gd(readop()); } + +static void WSUB16() { vm.W -= gw(readop()); } // 0x70 +static void WMUL16() { vm.W *= gw(readop()); } +static void WDIV16() { vm.W /= gw(readop()); } +static void WMOD16() { vm.W &= gw(readop()); } +static void WSHL16() { vm.W <<= gw(readop()); } +static void WSHR16() { vm.W >>= gw(readop()); } + +static void WSUB8() { vm.W -= gb(readop()); } // 0x78 +static void WMUL8() { vm.W *= gb(readop()); } +static void WDIV8() { vm.W /= gb(readop()); } +static void WMOD8() { vm.W &= gb(readop()); } +static void WSHL8() { vm.W <<= gb(readop()); } +static void WSHR8() { vm.W >>= gb(readop()); } + /* Filesystem At POSIX level, we don't have access to the underlying FS structure such as @@ -778,7 +799,7 @@ static void DRVWR() { fwrite(&vm.mem[src], SECSZ, 1, fp); } -#define OPCNT 0x78 +#define OPCNT 0x90 static void (*ops[OPCNT])() = { BR, CALL, RET, BRWR, BRA, BRC, NULL, YIELD, PSADD, RSADD, WLIT, ALIT, WADDN, AADDN, W2A, WSWAPA, @@ -793,6 +814,9 @@ static void (*ops[OPCNT])() = { AND, OR, XOR, NULL, NULL, NULL, NULL, NULL, BYE, BYEFAIL, QUIT, ABORT_, DBG, USLEEP, NULL, NULL, SHLN, SHRN, ANDN, ORN, XORN, WCHECKZ, STOREZ, ACHECKZ, + WSUB, WMUL, WDIV, WMOD, WSHL, WSHR, NULL, NULL, + WSUB16, WMUL16, WDIV16, WMOD16, WSHL16, WSHR16, NULL, NULL, + WSUB8, WMUL8, WDIV8, WMOD8, WSHL8, WSHR8, NULL, NULL, FCHILD, FOPEN, FREADBUF, FCLOSE, FINFO, FITER, NULL, FSEEK, MOUNTDRV, UNMOUNTDRV, DRVRD, DRVWR, NULL, NULL, NULL, NULL, }; @@ -837,6 +861,9 @@ static char *opnames[OPCNT-0x28] = { "and", "or", "xor", NULL, NULL, NULL, NULL, NULL, "bye", "byefail", "quit", "(abort)", "dbg", "_usleep", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "_fchild", "_fopen", "_freadbuf", "_fclose", "_finfo", "_fiter", NULL, "_fseek", "_mountdrv", "_unmountdrv", "_drv@", "_drv!", NULL, NULL, NULL, NULL }; @@ -887,6 +914,12 @@ static void buildsysdict() { entry("[@],"); compopwr(0x15); retwr(); entry("[!],"); compopwr(0x16); retwr(); entry("+,"); compopwr(0x17); retwr(); + entry("-,"); compopwr(0x68); retwr(); + entry("*,"); compopwr(0x69); retwr(); + entry("/,"); compopwr(0x6a); retwr(); + entry("%,"); compopwr(0x6b); retwr(); + entry("<<,"); compopwr(0x6c); retwr(); + entry(">>,"); compopwr(0x6d); retwr(); entry("lea,"); compopwr(0x28); retwr(); entry("cmpn,"); compileop(0x2f); writewr(); retwr(); entry("neg,"); compileop(0x4e); retwr();