From f0ae1d58e81d8e03010defdf4833cfec31034dc5 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 24 Apr 2010 22:22:54 +0100 Subject: [PATCH] [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 --- src/arch/i386/prefix/libprefix.S | 32 +++++++++++++++++++------------- src/arch/i386/prefix/romprefix.S | 10 ++++++---- src/arch/i386/scripts/i386.lds | 2 ++ 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/arch/i386/prefix/libprefix.S b/src/arch/i386/prefix/libprefix.S index bcf46858..f5f66919 100644 --- a/src/arch/i386/prefix/libprefix.S +++ b/src/arch/i386/prefix/libprefix.S @@ -21,16 +21,6 @@ FILE_LICENCE ( GPL2_OR_LATER ) .arch i386 -/** - * High memory temporary load address - * - * Temporary buffer into which to copy (or decompress) our runtime - * image, prior to calling get_memmap() and relocate(). We don't - * actually leave anything here once install() has returned. - */ - .globl HIGHMEM_LOADPOINT - .equ HIGHMEM_LOADPOINT, ( 1 << 20 ) - /* Image compression enabled */ #define COMPRESS 1 @@ -451,8 +441,8 @@ install: call alloc_basemem /* Image source = %cs:0000 */ xorl %esi, %esi - /* Image destination = HIGHMEM_LOADPOINT */ - movl $HIGHMEM_LOADPOINT, %edi + /* Image destination = default */ + xorl %edi, %edi /* Install text and data segments */ call install_prealloc /* Restore registers and return */ @@ -470,7 +460,7 @@ install: * %ax : .text16 segment address * %bx : .data16 segment address * %esi : Image source physical address (or zero for %cs:0000) - * %edi : Decompression temporary area physical address + * %edi : Decompression temporary area physical address (or zero for default) * Corrupts: * none **************************************************************************** @@ -550,6 +540,22 @@ a20_death_message: movw %ax, (init_libkir_vector+2) lcall *init_libkir_vector #else + /* Find a suitable decompression temporary area, if none specified */ + testl %ebp, %ebp + jnz 1f + /* Use INT 15,88 to find the highest available address via INT + * 15,88. This limits us to around 64MB, which should avoid + * all of the POST-time memory map failure modes. + */ + pushl %eax + movb $0x88, %ah + int $0x15 + movw %ax, %bp + addl $0x400, %ebp + subl $_textdata_memsz_kb, %ebp + shll $10, %ebp + popl %eax +1: /* Install .text and .data to temporary area in high memory, * prior to reading the E820 memory map and relocating * properly. diff --git a/src/arch/i386/prefix/romprefix.S b/src/arch/i386/prefix/romprefix.S index dc7c0744..80d3894c 100644 --- a/src/arch/i386/prefix/romprefix.S +++ b/src/arch/i386/prefix/romprefix.S @@ -483,9 +483,10 @@ init_message_done: .asciz "\n\n" .size init_message_done, . - init_message_done -/* ROM image location +/* Image source area * - * May be either within option ROM space, or within PMM-allocated block. + * May be either zero (indicating to use option ROM space as source), + * or within a PMM-allocated block. */ .globl image_source image_source: @@ -507,11 +508,12 @@ shrunk_rom_size: /* Temporary decompression area * - * May be either at HIGHMEM_LOADPOINT, or within PMM-allocated block. + * May be either zero (indicating to use default decompression area in + * high memory), or within a PMM-allocated block. */ .globl decompress_to decompress_to: - .long HIGHMEM_LOADPOINT + .long 0 .size decompress_to, . - decompress_to /* BBS version diff --git a/src/arch/i386/scripts/i386.lds b/src/arch/i386/scripts/i386.lds index 7c55c2f6..278a397e 100644 --- a/src/arch/i386/scripts/i386.lds +++ b/src/arch/i386/scripts/i386.lds @@ -208,4 +208,6 @@ SECTIONS { */ _text16_memsz_pgh = ( ( _text16_memsz + 15 ) / 16 ); _data16_memsz_pgh = ( ( _data16_memsz + 15 ) / 16 ); + _textdata_memsz_pgh = ( ( _textdata_memsz + 15 ) / 16 ); + _textdata_memsz_kb = ( ( _textdata_memsz + 1023 ) / 1024 ); }