commit 1475ca63cc81a04a58953072d9775062aab3f6cf
parent e1c1fdc502fb2108bde525fcf34d1879f595fa74
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Mon, 17 Oct 2022 15:09:21 -0400
app/cos: blkfs works!
f<< /app/cos/cvm.fs
cosfs$
cos
Collapse OS ok
0 LIST
MASTER INDEX
...
Diffstat:
10 files changed, 30 insertions(+), 23 deletions(-)
diff --git a/fs/app/cos/cvm.c b/fs/app/cos/cvm.c
@@ -48,8 +48,7 @@ static byte blkop[ #[ BLKOP_CMD_SZ c]# ];
*/
static byte io_read(word addr)
{
- addr &= $ff;
- IORD fn = vm.iord[addr];
+ IORD fn = vm.iord[addr&$ff];
if (fn != NULL) {
return fn();
} else {
@@ -60,8 +59,7 @@ static byte io_read(word addr)
static void io_write(word addr, byte val)
{
- addr &= $ff;
- IOWR fn = vm.iowr[addr];
+ IOWR fn = vm.iowr[addr&$ff];
if (fn != NULL) {
fn(val);
} else {
diff --git a/fs/app/cos/cvm.fs b/fs/app/cos/cvm.fs
@@ -1,12 +1,13 @@
-?f<< /cc/lib.fs
+?f<< /app/cos/tools/blkpack.fs
cc<< /app/cos/cvm.c
S" COSVM" findTypedef CType :export
: cos
- COS_init vm COSVM mem
- S" /app/cos/serial.bin" curpath :find# Path :open
+ COS_init
+ cosfs blkfp !
+ vm COSVM mem S" /app/cos/serial.bin" curpath :find# Path :open
tuck File :readall File :close
- ['] stdin vm COSVM iord !
+ ['] key vm COSVM iord !
['] stdout vm COSVM iowr !
begin 100 COS_steps not until COS_printdbg ;
diff --git a/fs/app/cos/tools/blkpack.c b/fs/app/cos/tools/blkpack.c
@@ -2,7 +2,7 @@
int lineno;
-void emptylines(int n)
+static void emptylines(int n)
{
int i;
for (i=0; i<64*n; i++) {
@@ -10,7 +10,7 @@ void emptylines(int n)
}
}
-int getmarker(char *line) // returns -1 on error, blkid otherwise
+static int getmarker(char *line) // returns -1 on error, blkid otherwise
{
if (sscanf("( ----- %d )", line)) {
return pspop();
@@ -19,7 +19,7 @@ int getmarker(char *line) // returns -1 on error, blkid otherwise
}
}
-unsigned int expectmarker(char *line)
+static unsigned int expectmarker(char *line)
{
int blkid = getmarker(line);
if (blkid < 0) { // could not scan
@@ -30,7 +30,7 @@ unsigned int expectmarker(char *line)
return blkid;
}
-extern void blkpack() {
+void blkpack() {
int prevblkid = -1;
int blkoff = 0;
int blkid;
@@ -54,8 +54,7 @@ extern void blkpack() {
"Block 0 encountered. Bumping current blkid to %d.\n",
ConsoleOut());
}
- // TODO: add +=
- blkid = blkid + blkoff;
+ blkid += blkoff;
if (blkid <= prevblkid) {
fprintf(
blkid, lineno,
diff --git a/fs/app/cos/tools/blkpack.fs b/fs/app/cos/tools/blkpack.fs
@@ -1,3 +1,10 @@
?f<< /cc/lib.fs
cc<< /app/cos/tools/blkpack.c
+320 $400 * MemFile :new const cosfs
+
+: cosfs$
+ 0 cosfs MemFile :seek
+ S" /app/cos/blk.fs" curpath :find# Path :open to StdIn
+ cosfs to StdOut
+ blkpack StdIn File :close stdio$ ;
diff --git a/fs/cc/gen.fs b/fs/cc/gen.fs
@@ -172,10 +172,10 @@ ASTIDCNT wordtbl gentbl ( node -- )
nip dup Node id AST_FUNCTION = if
\ Sometimes, we get a Function as dnode. In these cases, it's a global
\ address and its type is "void"
- TYPE_VOID to vmop type Function address mem>op
+ TYPE_VOID to vmop type Function address const>op
else Declare ctype ctype>op then
else ( inode )
- Ident name sysdict @ find ?dup _assert TYPE_VOID to vmop type mem>op then
+ Ident name sysdict @ find ?dup _assert TYPE_VOID to vmop type const>op then
_debug if .ops then ;
:w ( UnaryOp )
_debug if ." unaryop: " dup printast nl> then
@@ -226,7 +226,7 @@ ASTIDCNT wordtbl gentbl ( node -- )
dup Node id AST_FUNCTION = if Function :rettype
else Declare ctype CType type dup CType :funcsig? _assert CType type then
else
- vmop loc VM_*CONSTANT = if vmop arg wordfunctype else TYPE_VOID then then
+ vmop loc VM_CONSTANT = if vmop arg wordfunctype else TYPE_VOID then then
( node type ) vmop :push rot ( type 'copy node )
\ pass arguments
Node firstchild begin ( argnode )
diff --git a/fs/cc/vm/forth.fs b/fs/cc/vm/forth.fs
@@ -101,7 +101,7 @@ struct+[ VMOp
\ Call the address in current op. If the function has a result, you need to
\ pop it with vmpspop,
: vmcall, ( -- )
- VM_*CONSTANT vmop loc = if
+ VM_CONSTANT vmop loc = if
vmop arg execute, vmop :init
else vmop :compile vmop :forgetTOS compile execute then
\ psoff is *not* supposed to be nonzero when we begin calling a function,
diff --git a/fs/cc/vm/i386.fs b/fs/cc/vm/i386.fs
@@ -143,7 +143,7 @@ struct+[ VMOp
\ pop it with vmpspop,
: vmcall, ( -- )
callsz ?dup if bp i) sub, 0 to callsz then
- VM_*CONSTANT vmop loc = if
+ VM_CONSTANT vmop loc = if
vmop arg VM_NONE to vmop loc abs>rel else vmop :compile then
call, vmop :init ;
diff --git a/fs/tests/app/cos/cvm.fs b/fs/tests/app/cos/cvm.fs
@@ -1,5 +1,7 @@
?f<< /tests/harness.fs
-f<< /app/cos/cvm.fs
+?f<< /cc/lib.fs
+cc<< /app/cos/cvm.c
+S" COSVM" findTypedef CType :export
testbegin
\ Testing COS CVM
diff --git a/fs/tests/cc/test.c b/fs/tests/cc/test.c
@@ -145,7 +145,7 @@ int sysword(int a, int b) {
typedef unsigned int (*MaxSig)(unsigned int, unsigned int);
// Same as above, but through a function signature typedef
int funcsig(int a, int b) {
- MaxSig fn = &max;
+ MaxSig fn = max;
return fn(a, b);
}
diff --git a/fs/tests/cc/vm.fs b/fs/tests/cc/vm.fs
@@ -171,8 +171,8 @@ code test11 ( n -- n-42 )
vmcallarg,
42 const>op
vmcallarg,
- ' test1 mem>op ( a b -- a-b )
- TYPE_VOID to vmop type
+ ' test1 const>op ( a b -- a-b )
+ TYPE_VOID* to vmop type
vmcall,
vmpspop,
vmret,