xref: /original-bsd/sys/i386/stand/mem.c (revision e59fb703)
1 /*-
2  * Copyright (c) 1990 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * William Jolitz.
7  *
8  * %sccs.include.noredist.c%
9  *
10  *	@(#)mem.c	7.1 (Berkeley) 04/24/90
11  */
12 
13 /*
14  * Scan physical memory and talley, bypassing AT devices/roms
15  */
16 #define	CHK	4096
17 main() {
18 	long base;
19 	register long val;
20 
21 	base = 0;
22 	do {
23 		printf("0x%X - ", base);
24 		for ( ;; base+= CHK) {
25 			if (base >= 0xa0000 && base <= 0xe0000) break;
26 			if (base >= 0xfffff000) break;
27 			val = *((long *) base);
28 			*((long *) base) = base*4 + 0x55555555;
29 			if (*((long *) base) != base*4 + 0x55555555) {
30 				*((long *) base) = val ;
31 				break;
32 			}
33 			*((long *) base) = val ;
34 		}
35 		printf("0x%X\n", base-CHK) ;
36 		for ( ;; base+= CHK) {
37 			if (base >= 0xa0000 && base <= 0xe0000) continue ;
38 			if (base >= 0xfffff000) break;
39 			val = *((long *) base);
40 			*((long *) base) = base*4 + 0x55555555;
41 			if (*((long *) base) == base*4 + 0x55555555) {
42 				*((long *) base) = val ;
43 				break;
44 			}
45 		}
46 	} while (base < 0xfffff000);
47 	printf("finished\n");
48 	getchar();
49 }
50