Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/i386/stand Add some IBM PS/2 support bits:



details:   https://anonhg.NetBSD.org/src/rev/b8bc18ca6488
branches:  trunk
changeset: 510107:b8bc18ca6488
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Sat May 19 18:15:14 2001 +0000

description:
Add some IBM PS/2 support bits:
* recognize PS/2 L40 via biosmca() and biosmca_ps2model in gatea20.c, instead
  of being a compile time option
* if the system is PS/2 with MCA bus, map DTYPE_ESDI disks to ed(4) for
  COMPAT_OLDBOOT

The new code is conditional on SUPPORT_PS2 define, which is on by default
for biosboot-based bootblocks.

diffstat:

 sys/arch/i386/stand/biosboot/Makefile  |   4 +-
 sys/arch/i386/stand/biosboot/devopen.c |  32 +++++++++++++++++++++-------
 sys/arch/i386/stand/biosboot/main.c    |  10 ++++++++-
 sys/arch/i386/stand/biosboot/version   |   5 +++-
 sys/arch/i386/stand/lib/exec.c         |  38 +++++++++++++++++++++++++++------
 sys/arch/i386/stand/lib/gatea20.c      |  21 ++++++++++++------
 6 files changed, 84 insertions(+), 26 deletions(-)

diffs (259 lines):

diff -r be2f7c6c720b -r b8bc18ca6488 sys/arch/i386/stand/biosboot/Makefile
--- a/sys/arch/i386/stand/biosboot/Makefile     Sat May 19 17:53:30 2001 +0000
+++ b/sys/arch/i386/stand/biosboot/Makefile     Sat May 19 18:15:14 2001 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.35 2001/05/02 13:43:11 jdolecek Exp $
+#      $NetBSD: Makefile,v 1.36 2001/05/19 18:15:14 jdolecek Exp $
 
 S=     ${.CURDIR}/../../../../
 
@@ -15,7 +15,7 @@
 
 CLEANFILES+= ${BSSTART}
 
-CPPFLAGS+= -DCOMPAT_OLDBOOT -DCOMPAT_386BSD_MBRPART
+CPPFLAGS+= -DCOMPAT_OLDBOOT -DCOMPAT_386BSD_MBRPART -DSUPPORT_PS2
 
 .if (${BASE} == "biosboot")
 # Various serial line configurations
diff -r be2f7c6c720b -r b8bc18ca6488 sys/arch/i386/stand/biosboot/devopen.c
--- a/sys/arch/i386/stand/biosboot/devopen.c    Sat May 19 17:53:30 2001 +0000
+++ b/sys/arch/i386/stand/biosboot/devopen.c    Sat May 19 18:15:14 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: devopen.c,v 1.9 1999/10/28 05:20:05 mycroft Exp $       */
+/*     $NetBSD: devopen.c,v 1.10 2001/05/19 18:15:14 jdolecek Exp $     */
 
 /*
  * Copyright (c) 1996, 1997
@@ -46,6 +46,9 @@
 #ifdef _STANDALONE
 #include <bootinfo.h>
 #endif
+#ifdef SUPPORT_PS2
+#include <biosmca.h>
+#endif
 
 extern int parsebootfile __P((const char *, char**, char**, unsigned int*,
                              unsigned int*, const char**));
@@ -68,8 +71,13 @@
        },
        {
                "sd", 0x80
+       },
+#ifdef SUPPORT_PS2
+       {
+               "ed", 0x80
        }
-#endif
+#endif /* SUPPORT_PS2 */
+#endif /* COMPAT_OLDBOOT */
 };
 #define NUMBIOSDEVS (sizeof(biosdevtab) / sizeof(biosdevtab[0]))
 
