summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/i386/stand/libsa/gateA20.c97
-rw-r--r--sys/arch/i386/stand/libsa/libsa.h3
-rw-r--r--sys/arch/i386/stand/libsa/machdep.c28
-rw-r--r--sys/arch/i386/stand/libsa/ps2probe.h49
4 files changed, 101 insertions, 76 deletions
diff --git a/sys/arch/i386/stand/libsa/gateA20.c b/sys/arch/i386/stand/libsa/gateA20.c
index 6fde066209f..c6277445f91 100644
--- a/sys/arch/i386/stand/libsa/gateA20.c
+++ b/sys/arch/i386/stand/libsa/gateA20.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gateA20.c,v 1.7 2001/08/18 02:00:49 csapuntz Exp $ */
+/* $OpenBSD: gateA20.c,v 1.8 2001/08/18 15:34:17 mickey Exp $ */
/*
* Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
@@ -6,24 +6,24 @@
* Mach Operating System
* Copyright (c) 1992, 1991 Carnegie Mellon University
* All Rights Reserved.
- *
+ *
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
- *
+ *
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
+ *
* Carnegie Mellon requests users of this software to return to
- *
+ *
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
- *
+ *
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
@@ -36,56 +36,12 @@
#include "libsa.h"
-#define KC_CMD_WOUT 0xd1 /* write output port */
#define KB_A20 0xdf /* enable A20,
enable output buffer full interrupt
enable data line
enable clock line */
-#define A20_KBD 0
-#define A20_0x92 1
-
-int gateA20kbd __P((int));
-
-/*
- * Check for an oddball IBM_L40 machine.
- */
-int
-getA20type()
-{
- return(A20_KBD);
-}
-
-
-int
-gateA20kbd(on)
- int on;
-{
- u_int i = 1000000;
-
- while (i && (inb(IO_KBD + KBSTATP) & KBS_IBF)) i--;
- if (i == 0)
- return (1);
-
- while (inb(IO_KBD + KBSTATP) & KBS_DIB)
- (void)inb(IO_KBD + KBDATAP);
-
- outb(IO_KBD + KBCMDP, KC_CMD_WOUT);
- while (inb(IO_KBD + KBSTATP) & KBS_IBF);
-
- if (on)
- outb(IO_KBD + KBDATAP, KB_A20);
- else
- outb(IO_KBD + KBDATAP, 0xcd);
- while (inb(IO_KBD + KBSTATP) & KBS_IBF);
-
- while (inb(IO_KBD + KBSTATP) & KBS_DIB)
- (void)inb(IO_KBD + KBDATAP);
-
- return (0);
-}
-
/*
* Gate A20 for high memory
*/
@@ -93,20 +49,35 @@ void
gateA20(on)
int on;
{
- int data;
+ if (ps2model == 0xf82 ||
+ (inb(IO_KBD + KBSTATP) == 0xff && inb(IO_KBD + KBDATAP) == 0xff)) {
+ int data;
+
+ /* Try to use 0x92 to turn on A20 */
+ if (on) {
+ data = inb(0x92);
+ outb(0x92, data | 0x2);
+ } else {
+ data = inb(0x92);
+ outb(0x92, data & ~0x2);
+ }
+ } else {
- if (getA20type() == A20_KBD) {
- if (!gateA20kbd(on))
- return;
- }
+ while (inb(IO_KBD + KBSTATP) & KBS_IBF);
- /* Try to use 0x92 to turn on A20 */
- if (on) {
- data = inb(0x92);
- outb(0x92, data | 0x2);
- } else {
- data = inb(0x92);
- outb(0x92, data & ~0x2);
+ while (inb(IO_KBD + KBSTATP) & KBS_DIB)
+ (void)inb(IO_KBD + KBDATAP);
+
+ outb(IO_KBD + KBCMDP, KBC_CMDWOUT);
+ while (inb(IO_KBD + KBSTATP) & KBS_IBF);
+
+ if (on)
+ outb(IO_KBD + KBDATAP, KB_A20);
+ else
+ outb(IO_KBD + KBDATAP, 0xcd);
+ while (inb(IO_KBD + KBSTATP) & KBS_IBF);
+
+ while (inb(IO_KBD + KBSTATP) & KBS_DIB)
+ (void)inb(IO_KBD + KBDATAP);
}
}
-
diff --git a/sys/arch/i386/stand/libsa/libsa.h b/sys/arch/i386/stand/libsa/libsa.h
index 2a24d1cfb5d..7520b896174 100644
--- a/sys/arch/i386/stand/libsa/libsa.h
+++ b/sys/arch/i386/stand/libsa/libsa.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: libsa.h,v 1.32 2000/10/25 18:45:53 mickey Exp $ */
+/* $OpenBSD: libsa.h,v 1.33 2001/08/18 15:34:17 mickey Exp $ */
/*
* Copyright (c) 1996-1999 Michael Shalayeff
@@ -57,6 +57,7 @@ void machdep __P((void));
extern const char bdevs[][4];
extern const int nbdevs;
extern u_int cnvmem, extmem; /* XXX global pass memprobe()->machdep_start() */
+extern int ps2model;
/* diskprobe.c */
extern bios_diskinfo_t bios_diskinfo[];
diff --git a/sys/arch/i386/stand/libsa/machdep.c b/sys/arch/i386/stand/libsa/machdep.c
index f9b013a2235..95a26f5491c 100644
--- a/sys/arch/i386/stand/libsa/machdep.c
+++ b/sys/arch/i386/stand/libsa/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.30 2000/10/25 17:12:07 mickey Exp $ */
+/* $OpenBSD: machdep.c,v 1.31 2001/08/18 15:34:17 mickey Exp $ */
/*
* Copyright (c) 1997-1999 Michael Shalayeff
@@ -35,6 +35,7 @@
#include <machine/apmvar.h>
#include <machine/biosvar.h>
#include "debug.h"
+#include "ps2probe.h"
struct BIOS_regs BIOS_regs;
@@ -45,26 +46,29 @@ struct BIOS_regs BIOS_regs;
#endif
extern int debug;
+int ps2model;
void
machdep()
{
- /* here */ CKPT('0');
+ /* here */ CKPT('0');
+ printf("probing:");
#ifndef _TEST
- gateA20(1); CKPT('1');
- debug_init(); CKPT('2');
+ /* probe for a model number, gateA20() neds ps2model */
+ ps2probe(); CKPT('1');
+ gateA20(1); CKPT('2');
+ debug_init(); CKPT('3');
#endif
/* call console init before doing any io */
- printf("probing:");
- cninit(); CKPT('3');
+ cninit(); CKPT('4');
#ifndef _TEST
- apmprobe(); CKPT('4');
- pciprobe(); CKPT('5');
-/* smpprobe(); CKPT('6'); */
- memprobe(); CKPT('7');
+ apmprobe(); CKPT('5');
+ pciprobe(); CKPT('6');
+/* smpprobe(); CKPT('7'); */
+ memprobe(); CKPT('8');
printf("\n");
- diskprobe(); CKPT('8');
+ diskprobe(); CKPT('9');
#endif
- CKPT('Z');
+ CKPT('Z');
}
diff --git a/sys/arch/i386/stand/libsa/ps2probe.h b/sys/arch/i386/stand/libsa/ps2probe.h
new file mode 100644
index 00000000000..9e7bd7a3f7b
--- /dev/null
+++ b/sys/arch/i386/stand/libsa/ps2probe.h
@@ -0,0 +1,49 @@
+/* $OpenBSD: ps2probe.h,v 1.1 2001/08/18 15:34:17 mickey Exp $ */
+
+/*
+ * Copyright (c) 2001 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 AUTHOR OR HIS RELATIVES 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 MIND, 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.
+ */
+
+static __inline int
+ps2probe(void)
+{
+ char *p;
+ int r;
+
+ __asm __volatile(DOINT(0x15) "\n\t"
+ "setc %b0\n\t"
+ : "=a" (r), "=b" (p)
+ : "0" (0xc000)
+ : "%ecx", "cc");
+ if (!(r & 0xff))
+ return p[2];
+ else
+ return 0;
+}