summaryrefslogtreecommitdiff
path: root/sys/arch/i386
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>1997-08-12 21:39:02 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>1997-08-12 21:39:02 +0000
commit4708586154f2a20011f7d764fe9ff7f558defd91 (patch)
tree23aae33ce931a2eaaf6a7694b526ee7d00c55e98 /sys/arch/i386
parent084e3f66981ce7370c130880353703d2afb3321f (diff)
new cons
do inline BIOS calls
Diffstat (limited to 'sys/arch/i386')
-rw-r--r--sys/arch/i386/stand/libsa/Makefile6
-rw-r--r--sys/arch/i386/stand/libsa/bioscom.S144
-rw-r--r--sys/arch/i386/stand/libsa/bioscons.c145
-rw-r--r--sys/arch/i386/stand/libsa/biosdev.h20
-rw-r--r--sys/arch/i386/stand/libsa/bioskbd.S98
5 files changed, 149 insertions, 264 deletions
diff --git a/sys/arch/i386/stand/libsa/Makefile b/sys/arch/i386/stand/libsa/Makefile
index b0f36fda0c5..7d83c28a225 100644
--- a/sys/arch/i386/stand/libsa/Makefile
+++ b/sys/arch/i386/stand/libsa/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.20 1997/08/12 19:24:56 mickey Exp $
+# $OpenBSD: Makefile,v 1.21 1997/08/12 21:39:00 mickey Exp $
LIB= sa
@@ -13,8 +13,8 @@ DIR_KERN=$S/lib/libkern
#AS+= -a
# i386 stuff (so, it will possibly load in the same 64k)
-SRCS= unixsys.S bioscom.S bioskbd.S gidt.S \
- debug_i386.S dev_i386.c exec_i386.c biosdev.c gateA20.c memprobe.c \
+SRCS= unixsys.S gidt.S debug_i386.S \
+ bioscons.c dev_i386.c exec_i386.c biosdev.c gateA20.c memprobe.c \
time.c alloca.S apm_init.S machdep.c
# stand routines
diff --git a/sys/arch/i386/stand/libsa/bioscom.S b/sys/arch/i386/stand/libsa/bioscom.S
deleted file mode 100644
index ccccc527bc5..00000000000
--- a/sys/arch/i386/stand/libsa/bioscom.S
+++ /dev/null
@@ -1,144 +0,0 @@
-/* $OpenBSD: bioscom.S,v 1.6 1997/08/07 22:11:17 niklas Exp $ */
-
-/*
- * Copyright (c) 1997 Michael Shalayeff
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Michael Shalayeff.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
- .file "bioscom.S"
-
-#include <machine/asm.h>
-#define _LOCORE
-#include <machine/biosvar.h>
-#undef _LOCORE
-
-#define COM_ENT(i,op) \
-ENTRY(com/**/i/**/_/**/op) ; \
- xorl %edx, %edx ; \
- movb $i, %dl ; \
- jmp 1f
-
- .text
-/*
- * int com<N>_probe();
- * probe com<N> port
- */
-COM_ENT(0,probe)
-COM_ENT(1,probe)
-COM_ENT(2,probe)
-COM_ENT(3,probe)
-
-1: pushl %ebx
-
- DOINT(0x11) # get equipment (9-11 # of coms)
- shrl $9, %eax
- andb $7, %al
- cmpb %al, %dl
- jl 1f
- xorl %eax, %eax
- jmp 2f
-1:
- xorl %eax, %eax
- movb $0xe3, %al # 9600-N-8
- DOINT(0x14)
- xorl %eax, %eax
- incl %eax
-2:
- popl %ebx
- ret
-
-/*
- * void com<N>_putc(char ch)
- * send ch to serial port
- *
- */
-
-COM_ENT(0,putc)
-COM_ENT(1,putc)
-COM_ENT(2,putc)
-COM_ENT(3,putc)
-
-1: pushl %ebx
- movl 8(%esp), %eax
- movb $1, %ah
- DOINT(0x14)
- xorl %al, %al
- testb $0x80, %ah
- jz 1f
- movb %ah, %al
- andb $0x7f, %al
-1: movzbl %al, %eax
- popl %ebx
- ret
-
-/*
- * int com<N>_getc(void)
- * read a character from serial port
- */
-
-COM_ENT(0,getc)
-COM_ENT(1,getc)
-COM_ENT(2,getc)
-COM_ENT(3,getc)
-
-1: pushl %ebx
- xorl %eax, %eax
- movb $2, %ah
- DOINT(0x14)
- testb $0x80, %ah
- jz 1f
- movl $-1, %eax
- jmp 2f
-1: movzbl %al, %eax
-2: popl %ebx
- ret
-
-/*
- * int com<N>_ischar(void)
- * check for char available
- */
-
-COM_ENT(0,ischar)
-COM_ENT(1,ischar)
-COM_ENT(2,ischar)
-COM_ENT(3,ischar)
-
-1: pushl %ebx
- xorl %eax, %eax
- movb $3, %al
- DOINT(0x14)
- movb $0, %al
- testb $1, %ah
- jz 1f
- incl %eax
-1: movzbl %al, %eax
- popl %ebx
- ret
-
diff --git a/sys/arch/i386/stand/libsa/bioscons.c b/sys/arch/i386/stand/libsa/bioscons.c
new file mode 100644
index 00000000000..a365453bc74
--- /dev/null
+++ b/sys/arch/i386/stand/libsa/bioscons.c
@@ -0,0 +1,145 @@
+/* $OpenBSD: bioscons.c,v 1.1 1997/08/12 21:39:01 mickey Exp $ */
+
+/*
+ * Copyright (c) 1997 Michael Shalayeff
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Michael Shalayeff.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include <sys/types.h>
+#include <machine/biosvar.h>
+#include <machine/pio.h>
+#include <dev/isa/isareg.h>
+#include <dev/ic/mc146818reg.h>
+#include <i386/isa/nvram.h>
+#include <dev/cons.h>
+
+#define PRESENT_MASK (NVRAM_EQUIPMENT_KBD|NVRAM_EQUIPMENT_DISPLAY)
+
+void
+kbd_probe(cn)
+ struct consdev *cn;
+{
+ outb(IO_RTC, NVRAM_EQUIPMENT);
+ if ((inb(IO_RTC+1) & PRESENT_MASK) == PRESENT_MASK) {
+ cn->cn_pri = CN_INTERNAL;
+ /* XXX from i386/conf.c */
+ cn->cn_dev = makedev(12, 0);
+ }
+}
+
+void
+kbd_init(cn)
+ struct consdev *cn;
+{
+ /* nothing */
+}
+
+int
+kbd_getc(dev)
+ dev_t dev;
+{
+ u_int8_t rv;
+ __asm volatile("movb $1, %%ah\n\t"
+ DOINT(0x16) "\n\t"
+ "setz %%al"
+ : "=a" (rv) :: "%ecx", "%edx", "cc" );
+ if (rv)
+ return 0;
+
+ if (minor(dev) & 0x80)
+ return 1;
+
+ __asm volatile("xorl %%eax, %%eax\n\t"
+ DOINT(0x16) "\n\t"
+ : "=a" (rv) :: "%ecx", "edx", "cc" );
+ return rv;
+}
+
+void
+kbd_putc(dev, c)
+ dev_t dev;
+ int c;
+{
+ __asm volatile("movb $0x0e, %%ah\n\t"
+ "movl $0, %%ebx\n\t"
+ DOINT(0x10)
+ :: "a" (c) : "%ecx", "%edx", "cc" );
+}
+
+void
+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");
+ n >>= 9;
+ n &= 7;
+ for (i = 0; i < n; i++)
+ ;
+}
+
+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
+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 (minor(dev) & 0x80)
+ return 1;
+
+ return (rv & 0xff);
+}
+
+void
+com_putc(dev, c)
+ dev_t dev;
+ int c;
+{
+ int rv;
+ __asm volatile("movb $1, %%ah\n\t"
+ DOINT(0x14) "\n\t"
+ : "=a" (rv): "d" (minor(dev)), "a" (c) : "%ecx", "cc" );
+}
diff --git a/sys/arch/i386/stand/libsa/biosdev.h b/sys/arch/i386/stand/libsa/biosdev.h
index e78a4032403..bbb6ad4f32f 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.14 1997/08/12 19:24:58 mickey Exp $ */
+/* $OpenBSD: biosdev.h,v 1.15 1997/08/12 21:39:01 mickey Exp $ */
/*
* Copyright (c) 1996 Michael Shalayeff
@@ -40,24 +40,6 @@ int biosopen __P((struct open_file *, ...));
int biosclose __P((struct open_file *));
int biosioctl __P((struct open_file *, u_long, void *));
-/* bioskbd.S */
-int kbd_probe __P((void));
-void kbd_putc __P((int c));
-int kbd_getc __P((void));
-int kbd_ischar __P((void));
-
-/* bioscom.S */
-#define COM_PROTO(n) \
-int com##n##_probe __P((void)); \
-void com##n##_putc __P((int c)); \
-int com##n##_getc __P((void)); \
-int com##n##_ischar __P((void));
-COM_PROTO(0)
-COM_PROTO(1)
-COM_PROTO(2)
-COM_PROTO(3)
-#undef COM_PROTO
-
/* time.c */
void time_print __P((void));
time_t getsecs __P((void));
diff --git a/sys/arch/i386/stand/libsa/bioskbd.S b/sys/arch/i386/stand/libsa/bioskbd.S
deleted file mode 100644
index 815284c9cee..00000000000
--- a/sys/arch/i386/stand/libsa/bioskbd.S
+++ /dev/null
@@ -1,98 +0,0 @@
-/* $OpenBSD: bioskbd.S,v 1.10 1997/08/08 00:27:54 niklas Exp $ */
-
-/*
- * Copyright (c) 1997 Michael Shalayeff
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Michael Shalayeff.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-#include <machine/asm.h>
-#define _LOCORE
-#include <machine/biosvar.h>
-#include <dev/isa/isareg.h>
-#include <dev/ic/mc146818reg.h>
-#include <i386/isa/nvram.h>
-#undef _LOCORE
-
-/*
- * int kbd_probe();
- * probe if keyboard present
- *
- */
-ENTRY(kbd_probe)
- xorl %eax, %eax
- incl %eax
- ret
-
-/*
- * void kbd_putc(int c)
- * output byte to console
- */
-ENTRY(kbd_putc)
- pushl %ebx
-
- xorl %eax, %eax
- movb 8(%esp), %al
- movb $0x0e, %ah
- xorl %ebx, %ebx
- incl %ebx
- DOINT(0x10) # display a byte
- popl %ebx
- ret
-
-/*
- * int kbd_getc(void)
- * read character from keyboard
- */
-ENTRY(kbd_getc)
- pushl %ebx
- pushl %ecx
- xorl %eax, %eax
- DOINT(0x16)
- movzbl %al, %eax
- popl %ecx
- popl %ebx
- ret
-
-/*
- * int kbd_ischar(void)
- * check if there is character available from keyboard
- */
-ENTRY(kbd_ischar)
- pushl %ebx
- pushl %ecx
- xorl %eax, %eax
- incb %ah
- DOINT(0x16)
- setnz %al
- movzbl %al, %eax
- popl %ecx
- popl %ebx
- ret
-