@@ -98,22 +106,30 @@
        char          **devname;
        unsigned int   *unit;
 {
+       u_int8_t devidx;
+
        if (biosdev & 0x80) {
 #if defined(COMPAT_OLDBOOT) && defined(_STANDALONE)
                extern struct disklabel disklabel;
 
-               if(disklabel.d_magic == DISKMAGIC) {
-                       if(disklabel.d_type == DTYPE_SCSI)
-                               *devname = biosdevtab[3].name;
+               if (disklabel.d_magic == DISKMAGIC) {
+                       if (disklabel.d_type == DTYPE_SCSI)
+                               devidx = 3;
+#ifdef SUPPORT_PS2
+                       else if (disklabel.d_type == DTYPE_ESDI
+                                && biosmca_ps2model)
+                               devidx = 4;
+#endif
                        else
-                               *devname = biosdevtab[2].name;
+                               devidx = 2;
                } else
 #endif
                        /* call it "hd", we don't know better */
-                       *devname = biosdevtab[1].name;
+                       devidx = 1;
        } else
-               *devname = biosdevtab[0].name;
+               devidx = 0;
 
+       *devname = biosdevtab[devidx].name;
        *unit = biosdev & 0x7f;
 
        return (0);
diff -r be2f7c6c720b -r b8bc18ca6488 sys/arch/i386/stand/biosboot/main.c
--- a/sys/arch/i386/stand/biosboot/main.c       Sat May 19 17:53:30 2001 +0000
+++ b/sys/arch/i386/stand/biosboot/main.c       Sat May 19 18:15:14 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.24 2000/09/24 18:28:21 jdolecek Exp $       */
+/*     $NetBSD: main.c,v 1.25 2001/05/19 18:15:14 jdolecek Exp $       */
 
 /*
  * Copyright (c) 1996, 1997, 1999
@@ -47,6 +47,10 @@
 #include <libi386.h>
 #include "devopen.h"
 
+#ifdef SUPPORT_PS2
+#include <biosmca.h>
+#endif
+
 int errno;
 extern int boot_biosdev;
 
@@ -233,6 +237,10 @@
 #else
        initio(CONSDEV_PC);
 #endif
+
+#ifdef SUPPORT_PS2
+       biosmca();
+#endif
        gateA20();
 
 #ifdef RESET_VIDEO
diff -r be2f7c6c720b -r b8bc18ca6488 sys/arch/i386/stand/biosboot/version
--- a/sys/arch/i386/stand/biosboot/version      Sat May 19 17:53:30 2001 +0000
+++ b/sys/arch/i386/stand/biosboot/version      Sat May 19 18:15:14 2001 +0000
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.9 2000/09/24 12:32:35 jdolecek Exp $
+$NetBSD: version,v 1.10 2001/05/19 18:15:14 jdolecek Exp $
 
 NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE.  The format of this
 file is important - make sure the entries are appended on end, last item
@@ -15,3 +15,6 @@
 2.6:   Support ELF boot.
 2.7:   Support on-the-fly switching of console devices.
 2.8:   Support verbose/quiet boot.
+2.9:   Recognize PS/2 L40 at runtime and use appropriate gate A20
+       initialization (rather than using a compile flag).
+       Recognize ESDI disks and identify them as ed(4) for COMPAT_OLDBOOT.
diff -r be2f7c6c720b -r b8bc18ca6488 sys/arch/i386/stand/lib/exec.c
--- a/sys/arch/i386/stand/lib/exec.c    Sat May 19 17:53:30 2001 +0000
+++ b/sys/arch/i386/stand/lib/exec.c    Sat May 19 18:15:14 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exec.c,v 1.15 2000/02/22 07:45:04 dbj Exp $     */
+/*     $NetBSD: exec.c,v 1.16 2001/05/19 18:15:14 jdolecek Exp $        */
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -58,6 +58,9 @@
 #include "loadfile.h"
 #include "libi386.h"
 #include "bootinfo.h"
+#ifdef SUPPORT_PS2
+#include "biosmca.h"
+#endif
 
 #ifdef COMPAT_OLDBOOT
 static int dev2major __P((char *, int *));
@@ -67,13 +70,23 @@
        char           *devname;
        int            *major;
 {
-       static char    *devices[] = {"wd", "", "fd", "", "sd"};
-#define NUMDEVICES (sizeof(devices)/sizeof(char *))
+       static const struct {
+               const char *name;
+               int maj;
+       } devices[] = {
+               { "wd", 0  },
+               { "fd", 2  },
+               { "sd", 4  },
+#ifdef SUPPORT_PS2
+               { "ed", 20 },
+#endif
+       };
+#define NUMDEVICES (sizeof(devices)/sizeof(devices[0]))
        int             i;
 
        for (i = 0; i < NUMDEVICES; i++)
-               if (!strcmp(devname, devices[i])) {
-                       *major = i;
+               if (!strcmp(devname, devices[i].name)) {
+                       *major = devices[i].maj;
                        return (0);
                }
        return (-1);
@@ -166,10 +179,21 @@
                        /* generic BIOS disk, have to guess type */
                        struct open_file *f = &files[fd];       /* XXX */
 
-                       if (biosdisk_gettype(f) == DTYPE_SCSI)
+                       switch (biosdisk_gettype(f)) {
+                       case DTYPE_SCSI:
                                devname = "sd";
-                       else
+                               break;
+#ifdef SUPPORT_PS2
+                       case DTYPE_ESDI:
+                               if (biosmca_ps2model) {
+                                       devname = "ed";
+                                       break;
+                               }
+#endif
+                       default:
                                devname = "wd";
+                               break;
+                       }
 
                        /*
                         * The old boot block performed the following
diff -r be2f7c6c720b -r b8bc18ca6488 sys/arch/i386/stand/lib/gatea20.c
--- a/sys/arch/i386/stand/lib/gatea20.c Sat May 19 17:53:30 2001 +0000
+++ b/sys/arch/i386/stand/lib/gatea20.c Sat May 19 18:15:14 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gatea20.c,v 1.3 2000/05/11 16:11:54 jdolecek Exp $     */
+/*     $NetBSD: gatea20.c,v 1.4 2001/05/19 18:15:14 jdolecek Exp $     */
 
 /* extracted from freebsd:sys/i386/boot/biosboot/io.c */
 
@@ -8,6 +8,7 @@
 #include <lib/libsa/stand.h>
 
 #include "libi386.h"
+#include "biosmca.h"
 
 #define K_RDWR                 0x60            /* keyboard data & cmds (read/write) */
 #define K_STATUS       0x64            /* keyboard status */
@@ -27,15 +28,19 @@
 /*
  * Gate A20 for high memory
  */
-#ifndef IBM_L40
 static unsigned char   x_20 = KB_A20;
-#endif
 void gateA20()
 {
        __asm("pushfl ; cli");
-#ifdef IBM_L40
-       outb(0x92, 0x2);
-#else  /* !IBM_L40 */
+#ifdef SUPPORT_PS2
+       /*
+        * Check if the machine is PS/2 L40 via biosmca_model, which is
+        * initialized before gateA20() is called.
+        */
+       if (biosmca_ps2model == 0xf82)
+               outb(0x92, 0x2);
+       else {
+#endif
        while (inb(K_STATUS) & K_IBUF_FUL);
        while (inb(K_STATUS) & K_OBUF_FUL)
                (void)inb(K_RDWR);
@@ -46,6 +51,8 @@
        outb(K_RDWR, x_20);
        delay(100);
        while (inb(K_STATUS) & K_IBUF_FUL);
-#endif /* IBM_L40 */
+#ifdef SUPPORT_PS2
+       }
+#endif
        __asm("popfl");
 }



Home | Main Index | Thread Index | Old Index