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

Re: x86 /boot diff (please test)



Hi Tobias,

What exactly are these problems you describe? I installed an Intel
SCB2-based server this weekend and OpenBSD 3.0 only detects between 123 and
127 megs of the 256 megs installed as usable (it sees all 256 as present
though)... is this patch related? If so, should I (as Theo suggested in his
follow-up mail) go for the snapshot that includes this patch - I'm looking
to get this box into production by the end of the week, even if it is still
not detecting all the memory.

I've scanned the various list archives, the GNATS page and Google to no
avail - the only mention if this board is related to dual processor support
(we only have one processor for that very reason) and SCSI support (we have
the IDE version). There's also mention of the "stray interrupt 7" problem on
a FreeBSD list, we get this too, but can live with it. The only hardware
that seems unsupported is one of the ServerWorks items, which I guess is the
DMI stuff (we don't care too much about that). Aside from the memory
detection issues, this is one great server to run OpenBSD on - so far it's
been stable and very fast.

Michael

-----Original Message-----
From: Tobias Weingartner [mailto:weingart_(_at_)_natasha_(_dot_)_tepid_(_dot_)_org]
Sent: Monday, June 17, 2002 11:43 PM
To: tech_(_at_)_openbsd_(_dot_)_org
Subject: x86 /boot diff (please test)


This is the first diff for a cleanup of /boot memory detection on x86
machines.  Please test this diff, and let me know if there are any
changes.  Things should work the same as before, or better.  If there
are any regressions, please let me know ASAP.  Otherwise this will
miss the next release again.


Thank you,

--Toby.

Index: libsa/Makefile
===================================================================
RCS file: /cvs/src/sys/arch/i386/stand/libsa/Makefile,v
retrieving revision 1.38
diff -u -r1.38 Makefile
--- libsa/Makefile	25 Oct 2000 17:12:07 -0000	1.38
+++ libsa/Makefile	9 Jun 2002 18:33:43 -0000
@@ -17,12 +17,12 @@
 CLEANFILES+=	gidt.o debug_i386.o alloca.o \
 	biosdev.o bioscons.o gateA20.o apmprobe.o \
 	memprobe.o diskprobe.o smpprobe.o \
-	time.o
+	time.o biosprobe.o
 .else
 SRCS+=	gidt.S debug_i386.S alloca.S \
 	biosdev.c bioscons.c gateA20.c apmprobe.c \
 	memprobe.c diskprobe.c pciprobe.c smpprobe.c \
-	time.c
+	time.c biosprobe.c
 CLEANFILES+=	unixdev.o unixsys.o nullfs.o
 .endif
 
Index: libsa/apmprobe.c
===================================================================
RCS file: /cvs/src/sys/arch/i386/stand/libsa/apmprobe.c,v
retrieving revision 1.8
diff -u -r1.8 apmprobe.c
--- libsa/apmprobe.c	29 Jan 2000 21:49:36 -0000	1.8
+++ libsa/apmprobe.c	9 Jun 2002 18:33:43 -0000
@@ -186,12 +186,13 @@
 }
 
 void
-apmcheck()
+apmfixmem(void)
 {
 #ifdef DEBUG
-	printf("apm");
+	printf("apmremove (%d)", ai.apm_detail);
 #endif
-	mem_delete(i386_trunc_page(ai.apm_data_base),
-		   i386_round_page(ai.apm_data_base + ai.apm_data_len));
+	if (ai.apm_detail)
+		mem_delete(i386_trunc_page(ai.apm_data_base),
+			i386_round_page(ai.apm_data_base +
ai.apm_data_len));
 }
 
