aboutsummaryrefslogtreecommitdiffstats
path: root/c
diff options
context:
space:
mode:
Diffstat (limited to 'c')
-rw-r--r--c/blk.c13
-rw-r--r--c/gbos.h2
-rw-r--r--c/libc.s14
3 files changed, 29 insertions, 0 deletions
diff --git a/c/blk.c b/c/blk.c
new file mode 100644
index 0000000..adf2a58
--- /dev/null
+++ b/c/blk.c
@@ -0,0 +1,13 @@
+#include "gbos.h"
+/* blk: exercise the block device. blk fill <n> <v> | blk peek <n> */
+void main(void) {
+ char *argv[4];
+ unsigned char argc = argv_parse(argv, 4);
+ if (argc >= 3 && argv[0][0] == 'f') {
+ bfill(atou(argv[1]), atou(argv[2]));
+ } else if (argc >= 2 && argv[0][0] == 'p') {
+ putu(bpeek(atou(argv[1]))); nl();
+ } else {
+ puts("usage: blk fill <n> <v> | blk peek <n>"); nl();
+ }
+}
diff --git a/c/gbos.h b/c/gbos.h
index f76d1e0..03a91de 100644
--- a/c/gbos.h
+++ b/c/gbos.h
@@ -43,4 +43,6 @@ unsigned char psget(unsigned char slot, unsigned char *buf); /* {pid,state,prog}
void progname(unsigned char id, char *buf); /* id -> name */
void yield(void);
unsigned char reap(void); /* reap a finished bg job, or 0 */
+void bfill(unsigned char block, unsigned char byte); /* [debug] disk */
+unsigned char bpeek(unsigned char block); /* [debug] disk */
#endif
diff --git a/c/libc.s b/c/libc.s
index 2e2516b..5b81dca 100644
--- a/c/libc.s
+++ b/c/libc.s
@@ -199,3 +199,17 @@ _reap:
ld c, #22 ; SYS_REAP
rst #0x30
ret
+
+ .globl _bfill, _bpeek
+ ;; void bfill(unsigned char block /*A*/, unsigned char byte /*E*/)
+_bfill:
+ ld b, a
+ ld c, #23 ; SYS_BFILL
+ rst #0x30
+ ret
+ ;; unsigned char bpeek(unsigned char block /*A*/) -> A
+_bpeek:
+ ld b, a
+ ld c, #24 ; SYS_BPEEK
+ rst #0x30
+ ret