Browse Source

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

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

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

128
  * possible.
128
  * possible.
129
  */
129
  */
130
 void unhide_etherboot ( void ) {
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
 	unhook_bios_interrupt ( 0x15, ( unsigned int ) int15,
147
 	unhook_bios_interrupt ( 0x15, ( unsigned int ) int15,
132
 				&int15_vector );
148
 				&int15_vector );
133
 }
149
 }

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

230
  * GDT for flat real mode
230
  * GDT for flat real mode
231
  *
231
  *
232
  * We only ever use this GDT to set segment limits; the bases are
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
  * worry about the code or stack segments.  This makes everything much
234
  * worry about the code or stack segments.  This makes everything much
235
  * simpler.
235
  * simpler.
236
  ****************************************************************************
236
  ****************************************************************************
250
 	.word	0xffff, 0
250
 	.word	0xffff, 0
251
 	.byte	0, 0x93, 0xcf, 0
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
 gdt_end:
258
 gdt_end:
254
 	.equ	gdt_length, gdt_end - gdt
259
 	.equ	gdt_length, gdt_end - gdt
255
 	.size gdt, . - gdt
260
 	.size gdt, . - gdt
257
 #endif /* KEEP_IT_REAL */
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
 	
275
 	
271
 	.section ".prefix.lib"
276
 	.section ".prefix.lib"
272
 	.code16
277
 	.code16
273
-flatten_real_mode:
278
+set_real_mode_limits:
274
 	/* Preserve real-mode segment values and temporary registers */
279
 	/* Preserve real-mode segment values and temporary registers */
275
 	pushw	%es
280
 	pushw	%es
276
 	pushw	%ds
281
 	pushw	%ds
294
 	movl	%eax, %cr0
299
 	movl	%eax, %cr0
295
 
300
 
296
 	/* Set flat segment limits */
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
 	/* Switch back to real mode */
305
 	/* Switch back to real mode */
302
 	movl	%cr0, %eax
306
 	movl	%cr0, %eax
309
 	popw	%ds
313
 	popw	%ds
310
 	popw	%es
314
 	popw	%es
311
 	ret
315
 	ret
312
-	.size flatten_real_mode, . - flatten_real_mode
316
+	.size set_real_mode_limits, . - set_real_mode_limits
313
 	
317
 	
314
 #endif /* KEEP_IT_REAL */
318
 #endif /* KEEP_IT_REAL */
315
 	
319
 	
369
 	 * prior to reading the E820 memory map and relocating
373
 	 * prior to reading the E820 memory map and relocating
370
 	 * properly.
374
 	 * properly.
371
 	 */
375
 	 */
372
-	call	flatten_real_mode
376
+	movw	$FLAT_DS, %cx
377
+	call	set_real_mode_limits
373
 	movl	$HIGHMEM_LOADPOINT, %edi
378
 	movl	$HIGHMEM_LOADPOINT, %edi
374
 	call	install_highmem
379
 	call	install_highmem
375
 
380
 
383
 	addw	$4, %sp
388
 	addw	$4, %sp
384
 
389
 
385
 	/* Move code to new location, set up new protected-mode GDT */
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
 	pushl	%edi
393
 	pushl	%edi
388
 	es rep addr32 movsb
394
 	es rep addr32 movsb
389
 	popl	%edi
395
 	popl	%edi
390
 	lcall	*init_librm_vector
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
 	/* Restore registers and interrupt status */
402
 	/* Restore registers and interrupt status */
401
 	popl	%ecx
403
 	popl	%ecx

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

20
 #include <gpxe/shell.h>
20
 #include <gpxe/shell.h>
21
 #include <gpxe/shell_banner.h>
21
 #include <gpxe/shell_banner.h>
22
 #include <gpxe/shutdown.h>
22
 #include <gpxe/shutdown.h>
23
+#include <gpxe/hidemem.h>
23
 #include <usr/autoboot.h>
24
 #include <usr/autoboot.h>
24
 
25
 
25
 /**
26
 /**
28
  * Call this function only once, before doing (almost) anything else.
29
  * Call this function only once, before doing (almost) anything else.
29
  */
30
  */
30
 static void startup ( void ) {
31
 static void startup ( void ) {
32
+	hide_etherboot();
31
 	init_heap();
33
 	init_heap();
32
-	call_init_fns ();
34
+	call_init_fns();
33
 	probe_devices();
35
 	probe_devices();
34
 }
36
 }
35
 
37
 
41
  */
43
  */
42
 void shutdown ( void ) {
44
 void shutdown ( void ) {
43
 	remove_devices();
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
 	EXTMEM,
17
 	EXTMEM,
18
 };
18
 };
19
 
19
 
20
+extern void hide_etherboot();
21
+extern void unhide_etherboot();
20
 extern void hide_region ( unsigned int region_id, physaddr_t start,
22
 extern void hide_region ( unsigned int region_id, physaddr_t start,
21
 			  physaddr_t end );
23
 			  physaddr_t end );
22
 
24
 

Loading…
Cancel
Save