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 ); }