Browse Source

[prefix] Use area at top of INT 15,88 memory map for temporary decompression

Use INT 15,88 to find a suitable temporary decompression area, rather
than a fixed address.  This hopefully gives us a better chance of not
treading on any PMM-allocated areas, in BIOSes where PMM support
exists but tends not to give us the large blocks that we ask for.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
f0ae1d58e8
3 changed files with 27 additions and 17 deletions
  1. 19
    13
      src/arch/i386/prefix/libprefix.S
  2. 6
    4
      src/arch/i386/prefix/romprefix.S
  3. 2
    0
      src/arch/i386/scripts/i386.lds

+ 19
- 13
src/arch/i386/prefix/libprefix.S View File

@@ -21,16 +21,6 @@ FILE_LICENCE ( GPL2_OR_LATER )
21 21
 
22 22
 	.arch i386
23 23
 
24
-/**
25
- * High memory temporary load address
26
- *
27
- * Temporary buffer into which to copy (or decompress) our runtime
28
- * image, prior to calling get_memmap() and relocate().  We don't
29
- * actually leave anything here once install() has returned.
30
- */
31
-	.globl	HIGHMEM_LOADPOINT
32
-	.equ	HIGHMEM_LOADPOINT, ( 1 << 20 )
33
-
34 24
 /* Image compression enabled */
35 25
 #define COMPRESS 1
36 26
 
@@ -451,8 +441,8 @@ install:
451 441
 	call	alloc_basemem
452 442
 	/* Image source = %cs:0000 */
453 443
 	xorl	%esi, %esi
454
-	/* Image destination = HIGHMEM_LOADPOINT */
455
-	movl	$HIGHMEM_LOADPOINT, %edi
444
+	/* Image destination = default */
445
+	xorl	%edi, %edi
456 446
 	/* Install text and data segments */
457 447
 	call	install_prealloc
458 448
 	/* Restore registers and return */
@@ -470,7 +460,7 @@ install:
470 460
  *   %ax  : .text16 segment address
471 461
  *   %bx  : .data16 segment address
472 462
  *   %esi : Image source physical address (or zero for %cs:0000)
473
- *   %edi : Decompression temporary area physical address
463
+ *   %edi : Decompression temporary area physical address (or zero for default)
474 464
  * Corrupts:
475 465
  *   none
476 466
  ****************************************************************************
@@ -550,6 +540,22 @@ a20_death_message:
550 540
 	movw	%ax, (init_libkir_vector+2)
551 541
 	lcall	*init_libkir_vector
552 542
 #else
543
+	/* Find a suitable decompression temporary area, if none specified */
544
+	testl	%ebp, %ebp
545
+	jnz	1f
546
+	/* Use INT 15,88 to find the highest available address via INT
547
+	 * 15,88.  This limits us to around 64MB, which should avoid
548
+	 * all of the POST-time memory map failure modes.
549
+	 */
550
+	pushl	%eax
551
+	movb	$0x88, %ah
552
+	int	$0x15
553
+	movw	%ax, %bp
554
+	addl	$0x400, %ebp
555
+	subl	$_textdata_memsz_kb, %ebp
556
+	shll	$10, %ebp
557
+	popl	%eax
558
+1:
553 559
 	/* Install .text and .data to temporary area in high memory,
554 560
 	 * prior to reading the E820 memory map and relocating
555 561
 	 * properly.

+ 6
- 4
src/arch/i386/prefix/romprefix.S View File

@@ -483,9 +483,10 @@ init_message_done:
483 483
 	.asciz	"\n\n"
484 484
 	.size	init_message_done, . - init_message_done
485 485
 
486
-/* ROM image location
486
+/* Image source area
487 487
  *
488
- * May be either within option ROM space, or within PMM-allocated block.
488
+ * May be either zero (indicating to use option ROM space as source),
489
+ * or within a PMM-allocated block.
489 490
  */
490 491
 	.globl	image_source
491 492
 image_source:
@@ -507,11 +508,12 @@ shrunk_rom_size:
507 508
 
508 509
 /* Temporary decompression area
509 510
  *
510
- * May be either at HIGHMEM_LOADPOINT, or within PMM-allocated block.
511
+ * May be either zero (indicating to use default decompression area in
512
+ * high memory), or within a PMM-allocated block.
511 513
  */
512 514
 	.globl	decompress_to
513 515
 decompress_to:
514
-	.long	HIGHMEM_LOADPOINT
516
+	.long	0
515 517
 	.size	decompress_to, . - decompress_to
516 518
 
517 519
 /* BBS version

+ 2
- 0
src/arch/i386/scripts/i386.lds View File

@@ -208,4 +208,6 @@ SECTIONS {
208 208
      */
209 209
     _text16_memsz_pgh	= ( ( _text16_memsz + 15 ) / 16 );
210 210
     _data16_memsz_pgh	= ( ( _data16_memsz + 15 ) / 16 );
211
+    _textdata_memsz_pgh	= ( ( _textdata_memsz + 15 ) / 16 );
212
+    _textdata_memsz_kb	= ( ( _textdata_memsz + 1023 ) / 1024 );
211 213
 }

Loading…
Cancel
Save