summaryrefslogtreecommitdiff
path: root/sys/arch/i386/stand/libsa/memprobe.c
diff options
context:
space:
mode:
authorTobias Weingartner <weingart@cvs.openbsd.org>1998-02-24 22:06:57 +0000
committerTobias Weingartner <weingart@cvs.openbsd.org>1998-02-24 22:06:57 +0000
commit0bb9b7b7dca2172711ad9e6d3a1f6326861f5583 (patch)
tree7fc87e984297ab2cbb4798168fc77310dcb716f9 /sys/arch/i386/stand/libsa/memprobe.c
parent56d872e11254cc8a8ca03e06d9b6ae78fb8a078a (diff)
Changes/updates to /boot stuff. More to come.
Fixes many divide by zero and pointer bugs.
Diffstat (limited to 'sys/arch/i386/stand/libsa/memprobe.c')
-rw-r--r--sys/arch/i386/stand/libsa/memprobe.c42
1 files changed, 37 insertions, 5 deletions
diff --git a/sys/arch/i386/stand/libsa/memprobe.c b/sys/arch/i386/stand/libsa/memprobe.c
index 984b19f1efb..1deadbe9616 100644
--- a/sys/arch/i386/stand/libsa/memprobe.c
+++ b/sys/arch/i386/stand/libsa/memprobe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: memprobe.c,v 1.25 1997/11/30 21:51:47 mickey Exp $ */
+/* $OpenBSD: memprobe.c,v 1.26 1998/02/24 22:06:56 weingart Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner, Michael Shalayeff
@@ -37,10 +37,33 @@
#include <stand/boot/bootarg.h>
#include "libsa.h"
-static int addrprobe __P((u_int));
u_int cnvmem, extmem; /* XXX - compatibility */
bios_memmap_t *memory_map;
+
+/* Check gateA20
+ *
+ * A sanity check.
+ */
+static __inline int
+checkA20(void)
+{
+ char *p = (char *)0x100000;
+ char *q = (char *)0x000000;
+ int st;
+
+ /* Simple check */
+ if(*p != *q)
+ return(1);
+
+ /* Complex check */
+ *p = ~(*p);
+ st = (*p != *q);
+ *p = ~(*p);
+
+ return(st);
+}
+
/* BIOS int 15, AX=E820
*
* This is the "prefered" method.
@@ -283,14 +306,23 @@ memprobe()
/* XXX - Compatibility, remove later */
extmem = cnvmem = 0;
for(im = bm; im->type != BIOS_MAP_END; im++) {
- if (im->type == BIOS_MAP_FREE) {
+ /* Count only "good" memory chunks 4K an up in size */
+ if ((im->type == BIOS_MAP_FREE) && (im->size >= 4)) {
printf(" %luK", (u_long)im->size);
- if(im->addr < 0x100000)
+ /* We ignore "good" memory in the 640K-1M hole */
+ if(im->addr < 0xA0000)
cnvmem += im->size;
- else
+ if(im->addr >= 0x100000)
extmem += im->size;
}
}
+
+ /* Check if gate A20 is on */
+ if(checkA20())
+ printf(" [A20 on]");
+ else
+ printf(" [A20 off!]");
+
printf("\n");
}