|
@@ -2,14 +2,11 @@
|
2
|
2
|
#include "stddef.h"
|
3
|
3
|
#include "realmode.h"
|
4
|
4
|
#include "init.h"
|
|
5
|
+#include "etherboot.h"
|
5
|
6
|
#include "memsizes.h"
|
6
|
7
|
|
7
|
8
|
#define CF ( 1 << 0 )
|
8
|
9
|
|
9
|
|
-#ifndef MEMSIZES_DEBUG
|
10
|
|
-#define MEMSIZES_DEBUG 0
|
11
|
|
-#endif
|
12
|
|
-
|
13
|
10
|
/* by Eric Biederman */
|
14
|
11
|
|
15
|
12
|
struct meminfo meminfo;
|
|
@@ -19,10 +16,18 @@ BASEMEMSIZE - Get size of the conventional (base) memory
|
19
|
16
|
**************************************************************************/
|
20
|
17
|
static unsigned short basememsize ( void ) {
|
21
|
18
|
uint16_t int12_basememsize, fbms_basememsize;
|
|
19
|
+ uint16_t basememsize;
|
22
|
20
|
|
23
|
21
|
/* There are two methods for retrieving the base memory size:
|
24
|
22
|
* INT 12 and the BIOS FBMS counter at 40:13. We read both
|
25
|
23
|
* and use the smaller value, to be paranoid.
|
|
24
|
+ *
|
|
25
|
+ * We then store the smaller value in the BIOS FBMS counter so
|
|
26
|
+ * that other code (e.g. basemem.c) can rely on it and not
|
|
27
|
+ * have to use INT 12. This is especially important because
|
|
28
|
+ * basemem.c functions can be called in a context in which
|
|
29
|
+ * there is no real-mode stack (e.g. when trying to allocate
|
|
30
|
+ * memory for a real-mode stack...)
|
26
|
31
|
*/
|
27
|
32
|
|
28
|
33
|
REAL_EXEC ( rm_basememsize,
|
|
@@ -34,8 +39,12 @@ static unsigned short basememsize ( void ) {
|
34
|
39
|
|
35
|
40
|
get_real ( fbms_basememsize, 0x40, 0x13 );
|
36
|
41
|
|
37
|
|
- return ( int12_basememsize < fbms_basememsize ?
|
38
|
|
- int12_basememsize : fbms_basememsize );
|
|
42
|
+ basememsize = ( int12_basememsize < fbms_basememsize ?
|
|
43
|
+ int12_basememsize : fbms_basememsize );
|
|
44
|
+
|
|
45
|
+ put_real ( basememsize, 0x40, 0x13 );
|
|
46
|
+
|
|
47
|
+ return basememsize;
|
39
|
48
|
}
|
40
|
49
|
|
41
|
50
|
/**************************************************************************
|
|
@@ -204,7 +213,7 @@ void get_memsizes ( void ) {
|
204
|
213
|
}
|
205
|
214
|
}
|
206
|
215
|
|
207
|
|
-#if MEMSIZES_DEBUG
|
|
216
|
+#ifdef DEBUG_MEMSIZES
|
208
|
217
|
printf ( "basememsize %d\n", meminfo.basememsize );
|
209
|
218
|
printf ( "memsize %d\n", meminfo.memsize );
|
210
|
219
|
printf ( "Memory regions(%d):\n", meminfo.map_count );
|