summaryrefslogtreecommitdiff
path: root/sys/arch/i386/stand
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1997-08-13 14:24:03 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1997-08-13 14:24:03 +0000
commitd3a188da66877f24cf438d9749c84f8fe542bdbc (patch)
tree32f628b85878446350f893b29a27e192f8d0e259 /sys/arch/i386/stand
parentf33c6e50002d716df12f9116355332e01891bfd4 (diff)
s/kbd/pc/ for consistency with kernel. Do even better __asms for BIOS calls.
Adapt to new console probing and setting API. Do not try to probe pc0 via the NVRAM. Fix some other buglets.
Diffstat (limited to 'sys/arch/i386/stand')
-rw-r--r--sys/arch/i386/stand/boot/cmd.c14
-rw-r--r--sys/arch/i386/stand/boot/conf.c4
-rw-r--r--sys/arch/i386/stand/libsa/bioscons.c82
-rw-r--r--sys/arch/i386/stand/libsa/biosdev.h12
-rw-r--r--sys/arch/i386/stand/libsa/dev_i386.c33
5 files changed, 98 insertions, 47 deletions
diff --git a/sys/arch/i386/stand/boot/cmd.c b/sys/arch/i386/stand/boot/cmd.c
index 0e35233aa36..58afb95d137 100644
--- a/sys/arch/i386/stand/boot/cmd.c
+++ b/sys/arch/i386/stand/boot/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.22 1997/08/13 03:49:28 mickey Exp $ */
+/* $OpenBSD: cmd.c,v 1.23 1997/08/13 14:24:00 niklas Exp $ */
/*
* Copyright (c) 1997 Michael Shalayeff
@@ -264,9 +264,11 @@ readline(buf, to)
p = pe = buf;
continue;
case '\n':
+ case '\r':
pe[1] = *pe = '\0';
break;
case '\b':
+ case '\177':
if (p > buf) {
putchar('\177');
p--;
@@ -405,11 +407,17 @@ Xaddr()
static int
Xtty()
{
+ dev_t dev;
+
if (cmd.argc == 1)
- printf(ttyname(0));
+ printf("%s\n", ttyname(0));
else {
+ dev = ttydev(cmd.argv[1]);
+ if (dev == NODEV)
+ printf("%s not a console device\n", cmd.argv[1]);
+ else if (cnset(dev))
+ printf("%s console not present\n", cmd.argv[1]);
}
-
return 0;
}
diff --git a/sys/arch/i386/stand/boot/conf.c b/sys/arch/i386/stand/boot/conf.c
index 46bb31bc336..e149cb6ac93 100644
--- a/sys/arch/i386/stand/boot/conf.c
+++ b/sys/arch/i386/stand/boot/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.5 1997/08/12 21:46:52 mickey Exp $ */
+/* $OpenBSD: conf.c,v 1.6 1997/08/13 14:24:00 niklas Exp $ */
/*
* Copyright (c) 1996 Michael Shalayeff
@@ -94,7 +94,7 @@ struct consdev constab[] = {
#ifdef _TEST
{ unix_probe, unix_init, unix_getc, unix_putc },
#else
- { kbd_probe, kbd_init, kbd_getc, kbd_putc },
+ { pc_probe, pc_init, pc_getc, pc_putc },
{ com_probe, com_init, com_getc, com_putc },
#endif
{ NULL }
diff --git a/sys/arch/i386/stand/libsa/bioscons.c b/sys/arch/i386/stand/libsa/bioscons.c
index 68ba53d37d1..3dd6473b082 100644
--- a/sys/arch/i386/stand/libsa/bioscons.c
+++ b/sys/arch/i386/stand/libsa/bioscons.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bioscons.c,v 1.2 1997/08/12 23:34:21 mickey Exp $ */
+/* $OpenBSD: bioscons.c,v 1.3 1997/08/13 14:24:01 niklas Exp $ */
/*
* Copyright (c) 1997 Michael Shalayeff
@@ -39,11 +39,17 @@
#include <dev/ic/mc146818reg.h>
#include <i386/isa/nvram.h>
#include <dev/cons.h>
+#include <lib/libsa/stand.h>
+/* XXX cannot trust NVRAM on this. Maybe later we make a real probe. */
+#if 0
#define PRESENT_MASK (NVRAM_EQUIPMENT_KBD|NVRAM_EQUIPMENT_DISPLAY)
+#else
+#define PRESENT_MASK 0
+#endif
void
-kbd_probe(cn)
+pc_probe(cn)
struct consdev *cn;
{
outb(IO_RTC, NVRAM_EQUIPMENT);
@@ -51,44 +57,41 @@ kbd_probe(cn)
cn->cn_pri = CN_INTERNAL;
/* XXX from i386/conf.c */
cn->cn_dev = makedev(12, 0);
+ printf("pc%d detected\n", minor(cn->cn_dev));
}
}
void
-kbd_init(cn)
+pc_init(cn)
struct consdev *cn;
{
- /* nothing */
+ printf("using pc%d console\n", minor(cn->cn_dev));
}
int
-kbd_getc(dev)
+pc_getc(dev)
dev_t dev;
{
u_int8_t rv;
if (dev & 0x80) {
- __asm volatile("movb $1, %%ah\n\t"
- DOINT(0x16) "\n\t"
- "setnz %%al"
- : "=a" (rv) :: "%ecx", "%edx", "cc" );
- return rv;
+ __asm __volatile(DOINT(0x16) "; setnz %%al" : "=a" (rv) :
+ "a" (0x100) : "%ecx", "%edx", "cc" );
+ return (rv);
}
- __asm __volatile("xorl %%eax, %%eax\n\t"
- DOINT(0x16)
- : "=a" (rv) :: "%ecx", "edx", "cc" );
- return rv;
+ __asm __volatile(DOINT(0x16) : "=a" (rv) : "a" (0) :
+ "%ecx", "edx", "cc" );
+ return (rv);
}
void
-kbd_putc(dev, c)
+pc_putc(dev, c)
dev_t dev;
int c;
{
- __asm __volatile("movb $0x0e, %%ah\n\t"
- DOINT(0x10)
- :: "a" (c), "b" (0) : "%ecx", "%edx", "cc" );
+ __asm __volatile(DOINT(0x10) : : "a" (c | 0xe00), "b" (0) :
+ "%ecx", "%edx", "cc" );
}
void
@@ -96,21 +99,30 @@ com_probe(cn)
struct consdev *cn;
{
register int i, n;
- __asm __volatile(DOINT(0x11) "\n\t" /* get equipment (9-11 # of coms) */
- : "=a" (n) :: "%ecx", "%edx", "cc");
+
+ /* get equip. (9-11 # of coms) */
+ __asm __volatile(DOINT(0x11) : "=a" (n) : : "%ecx", "%edx", "cc");
n >>= 9;
n &= 7;
for (i = 0; i < n; i++)
- ;
+ printf("com%d detected\n", i);
+ if (n) {
+ cn->cn_pri = CN_NORMAL;
+ /* XXX from i386/conf.c */
+ cn->cn_dev = makedev(8, 0);
+ }
}
void
com_init(cn)
struct consdev *cn;
{
- __asm volatile("movb $0xe2, %%al\n\t"
- DOINT(0x14) "\n\t"
- :: "d" (minor(cn->cn_dev)) : "%ecx", "cc" );
+ int unit = minor(cn->cn_dev);
+
+ /* 9600-N-1 */
+ __asm __volatile(DOINT(0x14) : : "a" (0xe3), "d" (unit) :
+ "%ecx", "cc" );
+ printf("using com%d console\n", unit);
}
int
@@ -118,15 +130,17 @@ com_getc(dev)
dev_t dev;
{
register int rv;
- __asm volatile("movl $2, %%al\n\t"
- DOINT(0x14) "\n\t"
- : "=a" (rv): "d" (minor(dev)) : "%ecx", "cc" );
- if (!(rv & 0x8000))
- return 0;
+ if (dev & 0x80) {
+ __asm __volatile(DOINT(0x14) : "=a" (rv) :
+ "a" (0x300), "d" (minor(dev)) : "%ecx", "cc" );
+ return ((rv & 0x100) == 0x100);
+ }
- if (minor(dev) & 0x80)
- return 1;
+ do
+ __asm __volatile(DOINT(0x14) "\n\t" : "=a" (rv) :
+ "a" (0x200), "d" (minor(dev)) : "%ecx", "cc" );
+ while (rv & 0x8000);
return (rv & 0xff);
}
@@ -137,7 +151,7 @@ com_putc(dev, c)
int c;
{
int rv;
- __asm volatile("movb $1, %%ah\n\t"
- DOINT(0x14) "\n\t"
- : "=a" (rv): "d" (minor(dev)), "a" (c) : "%ecx", "cc" );
+
+ __asm __volatile(DOINT(0x14) "\n\t" : "=a" (rv) :
+ "d" (minor(dev)), "a" (c | 0x100) : "%ecx", "cc" );
}
diff --git a/sys/arch/i386/stand/libsa/biosdev.h b/sys/arch/i386/stand/libsa/biosdev.h
index a4b9a53fe51..3305ae729a4 100644
--- a/sys/arch/i386/stand/libsa/biosdev.h
+++ b/sys/arch/i386/stand/libsa/biosdev.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: biosdev.h,v 1.17 1997/08/13 03:35:08 mickey Exp $ */
+/* $OpenBSD: biosdev.h,v 1.18 1997/08/13 14:24:01 niklas Exp $ */
/*
* Copyright (c) 1996 Michael Shalayeff
@@ -43,11 +43,11 @@ int biosclose __P((struct open_file *));
int biosioctl __P((struct open_file *, u_long, void *));
/* bioscons.c */
-void kbd_probe __P((struct consdev *));
-void kbd_init __P((struct consdev *));
-int kbd_getc __P((dev_t));
-void kbd_putc __P((dev_t, int));
-void kbd_pollc __P((dev_t, int));
+void pc_probe __P((struct consdev *));
+void pc_init __P((struct consdev *));
+int pc_getc __P((dev_t));
+void pc_putc __P((dev_t, int));
+void pc_pollc __P((dev_t, int));
void com_probe __P((struct consdev *));
void com_init __P((struct consdev *));
int com_getc __P((dev_t));
diff --git a/sys/arch/i386/stand/libsa/dev_i386.c b/sys/arch/i386/stand/libsa/dev_i386.c
index 4c337d3683c..e42af67ad7e 100644
--- a/sys/arch/i386/stand/libsa/dev_i386.c
+++ b/sys/arch/i386/stand/libsa/dev_i386.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dev_i386.c,v 1.16 1997/08/12 22:14:36 mickey Exp $ */
+/* $OpenBSD: dev_i386.c,v 1.17 1997/08/13 14:24:02 niklas Exp $ */
/*
* Copyright (c) 1996 Michael Shalayeff
@@ -34,6 +34,8 @@
#include "libsa.h"
#include "biosdev.h"
+#include <sys/param.h>
+#include <dev/cons.h>
extern int debug;
@@ -44,6 +46,12 @@ const char bdevs[][4] = {
};
const int nbdevs = NENTS(bdevs);
+const char cdevs[][4] = {
+ "", "", "", "", "", "", "", "",
+ "com", "", "", "", "pc"
+};
+const int ncdevs = NENTS(cdevs);
+
/* pass dev_t to the open routines */
int
devopen(struct open_file *f, const char *fname, char **file)
@@ -160,5 +168,26 @@ char *
ttyname(fd)
int fd;
{
- return "tty";
+ static char buf[8];
+
+ sprintf(buf, "%s%d", cdevs[major(cn_tab->cn_dev)],
+ minor(cn_tab->cn_dev));
+ return (buf);
+}
+
+dev_t
+ttydev(name)
+ char *name;
+{
+ int i, unit = -1;
+ char *no = name + strlen(name) - 1;
+
+ while (no >= name && *no >= '0' && *no <= '9')
+ unit = (unit < 0 ? 0 : (unit * 10)) + *no-- - '0';
+ if (no < name || unit < 0)
+ return (NODEV);
+ for (i = 0; i < ncdevs; i++)
+ if (strncmp(name, cdevs[i], no - name + 1) == 0)
+ return (makedev(i, unit));
+ return (NODEV);
}