blob: a50cac42932e5a4dfe1b1a8d7ec83e3ba5b27e7a (
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
51
52
53
54
55
56
57
|
/* $OpenBSD: memprobe.c,v 1.2 1997/03/31 23:06:30 mickey Exp $ */
#include <sys/param.h>
#include "libsa.h"
#include "biosdev.h"
static int addrprobe __P((int));
void
memprobe()
{
int ram;
cnvmem = biosmem(0);
extmem = biosmem(1);
/* probe extended memory
*
* There is no need to do this in assembly language. This are
* much easier to debug in C anyways.
*/
for(ram = 1024; ram < 512*1024; ram += 4){
printf("Probing memory: %d KB\r", ram-1024);
if(addrprobe(ram)) break;
}
printf("\n");
extmem = ram - 1024;
}
/* 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);
}
|