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 44 of file relocate.c.
49 size_t size, padded_size;
60 DBGC ( ®ion,
"Relocate: currently at [%#08lx,%#08lx)\n" 61 "...need %#zx bytes for %d-byte alignment\n",
68 DBGC ( ®ion,
"Limiting relocation to [0,%#08lx)\n",
max );
84 if ( region.min >
max ) {
85 DBGC ( ®ion,
"...starts after max=%#08lx\n",
max );
90 DBGC ( ®ion,
"...not usable\n" );
94 if ( ( r_end == 0 ) || ( r_end >
max ) ) {
95 DBGC ( ®ion,
"...end truncated to max=%#08lx\n",
99 DBGC ( ®ion,
"...usable portion is [%#08lx,%#08lx)\n",
103 if ( ( r_end - r_start ) < padded_size ) {
104 DBGC ( ®ion,
"...too small (need %#zx bytes)\n",
111 DBGC ( ®ion,
"...new best block found.\n" );
117 new_start = new_end - padded_size;
118 new_start += ( (
start - new_start ) & (
ALIGN - 1 ) );
119 new_end = new_start +
size;
121 DBGC ( ®ion,
"Relocating from [%#08lx,%#08lx) to [%#08lx,%#08lx)\n",
static int memmap_is_usable(const struct memmap_region *region)
Check if memory region is usable.
uint16_t size
Buffer size.
uint32_t start
Starting offset.
static void memmap_dump_all(int hide)
Dump system memory map (for debugging)
#define for_each_memmap_from(region, start, hide)
Iterate over memory regions from a given starting address.
static uint64_t memmap_size(const struct memmap_region *region)
Get remaining size of memory region (from the described address upwards)
uint32_t end
Ending offset.
A memory region descriptor.
References _etextdata, _textdata, ALIGN, DBGC, DBGC_MEMMAP, i386_regs::ebp, i386_regs::ecx, i386_regs::edi, end, i386_regs::esi, for_each_memmap_from, max, MAX_ADDR, memmap_dump_all(), memmap_is_usable(), memmap_size(), memmap_region::min, i386_all_regs::regs, size, and start.