* Install block to specified address
*
* 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
* %ecx : length of (decompressed) data
* %edx : total length of block (including any uninitialised data portion)
* Returns:
- * none
+ * %esi : end offset within image (rounded up to next multiple of 16)
* Corrupts:
- * %esi, %edi, %ecx, %edx
+ * %edi, %ecx, %edx
****************************************************************************
*/
.section ".prefix.lib"
/* Preserve registers */
pushw %ds
pushl %eax
+ pushl %ebx
+ movl %esi, %ebx
/* Starting segment => %ds */
movw %cs, %ax
xorb %al, %al
rep addr32 stosb
+ /* Adjust %esi */
+ addl %ebx, %esi
+ addl $0xf, %esi
+ andl $~0xf, %esi
+
/* Restore registers */
+ popl %ebx
popl %eax
popw %ds
ret
* Parameters:
* %ax : .text16 segment address
* %bx : .data16 segment address
+ * %esi : start offset within loaded image (must be a multiple of 16)
* Returns:
- * none
+ * %esi : end offset within image (rounded up to next multiple of 16)
* Corrupts:
* none
****************************************************************************
install_basemem:
/* Preserve registers */
pushw %es
- pushl %esi
pushl %edi
pushl %ecx
pushl %edx
/* Install .text16 */
movw %ax, %es
xorl %edi, %edi
- movl $_text16_load_offset, %esi
movl $_text16_size, %ecx
movl %ecx, %edx
call install_block
/* Install .data16 */
movw %bx, %es
xorl %edi, %edi
- movl $_data16_load_offset, %esi
movl $_data16_progbits_size, %ecx
movl $_data16_size, %edx
call install_block
popl %edx
popl %ecx
popl %edi
- popl %esi
popw %es
ret
.size install_basemem, . - install_basemem
* Install .text and .data into high memory
*
* Parameters:
+ * %esi : start offset within loaded image (must be a multiple of 16)
* %es:edi : address in high memory
* Returns:
- * none
+ * %esi : end offset within image (rounded up to next multiple of 16)
* Corrupts:
* none
****************************************************************************
.code16
install_highmem:
/* Preserve registers */
- pushl %esi
pushl %edi
pushl %ecx
pushl %edx
/* Install .text and .data to specified address */
- movl $_textdata_load_offset, %esi
movl $_textdata_progbits_size, %ecx
movl $_textdata_size, %edx
call install_block
popl %edx
popl %ecx
popl %edi
- popl %esi
ret
.size install_highmem, . - install_highmem
.size install, . - install
.globl install_prealloc
install_prealloc:
+ /* Save registers */
+ pushl %esi
/* Install .text16 and .data16 */
+ movl $_payload_offset, %esi
call install_basemem
#ifdef KEEP_IT_REAL
pushfw
pushw %ds
pushw %es
- pushl %esi
pushl %ecx
cli
/* Load up %ds and %es, and set up vectors for far calls to .text16 */
movw %bx, %ds
- xorw %si, %si
- movw %si, %es
+ xorw %cx, %cx
+ movw %cx, %es
movw %ax, (init_librm_vector+2)
movw %ax, (prot_call_vector+2)
/* Restore registers and interrupt status */
popl %ecx
- popl %esi
popw %es
popw %ds
popfw
#endif
+ popl %esi
ret
.size install_prealloc, . - install_prealloc