blob: 1a67eafb84d4ea969eeaf6b5a166f13a25347d12 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/* $OpenBSD: memprobe.c,v 1.1 1997/03/31 03:12:14 weingart Exp $ */
#include <sys/param.h>
#include <libsa.h>
/* addrprobe(kloc): Probe memory at address kloc * 1024.
*
* This is a hack, but it seems to work ok. Maybe this is
* the *real* way that you are supposed to do probing???
*/
static int addrprobe(int kloc){
volatile int *loc, i;
static int pat[] = {
0x00000000, 0xFFFFFFFF,
0x01010101, 0x10101010,
0x55555555, 0xCCCCCCCC
};
/* Get location */
loc = (int *)(kloc * 1024);
/* Probe address */
for(i = 0; i < sizeof(pat)/sizeof(pat[0]); i++){
*loc = pat[i];
if(*loc != pat[i]) return(1);
}
return(0);
}
/* memprobe(): return probed memory size in KB for extended memory
*
* There is no need to do this in assembly language. This are
* much easier to debug in C anyways.
*/
int memprobe(void){
int ram;
for(ram = 1024; ram < 512*1024; ram += 4){
printf("Probing memory: %d KB\r", ram-1024);
if(addrprobe(ram)) break;
}
printf("\n");
return(ram-1024);
}
|