image->name, rm_cmdline );
}
-/**
- * Align initrd length
- *
- * @v len Length
- * @ret len Length rounded up to INITRD_ALIGN
- */
-static inline size_t bzimage_align ( size_t len ) {
-
- return ( ( len + INITRD_ALIGN - 1 ) & ~( INITRD_ALIGN - 1 ) );
-}
-
/**
* Load initrd
*
/* Calculate length */
len += bzimage_load_initrd ( image, initrd, NULL );
- len = bzimage_align ( len );
+ len = initrd_align ( len );
DBGC ( image, "bzImage %s initrd %s from [%#08lx,%#08lx)%s%s\n",
image->name, initrd->name, virt_to_phys ( initrd->data ),
for_each_image ( initrd ) {
if ( virt_to_phys ( initrd->data ) >= top ) {
top = ( virt_to_phys ( initrd->data ) +
- bzimage_align ( initrd->len ) );
+ initrd_align ( initrd->len ) );
}
}
if ( other == initrd )
offset = 0;
offset += bzimage_load_initrd ( image, other, NULL );
- offset = bzimage_align ( offset );
+ offset = initrd_align ( offset );
}
/* Load initrd at this address */
struct image *initrd;
struct image *highest;
void *data;
- size_t len;
/* Squash up any initrds already within or below the region */
while ( 1 ) {
break;
/* Move this image to its final position */
- len = ( ( highest->len + INITRD_ALIGN - 1 ) &
- ~( INITRD_ALIGN - 1 ) );
- current -= len;
+ current -= initrd_align ( highest->len );
DBGC ( &images, "INITRD squashing %s [%#08lx,%#08lx)->"
"[%#08lx,%#08lx)\n", highest->name,
virt_to_phys ( highest->data ),
/* Copy any remaining initrds (e.g. embedded images) to the region */
for_each_image ( initrd ) {
if ( virt_to_phys ( initrd->data ) >= top ) {
- len = ( ( initrd->len + INITRD_ALIGN - 1 ) &
- ~( INITRD_ALIGN - 1 ) );
- current -= len;
+ current -= initrd_align ( initrd->len );
DBGC ( &images, "INITRD copying %s [%#08lx,%#08lx)->"
"[%#08lx,%#08lx)\n", initrd->name,
virt_to_phys ( initrd->data ),
( virt_to_phys ( high->data ) + high->len ), high->name );
/* Calculate padded lengths */
- low_len = ( ( low->len + INITRD_ALIGN - 1 ) & ~( INITRD_ALIGN - 1 ) );
- high_len = ( ( high->len + INITRD_ALIGN - 1 ) & ~( INITRD_ALIGN - 1 ));
+ low_len = initrd_align ( low->len );
+ high_len = initrd_align ( high->len );
len = ( low_len + high_len );
data = low->rwdata;
assert ( high->data == ( data + low_len ) );
struct image *low;
struct image *high;
const void *adjacent;
- size_t padded_len;
/* Find any pair of initrds that can be swapped */
for_each_image ( low ) {
/* Calculate location of adjacent image (if any) */
- padded_len = ( ( low->len + INITRD_ALIGN - 1 ) &
- ~( INITRD_ALIGN - 1 ) );
- adjacent = ( low->data + padded_len );
+ adjacent = ( low->data + initrd_align ( low->len ) );
/* Search for adjacent image */
for_each_image ( high ) {
extern void initrd_reshuffle ( physaddr_t bottom );
extern int initrd_reshuffle_check ( size_t len, physaddr_t bottom );
+/** Initial ramdisk chunk alignment */
+#define INITRD_ALIGN 4096
+
+/**
+ * Align initrd length
+ *
+ * @v len Length
+ * @ret len Aligned length
+ */
+static inline __attribute__ (( always_inline )) size_t
+initrd_align ( size_t len ) {
+
+ return ( ( len + INITRD_ALIGN - 1 ) & ~( INITRD_ALIGN - 1 ) );
+}
+
#endif /* _IPXE_INITRD_H */