|
@@ -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 );
|