Skip to content

Commit

Permalink
mambo: Merge PMEM_DISK and PMEM_VOLATILE code
Browse files Browse the repository at this point in the history
PMEM_VOLATILE and PMEM_DISK can't be used together and are basically
copies of the same code.

This merges the two and allows them used together.  Same API is kept.

Signed-off-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
  • Loading branch information
mikey authored and stewartsmith committed Sep 20, 2018
1 parent 0f78682 commit 832cac1
Showing 1 changed file with 31 additions and 46 deletions.
77 changes: 31 additions & 46 deletions external/mambo/skiboot.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -239,60 +239,45 @@ if { [info exists env(SKIBOOT_INITRD)] } {
mysim of addprop $chosen_node int "linux,initrd-end" $cpio_end
}


# Map persistent memory disks
if { [info exists env(PMEM_DISK)] } {
proc pmem_node_add { root start size } {
set start_hex [format %x $start]
set node [mysim of addchild $root "pmem@$start_hex" ""]
set reg [list [expr $start >> 32] [expr $start & 0xffffffff] [expr $size >> 32] [expr $size & 0xffffffff] ]
mysim of addprop $node array "reg" reg
mysim of addprop $node string "compatible" "pmem-region"
mysim of addprop $node empty "volatile" "1"
return [expr $start + $size]
}

set pmem_files ""
if { [info exists env(PMEM_DISK)] } {
set pmem_files [split $env(PMEM_DISK) ","]

set pmem_root [mysim of addchild $root_node "pmem" ""]
mysim of addprop $pmem_root int "#address-cells" 2
mysim of addprop $pmem_root int "#size-cells" 2
mysim of addprop $pmem_root empty "ranges" ""

# Start above where XICS normally is at 0x1A0000000000
set pmem_start [expr 0x20000000000]
foreach pmem_file $pmem_files {
set pmem_file [string trim $pmem_file]
set pmem_size [file size $pmem_file]
set pmem_start_hex [format %x $pmem_start]
set pmem_node [mysim of addchild $pmem_root "pmem@$pmem_start_hex" ""]
set reg [list [expr $pmem_start >> 32] [expr $pmem_start & 0xffffffff] [expr $pmem_size >> 32] [expr $pmem_size & 0xffffffff] ]
mysim of addprop $pmem_node array "reg" reg
mysim of addprop $pmem_node string "compatible" "pmem-region"
mysim of addprop $pmem_root empty "volatile" ""
if {[catch {mysim memory mmap $pmem_start $pmem_size $pmem_file rw}]} {
puts "ERROR: pmem: 'mysim mmap' command needs newer mambo"
exit
}
set pmem_start [expr $pmem_start + $pmem_size]
}
}

set pmem_sizes ""
if { [info exists env(PMEM_VOLATILE)] } {

set pmem_sizes [split $env(PMEM_VOLATILE) ","]

set pmem_root [mysim of addchild $root_node "pmem" ""]
mysim of addprop $pmem_root int "#address-cells" 2
mysim of addprop $pmem_root int "#size-cells" 2
mysim of addprop $pmem_root empty "ranges" ""

# Start above where XICS normally is at 0x1A0000000000
if (![info exists pmem_start]) {
set pmem_start [expr 0x20000000000]
}

foreach pmem_size $pmem_sizes {
set pmem_size [string trim $pmem_size]
set pmem_start_hex [format %x $pmem_start]
set pmem_node [mysim of addchild $pmem_root "pmem@$pmem_start_hex" ""]
set reg [list [expr $pmem_start >> 32] [expr $pmem_start & 0xffffffff] [expr $pmem_size >> 32] [expr $pmem_size & 0xffffffff] ]
mysim of addprop $pmem_node array "reg" reg
mysim of addprop $pmem_node string "compatible" "pmem-region"
mysim of addprop $pmem_root int "volatile" 1
set pmem_start [expr $pmem_start + $pmem_size]
}
set pmem_root [mysim of addchild $root_node "pmem" ""]
mysim of addprop $pmem_root int "#address-cells" 2
mysim of addprop $pmem_root int "#size-cells" 2
mysim of addprop $pmem_root empty "ranges" ""
# Start above where XICS normally is at 0x1A0000000000
set pmem_start [expr 0x20000000000]
foreach pmem_file $pmem_files { # PMEM_DISK
set pmem_file [string trim $pmem_file]
set pmem_size [file size $pmem_file]
if {[catch {mysim memory mmap $pmem_start $pmem_size $pmem_file rw}]} {
puts "ERROR: pmem: 'mysim mmap' command needs newer mambo"
exit
}
set pmem_start [pmem_node_add $pmem_root $pmem_start $pmem_size]
}
foreach pmem_size $pmem_sizes { # PMEM_VOLATILE
set pmem_start [pmem_node_add $pmem_root $pmem_start $pmem_size]
}


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

0 comments on commit 832cac1

Please sign in to comment.