summaryrefslogtreecommitdiffstats
path: root/src/build/simics/startup.simics
blob: 440e9562b76a10b79dd03be03f8ee7c0cdccf074 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171

$hb_mode = 1  #Old Mode -- No simics internals changed
$runsim_lookup = (lookup-file -query "%simics%/runsim")
if ($runsim_lookup) {
    $hb_mode = 0 #New Mode -- Some simics internal changes
}

# $hb_script_to_run is only set in Axone Standalone and onwards
# we need to add the script directory in the Axone standalone model
# for the older models the directory is already in the path
if defined hb_script_to_run {
    $hb_script_location = (python "''.join(map('/'.__add__,\""+$hb_script_to_run+"\"[1:].split('/')[0:-1]))")
    $script_dir = (python "''.join(map('/'.__add__,\""+$hb_script_location+"\"[1:].split('/')[0:-1]))")
    add-directory $script_dir
}

$hb_startup_path = (lookup-file hbfw/startup.simics)

# if we are in older simics models (before Axone standalone)
# we must now set $hb_script_location as it is not above
if not defined hb_script_location {
    $hb_script_location = (python "''.join(map('/'.__add__,\""+$hb_startup_path+"\"[1:].split('/')[0:-1]))")
}

python "os.environ['HB_TOOLPATH'] = \""+$hb_script_location+"\""

# TODO RTC: 204842 Revist once we get way to read CEC_TYPE from simics
if ($hb_mode == 1) {

    $model=""
    if(env -x CEC_TYPE) {
        $model = (env CEC_TYPE)
    }

    $machine_name=""
    if(env -x MACHINE) {
        $machine_name = (env MACHINE)
    }

    $hb_machine = "unknown"
    if ($model == "p9_zztop")     {$hb_machine = "zztop"}
    if ($model == "p9_zeppelin")  {$hb_machine = "zeppelin"}
    if ($model == "p9_fleetwood") {$hb_machine = "fleetwood"}
    if ($model == "p9_nimbus")    {$hb_machine = "nimbus"}
    if ($model == "p9_cumulus") {
        if ($machine_name == "CUMULUS_CDIMM") { $hb_machine = "cumulus_cdimm" }
        if ($machine_name != "CUMULUS_CDIMM") { $hb_machine = "cumulus" }
    }

}else{
    # simics now provides us the chip type (starting w/ p9a ) 
    $hb_machine = $proc_chip_type
}

python "os.environ['HB_MACHINE'] = \""+$hb_machine+"\""
echo "HB_MACHINE is: "+$hb_machine

$hb_pnor = ""

if( $hb_mode == 1) {
  # Setup some common vars to use across machine types
  $hb_masterproc = (get-master-proc)
  $hb_masterproc_cecchip = (get-master-cec-chip)
  $hb_pnor = (get-master-pnor)
} else {
  $hb_masterproc = (get-master-procs)[0]
  $hb_masterproc_cecchip = (get-master-cec-chips)[0]
  $hb_pnor = (get-master-pnors)[0]
}

echo "Master Proc is: "+$hb_masterproc
echo "Master Proc Cec-Chip is: "+$hb_masterproc_cecchip

#New Simics flow can simply get the string from get-master-pnor command

if ($hb_pnor == NIL) {
    try {
        @simenv.hb_pnor = quiet_run_command("get-master-pnor")[0]
        @SIM_get_object(simenv.hb_pnor[0])
    } except {
        # Default to Nimbus name
        foreach $pnor in (get-object-list -all BmcCmp) {
            $hb_pnor = ($pnor)
        }
        $hb_pnor = $hb_pnor+".sfc_master_mem"
    }
}
echo "Master PNOR is: "+$hb_pnor

# Choose a default core to start with
$hb_cpu = "system_cmp0.cpu0_0_00_0"
echo "Defaulting to CPU "+$hb_cpu+" for Hostboot tools"

# Prevent SBE Updates from happening on an IPL
echo "Altering SBE SEEPROM Versions to disable Update in IPL"
if ($hb_mode == 1) {
    foreach $cc in (get-object-list p9_proc) {
        ($cc).seeprom1.seeprom1_image.set 0x3FED9 0x5A5A5A5A 8 -l
        ($cc).seeprom3.seeprom3_image.set 0x3FED9 0x5A5A5A5A 8 -l
    }
} else {
    foreach $proc in (get-all-procs) {
        ($proc.get-seeprom 1).set 0x3FED9 0x5A5A5A5A 8 -l
        ($proc.get-seeprom 3).set 0x3FED9 0x5A5A5A5A 8 -l
    }
}

# Load HB debug tools.
try {
    run-python-file (lookup-file hbfw/simics-debug-framework.py)
}   except { echo "ERROR: Failed to load Simics debug framework (simics-debug-framework.py)" }
try {
    run-python-file (lookup-file hbfw/hb-simdebug.py)
} except { echo "ERROR: Failed to load Hostboot debug tools (hb-simdebug.py)" }


# Determine security state
$hw_security=(shell "echo $SECURITY_HW_POLICY")
if($hw_security == "") {
    # Assume default (no HW security) if not specified
    $hw_security = "0"
}

if(($hw_security != "1") and ($hw_security != "0")) {
    # Emit warning and assume default
    echo ("SECURITY: WARNING! Bad value "+
        $hw_security+" for HW security policy, defaulting to 0")
    $hw_security = "0"
}
echo "SECURITY: HW security policy set to "+$hw_security

# Translate security state to SIMICS jumper state
$jumperApplied=TRUE
if($hw_security == "1") {
    $jumperApplied=FALSE
}

if ($hb_machine == "p9a") {
    # Set logical jumper state in SIMICS based on HW policy
    #     "TRUE"=jumper applied(security disabled, default)
    #     "FALSE"=jumper removed(security enabled)

    # Load jumper state to the master processor
    $hb_masterproc.set-secure-jumper value = $jumperApplied

    # Load jumper state to all slave processors
    foreach $procS in ($hb_masterproc.get-slave-procs) {
        $procS.set-secure-jumper value = $jumperApplied
    }
} else {
  # Load jumper state to each processor
  foreach $procX in (get-object-list p9_proc) {

      # Set logical jumper state in SIMICS based on HW policy
      #     "TRUE"=jumper applied(security disabled, default)
      #     "FALSE"=jumper removed(security enabled)
      (($procX)->secure_jumper=$jumperApplied)
  }
}

if ($hb_mode == 0) {
    run-command-file (lookup-file hbfw/standalone.simics)
}

########################### WORKAROUNDS ####################################
# Setup the mailbox.
# for mbox on core 0 use:
# proc_venicechip_cmp0.psi_hb->psihb_xivr_fsi=0x0140000000     #02010917
# for mbox on core 5 use:
#proc_venicechip_cmp0.psi_hb->psihb_xivr_fsi=0x0000A00140000000   #02010917
#proc_venicechip_cmp0.psi_hb->psihb_irsn=0x00030003FFFF0000 #0201091b
OpenPOWER on IntegriCloud