Index: libsa/biosprobe.c
===================================================================
RCS file: libsa/biosprobe.c
diff -N libsa/biosprobe.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libsa/biosprobe.c	9 Jun 2002 18:33:43 -0000
@@ -0,0 +1,83 @@
+/*	$OpenBSD$	*/
+
+/*
+ * Copyright (c) 2002 Tobias Weingartner
+ * 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 Tobias Weingartner.
+ * 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 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/cons.h>
+#include <lib/libsa/stand.h>
+#include "debug.h"
+
+
+void *
+getSYSCONFaddr()
+{
+ 	u_int32_t status;
+	u_int8_t *vers;
+
+ 	__asm __volatile(DOINT(0x15) "\n\t"
+			"setc %%al\n\t"
+			: "=a" (status)
+			: "0" (0xC000)
+			: "%ebx", "%ecx", "%edx", "%esi", "%edi", "cc");
+
+	/* On failure we go for a NULL */
+	if(status)
+		return(NULL);
+
+	/* Calculate where the version bytes are */
+	vers = (void*)((BIOS_regs.biosr_es << 4) | BIOS_regs.biosr_bx);
+	return(vers);
+}
+
+void *
+getEBDAaddr()
+{
+	u_int32_t status;
+	u_int8_t *info;
+
+	info = getSYSCONFaddr();
+	if(!info) return(NULL);
+
+	__asm __volatile(DOINT(0x15) "\n\t"
+			"setc %%al"
+			: "=a" (status)
+			: "0" (0xC100)
+			: "%ebx", "%ecx", "%edx", "%esi", "%edi", "cc");
+
+	if(status) return(NULL);
+
+	info = (void *)(BIOS_regs.biosr_es << 4);
+
+	return(info);
+}
+
Index: libsa/libsa.h
===================================================================
RCS file: /cvs/src/sys/arch/i386/stand/libsa/libsa.h,v
retrieving revision 1.34
diff -u -r1.34 libsa.h
--- libsa/libsa.h	14 Mar 2002 01:26:34 -0000	1.34
+++ libsa/libsa.h	9 Jun 2002 18:33:43 -0000
@@ -45,7 +45,7 @@
 void memprobe(void);
 void diskprobe(void);
 void apmprobe(void);
-void apmcheck(void);
+void apmfixmem(void);
 void dump_biosmem(bios_memmap_t *);
 int mem_add(long, long);
 int mem_delete(long, long);
@@ -53,6 +53,9 @@
 
 void devboot(dev_t, char *);
 void machdep(void);
+
+void *getSYSCONFaddr(void);
+void *getEBDAaddr(void);
 
 extern const char bdevs[][4];
 extern const int nbdevs;
Index: libsa/memprobe.c
===================================================================
RCS file: /cvs/src/sys/arch/i386/stand/libsa/memprobe.c,v
retrieving revision 1.36
diff -u -r1.36 memprobe.c
--- libsa/memprobe.c	3 May 2002 13:58:11 -0000	1.36
+++ libsa/memprobe.c	9 Jun 2002 18:33:43 -0000
@@ -2,7 +2,7 @@
 
 /*
  * Copyright (c) 1997-1999 Michael Shalayeff
- * Copyright (c) 1997 Tobias Weingartner
+ * Copyright (c) 1997-1999 Tobias Weingartner
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -73,7 +73,9 @@
 bios_E820(mp)
 	register bios_memmap_t *mp;
 {
+	void *info;
 	int rc, off = 0, sig, gotcha = 0;
+	info = getEBDAaddr();
 
 	do {
 		BIOS_regs.biosr_es = ((u_int)(mp) >> 4);
@@ -100,29 +102,46 @@
 	return (mp);
 }
 
-/* XXX Disabled until it is shown it is needed, and a version that does not
- * confuse the AT&T Globalyst 580 comes up.  Ask niklas_(_at_)_openbsd_(_dot_)_org if you
- * want to know details.
- */
 #if 0
 /* BIOS int 15, AX=E801
  *
  * Only used if int 15, AX=E820 does not work.
- * This should work for more than 64MB.
+ * This should work for more than 64MB on most
+ * modern machines.  However, there is always
+ * an exception, the older IBM machine do not
+ * like this call.
  */
 static __inline bios_memmap_t *
 bios_E801(mp)
 	register bios_memmap_t *mp;
 {
-	int rc, m1, m2;
+	int rc, m1, m2, m3, m4;
+	u_int8_t *info;
 
-	/* Test for 0xE801 */
-	__asm __volatile(DOINT(0x15) "; setc %b1"
-		: "=a" (m1), "=b" (m2), "=c" (rc) : "0" (0xE801));
+	/* Test for possibility of 0xE801 */
+	info =  getSYSCONFaddr();
+	if(!info) return(NULL);
+	/* XXX - Should test model/submodel/rev here */
+	printf("model(%d,%d,%d)", info[2], info[3], info[4]);
+
+	/* Check for 94 or later bios */
+	info = (void *)0xFFFFB;
+	if(info[0] == '9' && info[1] <= '3') return(NULL);
+
+	/* We might have this call */
+	__asm __volatile(DOINT(0x15) "; mov %%ax, %%si; setc %b0"
+		: "=a" (rc), "=S" (m1), "=b" (m2), "=c" (m3), "=d" (m4)
+		: "0" (0xE801));
 
-	/* Make a memory map from info */
+	/* Test for failure */
 	if(rc & 0xff)
 		return (NULL);
+
+	/* Fixup for screwed up machines */
+	if(m1 == 0){
+		m1 = m3;
+		m2 = m4;
+	}
 #ifdef DEBUG
 	printf("0x15[E801] ");
 #endif
@@ -306,11 +325,12 @@
 			pm = im;
 		}
 	}
