Skip to content

Commit

Permalink
mambo: Allow loading multiple CPIOs
Browse files Browse the repository at this point in the history
Currently we have support for loading a single CPIO and telling Linux to
use it as the initrd. But the Linux code actually supports having
multiple CPIOs contiguously in memory, between initrd-start and end, and
will unpack them all in order. That is a really nice feature as it means
you can have a base CPIO with your root filesystem, and then tack on
others as you need for various tests etc.

So expand the logic to handle SKIBOOT_INITRD, and treat it as a comma
separated list of CPIOs to load. I chose comma as it's fairly rare in
filenames, but we could make it space, colon, whatever. Or we could add
a new environment variable entirely. The code also supports trimming
whitespace from the values, so you can have "cpio1, cpio2".

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
  • Loading branch information
mpe authored and stewartsmith committed May 31, 2017
1 parent 6cad88d commit 1c70570
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions external/mambo/skiboot.tcl
Expand Up @@ -190,13 +190,19 @@ mysim of addprop $xscom_node byte_array "compatible" $compat
set cpio_start 0x80000000
set cpio_end $cpio_start
if { [info exists env(SKIBOOT_INITRD)] } {
set cpio_file $env(SKIBOOT_INITRD)

set cpios [split $env(SKIBOOT_INITRD) ","]

foreach cpio_file $cpios {
set cpio_file [string trim $cpio_file]
set cpio_size [file size $cpio_file]
mysim mcm 0 memory fread $cpio_end $cpio_size $cpio_file
set cpio_end [expr $cpio_end + $cpio_size]
}

set chosen_node [mysim of find_device /chosen]
set cpio_size [file size $cpio_file]
set cpio_end [expr $cpio_start + $cpio_size]
mysim of addprop $chosen_node int "linux,initrd-start" $cpio_start
mysim of addprop $chosen_node int "linux,initrd-end" $cpio_end
mysim mcm 0 memory fread $cpio_start $cpio_size $cpio_file
}

# Default NVRAM is blank and will be formatted by Skiboot if no file is provided
Expand Down

0 comments on commit 1c70570

Please sign in to comment.