wm: teppich

Download patch

ref: 7c7ce1f9c1bd9ddd7b381bb2dd0a84d6c66074f5
parent: 4ac86cf6bcb29e89ec0e1c658a5699642986993c
author: mkf <mkf@cloud9p.org>
date: Fri Nov 24 03:57:45 EST 2023

add check and clear for real this time

--- /dev/null
+++ b/cmd/check.c
@@ -1,0 +1,42 @@
+/* health check, stuff should look fine */
+
+#include <u.h>
+#include <libc.h>
+
+#include <err.h>
+#include <mem.h>
+
+void
+malloc_test(void)
+{
+	void *a, *b, *c;
+	 
+	a = malloc(1);
+	b = malloc(2);
+	c = malloc(3);
+
+	printf("a = %x\n", a);
+	printf("b = %x\n", b);
+	printf("c = %x\n", c);
+
+	printf("a location in memap = %x\n", ((int)(a) - MEM_BEG) / BLOCKSIZE);
+	printf("b location in memap = %x\n", ((int)(b) - MEM_BEG) / BLOCKSIZE);
+	printf("c location in memap = %x\n", ((int)(b) - MEM_BEG) / BLOCKSIZE);
+
+	printf("memap[a] = %x\n", memap[(((int)(a) - MEM_BEG) / BLOCKSIZE) + 1]);
+	printf("memap[b] = %x\n", memap[(((int)(b) - MEM_BEG) / BLOCKSIZE) + 1]);
+	printf("memap[c] = %x\n", memap[(((int)(c) - MEM_BEG) / BLOCKSIZE) + 1]);
+
+	free(a);
+	free(b);
+	free(c);
+}
+
+int
+check_main(int argc, char **argv)
+{
+	malloc_test();
+	printf("Press any key to quit test\n");
+	scanf("");
+	return OK;
+}
--- /dev/null
+++ b/cmd/clear.c
@@ -1,0 +1,37 @@
+#include <u.h>
+#include <libc.h>
+
+#include <vga.h>
+#include <ps2.h>
+
+#include <err.h>
+
+void
+clear_usage(void)
+{
+	vga_puts("usage: clear [-k]\n");
+}
+
+int
+clear_main(int argc, char **argv)
+{
+
+	char c;
+	
+	if(argc == 2)
+	{
+		if(!strcmp(argv[1], "-k"))
+		{
+			vga_puts("Please press any key to clear the screen\n");
+			ps2_getc();
+		}
+		else 
+		{
+			clear_usage();
+			return USAGE;
+		}
+	}
+	
+	vga_clear(c);
+	return OK;
+}