Browse Source

Added more verbose memory-map debugging.

Added redundant call to get_memmap() in int13_boot() immediately
before jumping to boot sector, to assist in debugging.
tags/v0.9.3
Michael Brown 17 years ago
parent
commit
a7eee64506
2 changed files with 43 additions and 11 deletions
  1. 34
    11
      src/arch/i386/firmware/pcbios/memmap.c
  2. 9
    0
      src/arch/i386/interface/pcbios/int13.c

+ 34
- 11
src/arch/i386/firmware/pcbios/memmap.c View File

@@ -74,16 +74,19 @@ static unsigned int extmemsize_e801 ( void ) {
74 74
 				 "=d" ( confmem_16m_plus_64k )
75 75
 			       : "a" ( 0xe801 ) );
76 76
 
77
-	if ( flags & CF )
77
+	if ( flags & CF ) {
78
+		DBG ( "INT 15,e801 failed with CF set\n" );
78 79
 		return 0;
80
+	}
79 81
 
80 82
 	if ( ! ( extmem_1m_to_16m_k | extmem_16m_plus_64k ) ) {
83
+		DBG ( "INT 15,e801 extmem=0, using confmem\n" );
81 84
 		extmem_1m_to_16m_k = confmem_1m_to_16m_k;
82 85
 		extmem_16m_plus_64k = confmem_16m_plus_64k;
83 86
 	}
84 87
 
85 88
 	extmem = ( extmem_1m_to_16m_k + ( extmem_16m_plus_64k * 64 ) );
86
-	DBG ( "Extended memory size %d+64*%d=%d kB\n",
89
+	DBG ( "INT 15,e801 extended memory size %d+64*%d=%d kB\n",
87 90
 	      extmem_1m_to_16m_k, extmem_16m_plus_64k, extmem );
88 91
 	return extmem;
89 92
 }
@@ -100,7 +103,7 @@ static unsigned int extmemsize_88 ( void ) {
100 103
 	__asm__ __volatile__ ( REAL_CODE ( "int $0x15" )
101 104
 			       : "=a" ( extmem ) : "a" ( 0x8800 ) );
102 105
 
103
-	DBG ( "Extended memory size %d kB\n", extmem );
106
+	DBG ( "INT 15,88 extended memory size %d kB\n", extmem );
104 107
 	return extmem;
105 108
 }
106 109
 
@@ -149,14 +152,19 @@ static int meme820 ( struct memory_map *memmap ) {
149 152
 					 "d" ( SMAP )
150 153
 				       : "memory" );
151 154
 
152
-		if ( smap != SMAP )
155
+		if ( smap != SMAP ) {
156
+			DBG ( "INT 15,e820 failed SMAP signature check\n" );
153 157
 			return -ENOTSUP;
158
+		}
154 159
 
155
-		if ( flags & CF )
160
+		if ( flags & CF ) {
161
+			DBG ( "INT 15,e820 terminated on CF set\n" );
156 162
 			break;
163
+		}
157 164
 
158
-		DBG ( "E820 region [%llx,%llx) type %d\n", e820buf.start,
159
-		      ( e820buf.start + e820buf.len ), ( int ) e820buf.type );
165
+		DBG ( "INT 15,e820 region [%llx,%llx) type %d\n",
166
+		      e820buf.start, ( e820buf.start + e820buf.len ),
167
+		      ( int ) e820buf.type );
160 168
 		if ( e820buf.type != E820_TYPE_RAM )
161 169
 			continue;
162 170
 
@@ -164,9 +172,18 @@ static int meme820 ( struct memory_map *memmap ) {
164 172
 		region->end = e820buf.start + e820buf.len;
165 173
 		region++;
166 174
 		memmap->count++;
167
-	} while ( ( next != 0 ) && 
168
-		  ( memmap->count < ( sizeof ( memmap->regions ) /
169
-				      sizeof ( memmap->regions[0] ) ) ) );
175
+
176
+		if ( memmap->count >= ( sizeof ( memmap->regions ) /
177
+					sizeof ( memmap->regions[0] ) ) ) {
178
+			DBG ( "INT 15,e820 too many regions returned\n" );
179
+			/* Not a fatal error; what we've got so far at
180
+			 * least represents valid regions of memory,
181
+			 * even if we couldn't get them all.
182
+			 */
183
+			break;
184
+		}
185
+	} while ( next != 0 );
186
+
170 187
 	return 0;
171 188
 }
172 189
 
@@ -179,18 +196,24 @@ void get_memmap ( struct memory_map *memmap ) {
179 196
 	unsigned int basemem, extmem;
180 197
 	int rc;
181 198
 
199
+	DBG ( "Fetching system memory map\n" );
200
+
182 201
 	/* Clear memory map */
183 202
 	memset ( memmap, 0, sizeof ( *memmap ) );
184 203
 
185 204
 	/* Get base and extended memory sizes */
186 205
 	basemem = basememsize();
206
+	DBG ( "FBMS base memory size %d kB\n", basemem );
187 207
 	extmem = extmemsize();
188 208
 	
189 209
 	/* Try INT 15,e820 first */
190
-	if ( ( rc = meme820 ( memmap ) ) == 0 )
210
+	if ( ( rc = meme820 ( memmap ) ) == 0 ) {
211
+		DBG ( "Obtained system memory map via INT 15,e820\n" );
191 212
 		return;
213
+	}
192 214
 
193 215
 	/* Fall back to constructing a map from basemem and extmem sizes */
216
+	DBG ( "INT 15,e820 failed; constructing map\n" );
194 217
 	memmap->regions[0].end = ( basemem * 1024 );
195 218
 	memmap->regions[1].start = 0x100000;
196 219
 	memmap->regions[1].end = 0x100000 + ( extmem * 1024 );

+ 9
- 0
src/arch/i386/interface/pcbios/int13.c View File

@@ -23,6 +23,7 @@
23 23
 #include <assert.h>
24 24
 #include <gpxe/list.h>
25 25
 #include <gpxe/blockdev.h>
26
+#include <gpxe/memmap.h>
26 27
 #include <realmode.h>
27 28
 #include <bios.h>
28 29
 #include <biosint.h>
@@ -601,6 +602,7 @@ void unregister_int13_drive ( struct int13_drive *drive ) {
601 602
  * Note that this function can never return success, by definition.
602 603
  */
603 604
 int int13_boot ( unsigned int drive ) {
605
+	struct memory_map memmap;
604 606
 	int status, signature;
605 607
 	int discard_c, discard_d;
606 608
 	int rc;
@@ -634,6 +636,13 @@ int int13_boot ( unsigned int drive ) {
634 636
 		return -ENOEXEC;
635 637
 	}
636 638
 
639
+	/* Dump out memory map prior to boot, if memmap debugging is
640
+	 * enabled.  Not required for program flow, but we have so
641
+	 * many problems that turn out to be memory-map related that
642
+	 * it's worth doing.
643
+	 */
644
+	get_memmap ( &memmap );
645
+
637 646
 	/* Jump to boot sector */
638 647
 	if ( ( rc = call_bootsector ( 0x0, 0x7c00, drive ) ) != 0 ) {
639 648
 		DBG ( "INT 13 drive %02x boot returned\n", drive );

Loading…
Cancel
Save