-
 	pm->type = BIOS_MAP_END;
-	/* gotta peephole optimize the list */
 
-	apmcheck();
+	/* XXX - gotta peephole optimize the list */
+
+	/* Remove APM needed RAM */
+	apmfixmem();
 
 #ifdef DEBUG
 	printf(")[");
@@ -359,9 +379,14 @@
 	if (!tm)
 		tm = bios_memmap;
 
+	/* libsa printf does not handle quad args, so we use long
+	 * instead.  Note, since we're unlikely to support more than
+	 * 4G of RAM on a x86 box, this not likely to cause a problem.
+	 * If/when we do, libsa may need to be updated some...
+	 */
 	for(p = tm; p->type != BIOS_MAP_END; p++) {
 		printf("Region %ld: type %u at 0x%x for %uKB\n", 
-		    (long)(p - tm), p->type, (u_int)p->addr, 
+		    (long)(p - tm), p->type, (u_int)p->addr,
 		    (u_int)(p->size / 1024));
 
 		if(p->type == BIOS_MAP_FREE)
@@ -380,7 +405,7 @@
 
 	for (p = bios_memmap; p->type != BIOS_MAP_END; p++) {
 		if (p->type == BIOS_MAP_FREE) {
-			register int32_t sp = p->addr, ep = p->addr +
p->size;
+			register int64_t sp = p->addr, ep = p->addr +
p->size;
 
 			/* can we eat it as a whole? */
 			if ((sa - sp) <= NBPG && (ep - ea) <= NBPG) {
@@ -418,7 +443,7 @@
 
 	for (p = bios_memmap; p->type != BIOS_MAP_END; p++) {
 		if (p->type == BIOS_MAP_FREE) {
-			register int32_t sp = p->addr, ep = p->addr +
p->size;
+			register int64_t sp = p->addr, ep = p->addr +
p->size;
 
 			/* is it already there? */
 			if (sp <= sa && ea <= ep) {


*******************************************************************************************
<http://www.intec-telecom-systems.com/>

This e-mail and any attachments are confidential and may also be privileged
and/or copyright material of Independent Technology Systems Limited
(or its affiliated companies). If you are not the intended or authorised recipient 
of this email or have received it in error, please delete it immediately and 
notify the sender by e-mail. In such a case reading, reproducing, printing or 
further dissemination of this e-mail is strictly prohibited and may be unlawful.

Independent Technology Systems Limited does not represent or warrant that 
an attachment hereto is free from computer viruses or other defects.

The opinions expressed in this e-mail and any of the attachments may 
be those of the author and are not necessarily those of Independent 
Technology Systems Limited.
******************************************************************************************