david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

Minor refactoring to eliminate duplication.

This commit is contained in:
Michael Brown 2007-09-25 19:06:38 +01:00
parent dec325fe43
commit b8a8eea850
1 changed files with 40 additions and 50 deletions

View File

@ -162,7 +162,7 @@ pm_call:
movl %eax, %cr0 movl %eax, %cr0
/* Restore registers and flags */ /* Restore registers and flags */
lret lret /* will ljmp to 99f */
99: popw %ss 99: popw %ss
popw %ds popw %ds
popw %es popw %es
@ -298,16 +298,17 @@ alloc_basemem:
/**************************************************************************** /****************************************************************************
* install_basemem (real-mode near call) * install_basemem (real-mode near call)
* *
* Install .text16 and .data16 into base memory * Install source block into base memory
* *
* Parameters: * Parameters:
* %ax : .text16 segment address
* %bx : .data16 segment address
* %esi : source physical address (must be a multiple of 16) * %esi : source physical address (must be a multiple of 16)
* %es : destination segment address
* %cx : length of (decompressed) data
* %dx : total length of block (including any uninitialised data portion)
* Returns: * Returns:
* %esi : next source physical address (will be a multiple of 16) * %esi : next source physical address (will be a multiple of 16)
* Corrupts: * Corrupts:
* none * %edi, %ecx, %edx
**************************************************************************** ****************************************************************************
*/ */
.section ".prefix.lib" .section ".prefix.lib"
@ -315,42 +316,24 @@ alloc_basemem:
install_basemem: install_basemem:
/* Preserve registers */ /* Preserve registers */
pushw %ds pushw %ds
pushw %es
pushl %edi
pushl %ecx
pushl %edx
/* Install .text16 */ /* Preserve original %esi */
pushl %esi pushl %esi
/* Install to specified address */
shrl $4, %esi shrl $4, %esi
movw %si, %ds movw %si, %ds
xorw %si, %si xorw %si, %si
movw %ax, %es
xorl %edi, %edi xorl %edi, %edi
movl $_text16_size, %ecx movzwl %cx, %ecx
movl %ecx, %edx movzwl %dx, %edx
call install_block call install_block
popl %ecx
addl %ecx, %esi
/* Install .data16 */ /* Fix up %esi for return */
pushl %esi
shrl $4, %esi
movw %si, %ds
xorw %si, %si
movw %bx, %es
xorl %edi, %edi
movl $_data16_progbits_size, %ecx
movl $_data16_size, %edx
call install_block
popl %ecx popl %ecx
addl %ecx, %esi addl %ecx, %esi
/* Restore registers */ /* Restore registers */
popl %edx
popl %ecx
popl %edi
popw %es
popw %ds popw %ds
ret ret
.size install_basemem, . - install_basemem .size install_basemem, . - install_basemem
@ -358,15 +341,17 @@ install_basemem:
/**************************************************************************** /****************************************************************************
* install_highmem (real-mode near call) * install_highmem (real-mode near call)
* *
* Install .text and .data into high memory * Install source block into high memory
* *
* Parameters: * Parameters:
* %esi : source physical address (must be a multiple of 16) * %esi : source physical address (must be a multiple of 16)
* %edi : destination physical address * %edi : destination physical address
* %ecx : length of (decompressed) data
* %edx : total length of block (including any uninitialised data portion)
* Returns: * Returns:
* %esi : next source physical address (will be a multiple of 16) * %esi : next source physical address (will be a multiple of 16)
* Corrupts: * Corrupts:
* none * %edi, %ecx, %edx
**************************************************************************** ****************************************************************************
*/ */
@ -377,20 +362,12 @@ install_basemem:
install_highmem: install_highmem:
/* Preserve registers */ /* Preserve registers */
pushw %ax pushw %ax
pushl %edi
pushl %ecx
pushl %edx
/* Install .text and .data to specified address */ /* Install to specified address */
movl $_textdata_progbits_size, %ecx
movl $_textdata_size, %edx
movw $install_block, %ax movw $install_block, %ax
call pm_call call pm_call
/* Restore registers */ /* Restore registers */
popl %edx
popl %ecx
popl %edi
popw %ax popw %ax
ret ret
.size install_highmem, . - install_highmem .size install_highmem, . - install_highmem
@ -425,7 +402,10 @@ install:
install_prealloc: install_prealloc:
/* Save registers */ /* Save registers */
pushw %ds pushw %ds
pushw %es
pushl %esi pushl %esi
pushl %ecx
pushl %edx
/* Sanity: clear the direction flag asap */ /* Sanity: clear the direction flag asap */
cld cld
@ -436,7 +416,16 @@ install_prealloc:
shll $4, %esi shll $4, %esi
addl $_payload_offset, %esi addl $_payload_offset, %esi
/* Install .text16 and .data16 */ /* Install .text16 */
movw %ax, %es
movw $_text16_size, %cx
movw %cx, %dx
call install_basemem
/* Install .data16 */
movw %bx, %es
movw $_data16_progbits_size, %cx
movw $_data16_size, %dx
call install_basemem call install_basemem
/* Set up %ds for access to .data16 */ /* Set up %ds for access to .data16 */
@ -447,16 +436,16 @@ install_prealloc:
movw %ax, (init_libkir_vector+2) movw %ax, (init_libkir_vector+2)
lcall *init_libkir_vector lcall *init_libkir_vector
#else #else
/* Save registers */
pushl %edi
pushl %ecx
/* Install .text and .data to temporary area in high memory, /* Install .text and .data to temporary area in high memory,
* prior to reading the E820 memory map and relocating * prior to reading the E820 memory map and relocating
* properly. * properly.
*/ */
movl $HIGHMEM_LOADPOINT, %edi movl $HIGHMEM_LOADPOINT, %edi
movl $_textdata_progbits_size, %ecx
movl $_textdata_size, %edx
pushl %edi
call install_highmem call install_highmem
popl %edi
/* Initialise librm at current location */ /* Initialise librm at current location */
movw %ax, (init_librm_vector+2) movw %ax, (init_librm_vector+2)
@ -469,7 +458,7 @@ install_prealloc:
movw %ax, (prot_call_vector+2) movw %ax, (prot_call_vector+2)
pushl $relocate pushl $relocate
lcall *prot_call_vector lcall *prot_call_vector
addw $4, %sp popl %edx /* discard */
/* Copy code to new location */ /* Copy code to new location */
pushl %edi pushl %edi
@ -482,11 +471,12 @@ install_prealloc:
/* Initialise librm at new location */ /* Initialise librm at new location */
lcall *init_librm_vector lcall *init_librm_vector
/* Restore registers */
popl %ecx
popl %edi
#endif #endif
/* Restore registers */
popl %edx
popl %ecx
popl %esi popl %esi
popw %es
popw %ds popw %ds
ret ret
.size install_prealloc, . - install_prealloc .size install_prealloc, . - install_prealloc