Simple console I/O, mostly for debugging.
authorhpa <hpa>
Mon, 10 Dec 2001 09:03:58 +0000 (09:03 +0000)
committerhpa <hpa>
Mon, 10 Dec 2001 09:03:58 +0000 (09:03 +0000)
memdisk/conio.c [new file with mode: 0644]
memdisk/conio.h [new file with mode: 0644]

diff --git a/memdisk/conio.c b/memdisk/conio.c
new file mode 100644 (file)
index 0000000..5e6cc66
--- /dev/null
@@ -0,0 +1,46 @@
+#ident "$Id$"
+/* ----------------------------------------------------------------------- *
+ *   
+ *   Copyright 2001 H. Peter Anvin - All Rights Reserved
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+ *   Bostom MA 02111-1307, USA; either version 2 of the License, or
+ *   (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * conio.c
+ *
+ * Output to the screen
+ */
+
+#include "conio.h"
+
+int putchar(int ch)
+{
+  if ( ch == '\n' )
+    putchar('\r');             /* \n -> \r\n */
+
+  asm volatile("int $0x10"
+              :: "a" (0x1400|(ch&0xff)),
+              "b" (0x07)
+              : "eax", "ebx", "ecx", "edx",
+              "esi", "edi", "ebp");
+
+  return ch;
+}
+
+int puts(const char *s)
+{
+  int count = 0;
+
+  while ( *s ) {
+    putchar(*s);
+    count++;
+  }
+
+  return count;
+}
diff --git a/memdisk/conio.h b/memdisk/conio.h
new file mode 100644 (file)
index 0000000..ced7c2c
--- /dev/null
@@ -0,0 +1,26 @@
+#ident "$Id$"
+/* ----------------------------------------------------------------------- *
+ *   
+ *   Copyright 2001 H. Peter Anvin - All Rights Reserved
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+ *   Bostom MA 02111-1307, USA; either version 2 of the License, or
+ *   (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * conio.h
+ *
+ * Limited console I/O
+ */
+
+#ifndef CONIO_H
+#define CONIO_H
+
+int putchar(int);
+int puts(const char *);
+
+#endif