Browse Source

Call hide_etherboot() from startup(), rather than requiring the prefix to

do it.
tags/v0.9.3
Michael Brown 17 years ago
parent
commit
dca369ddc3

+ 16
- 0
src/arch/i386/firmware/pcbios/hidemem.c View File

@@ -128,6 +128,22 @@ void hide_etherboot ( void ) {
128 128
  * possible.
129 129
  */
130 130
 void unhide_etherboot ( void ) {
131
+
132
+	/* If we have more than one hooked interrupt at this point, it
133
+	 * means that some other vector is still hooked, in which case
134
+	 * we can't safely unhook INT 15 because we need to keep our
135
+	 * memory protected.  (We expect there to be at least one
136
+	 * hooked interrupt, because INT 15 itself is still hooked).
137
+	 */
138
+	if ( hooked_bios_interrupts > 1 ) {
139
+		DBG ( "Cannot unhide: %d interrupt vectors still hooked\n",
140
+		      hooked_bios_interrupts );
141
+		return;
142
+	}
143
+
144
+	/* Try to unhook INT 15.  If it fails, then just leave it
145
+	 * hooked; it takes care of protecting itself.  :)
146
+	 */
131 147
 	unhook_bios_interrupt ( 0x15, ( unsigned int ) int15,
132 148
 				&int15_vector );
133 149
 }

+ 22
- 20
src/arch/i386/prefix/libprefix.S View File

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

+ 5
- 2
src/core/main.c View File

@@ -20,6 +20,7 @@ Literature dealing with the network protocols:
20 20
 #include <gpxe/shell.h>
21 21
 #include <gpxe/shell_banner.h>
22 22
 #include <gpxe/shutdown.h>
23
+#include <gpxe/hidemem.h>
23 24
 #include <usr/autoboot.h>
24 25
 
25 26
 /**
@@ -28,8 +29,9 @@ Literature dealing with the network protocols:
28 29
  * Call this function only once, before doing (almost) anything else.
29 30
  */
30 31
 static void startup ( void ) {
32
+	hide_etherboot();
31 33
 	init_heap();
32
-	call_init_fns ();
34
+	call_init_fns();
33 35
 	probe_devices();
34 36
 }
35 37
 
@@ -41,7 +43,8 @@ static void startup ( void ) {
41 43
  */
42 44
 void shutdown ( void ) {
43 45
 	remove_devices();
44
-	call_exit_fns ();
46
+	call_exit_fns();
47
+	unhide_etherboot();
45 48
 }
46 49
 
47 50
 /**

+ 2
- 0
src/include/gpxe/hidemem.h View File

@@ -17,6 +17,8 @@ enum hidemem_region_id {
17 17
 	EXTMEM,
18 18
 };
19 19
 
20
+extern void hide_etherboot();
21
+extern void unhide_etherboot();
20 22
 extern void hide_region ( unsigned int region_id, physaddr_t start,
21 23
 			  physaddr_t end );
22 24
 

Loading…
Cancel
Save