Relocate iPXE.
- Parameters
-
ebp | Maximum address to use for relocation |
- Return values
-
esi | Current physical address |
edi | New physical address |
ecx | Length to copy |
This finds a suitable location for iPXE near the top of 32-bit address space, and returns the physical address of the new location to the prefix in edi.
Definition at line 43 of file relocate.c.
56 DBG (
"Relocate: currently at [%x,%x)\n" 57 "...need %x bytes for %d-byte alignment\n",
64 DBG (
"Limiting relocation to [0,%x)\n",
max );
71 for ( i = 0 ; i < memmap.count ; i++ ) {
75 DBG (
"Considering [%llx,%llx)\n", region->
start, region->
end);
82 DBG (
"...starts after max=%x\n",
max );
85 r_start = region->
start;
87 DBG (
"...end truncated to max=%x\n",
max );
92 DBG (
"...usable portion is [%x,%x)\n", r_start, r_end );
97 if ( r_end < r_start ) {
98 DBG (
"...truncated to negative size\n" );
103 if ( ( r_end - r_start ) <
size ) {
104 DBG (
"...too small (need %x bytes)\n",
size );
116 if ( ( r_end -
size ) > new_end ) {
118 DBG (
"...new best block found.\n" );
125 new_start = new_end - padded_size;
126 new_start += ( (
start - new_start ) & (
ALIGN - 1 ) );
127 new_end = new_start +
size;
129 DBG (
"Relocating from [%x,%x) to [%x,%x)\n",
void get_memmap(struct memory_map *memmap)
Get memory map.
uint8_t size
Entry size (in 32-bit words)
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
uint32_t start
Starting offset.
uint64_t start
Physical start address.
uint32_t end
Ending offset.
#define DBG(...)
Print a debugging message.
uint64_t end
Physical end address.
References _etextdata, _textdata, ALIGN, memory_map::count, DBG, i386_regs::ebp, i386_regs::ecx, i386_regs::edi, end, memory_region::end, i386_regs::esi, get_memmap(), max, MAX_ADDR, memory_map::regions, i386_all_regs::regs, size, start, memory_region::start, and virt_to_phys().