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

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

21
 
21
 
22
 	.arch i386
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
 /* Image compression enabled */
24
 /* Image compression enabled */
35
 #define COMPRESS 1
25
 #define COMPRESS 1
36
 
26
 
451
 	call	alloc_basemem
441
 	call	alloc_basemem
452
 	/* Image source = %cs:0000 */
442
 	/* Image source = %cs:0000 */
453
 	xorl	%esi, %esi
443
 	xorl	%esi, %esi
454
-	/* Image destination = HIGHMEM_LOADPOINT */
455
-	movl	$HIGHMEM_LOADPOINT, %edi
444
+	/* Image destination = default */
445
+	xorl	%edi, %edi
456
 	/* Install text and data segments */
446
 	/* Install text and data segments */
457
 	call	install_prealloc
447
 	call	install_prealloc
458
 	/* Restore registers and return */
448
 	/* Restore registers and return */
470
  *   %ax  : .text16 segment address
460
  *   %ax  : .text16 segment address
471
  *   %bx  : .data16 segment address
461
  *   %bx  : .data16 segment address
472
  *   %esi : Image source physical address (or zero for %cs:0000)
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
  * Corrupts:
464
  * Corrupts:
475
  *   none
465
  *   none
476
  ****************************************************************************
466
  ****************************************************************************
550
 	movw	%ax, (init_libkir_vector+2)
540
 	movw	%ax, (init_libkir_vector+2)
551
 	lcall	*init_libkir_vector
541
 	lcall	*init_libkir_vector
552
 #else
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
 	/* Install .text and .data to temporary area in high memory,
559
 	/* Install .text and .data to temporary area in high memory,
554
 	 * prior to reading the E820 memory map and relocating
560
 	 * prior to reading the E820 memory map and relocating
555
 	 * properly.
561
 	 * properly.

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

483
 	.asciz	"\n\n"
483
 	.asciz	"\n\n"
484
 	.size	init_message_done, . - init_message_done
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
 	.globl	image_source
491
 	.globl	image_source
491
 image_source:
492
 image_source:
507
 
508
 
508
 /* Temporary decompression area
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
 	.globl	decompress_to
514
 	.globl	decompress_to
513
 decompress_to:
515
 decompress_to:
514
-	.long	HIGHMEM_LOADPOINT
516
+	.long	0
515
 	.size	decompress_to, . - decompress_to
517
 	.size	decompress_to, . - decompress_to
516
 
518
 
517
 /* BBS version
519
 /* BBS version

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

208
      */
208
      */
209
     _text16_memsz_pgh	= ( ( _text16_memsz + 15 ) / 16 );
209
     _text16_memsz_pgh	= ( ( _text16_memsz + 15 ) / 16 );
210
     _data16_memsz_pgh	= ( ( _data16_memsz + 15 ) / 16 );
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