From 9d6e6790e132ce0b1fa9846775b8dc2fc5b44058 Mon Sep 17 00:00:00 2001 From: Toby Jaffey Date: Mon, 8 Dec 2025 12:53:33 +0000 Subject: [PATCH] Cleanup syscall numbers --- Makefile | 2 ++ common/uvm32_common_custom.h | 16 ++++++++-------- common/uvm32_sys.h | 6 +++--- host-arduino/common/uvm32_common_custom.h | 15 ++++++++------- host-arduino/common/uvm32_sys.h | 6 +++--- host-arduino/uvm32.cpp | 2 ++ host-arduino/uvm32.h | 5 +---- host-mini/Makefile | 2 +- host-parallel/Makefile | 2 +- host/Makefile | 2 +- precompiled/conio.bin | Bin 150 -> 150 bytes precompiled/hello-asm.bin | Bin 0 -> 27 bytes precompiled/helloworld.bin | Bin 48 -> 48 bytes precompiled/mandel.bin | Bin 236 -> 236 bytes precompiled/rust-hello.bin | Bin 0 -> 78 bytes precompiled/sketch.bin | Bin 0 -> 112 bytes precompiled/zigtris.bin | Bin 16364 -> 16364 bytes uvm32/uvm32.c | 1 + uvm32/uvm32.h | 5 +---- 19 files changed, 32 insertions(+), 32 deletions(-) create mode 100755 precompiled/hello-asm.bin create mode 100755 precompiled/rust-hello.bin create mode 100755 precompiled/sketch.bin diff --git a/Makefile b/Makefile index 1a8c807..9f8a3ba 100644 --- a/Makefile +++ b/Makefile @@ -10,3 +10,5 @@ clean: (cd host-parallel && make clean) (cd apps && make clean) +world: + make && (cd apps && make) && cp apps/*/*.bin precompiled/ diff --git a/common/uvm32_common_custom.h b/common/uvm32_common_custom.h index 0fb8c94..5e58ce9 100644 --- a/common/uvm32_common_custom.h +++ b/common/uvm32_common_custom.h @@ -1,11 +1,11 @@ // Definitions needed by both host and target -// syscalls for exposed host functions -#define UVM32_SYSCALL_PRINT 0x13A -#define UVM32_SYSCALL_PRINTLN 0x13B -#define UVM32_SYSCALL_PRINTD 0x13C -#define UVM32_SYSCALL_PRINTX 0x13D -#define UVM32_SYSCALL_MILLIS 0x13F -#define UVM32_SYSCALL_PRINTC 0x140 -#define UVM32_SYSCALL_GETC 0x141 +// syscalls for exposed host functions, start at 0 +#define UVM32_SYSCALL_PRINTC 0x00000000 +#define UVM32_SYSCALL_GETC 0x00000001 +#define UVM32_SYSCALL_PRINT 0x00000002 +#define UVM32_SYSCALL_PRINTLN 0x00000003 +#define UVM32_SYSCALL_PRINTD 0x00000004 +#define UVM32_SYSCALL_PRINTX 0x00000005 +#define UVM32_SYSCALL_MILLIS 0x00000006 diff --git a/common/uvm32_sys.h b/common/uvm32_sys.h index e11b236..82dec7d 100644 --- a/common/uvm32_sys.h +++ b/common/uvm32_sys.h @@ -1,5 +1,5 @@ -// System provided UVM32_SYSCALLs -#define UVM32_SYSCALL_HALT 0x138 -#define UVM32_SYSCALL_YIELD 0x139 +// System provided UVM32_SYSCALLs, start at 0x10000000 +#define UVM32_SYSCALL_HALT 0x1000000 +#define UVM32_SYSCALL_YIELD 0x1000001 #include "uvm32_common_custom.h" diff --git a/host-arduino/common/uvm32_common_custom.h b/host-arduino/common/uvm32_common_custom.h index 2c56fb7..5e58ce9 100644 --- a/host-arduino/common/uvm32_common_custom.h +++ b/host-arduino/common/uvm32_common_custom.h @@ -1,10 +1,11 @@ // Definitions needed by both host and target -// CSRs for exposed host functions -#define UVM32_SYSCALL_PRINT 0x13A -#define UVM32_SYSCALL_PRINTLN 0x13B -#define UVM32_SYSCALL_PRINTD 0x13C -#define UVM32_SYSCALL_PRINTX 0x13D -#define UVM32_SYSCALL_MILLIS 0x13F -#define UVM32_SYSCALL_PRINTC 0x140 +// syscalls for exposed host functions, start at 0 +#define UVM32_SYSCALL_PRINTC 0x00000000 +#define UVM32_SYSCALL_GETC 0x00000001 +#define UVM32_SYSCALL_PRINT 0x00000002 +#define UVM32_SYSCALL_PRINTLN 0x00000003 +#define UVM32_SYSCALL_PRINTD 0x00000004 +#define UVM32_SYSCALL_PRINTX 0x00000005 +#define UVM32_SYSCALL_MILLIS 0x00000006 diff --git a/host-arduino/common/uvm32_sys.h b/host-arduino/common/uvm32_sys.h index e11b236..82dec7d 100644 --- a/host-arduino/common/uvm32_sys.h +++ b/host-arduino/common/uvm32_sys.h @@ -1,5 +1,5 @@ -// System provided UVM32_SYSCALLs -#define UVM32_SYSCALL_HALT 0x138 -#define UVM32_SYSCALL_YIELD 0x139 +// System provided UVM32_SYSCALLs, start at 0x10000000 +#define UVM32_SYSCALL_HALT 0x1000000 +#define UVM32_SYSCALL_YIELD 0x1000001 #include "uvm32_common_custom.h" diff --git a/host-arduino/uvm32.cpp b/host-arduino/uvm32.cpp index 687c9ec..e2a1dde 100644 --- a/host-arduino/uvm32.cpp +++ b/host-arduino/uvm32.cpp @@ -154,6 +154,7 @@ uint32_t uvm32_run(uvm32_state_t *vmst, uvm32_evt_t *evt, uint32_t instr_meter) get_safeptr_terminated(vmst, value, 0x00, &vmst->ioevt.data.syscall.val.buf); break; case UVM32_SYSCALL_TYP_U32_RD: + // pass link to r1 for user function to update vmst->ioevt.data.syscall.val.u32p = &vmst->core->regs[11]; break; } @@ -167,6 +168,7 @@ uint32_t uvm32_run(uvm32_state_t *vmst, uvm32_evt_t *evt, uint32_t instr_meter) } // no mapping found if (!syscall_valid) { +printf("BADSYS %08x halt=%08x YIELD=%08x\n", syscall, UVM32_SYSCALL_HALT, UVM32_SYSCALL_YIELD); setStatusErr(vmst, UVM32_ERR_BAD_SYSCALL); } break; diff --git a/host-arduino/uvm32.h b/host-arduino/uvm32.h index 786390f..93796bf 100644 --- a/host-arduino/uvm32.h +++ b/host-arduino/uvm32.h @@ -3,10 +3,7 @@ #include #include - -// "well-known" system UVM32_SYSCALL functions -#define UVM32_SYSCALL_HALT 0x138 -#define UVM32_SYSCALL_YIELD 0x139 +#include "common/uvm32_sys.h" #define LIST_OF_UVM32_ERRS \ X(UVM32_ERR_NONE) \ diff --git a/host-mini/Makefile b/host-mini/Makefile index 3f23026..778761a 100644 --- a/host-mini/Makefile +++ b/host-mini/Makefile @@ -1,5 +1,5 @@ all: - gcc -Wall -DUVM32_MEMORY_SIZE=512 -I../uvm32 -o host-mini ../uvm32/uvm32.c host-mini.c + gcc -Wall -DUVM32_MEMORY_SIZE=512 -I../uvm32 -I../common -o host-mini ../uvm32/uvm32.c host-mini.c clean: rm -f host-mini diff --git a/host-parallel/Makefile b/host-parallel/Makefile index d853710..bdf7b46 100644 --- a/host-parallel/Makefile +++ b/host-parallel/Makefile @@ -1,5 +1,5 @@ all: - gcc -Wall -DUVM32_MEMORY_SIZE=512 -I../uvm32 -o host-parallel ../uvm32/uvm32.c host-parallel.c + gcc -Wall -DUVM32_MEMORY_SIZE=512 -I../uvm32 -I../common -o host-parallel ../uvm32/uvm32.c host-parallel.c clean: rm -f host-parallel diff --git a/host/Makefile b/host/Makefile index 4e137e3..a77caca 100644 --- a/host/Makefile +++ b/host/Makefile @@ -1,5 +1,5 @@ all: - gcc -Wall -Werror -pedantic -std=c99 -O2 -DUVM32_MEMORY_SIZE=32768 -I../uvm32 -o host ../uvm32/uvm32.c host.c + gcc -Wall -Werror -pedantic -std=c99 -O2 -DUVM32_MEMORY_SIZE=32768 -I../uvm32 -I../common -o host ../uvm32/uvm32.c host.c clean: rm -f host diff --git a/precompiled/conio.bin b/precompiled/conio.bin index 97cdf8b081cd1be5a1b1891c45064074fff74faf..68001a52dc474e0a95195b677aa3a20593709ba6 100755 GIT binary patch delta 90 zcmbQnIE~RjSxu1PJp%*db`A!{Vg?8>XJu#*W@Y7=%wfO)5))?s@L!mffnhR-0K-HB aIXMNe=wyxn2H{qAFdL%dC|JkD94!E~8V~0H delta 90 zcmbQnIE~RjSxu1PJp%*dWR3>mVg?8>XJu#*W@Y7=%&`G1Cd~ffzc4EU!(I05X&V-2eap literal 0 HcmV?d00001 diff --git a/precompiled/helloworld.bin b/precompiled/helloworld.bin index 07ed4a216a07f9a0d4fdb9b26bb5081c5e878459..0b14b655ff17d9c8feadb36f06e90551044f64db 100755 GIT binary patch literal 48 xcmY#Z6J&VLz`(ejgMqP_0Rn_s85kzBFJPF=;lKbA6J`}{BLDyZ diff --git a/precompiled/mandel.bin b/precompiled/mandel.bin index b64645a8be943d37439b6b1faf442be6015c87e7..d44b2673f81981152491709dc51cf921ce294ecc 100755 GIT binary patch literal 236 zcmY#Z6J&VLaDZVu2Lod<0|SHk*Z=>wivsCq|NjfKe_-71&cLvpje${^H2HjyuXQ z8E8lThx@;Q<^c6EFo4zb$#Fiub@-<+>jH!r#|+8GcbLALvobUYv$FC{<}d)OO>bae R@JP+c$yX@PFUm<_006B2M??Ss literal 236 zcmY#Z6J&VLaDZVlM}u%N0|SHk*Z=>wivsCq|Nl>B`@ks7e)Y`cc2i?vj}4Pdj=8-S8f R;E|e>ldn*oUzC%=002VFMkoLP diff --git a/precompiled/rust-hello.bin b/precompiled/rust-hello.bin new file mode 100755 index 0000000000000000000000000000000000000000..b759e3d1e3bbcd79d2a7f47bc468863cf435319d GIT binary patch literal 78 zcmY#Z6J&VLaDZVu2Lod<0|SFFD-g3SV3^F|z>v(r#sCo$Wq2%e^q)B^LxV6YE6ZdK Z1F(2{0|SFcYEDkRjzW2UQBH~?0{}?J5Jvz2 literal 0 HcmV?d00001 diff --git a/precompiled/sketch.bin b/precompiled/sketch.bin new file mode 100755 index 0000000000000000000000000000000000000000..abf3805d22e9a0cba0179cd8bc636b3fcd9f856b GIT binary patch literal 112 zcmY#Z6J&VL;K00{gMqP_0RpzOGc+(SWoMtv;lKbA1F?nKMH!S=JZBSDUCNN&z`!8P w$oLIhT01bT;6#xJL delta 75 zcmaD;|E8WtSxu1PJp)6`WR3>mjXd92nLY?_W?`GfEc8LRn1O*|awjXpWL^P=$s7VA cn>TQ(aWgFto_s?j4MaJJdI71;J)#L(0DnLhmH+?% diff --git a/uvm32/uvm32.c b/uvm32/uvm32.c index 5831bd8..ca5df33 100644 --- a/uvm32/uvm32.c +++ b/uvm32/uvm32.c @@ -167,6 +167,7 @@ uint32_t uvm32_run(uvm32_state_t *vmst, uvm32_evt_t *evt, uint32_t instr_meter) } // no mapping found if (!syscall_valid) { +printf("BADSYS %08x halt=%08x YIELD=%08x\n", syscall, UVM32_SYSCALL_HALT, UVM32_SYSCALL_YIELD); setStatusErr(vmst, UVM32_ERR_BAD_SYSCALL); } break; diff --git a/uvm32/uvm32.h b/uvm32/uvm32.h index 786390f..c7e487b 100644 --- a/uvm32/uvm32.h +++ b/uvm32/uvm32.h @@ -3,10 +3,7 @@ #include #include - -// "well-known" system UVM32_SYSCALL functions -#define UVM32_SYSCALL_HALT 0x138 -#define UVM32_SYSCALL_YIELD 0x139 +#include "uvm32_sys.h" #define LIST_OF_UVM32_ERRS \ X(UVM32_ERR_NONE) \