Просмотр исходного кода

basememsize() updates the BIOS FBMS counter at 40:13.

tags/v0.9.3
Michael Brown 19 лет назад
Родитель
Сommit
fd95189c4d
1 измененных файлов: 16 добавлений и 7 удалений
  1. 16
    7
      src/arch/i386/firmware/pcbios/memsizes.c

+ 16
- 7
src/arch/i386/firmware/pcbios/memsizes.c Просмотреть файл

2
 #include "stddef.h"
2
 #include "stddef.h"
3
 #include "realmode.h"
3
 #include "realmode.h"
4
 #include "init.h"
4
 #include "init.h"
5
+#include "etherboot.h"
5
 #include "memsizes.h"
6
 #include "memsizes.h"
6
 
7
 
7
 #define CF ( 1 << 0 )
8
 #define CF ( 1 << 0 )
8
 
9
 
9
-#ifndef MEMSIZES_DEBUG 
10
-#define MEMSIZES_DEBUG 0
11
-#endif
12
-
13
 /* by Eric Biederman */
10
 /* by Eric Biederman */
14
 
11
 
15
 struct meminfo meminfo;
12
 struct meminfo meminfo;
19
 **************************************************************************/
16
 **************************************************************************/
20
 static unsigned short basememsize ( void ) {
17
 static unsigned short basememsize ( void ) {
21
 	uint16_t int12_basememsize, fbms_basememsize;
18
 	uint16_t int12_basememsize, fbms_basememsize;
19
+	uint16_t basememsize;
22
 
20
 
23
 	/* There are two methods for retrieving the base memory size:
21
 	/* There are two methods for retrieving the base memory size:
24
 	 * INT 12 and the BIOS FBMS counter at 40:13.  We read both
22
 	 * INT 12 and the BIOS FBMS counter at 40:13.  We read both
25
 	 * and use the smaller value, to be paranoid.
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
 	REAL_EXEC ( rm_basememsize,
33
 	REAL_EXEC ( rm_basememsize,
34
 
39
 
35
 	get_real ( fbms_basememsize, 0x40, 0x13 );
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
 		}
213
 		}
205
 	}
214
 	}
206
 
215
 
207
-#if MEMSIZES_DEBUG
216
+#ifdef DEBUG_MEMSIZES
208
 	printf ( "basememsize %d\n", meminfo.basememsize );
217
 	printf ( "basememsize %d\n", meminfo.basememsize );
209
 	printf ( "memsize %d\n",     meminfo.memsize );
218
 	printf ( "memsize %d\n",     meminfo.memsize );
210
 	printf ( "Memory regions(%d):\n", meminfo.map_count );
219
 	printf ( "Memory regions(%d):\n", meminfo.map_count );

Загрузка…
Отмена
Сохранить