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.
44 {
49 size_t size, padded_size;
50
51
53
54
59
60 DBGC ( ®ion,
"Relocate: currently at [%#08lx,%#08lx)\n"
61 "...need %#zx bytes for %d-byte alignment\n",
63
64
68 DBGC ( ®ion,
"Limiting relocation to [0,%#08lx)\n",
max );
69 }
70
71
72
73
74
77
78
79
80
81
82
84 if ( region.min >
max ) {
85 DBGC ( ®ion,
"...starts after max=%#08lx\n",
max );
86 break;
87 }
88 r_start = region.min;
90 DBGC ( ®ion,
"...not usable\n" );
91 continue;
92 }
94 if ( ( r_end == 0 ) || ( r_end >
max ) ) {
95 DBGC ( ®ion,
"...end truncated to max=%#08lx\n",
98 }
99 DBGC ( ®ion,
"...usable portion is [%#08lx,%#08lx)\n",
100 r_start, r_end );
101
102
103 if ( ( r_end - r_start ) < padded_size ) {
104 DBGC ( ®ion,
"...too small (need %#zx bytes)\n",
105 padded_size );
106 continue;
107 }
108
109
110 new_end = r_end;
111 DBGC ( ®ion,
"...new best block found.\n" );
112 }
113
114
115
116
117 new_start = new_end - padded_size;
118 new_start += ( (
start - new_start ) & (
ALIGN - 1 ) );
119 new_end = new_start +
size;
120
121 DBGC ( ®ion,
"Relocating from [%#08lx,%#08lx) to [%#08lx,%#08lx)\n",
123
124
128}
uint32_t start
Starting offset.
uint16_t size
Buffer size.
#define for_each_memmap_from(region, start, hide)
Iterate over memory regions from a given starting address.
static int memmap_is_usable(const struct memmap_region *region)
Check if memory region is usable.
static uint64_t memmap_size(const struct memmap_region *region)
Get remaining size of memory region (from the described address upwards)
static void memmap_dump_all(int hide)
Dump system memory map (for debugging)
uint32_t end
Ending offset.
A memory region descriptor.
References __asmcall, _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.