summaryrefslogtreecommitdiff
path: root/sys/arch/i386
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>1997-10-12 21:01:02 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>1997-10-12 21:01:02 +0000
commit345757705da17aafac67f3c66fb9ea2ff7eb60e8 (patch)
treed876e31865e29f72cadd4d81805147c9bcc562d1 /sys/arch/i386
parent08eacca3df59e33e7e2f6e64e9b847cfb12441a4 (diff)
safe memprobe; preserve memory contents
Diffstat (limited to 'sys/arch/i386')
-rw-r--r--sys/arch/i386/stand/libsa/memprobe.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/sys/arch/i386/stand/libsa/memprobe.c b/sys/arch/i386/stand/libsa/memprobe.c
index bb3d5856d8f..180d742f4dc 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.13 1997/10/12 20:14:27 mickey Exp $ */
+/* $OpenBSD: memprobe.c,v 1.14 1997/10/12 21:01:01 mickey Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -82,33 +82,43 @@ static int
addrprobe(kloc)
u_int kloc;
{
- __volatile u_int *loc, i;
+ __volatile u_int *loc;
static const u_int pat[] = {
0x00000000, 0xFFFFFFFF,
0x01010101, 0x10101010,
0x55555555, 0xCCCCCCCC
};
+ register u_int i, ret = 0;
+ u_int save[NENTS(pat)];
/* Get location */
loc = (int *)(kloc * 1024);
+ save[0] = *loc;
/* Probe address */
for(i = 0; i < NENTS(pat); i++){
*loc = pat[i];
if(*loc != pat[i])
- return (1);
+ ret++;
+ }
+ *loc = save[0];
+
+ if (!ret) {
+ /* Write address */
+ for(i = 0; i < NENTS(pat); i++) {
+ save[i] = loc[i];
+ loc[i] = pat[i];
+ }
+
+ /* Read address */
+ for(i = 0; i < NENTS(pat); i++) {
+ if(loc[i] != pat[i])
+ ret++;
+ loc[i] = save[i];
+ }
}
- /* Write address */
- for(i = 0; i < NENTS(pat); i++)
- loc[i] = pat[i];
-
- /* Read address */
- for(i = 0; i < NENTS(pat); i++)
- if(loc[i] != pat[i])
- return (1);
-
- return (0);
+ return ret;
}