|
iPXE
|
Initial ramdisk (initrd) reshuffling. More...
#include <string.h>#include <errno.h>#include <ipxe/image.h>#include <ipxe/uaccess.h>#include <ipxe/init.h>#include <ipxe/cpio.h>#include <ipxe/uheap.h>#include <ipxe/initrd.h>Go to the source code of this file.
Functions | |
| FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
| static void | initrd_squash_high (physaddr_t start, physaddr_t end) |
| Squash initrds as high as possible in memory. More... | |
| static void | initrd_reverse (void *data, size_t len) |
| Reverse aligned memory region. More... | |
| static void | initrd_swap (struct image *low, struct image *high) |
| Swap position of two adjacent initrds. More... | |
| static int | initrd_swap_any (physaddr_t start, physaddr_t end) |
| Swap position of any two adjacent initrds not currently in the correct order. More... | |
| static void | initrd_dump (void) |
| Dump initrd locations (for debug) More... | |
| void | initrd_reshuffle (void) |
| Reshuffle initrds into desired order at top of memory. More... | |
| static size_t | initrd_load (struct image *initrd, void *address) |
| Load initrd. More... | |
| size_t | initrd_load_all (void *address) |
| Load all initrds. More... | |
| int | initrd_region (size_t len, struct memmap_region *region) |
| Calculate post-reshuffle initrd load region. More... | |
| static void | initrd_startup (void) |
| initrd startup function More... | |
| struct startup_fn startup_initrd | __startup_fn (STARTUP_LATE) |
| initrd startup function More... | |
Variables | |
| static physaddr_t | initrd_end |
| End of reshuffle region. More... | |
Initial ramdisk (initrd) reshuffling.
Definition in file initrd.c.
| FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Squash initrds as high as possible in memory.
| start | Start of reshuffle region |
| end | End of reshuffle region |
Definition at line 50 of file initrd.c.
References data, image::data, DBGC, end, for_each_image, images, initrd_align(), image::len, memmove(), image::name, NULL, and start.
Referenced by initrd_reshuffle().
|
static |
Swap position of two adjacent initrds.
| low | Lower initrd |
| high | Higher initrd |
Definition at line 118 of file initrd.c.
References assert(), data, DBGC, high, images, initrd_align(), initrd_reverse(), len, and low.
Referenced by initrd_swap_any().
|
static |
Swap position of any two adjacent initrds not currently in the correct order.
| start | Start of reshuffle region |
| end | End of reshuffle region |
| swapped | A pair of initrds was swapped |
Definition at line 155 of file initrd.c.
References addr, end, for_each_image, high, initrd_align(), initrd_swap(), low, and start.
Referenced by initrd_reshuffle().
|
static |
Dump initrd locations (for debug)
Definition at line 203 of file initrd.c.
References image::data, DBG_LOG, DBGC, DBGC2_MD5A, for_each_image, images, image::len, and image::name.
Referenced by initrd_reshuffle().
| void initrd_reshuffle | ( | void | ) |
Reshuffle initrds into desired order at top of memory.
After this function returns, the initrds have been rearranged in memory and the external heap structures will have been corrupted. Reshuffling must therefore take place immediately prior to jumping to the loaded OS kernel; no further execution within iPXE is permitted.
Definition at line 229 of file initrd.c.
References end, initrd_dump(), initrd_end, initrd_squash_high(), initrd_swap_any(), start, uheap_end, and uheap_limit.
Referenced by bzimage_load_initrds(), and lkrn_exec().
Load initrd.
| initrd | initrd image |
| address | Address at which to load, or NULL |
| len | Length of loaded image, excluding zero-padding |
Definition at line 257 of file initrd.c.
References address, assert(), cpio_header(), cpio_name(), cpio_pad_len(), image::data, DBGC, DBGC2_MD5A, image::flags, IMAGE_HIDDEN, images, INITRD_ALIGN, image::len, len, memcpy(), memmove(), memset(), image::name, NULL, and offset.
Referenced by initrd_load_all().
| size_t initrd_load_all | ( | void * | address | ) |
Load all initrds.
| address | Load address, or NULL |
| len | Length |
This function is called after the point of no return, when the external heap has been corrupted by reshuffling and there is no way to resume normal execution. The caller must have previously ensured that there is no way for installation to this address to fail.
Definition at line 317 of file initrd.c.
References address, assert(), dest, for_each_image, INITRD_ALIGN, initrd_align(), initrd_load(), len, memset(), NULL, and pad_len.
Referenced by bzimage_load_initrds(), initrd_len(), and lkrn_exec().
| int initrd_region | ( | size_t | len, |
| struct memmap_region * | region | ||
| ) |
Calculate post-reshuffle initrd load region.
| len | Length of initrds (from initrd_len()) |
| region | Region descriptor to fill in |
| rc | Return status code |
If successful, then any suitably aligned range within the region may be used as the load address after reshuffling. The caller does not need to call prep_segment() for a range in this region. (Calling prep_segment() would probably fail, since prior to reshuffling the region is still in use by the external heap.)
Definition at line 354 of file initrd.c.
References DBGC, ENOSPC, memmap_region::flags, images, initrd_end, len, memmap_region::max, MEMMAP_FL_MEMORY, min, memmap_region::min, memmap_region::name, uheap_end, and uheap_limit.
Referenced by bzimage_check_initrds(), and lkrn_exec().
|
static |
initrd startup function
Definition at line 379 of file initrd.c.
References DBGC, images, initrd_end, and uheap_start.
| struct startup_fn startup_initrd __startup_fn | ( | STARTUP_LATE | ) |
initrd startup function
|
static |
End of reshuffle region.
Definition at line 42 of file initrd.c.
Referenced by comboot_fetch_kernel(), initrd_region(), initrd_reshuffle(), and initrd_startup().
1.8.15