53 struct image *highest;
62 if ( ( virt_to_phys ( initrd->
data ) >=
start ) &&
63 ( virt_to_phys ( initrd->
data ) < current ) &&
64 ( ( highest ==
NULL ) ||
65 ( virt_to_phys ( initrd->
data ) >
66 virt_to_phys ( highest->
data ) ) ) ) {
75 if ( current <= virt_to_phys ( highest->
data ) ) {
77 current = virt_to_phys ( highest->
data );
82 DBGC ( &
images,
"INITRD squashing %s [%#08lx,%#08lx)->" 83 "[%#08lx,%#08lx)\n", highest->
name,
84 virt_to_phys ( highest->
data ),
85 ( virt_to_phys ( highest->
data ) + highest->
len ),
86 current, ( current + highest->
len ) );
87 data = phys_to_virt ( current );
124 DBGC ( &
images,
"INITRD swapping %s [%#08lx,%#08lx)<->[%#08lx,%#08lx) " 125 "%s\n",
low->name, virt_to_phys (
low->data ),
126 ( virt_to_phys (
low->data ) +
low->len ),
127 virt_to_phys (
high->data ),
128 ( virt_to_phys (
high->data ) +
high->len ),
high->name );
133 len = ( low_len + high_len );
138 high->data -= low_len;
139 low->data += high_len;
158 const void *adjacent;
165 addr = virt_to_phys (
low->data );
188 if (
high->data == adjacent ) {
204 struct image *initrd;
212 DBGC ( &
images,
"INITRD %s at [%#08lx,%#08lx)\n",
213 initrd->
name, virt_to_phys ( initrd->
data ),
214 ( virt_to_phys ( initrd->
data ) + initrd->
len ) );
258 const char *filename =
cpio_name ( initrd );
275 for ( i = 0 ; ( cpio_len =
cpio_header ( initrd, i, &cpio ) ) ; i++ )
283 for ( i = 0 ; ( cpio_len =
cpio_header ( initrd, i, &cpio ) ) ;
288 filename, ( cpio_len -
sizeof ( cpio ) ) );
292 DBGC ( &
images,
"INITRD %s [%#08lx,%#08lx,%#08lx)%s%s\n",
296 ( filename ?
" " :
"" ), ( filename ? filename :
"" ) );
318 struct image *initrd;
361 if ( available <
len )
363 DBGC ( &
images,
"INITRD post-reshuffle region is [%#08lx,%#08lx)\n",
364 min, (
min + available ) );
368 region->
max = (
min + available - 1 );
370 region->
name =
"initrd";
390 DBGC ( &
images,
"INITRD limiting reshuffling to below " static void initrd_reverse(void *data, size_t len)
Reverse aligned memory region.
uint32_t low
Low 16 bits of address.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
uint64_t max
Maximum address in region.
const void * data
Read-only data.
uint64_t address
Base address.
static size_t initrd_load(struct image *initrd, void *address)
Load initrd.
physaddr_t uheap_start
Start of external heap.
int initrd_region(size_t len, struct memmap_region *region)
Calculate post-reshuffle initrd load region.
static physaddr_t initrd_end
End of reshuffle region.
static size_t initrd_align(size_t len)
Align initrd length.
static size_t cpio_pad_len(size_t len)
Get CPIO header zero-padding length.
struct startup_fn startup_initrd __startup_fn(STARTUP_LATE)
initrd startup function
void initrd_reshuffle(void)
Reshuffle initrds into desired order at top of memory.
#define STARTUP_LATE
Late startup.
#define INITRD_ALIGN
Initial ramdisk chunk alignment.
uint32_t start
Starting offset.
A startup/shutdown function.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
size_t cpio_header(struct image *image, unsigned int index, struct cpio_header *cpio)
Construct CPIO header for image, if applicable.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
Access to external ("user") memory.
static void initrd_dump(void)
Dump initrd locations (for debug)
size_t initrd_load_all(void *address)
Load all initrds.
uint32_t high
High 32 bits of address.
#define for_each_image(image)
Iterate over all registered images.
static void initrd_squash_high(physaddr_t start, physaddr_t end)
Squash initrds as high as possible in memory.
unsigned int flags
Region flags.
size_t len
Length of raw file image.
struct list_head images
List of registered images.
#define IMAGE_HIDDEN
Image will be hidden from enumeration.
uint32_t addr
Buffer address.
static void initrd_startup(void)
initrd startup function
const char * name
Region name (for debug messages)
static void initrd_swap(struct image *low, struct image *high)
Swap position of two adjacent initrds.
void * memmove(void *dest, const void *src, size_t len) __nonnull
Initial ramdisk (initrd) reshuffling.
#define ENOSPC
No space left on device.
physaddr_t uheap_limit
Minimum possible start of external heap.
#define MEMMAP_FL_MEMORY
Contains memory.
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" return dest
uint32_t end
Ending offset.
uint8_t data[48]
Additional event data.
uint64_t min
Minimum address in region.
A memory region descriptor.
uint16_t offset
Offset to command line.
#define NULL
NULL pointer (VOID *)
static int initrd_swap_any(physaddr_t start, physaddr_t end)
Swap position of any two adjacent initrds not currently in the correct order.
physaddr_t uheap_end
End of external heap.
void * memset(void *dest, int character, size_t len) __nonnull
static const char * cpio_name(struct image *image)
Get CPIO image name.