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 another memory size detection routin...



details:   https://anonhg.NetBSD.org/src/rev/dcabceb5cab3
branches:  trunk
changeset: 542208:dcabceb5cab3
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Thu Jan 23 21:22:24 2003 +0000

description:
add another memory size detection routine, using int15, function 0xc7, which
is supported on later IBM PS/2 models; this is necessary to detect memory
over 64MB
thanks go to Pavel Cahyna for testing on his IBM PS/2 machine with 128MB

bump biosboot version to 2.15

diffstat:

 sys/arch/i386/stand/biosboot/version |    6 +-
 sys/arch/i386/stand/lib/Makefile     |    4 +-
 sys/arch/i386/stand/lib/biosmemps2.S |  103 +++++++++++++++++++++++++++++++++++
 sys/arch/i386/stand/lib/getextmemx.c |   22 +++++++-
 4 files changed, 131 insertions(+), 4 deletions(-)

diffs (190 lines):

diff -r 0954d38a5ac7 -r dcabceb5cab3 sys/arch/i386/stand/biosboot/version
--- a/sys/arch/i386/stand/biosboot/version      Thu Jan 23 21:17:15 2003 +0000
+++ b/sys/arch/i386/stand/biosboot/version      Thu Jan 23 21:22:24 2003 +0000
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.14 2002/12/04 18:26:56 jdolecek Exp $
+$NetBSD: version,v 1.15 2003/01/23 21:22:24 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
@@ -22,3 +22,7 @@
 2.11:  loadfile() update:  ELF symbols no longer need backward seeks.
 2.12:  loadfile() update to avoid backwards seeks for ELF Program Headers.
 2.13:  Support boot from 1.44MB floppies in 2.88MB floppy drives.
+2.14:  Add a quirk for BIOSes which report extended memory size
+       in slightly nonstandard way in int15, function 0xE801
+2.15:  Use int15/0xc7 to get memory information on machines which support
+       it, like later IBM PS/2 machines
diff -r 0954d38a5ac7 -r dcabceb5cab3 sys/arch/i386/stand/lib/Makefile
--- a/sys/arch/i386/stand/lib/Makefile  Thu Jan 23 21:17:15 2003 +0000
+++ b/sys/arch/i386/stand/lib/Makefile  Thu Jan 23 21:22:24 2003 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.20 2001/12/12 01:49:44 tv Exp $
+#      $NetBSD: Makefile,v 1.21 2003/01/23 21:22:25 jdolecek Exp $
 
 S?=    ${.CURDIR}/../../../../
 
@@ -35,7 +35,7 @@
 SRCS+= biospci.c bios_pci.S isapnp.c isadma.c
 .endif
 .if (${I386_INCLUDE_PS2} == "yes")
-SRCS+= biosmca.S
+SRCS+= biosmca.S biosmemps2.S
 .endif
 
 .include <bsd.own.mk>
diff -r 0954d38a5ac7 -r dcabceb5cab3 sys/arch/i386/stand/lib/biosmemps2.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/stand/lib/biosmemps2.S      Thu Jan 23 21:22:24 2003 +0000
@@ -0,0 +1,103 @@
+/*     $NetBSD: biosmemps2.S,v 1.1 2003/01/23 21:22:25 jdolecek Exp $  */
+
+/*-
+ * Copyright (c) 2003 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jaromir Dolecek.
+ *
+ * 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 the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION 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        addr32  .byte 0x67
+#define        data32  .byte 0x66
+
+       .text
+
+/* int getextmemp2(void buffer)
+   call int 15 function 0xc7 - later PS/2s - RETURN MEMORY-MAP INFORMATION
+   return: 0=OK, nonzero=error
+   buffer: filled with memory-map table structure
+*/
+ENTRY(getextmemps2)
+       pushl   %ebp
+       movl    %esp,%ebp
+       pushl   %ebx
+       pushl   %ecx
+       pushl   %edx
+       push    %esi
+       push    %edi
+
+       movl    8(%ebp), %edx   # parameter
+
+       call    _C_LABEL(prot_to_real)
+
+       # do int15, function 0xc0 call to discover if C7h is supported
+       movb    $0xc0, %ah
+       int     $0x15
+       setc    %bl
+       jc      out             # 0xc0 not supported if carry set
+
+       # check feature byte 2, bit 4 to see if return memory map is supported
+       addr32
+       movb    %es:6(%ebx), %al
+       andb    $0x10, %al
+       jnz     getmem          # 0xc7 supported
+       
+       # set %bl to indicate failure, and exit
+       movb    $2, %bl
+       jmp     out
+
+getmem:
+       # move the parameter to right register
+       data32
+       movl    %edx, %esi
+
+       # actually call int15, function 0xc7 now
+       movb    $0xc7, %ah
+       int     $0x15
+       setc    %bl             # save carry
+
+out:
+       data32
+       call    _C_LABEL(real_to_prot)
+
+       xorl    %eax, %eax
+       movb    %bl, %al        # return value in %ax
+
+       pop     %edi
+       pop     %esi
+       popl    %edx
+       popl    %ecx
+       popl    %ebx
+       popl    %ebp
+       ret
diff -r 0954d38a5ac7 -r dcabceb5cab3 sys/arch/i386/stand/lib/getextmemx.c
--- a/sys/arch/i386/stand/lib/getextmemx.c      Thu Jan 23 21:17:15 2003 +0000
+++ b/sys/arch/i386/stand/lib/getextmemx.c      Thu Jan 23 21:22:24 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: getextmemx.c,v 1.2 1999/03/08 21:38:28 drochner Exp $  */
+/*     $NetBSD: getextmemx.c,v 1.3 2003/01/23 21:22:25 jdolecek Exp $  */
 
 /*
  * Copyright (c) 1997, 1999
@@ -43,12 +43,21 @@
 
 extern int getextmem2 __P((int *));
 extern int getmementry __P((int *, int *));
+extern int getextmemps2 __P((void *));
 
 int
 getextmemx()
 {
        int buf[5], i;
        int extmem = getextmem1();
+#ifdef SUPPORT_PS2
+       struct {
+               uint16_t len;
+               uint32_t dta[8];
+               /* pad to 64 bytes - without this, machine would reset */
+               uint8_t __pad[30];
+       } __attribute__((__packed__)) bufps2;
+#endif
 
        if (!getextmem2(buf) && buf[0] <= 15 * 1024) {
                int help = buf[0];
@@ -67,5 +76,16 @@
                        extmem = buf[2] / 1024;
        } while (i);
 
+#ifdef SUPPORT_PS2
+       /* use local memory information from RETURN MEMORY-MAP INFORMATION */
+       if (!getextmemps2((void *) &bufps2)) {
+               int help = bufps2.dta[0];
+               if (help == 15 * 1024)
+                       help += bufps2.dta[1];
+               if (extmem < help)
+                       extmem = help;
+       }
+#endif
+
        return (extmem);
 }



Home | Main Index | Thread Index | Old Index