mirror of https://github.com/ipxe/ipxe.git
Use a single _payload_offset linker-defined variable to locate the
start of the non-prefix blocks in the loaded image, and rely on the image ordering. This should make introducing compression much easier.pull/1/head
parent
aa729d2d10
commit
ab859a5355
|
@ -49,14 +49,14 @@
|
||||||
* Install block to specified address
|
* Install block to specified address
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* %esi : byte offset within loaded image (must be a multiple of 16)
|
* %esi : start offset within loaded image (must be a multiple of 16)
|
||||||
* %es:edi : destination address
|
* %es:edi : destination address
|
||||||
* %ecx : length of (decompressed) data
|
* %ecx : length of (decompressed) data
|
||||||
* %edx : total length of block (including any uninitialised data portion)
|
* %edx : total length of block (including any uninitialised data portion)
|
||||||
* Returns:
|
* Returns:
|
||||||
* none
|
* %esi : end offset within image (rounded up to next multiple of 16)
|
||||||
* Corrupts:
|
* Corrupts:
|
||||||
* %esi, %edi, %ecx, %edx
|
* %edi, %ecx, %edx
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
*/
|
*/
|
||||||
.section ".prefix.lib"
|
.section ".prefix.lib"
|
||||||
|
@ -65,6 +65,8 @@ install_block:
|
||||||
/* Preserve registers */
|
/* Preserve registers */
|
||||||
pushw %ds
|
pushw %ds
|
||||||
pushl %eax
|
pushl %eax
|
||||||
|
pushl %ebx
|
||||||
|
movl %esi, %ebx
|
||||||
|
|
||||||
/* Starting segment => %ds */
|
/* Starting segment => %ds */
|
||||||
movw %cs, %ax
|
movw %cs, %ax
|
||||||
|
@ -87,7 +89,13 @@ install_block:
|
||||||
xorb %al, %al
|
xorb %al, %al
|
||||||
rep addr32 stosb
|
rep addr32 stosb
|
||||||
|
|
||||||
|
/* Adjust %esi */
|
||||||
|
addl %ebx, %esi
|
||||||
|
addl $0xf, %esi
|
||||||
|
andl $~0xf, %esi
|
||||||
|
|
||||||
/* Restore registers */
|
/* Restore registers */
|
||||||
|
popl %ebx
|
||||||
popl %eax
|
popl %eax
|
||||||
popw %ds
|
popw %ds
|
||||||
ret
|
ret
|
||||||
|
@ -144,8 +152,9 @@ alloc_basemem:
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* %ax : .text16 segment address
|
* %ax : .text16 segment address
|
||||||
* %bx : .data16 segment address
|
* %bx : .data16 segment address
|
||||||
|
* %esi : start offset within loaded image (must be a multiple of 16)
|
||||||
* Returns:
|
* Returns:
|
||||||
* none
|
* %esi : end offset within image (rounded up to next multiple of 16)
|
||||||
* Corrupts:
|
* Corrupts:
|
||||||
* none
|
* none
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
|
@ -155,7 +164,6 @@ alloc_basemem:
|
||||||
install_basemem:
|
install_basemem:
|
||||||
/* Preserve registers */
|
/* Preserve registers */
|
||||||
pushw %es
|
pushw %es
|
||||||
pushl %esi
|
|
||||||
pushl %edi
|
pushl %edi
|
||||||
pushl %ecx
|
pushl %ecx
|
||||||
pushl %edx
|
pushl %edx
|
||||||
|
@ -163,7 +171,6 @@ install_basemem:
|
||||||
/* Install .text16 */
|
/* Install .text16 */
|
||||||
movw %ax, %es
|
movw %ax, %es
|
||||||
xorl %edi, %edi
|
xorl %edi, %edi
|
||||||
movl $_text16_load_offset, %esi
|
|
||||||
movl $_text16_size, %ecx
|
movl $_text16_size, %ecx
|
||||||
movl %ecx, %edx
|
movl %ecx, %edx
|
||||||
call install_block
|
call install_block
|
||||||
|
@ -171,7 +178,6 @@ install_basemem:
|
||||||
/* Install .data16 */
|
/* Install .data16 */
|
||||||
movw %bx, %es
|
movw %bx, %es
|
||||||
xorl %edi, %edi
|
xorl %edi, %edi
|
||||||
movl $_data16_load_offset, %esi
|
|
||||||
movl $_data16_progbits_size, %ecx
|
movl $_data16_progbits_size, %ecx
|
||||||
movl $_data16_size, %edx
|
movl $_data16_size, %edx
|
||||||
call install_block
|
call install_block
|
||||||
|
@ -180,7 +186,6 @@ install_basemem:
|
||||||
popl %edx
|
popl %edx
|
||||||
popl %ecx
|
popl %ecx
|
||||||
popl %edi
|
popl %edi
|
||||||
popl %esi
|
|
||||||
popw %es
|
popw %es
|
||||||
ret
|
ret
|
||||||
.size install_basemem, . - install_basemem
|
.size install_basemem, . - install_basemem
|
||||||
|
@ -191,9 +196,10 @@ install_basemem:
|
||||||
* Install .text and .data into high memory
|
* Install .text and .data into high memory
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
|
* %esi : start offset within loaded image (must be a multiple of 16)
|
||||||
* %es:edi : address in high memory
|
* %es:edi : address in high memory
|
||||||
* Returns:
|
* Returns:
|
||||||
* none
|
* %esi : end offset within image (rounded up to next multiple of 16)
|
||||||
* Corrupts:
|
* Corrupts:
|
||||||
* none
|
* none
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
|
@ -205,13 +211,11 @@ install_basemem:
|
||||||
.code16
|
.code16
|
||||||
install_highmem:
|
install_highmem:
|
||||||
/* Preserve registers */
|
/* Preserve registers */
|
||||||
pushl %esi
|
|
||||||
pushl %edi
|
pushl %edi
|
||||||
pushl %ecx
|
pushl %ecx
|
||||||
pushl %edx
|
pushl %edx
|
||||||
|
|
||||||
/* Install .text and .data to specified address */
|
/* Install .text and .data to specified address */
|
||||||
movl $_textdata_load_offset, %esi
|
|
||||||
movl $_textdata_progbits_size, %ecx
|
movl $_textdata_progbits_size, %ecx
|
||||||
movl $_textdata_size, %edx
|
movl $_textdata_size, %edx
|
||||||
call install_block
|
call install_block
|
||||||
|
@ -220,7 +224,6 @@ install_highmem:
|
||||||
popl %edx
|
popl %edx
|
||||||
popl %ecx
|
popl %ecx
|
||||||
popl %edi
|
popl %edi
|
||||||
popl %esi
|
|
||||||
ret
|
ret
|
||||||
.size install_highmem, . - install_highmem
|
.size install_highmem, . - install_highmem
|
||||||
|
|
||||||
|
@ -343,7 +346,10 @@ install:
|
||||||
.size install, . - install
|
.size install, . - install
|
||||||
.globl install_prealloc
|
.globl install_prealloc
|
||||||
install_prealloc:
|
install_prealloc:
|
||||||
|
/* Save registers */
|
||||||
|
pushl %esi
|
||||||
/* Install .text16 and .data16 */
|
/* Install .text16 and .data16 */
|
||||||
|
movl $_payload_offset, %esi
|
||||||
call install_basemem
|
call install_basemem
|
||||||
|
|
||||||
#ifdef KEEP_IT_REAL
|
#ifdef KEEP_IT_REAL
|
||||||
|
@ -358,14 +364,13 @@ install_prealloc:
|
||||||
pushfw
|
pushfw
|
||||||
pushw %ds
|
pushw %ds
|
||||||
pushw %es
|
pushw %es
|
||||||
pushl %esi
|
|
||||||
pushl %ecx
|
pushl %ecx
|
||||||
cli
|
cli
|
||||||
|
|
||||||
/* Load up %ds and %es, and set up vectors for far calls to .text16 */
|
/* Load up %ds and %es, and set up vectors for far calls to .text16 */
|
||||||
movw %bx, %ds
|
movw %bx, %ds
|
||||||
xorw %si, %si
|
xorw %cx, %cx
|
||||||
movw %si, %es
|
movw %cx, %es
|
||||||
movw %ax, (init_librm_vector+2)
|
movw %ax, (init_librm_vector+2)
|
||||||
movw %ax, (prot_call_vector+2)
|
movw %ax, (prot_call_vector+2)
|
||||||
|
|
||||||
|
@ -401,11 +406,11 @@ install_prealloc:
|
||||||
|
|
||||||
/* Restore registers and interrupt status */
|
/* Restore registers and interrupt status */
|
||||||
popl %ecx
|
popl %ecx
|
||||||
popl %esi
|
|
||||||
popw %es
|
popw %es
|
||||||
popw %ds
|
popw %ds
|
||||||
popfw
|
popfw
|
||||||
#endif
|
#endif
|
||||||
|
popl %esi
|
||||||
ret
|
ret
|
||||||
.size install_prealloc, . - install_prealloc
|
.size install_prealloc, . - install_prealloc
|
||||||
|
|
||||||
|
|
|
@ -215,6 +215,8 @@ SECTIONS {
|
||||||
|
|
||||||
_load_size = . - _load_addr;
|
_load_size = . - _load_addr;
|
||||||
|
|
||||||
|
_payload_offset = _text16_load_offset;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Alignment checks. ALIGN() can only operate on the location
|
* Alignment checks. ALIGN() can only operate on the location
|
||||||
* counter, so we set the location counter to each value we want
|
* counter, so we set the location counter to each value we want
|
||||||
|
|
Loading…
Reference in New Issue