summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1998-10-11 10:05:13 +0000
committerpeter <peter@FreeBSD.org>1998-10-11 10:05:13 +0000
commitea08aa40134629a9b1f5d3ed141fca25d43c565c (patch)
tree5ae7c0d3ddb6808230ae8fc29d488840db23d383
parent2f4399a06354c2d44d27a60265ac2b65b3d94ae8 (diff)
downloadFreeBSD-src-ea08aa40134629a9b1f5d3ed141fca25d43c565c.zip
FreeBSD-src-ea08aa40134629a9b1f5d3ed141fca25d43c565c.tar.gz
Fix comconsole mode. The int 0x14 read and status commands were reversed.
Also, make sure we set %dx each time around otherwise the commands suddenly start trying to work on things like com92 instead of com1. Make sure comc_init() is only run once. Cosmetic change to init-time character eater.
-rw-r--r--sys/boot/i386/libi386/comconsole.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/sys/boot/i386/libi386/comconsole.c b/sys/boot/i386/libi386/comconsole.c
index d493e7c..261e909 100644
--- a/sys/boot/i386/libi386/comconsole.c
+++ b/sys/boot/i386/libi386/comconsole.c
@@ -24,7 +24,7 @@
*
* From Id: probe_keyboard.c,v 1.13 1997/06/09 05:10:55 bde Exp
*
- * $Id: comconsole.c,v 1.2 1998/09/17 23:52:09 msmith Exp $
+ * $Id: comconsole.c,v 1.3 1998/10/02 16:32:45 msmith Exp $
*/
#include <stand.h>
@@ -38,6 +38,8 @@ static void comc_putchar(int c);
static int comc_getchar(void);
static int comc_ischar(void);
+static int comc_started;
+
struct console comconsole = {
"comconsole",
"BIOS serial port",
@@ -61,12 +63,21 @@ comc_probe(struct console *cp)
static int
comc_init(int arg)
{
- v86.ctl = V86_FLAGS;
+ int i;
+
+ if (comc_started && arg == 0)
+ return 0;
+ comc_started = 1;
+ v86.ctl = 0;
v86.addr = 0x14;
v86.eax = 0xe3; /* 9600N81 */
v86.edx = BIOS_COMPORT; /* XXX take as arg, or use env var? */
v86int();
- return(v86.efl & 1);
+
+ for(i = 0; i < 10 && comc_ischar(); i++)
+ (void)comc_getchar();
+
+ return(0);
}
static void
@@ -74,7 +85,8 @@ comc_putchar(int c)
{
v86.ctl = 0;
v86.addr = 0x14;
- v86.eax = 0x100 | c;
+ v86.eax = 0x100 | c; /* Function 1 = write */
+ v86.edx = BIOS_COMPORT; /* XXX take as arg, or use env var? */
v86int();
}
@@ -84,7 +96,8 @@ comc_getchar(void)
if (comc_ischar()) {
v86.ctl = 0;
v86.addr = 0x14;
- v86.eax = 0x300;
+ v86.eax = 0x200; /* Function 2 = read */
+ v86.edx = BIOS_COMPORT; /* XXX take as arg, or use env var? */
v86int();
return(v86.eax & 0xff);
} else {
@@ -97,7 +110,8 @@ comc_ischar(void)
{
v86.ctl = 0;
v86.addr = 0x14;
- v86.eax = 0x200;
+ v86.eax = 0x300; /* Function 3 = status */
+ v86.edx = BIOS_COMPORT; /* XXX take as arg, or use env var? */
v86int();
- return(v86.eax & 0x1);
+ return(v86.eax & 0x100); /* AH bit 1 is "receive data ready" */
}
OpenPOWER on IntegriCloud