|
@@ -230,7 +230,7 @@ install_highmem:
|
230
|
230
|
* GDT for flat real mode
|
231
|
231
|
*
|
232
|
232
|
* We only ever use this GDT to set segment limits; the bases are
|
233
|
|
- * unused. Also, we only flatten data segments, so we don't need to
|
|
233
|
+ * unused. Also, we only change data segments, so we don't need to
|
234
|
234
|
* worry about the code or stack segments. This makes everything much
|
235
|
235
|
* simpler.
|
236
|
236
|
****************************************************************************
|
|
@@ -250,6 +250,11 @@ flat_ds: /* Flat real mode data segment */
|
250
|
250
|
.word 0xffff, 0
|
251
|
251
|
.byte 0, 0x93, 0xcf, 0
|
252
|
252
|
|
|
253
|
+real_ds: /* Normal real mode data segment */
|
|
254
|
+ .equ REAL_DS, real_ds - gdt
|
|
255
|
+ .word 0xffff, 0
|
|
256
|
+ .byte 0, 0x93, 0x00, 0
|
|
257
|
+
|
253
|
258
|
gdt_end:
|
254
|
259
|
.equ gdt_length, gdt_end - gdt
|
255
|
260
|
.size gdt, . - gdt
|
|
@@ -257,12 +262,12 @@ gdt_end:
|
257
|
262
|
#endif /* KEEP_IT_REAL */
|
258
|
263
|
|
259
|
264
|
/****************************************************************************
|
260
|
|
- * flatten_real_mode (real-mode near call)
|
|
265
|
+ * set_real_mode_limits (real-mode near call)
|
261
|
266
|
*
|
262
|
|
- * Sets 4GB limits on the data segments %ds and %es.
|
|
267
|
+ * Sets limits on the data segments %ds and %es.
|
263
|
268
|
*
|
264
|
|
- * Parameters:
|
265
|
|
- * none
|
|
269
|
+ * Parameters:
|
|
270
|
+ * %cx : segment type (FLAT_DS for 4GB or REAL_DS for 64kB)
|
266
|
271
|
****************************************************************************
|
267
|
272
|
*/
|
268
|
273
|
|
|
@@ -270,7 +275,7 @@ gdt_end:
|
270
|
275
|
|
271
|
276
|
.section ".prefix.lib"
|
272
|
277
|
.code16
|
273
|
|
-flatten_real_mode:
|
|
278
|
+set_real_mode_limits:
|
274
|
279
|
/* Preserve real-mode segment values and temporary registers */
|
275
|
280
|
pushw %es
|
276
|
281
|
pushw %ds
|
|
@@ -294,9 +299,8 @@ flatten_real_mode:
|
294
|
299
|
movl %eax, %cr0
|
295
|
300
|
|
296
|
301
|
/* Set flat segment limits */
|
297
|
|
- movw $FLAT_DS, %ax
|
298
|
|
- movw %ax, %ds
|
299
|
|
- movw %ax, %es
|
|
302
|
+ movw %cx, %ds
|
|
303
|
+ movw %cx, %es
|
300
|
304
|
|
301
|
305
|
/* Switch back to real mode */
|
302
|
306
|
movl %cr0, %eax
|
|
@@ -309,7 +313,7 @@ flatten_real_mode:
|
309
|
313
|
popw %ds
|
310
|
314
|
popw %es
|
311
|
315
|
ret
|
312
|
|
- .size flatten_real_mode, . - flatten_real_mode
|
|
316
|
+ .size set_real_mode_limits, . - set_real_mode_limits
|
313
|
317
|
|
314
|
318
|
#endif /* KEEP_IT_REAL */
|
315
|
319
|
|
|
@@ -369,7 +373,8 @@ install_prealloc:
|
369
|
373
|
* prior to reading the E820 memory map and relocating
|
370
|
374
|
* properly.
|
371
|
375
|
*/
|
372
|
|
- call flatten_real_mode
|
|
376
|
+ movw $FLAT_DS, %cx
|
|
377
|
+ call set_real_mode_limits
|
373
|
378
|
movl $HIGHMEM_LOADPOINT, %edi
|
374
|
379
|
call install_highmem
|
375
|
380
|
|
|
@@ -383,19 +388,16 @@ install_prealloc:
|
383
|
388
|
addw $4, %sp
|
384
|
389
|
|
385
|
390
|
/* Move code to new location, set up new protected-mode GDT */
|
386
|
|
- call flatten_real_mode
|
|
391
|
+ movw $FLAT_DS, %cx
|
|
392
|
+ call set_real_mode_limits
|
387
|
393
|
pushl %edi
|
388
|
394
|
es rep addr32 movsb
|
389
|
395
|
popl %edi
|
390
|
396
|
lcall *init_librm_vector
|
391
|
|
-
|
392
|
|
- /* Hide Etherboot from BIOS memory map. Note that making this
|
393
|
|
- * protected-mode call will also restore normal (non-flat)
|
394
|
|
- * real mode, as part of the protected-to-real transition.
|
395
|
|
- */
|
396
|
|
- pushl $hide_etherboot
|
397
|
|
- lcall *prot_call_vector
|
398
|
|
- addw $4, %sp
|
|
397
|
+
|
|
398
|
+ /* Restore real-mode segment limits */
|
|
399
|
+ movw $REAL_DS, %cx
|
|
400
|
+ call set_real_mode_limits
|
399
|
401
|
|
400
|
402
|
/* Restore registers and interrupt status */
|
401
|
403
|
popl %ecx
|