[Skiboot] [PATCH] mambo: Allow loading multiple CPIOs

Michael Ellerman mpe at ellerman.id.au
Fri May 26 21:35:24 AEST 2017


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 at ellerman.id.au>
---
 external/mambo/skiboot.tcl | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/external/mambo/skiboot.tcl b/external/mambo/skiboot.tcl
index 1b74c9bc5f3d..f4068fac0a20 100644
--- a/external/mambo/skiboot.tcl
+++ b/external/mambo/skiboot.tcl
@@ -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
-- 
2.7.4



More information about the Skiboot mailing list