summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhpa <hpa>2001-12-10 09:03:58 +0000
committerhpa <hpa>2001-12-10 09:03:58 +0000
commit5f730deba07322d48594722e603eeb198954daef (patch)
tree3c9516bb7fe9c9493f83333f4e74523a8b0bfe21
parent2a751970a0c39afc8edab45dbcbfa187c772b78a (diff)
downloadsyslinux-5f730deba07322d48594722e603eeb198954daef.tar.gz
Simple console I/O, mostly for debugging.
-rw-r--r--memdisk/conio.c46
-rw-r--r--memdisk/conio.h26
2 files changed, 72 insertions, 0 deletions
diff --git a/memdisk/conio.c b/memdisk/conio.c
new file mode 100644
index 00000000..5e6cc662
--- /dev/null
+++ b/memdisk/conio.c
@@ -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
index 00000000..ced7c2cb
--- /dev/null
+++ b/memdisk/conio.h
@@ -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