wm: teppich

Download patch

ref: 3997e19fbe2c91c70e515117ddd53e3fd67e6936
parent: 6bc6f739a4dde17d87b49e44304bd51e226d3720
author: mkf <mkf@cloud9p.org>
date: Sun Dec 3 02:07:12 EST 2023

fix old cons bugs

old bugs were caused by the fact that pccons and bitcons were incorrectly
marked as static in pccons.h and bitcons.h, making them creating a new object
each time called in a new translation unit. i think...

--- a/include/cons.h
+++ b/include/cons.h
@@ -11,9 +11,14 @@
 	void (*scroll)(int lines);
 }consdev_t;
 
-void consinit(consdev_t cons);
-void consclear(consdev_t cons, char c);
-void conswrite(consdev_t cons, char *s);
-void consputc(consdev_t cons, char c);
-char consread(consdev_t cons);
-void consscroll(consdev_t cons, int lines);
+extern consdev_t pccons;
+extern consdev_t bitcons;
+extern consdev_t serialcons;
+
+void cons_init(consdev_t cons);
+void cons_clear(consdev_t cons, char c);
+void cons_write(consdev_t cons, char *s);
+void cons_putc(consdev_t cons, char c);
+void cons_puts(consdev_t cons, char *s);
+char cons_read(consdev_t cons);
+void cons_scroll(consdev_t cons, int lines);
--- a/pc/cons.c
+++ b/pc/cons.c
@@ -1,31 +1,67 @@
 #include <cons.h>
+#include <vga.h>
+#include <ps2.h>
+#include <bitmap.h>
+#include <com.h>
 
+consdev_t pccons = 
+{
+	.name = "cons",
+	.init = vga_init,
+	.clear = vga_clear,
+	.puts = vga_puts,
+	.putc = vga_putc,
+	.getc = ps2_getc,
+	.scroll = vga_scroll,
+};
+
+consdev_t bitcons =
+{
+	.name = "bitcons",
+	.init = vga_init,
+	.clear = vga_clear,
+	.puts = bitputs,
+	.putc = bitputc,
+	.getc = ps2_getc,
+	.scroll = vga_scroll,
+};
+
+consdev_t serialcons =
+{
+	.name = "serialcons",
+	.init = com_init,
+	/* .clear = nil */
+	.puts = com_puts,
+	.getc = com_getc,
+	/* .scroll = nil */
+};
+
 void
-consinit(consdev_t cons)
+cons_init(consdev_t cons)
 {
 	cons.init();
 }
 
 void
-consclear(consdev_t cons, char c)
+cons_clear(consdev_t cons, char c)
 {
 	cons.clear(c);
 }
 
 void
-consputc(consdev_t cons, char c)
+cons_putc(consdev_t cons, char c)
 {
 	cons.putc(c);
 }
 
 void
-conswrite(consdev_t cons, char *s)
+cons_write(consdev_t cons, char *s)
 {
 	cons.puts(s);
 }
 
 char
-consread(consdev_t cons)
+cons_read(consdev_t cons)
 {
 	return cons.getc();	
 }