-
Notifications
You must be signed in to change notification settings - Fork 97
/
hb
executable file
·1028 lines (903 loc) · 36.7 KB
/
hb
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# IBM_PROLOG_BEGIN_TAG
# This is an automatically generated prolog.
#
# $Source: src/build/tools/hb $
#
# OpenPOWER HostBoot Project
#
# Contributors Listed Below - COPYRIGHT 2011,2024
# [+] International Business Machines Corp.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# IBM_PROLOG_END_TAG
execute_in_sandbox()
{
[ -z "${SANDBOXBASE}" ] && echo "Missing SANDBOXBASE." && exit 1
[ -z "${SANDBOXROOT}" ] && echo "Missing SANDBOXROOT." && exit 1
[ -z "${SANDBOXNAME}" ] && echo "Missing SANDBOXNAME." && exit 1
if [ ! -d "${SANDBOXBASE}" ]; then
echo "Sandbox does not exist. Create with 'hb simsetup."
exit 1
fi
SANDBOXRC="${SANDBOXROOT}/hbsandboxrc"
WORKON_CMD="workon -rc ${SANDBOXRC} -sb ${SANDBOXNAME} -m $2 "
echo $1 > ${SANDBOXBASE}/src/sandbox_execute_cmd
chmod 700 ${SANDBOXBASE}/src/sandbox_execute_cmd
echo "Sandbox :: $1"
${WORKON_CMD} -c ./sandbox_execute_cmd
if [ $? -ne 0 ]; then
echo "Sandbox cmd failed"
rm ${SANDBOXBASE}/src/sandbox_execute_cmd
exit 1
fi
rm ${SANDBOXBASE}/src/sandbox_execute_cmd
}
export_key_variables()
{
# Export MACHINE variable
MACHINE=${MACHINE:-$DEFAULT_MACHINE}
export MACHINE
echo "Setting up for Machine = $MACHINE"
# Export PNOR_LAYOUT_SELECTED variable
# Dynamically check if file exists indicating the fsprelease.config was used
# Note this file is generated in the hb config file rule in top level makefile
if [[ -f ${PROJECT_ROOT}/obj/genfiles/hb_fsp_release ]]; then
echo "FSP build, using fsp pnor xml layout"
export PNOR_LAYOUT_SELECTED=FSP
elif [[ -f ${PROJECT_ROOT}/obj/genfiles/hb_simics_p10_release ]]; then
echo "P10 build, using P10 PNOR XML layout"
export PNOR_LAYOUT_SELECTED=P10
export HB_STANDALONE=1
elif [ ! -z "${VPO_COMPILE}" ]; then
echo "VPO build, using VPO PNOR XML layout"
export PNOR_LAYOUT_SELECTED=VPO
export HB_STANDALONE=1
else
echo "Non FSP build, using standalone (default) pnor xml layout"
export PNOR_LAYOUT_SELECTED=STANDALONE
fi
}
hb_helptext()
{
echo "Hostboot Utility Script"
case $1 in
workon)
echo " Topic 'workon'"
echo
echo " Usage:"
echo " hb workon"
echo
echo " Sources necessary environment files for building hostboot"
echo " and begins a new shell. The workon may be left via 'exit'."
echo
echo " Environment Variables:"
echo " SHELL: The shell program to launch."
echo
echo " See also:"
echo " customrc"
;;
fipssetup)
echo " Topic 'fipssetup'"
echo
echo " Usage:"
echo " hb fipssetup"
echo
echo " Creates a simics workspace (FSP sandbox) in the directed"
echo " location."
echo
echo " FSP backing build are chosen as directed"
echo " by the CI test files (src/build/citest/etc)."
echo
echo " Environment Variables:"
echo " SANDBOXROOT: Root directory of where the sandboxes"
echo " should go."
echo " SANDBOXNAME: Desired name of the hostboot sandbox."
;;
simsetup)
echo " Topic 'simsetup'"
echo
echo " Usage:"
echo " hb simsetup"
echo
echo " Creates a simics workspace in the directed location and"
echo " initializes simics as well as executing any hostboot specific"
echo " workarounds."
echo
echo " If using an ODE sandbox FSP backing build and workarounds are"
echo " chosen as directed by the CI test files (src/build/citest/etc)."
echo
echo " Environment Variables (when using an ODE sandbox):"
echo " SANDBOXROOT: Root directory of where the sandboxes"
echo " should go."
echo " SANDBOXNAME: Desired name of the hostboot sandbox."
;;
prime)
echo " Topic 'prime'"
echo
echo " Usage:"
echo " hb prime"
echo " hb prime --test"
echo
echo " Copies hostboot images and simics scripts into the simics"
echo " workspace."
echo
echo " Options:"
echo " --test : Copy test images (as opposed to non-test)."
echo " --secureboot : Build a secure pnor with proper signing"
echo
echo " See also:"
echo " simsetup"
;;
buildmodules)
echo " Topic 'buildmodules'"
echo
echo " Usags:"
echo " hb buildmodules"
echo
echo " Builds the Hostboot submodules (sbe, ppe, and ekb subrepos) but"
echo " does not perform other prime activities like building PNOR or"
echo " copying images. Use this command if you need to rebuild the"
echo " internal submodules."
echo
echo " See also:"
echo " prime"
;;
startsimics)
echo " Topic 'startsimics'"
echo
echo " Usage:"
echo " hb startsimics <opts>"
echo
echo " Enters the simics workspace and starts simics using the"
echo " start_simics utility. Any options are passed directly to"
echo " the start_simics script."
echo
echo " Requires the hostboot image to be 'prime'd into the workspace."
echo
echo " Environment Variables:"
echo " MACHINE: Alternate simics machine type (default p10_standalone)"
echo " SIMICSOPTIONS: Additional options to always pass to the"
echo " start simics script, such as '-nre'."
echo
echo " See also:"
echo " simsetup, prime"
;;
rsync)
echo " Topic 'rsync'"
echo
echo " Usage:"
echo " hb rsync <opts>"
echo
echo " Synchronizes an entire Hostboot repository with another"
echo " directory. This can be useful for creating a backup of"
echo " the repository or for pushing it to a remote host, such"
echo " as a pool machine where simics is executed."
echo
echo " Options:"
echo " --force : Skip user prompt for RSYNCDIR confirmation (reserve for cronjobs)."
echo
echo " Environment Variables:"
echo " RSYNCHOST: (optional) remote host to rsync to."
echo " RSYNCDIR: Destination directory of the rsync."
echo
echo " The trailing slash on RSYNCDIR, or lack thereof, has"
echo " meaning to rsync. Specifically /.../foo will create a new"
echo " directory called 'foo' with the contents of your repository"
echo " in it, while /.../foo/ will create a subdirectory within foo"
echo " by the name of your repository's directory name."
;;
objsizes)
echo " Topic 'objsizes'"
echo
echo " Usage:"
echo " hb objsizes"
echo
echo " Reads the ELF header information from all of the hostboot"
echo " modules and generates a CSV output of the sizes of the text"
echo " and data sections of the modules."
;;
copyright_check)
echo " Topic 'copyright_check'"
echo
echo " Usage:"
echo " hb copyright_check"
echo
echo " Executes addCopyright in validate mode against the most"
echo " recent commit in your repository to ensure the prologs are"
echo " all added properly."
;;
errlparser)
echo " Topic 'errlparser'"
echo
echo " Usage:"
echo " hb errlparser"
echo
echo " Prepares a copy of FipS errl tool that is hostboot aware,"
echo " places it in simics directory."
;;
cachesync)
echo " Topic 'cachesync'"
echo
echo " Usage:"
echo " hb cachesync"
echo
echo " Synchronizes the repository's binary file cache with the"
echo " project repository."
;;
cacheadd)
echo " Topic 'cacheadd'"
echo
echo " Usage:"
echo " hb cacheadd [--local] <file> \"<msg>\""
echo
echo " Inserts a file into the project binary file cache."
echo
echo " Options:"
echo " --local: Indicates file should be put only in local cache."
;;
customrc)
echo " Topic 'customrc'"
echo
echo " Setting up this file in the root of your repository gives a"
echo " convienient way to create default environment variables for"
echo " the 'hb' script and your hostboot workon environment. Some"
echo " of the hb sub-commands require environment variables assigned"
echo " and they should be done through this 'customrc' file. You"
echo " may also use this as a place to source other files you need"
echo " for your environment, such as setting up 'git'."
echo
echo " The 'customrc' file is in the .gitignore file and should"
echo " NEVER be committed to git. These are your own custom "
echo " settings."
echo
echo " The minimal example 'customrc' file is as follows:"
echo " #!/bin/sh"
echo " export SANDBOXROOT=~/sandboxes"
echo " export SANDBOXNAME=hostboot"
echo
echo " See also:"
echo " All other sub-commands."
;;
*)
echo " Usage:"
echo " hb <cmd>"
echo " hb help [<cmd>|<topic>]"
echo
echo " Available Commands:"
echo " workon, simsetup, prime, startsimics, rsync, objsizes,"
echo " copyright_check, errlparser, cachesync, cacheadd, fipssetup,"
echo " flags"
echo
echo " Additional Help Topics:"
echo " customrc"
echo
echo " For initial setup:"
echo " 1) Create customrc file."
echo " 2) hb workon"
echo " 3) hb simsetup"
echo " 4) Create images (edit code, make, etc.)."
echo " 5) hb prime [--test]"
echo " 6) hb startsimics"
echo " 7) Return to step 4 until satisfied."
;;
esac
}
hb_workon()
{
if [ -n "${HOSTBOOT_INSIDE_WORKON}" ]; then
echo "Already in a workon."
exit 1
else
export HOSTBOOT_INSIDE_WORKON=1
echo "Setting environment variables..."
. ./env.bash
echo "Spawning new shell (${SHELL})..."
${SHELL} && exit 0
fi
}
hb_buildmodules()
{
export_key_variables
source standaloneHelper --generateHcodeImage
source standaloneHelper --generateSbeOdysseyImages
source standaloneHelper --generateSbeImage
}
hb_prime()
{
export_key_variables
# Priming for P10 Standalone without ODE SB
if [[ $HB_STANDALONE -eq 1 ]] && [[ $PNOR_LAYOUT_SELECTED != "FSP" ]]; then
hbDistribute --hb-standalone $*
exit $?
fi
# Priming using ODE SB
[ -z "${SANDBOXBASE}" ] && echo "Missing SANDBOXBASE." && exit 1
[ -z "${PROJECT_ROOT}" ] && echo "Missing PROJECT_ROOT." && exit 1
if [ ! -d "${SANDBOXBASE}" ]; then
echo "Sandbox does not exist. Create with 'hb simsetup."
exit 1
fi
# Prevent error message in cases where SANDBOXBASE is set but hb simsetup
# is not performed. Example seen in cronjob scripts
if [[ -f ${SANDBOXBASE}/rc_files/sb.conf ]] &&
[[ -f ${PROJECT_ROOT}/src/build/citest/etc/bbuild ]]; then
SBDRIVER=`cat ${SANDBOXBASE}/rc_files/sb.conf | \
grep "backing_build" | awk '{ print $3 }'`
DRIVER=`cat ${PROJECT_ROOT}/src/build/citest/etc/bbuild`
if [ ${SBDRIVER} != ${DRIVER} ]; then
echo "ERROR: Driver mismatch between sandbox and src/build/citest/etc/bbuild."
echo "Sandbox at ${SBDRIVER}"
echo "bbuild at ${DRIVER}"
echo "Update sandbox with 'hb simsetup'."
exit 1
fi
fi
echo "Calling hbDistribute --hb-standalone "
hbDistribute --hb-standalone $*
if [[ $PNOR_LAYOUT_SELECTED == "FSP" ]] && [[ -n "${HB_NFS_DIR}" ]]; then
mkdir -p ${HB_NFS_DIR}/test/pnor
cp -v ${PROJECT_ROOT}/img/hbotStringFile ${PROJECT_ROOT}/img/*.list.bz2 ${PROJECT_ROOT}/img/*.syms ${PROJECT_ROOT}/img/*.bin.modinfo ${HB_NFS_DIR}/test/pnor/
# Below, in addition to creating hostboot patches, the pieces of auto-patching and auto-booting will be put in
# place. For more information on how to properly setup and use FSP auto-patching and auto-booting in simics see
# the README in src/build/simics
#
# The list of commands to build the hostboot code patches to be dropped in /nfs/test/pnor/ on the FSP
# The command does the minimum necessary work to do that for time saving reasons. This will not build targeting
# patches since that takes much more time and is done less often than just code patches.
buildPatch="mkdir -p ${SANDBOXBASE}/src/hbfw/img && cd ${SANDBOXBASE}/src/hbfw \
&& mk expand_tars_fsp.tar expand_tars_simics.tar && \
cd ${SANDBOXBASE}/src/hbfw/img/ \
&& mk -j16"
# This command will copy the output binaries generated from buildPatch and drop them in $HB_NFS_DIR if it exists.
copyToNFS="cd ${SANDBOXBASE} && \
cp ${SANDBOXBASE}/obj/ppc/hbfw/img/h*header.bin \$HB_NFS_DIR/test/pnor"
# Stick the two commands together. They were separated for easier readability.
prepareFspPatch="${buildPatch} && ${copyToNFS}"
# Execute the command in a ODE sandbox workon.
execute_in_sandbox "${prepareFspPatch}" "ppc"
fi
}
hb_fipssetup()
{
[ -z "${SANDBOXBASE}" ] && echo "Missing SANDBOXBASE." && exit 1
[ -z "${SANDBOXROOT}" ] && echo "Missing SANDBOXROOT." && exit 1
[ -z "${SANDBOXNAME}" ] && echo "Missing SANDBOXNAME." && exit 1
[ -z "${PROJECT_ROOT}" ] && echo "Missing PROJECT_ROOT." && exit 1
SANDBOXRC="${SANDBOXROOT}/hbsandboxrc"
DRIVER=`cat ${PROJECT_ROOT}/src/build/citest/etc/bbuild`
if [ -d "${SANDBOXBASE}" ]; then
echo "Removing old sandbox."
mksb -rc ${SANDBOXRC} -dir ${SANDBOXROOT} -undo $SANDBOXNAME
fi
if [ ! -d "${SANDBOXROOT}" ]; then
echo "Creating sandbox root directory."
mkdir -p ${SANDBOXROOT}
fi
if [ ! -d "${DRIVER}" ]; then
echo "ERROR: Backing build in src/build/citest/etc/bbuild not found!"
exit 1
fi
echo "Creating new sandbox."
mksb -rc ${SANDBOXRC} -dir ${SANDBOXROOT} -back $DRIVER \
-sb ${SANDBOXNAME} -m ppc
echo "All done"
}
hb_simsetup()
{
export_key_variables
# Note - need to use 'eval echo $(cat' to expand the embedded env var in the path
SIMICS_LEVEL=`eval echo $(cat ${PROJECT_ROOT}/src/build/citest/etc/simbuild)`
# Setup for P10 Standalone without ODE SB
if [[ $HB_STANDALONE -eq 1 ]] && [[ $PNOR_LAYOUT_SELECTED != "FSP" ]]; then
STANDALONE_SIMICS=${PROJECT_ROOT}/standalone/simics
STANDALONE_FFS=${PROJECT_ROOT}/standalone/ffs
if [[ -d ${STANDALONE_SIMICS} ]];then
# standalone dir exists, ask Dev to clear it out and reinstall
echo
echo "Simics is already set up for a Standalone environment."
echo "Would you like to clear it out and reinstall? [y/n]"
read SHOULD_REINSTALL
if [[ ${SHOULD_REINSTALL} != "y" ]]; then
echo "Stopping 'hb simsetup', Simics was not reinstalled."
exit 0
fi
# Will need to prime again.
echo "Don't forget to run 'hb prime' after simsetup is done."
echo
# remove Simics
echo "rm -rf ${STANDALONE_SIMICS}"
rm -rf "${STANDALONE_SIMICS}"
echo "rm -rf ${STANDALONE_FFS}"
rm -rf "${STANDALONE_FFS}"
fi
mkdir -p ${STANDALONE_SIMICS}/hbfw
echo tar -xf ${SIMICS_LEVEL} -C ${STANDALONE_SIMICS}
tar -xf ${SIMICS_LEVEL} -C ${STANDALONE_SIMICS}
echo "cd ${STANDALONE_SIMICS} && ./INSTALL.sh"
cd ${STANDALONE_SIMICS} && ./INSTALL.sh
# Copy prebuilt EECACHE for 1 and 2 proc Standalone and for VPO (1 proc)
# so that there is no need to run "hb simsetup" again if the
# configuration you want to test changes, you'll only need to run
# "hb prime" again in that case.
# EECACHE to be used for VPO
EECACHE_VPO_PREBUILT=`eval echo $(cat ${PROJECT_ROOT}/src/build/citest/etc/eecache_vpo_prebuilt)`
echo "cp ${EECACHE_VPO_PREBUILT} ${STANDALONE_SIMICS}/eecache_vpo_prebuilt.bin.ecc"
cp ${EECACHE_VPO_PREBUILT} ${STANDALONE_SIMICS}/eecache_vpo_prebuilt.bin.ecc
# DD1 EECACHE to be used for $PNOR_LAYOUT_SELECTED set as "P10" or "STANDALONE" when STANDALONE_TEST_DD1 has
# been exported as an env variable
EECACHE_PREBUILT=`eval echo $(cat ${PROJECT_ROOT}/src/build/citest/etc/eecache_prebuilt)`
echo "cp ${EECACHE_PREBUILT} ${STANDALONE_SIMICS}/eecache_prebuilt.bin.ecc"
cp ${EECACHE_PREBUILT} ${STANDALONE_SIMICS}/eecache_prebuilt.bin.ecc
# DD2 EECACHE to be used for $PNOR_LAYOUT_SELECTED set as "P10" or "STANDALONE" as the default.
EECACHE_PREBUILT=`eval echo $(cat ${PROJECT_ROOT}/src/build/citest/etc/eecache_prebuilt_dd2)`
echo "cp ${EECACHE_PREBUILT} ${STANDALONE_SIMICS}/eecache_prebuilt_dd2.bin.ecc"
cp ${EECACHE_PREBUILT} ${STANDALONE_SIMICS}/eecache_prebuilt_dd2.bin.ecc
# EECACHE to be used for MACHINE set as "bonito"
EECACHE_PREBUILT=`eval echo $(cat ${PROJECT_ROOT}/src/build/citest/etc/eecache_prebuilt_bonito)`
echo "cp ${EECACHE_PREBUILT} ${STANDALONE_SIMICS}/eecache_prebuilt_bonito.bin.ecc"
cp ${EECACHE_PREBUILT} ${STANDALONE_SIMICS}/eecache_prebuilt_bonito.bin.ecc
exit 0
fi
# Nothing should land here
echo "**** Don't know how to do a non-standalone simsetup! ***"
echo "Try 'hb fipssetup' instead"
exit 1
}
hb_startsimics()
{
export_key_variables
# Dynamically check config file if secureboot enabled build occurred and
# set mode accordingly
if [[ -f ${PROJECT_ROOT}/obj/genfiles/config.h ]]; then
if cat ${PROJECT_ROOT}/obj/genfiles/config.h | grep -q "CONFIG_SECUREBOOT 1"; then
if [ ! -z "${DISABLE_SECUREBOOT}" ]; then
echo "Secureboot is disabled via DISABLE_SECUREBOOT env var"
else
echo "In secure mode"
fi
else
export DISABLE_SECUREBOOT="1"
echo "In unsecure mode"
fi
else
echo "File DNE ${PROJECT_ROOT}/obj/genfiles/config.h"
exit 1
fi
# Starting Simics for P10 Standalone without ODE SB
if [[ $HB_STANDALONE -eq 1 ]] && [[ $PNOR_LAYOUT_SELECTED != "FSP" ]]; then
STANDALONE_SIMICS=${PROJECT_ROOT}/standalone/simics
# Env. vars. for startup.simics and hb-tools scripts
export HBBLPATH=${PROJECT_ROOT}/standalone/pnor/hbbl.bin
export HBICORE_EXTENDED_PATH=${PROJECT_ROOT}/standalone/staging/hbicore_extended.bin
export PATH=${STANDALONE_SIMICS}/hbfw/:${PATH}
if [[ ! -d ${STANDALONE_SIMICS} ]] || [[ ! -d ${STANDALONE_SIMICS}/hbfw ]]; then
echo "Missing Simics files, please run \"hb simsetup\"."
exit 1
fi
PPE_SUBREPO_TOP_COMMIT=$(git submodule status src/build/tools/extern/ppe | awk '{print $1}' | sed 's/^-//')
PPE_CACHE_DIR=${HOSTBOOT_ENVIRONMENT}/prime/ppe/master-p10/${PPE_SUBREPO_TOP_COMMIT}
# Pick up cached SBE images unless they don't exist or we were told to rebuild them locally
if [[ "$HB_FAST_PRIME" ]] && [[ -d ${PPE_CACHE_DIR} ]] && [[ -z "$HB_FORCE_REBUILD_SBE" ]]; then
# Pick up pre-built SBE images
SBE_STANDALONE_IMG=${PPE_CACHE_DIR}/sbe_seeprom_p10.bin.ecc
SBE_STANDALONE_MEASURE_IMG=${PPE_CACHE_DIR}/sbe_measurement_p10.bin.ecc
SBE_STANDALONE_OTPROM_IMG=${PPE_CACHE_DIR}/sbe_otprom_p10.bin
SBE_SCRIPT_TO_RUN=${PPE_CACHE_DIR}/sbeTest/sbe_startup.simics
SBE_SCRIPT_PATH=${PPE_CACHE_DIR}/sbeTest/
else
SBE_STANDALONE_IMG=${PROJECT_ROOT}/standalone/simics/import/boot_roms/sbe_seeprom_p10.bin.ecc
SBE_STANDALONE_MEASURE_IMG=${PROJECT_ROOT}/standalone/simics/import/boot_roms/sbe_measurement_p10.bin.ecc
SBE_STANDALONE_OTPROM_IMG=${PROJECT_ROOT}/standalone/simics/import/boot_roms/sbe_otprom_p10.bin
SBE_SCRIPT_TO_RUN=${PROJECT_ROOT}/standalone/simics/targets/p10_standalone/sbeTest/sbe_startup.simics
SBE_SCRIPT_PATH=${PROJECT_ROOT}/standalone/simics/targets/p10_standalone/sbeTest/
fi
if [[ ! -f ${SBE_STANDALONE_IMG} ]]; then
echo "File does not exist: SBE_STANDALONE_IMG"
echo "Please make sure to run \"hb prime\" to create it."
exit 1
fi
if [[ ! -f ${SBE_STANDALONE_MEASURE_IMG} ]]; then
echo "File does not exist: SBE_STANDALONE_MEASURE_IMG"
echo "Please make sure to run \"hb prime\" to create it."
exit 1
fi
if [[ ! -f ${SBE_STANDALONE_OTPROM_IMG} ]]; then
echo "File does not exist: SBE_STANDALONE_OTPROM_IMG"
echo "Please make sure to run \"hb prime\" to create it."
exit 1
fi
if [[ ! -f ${SBE_SCRIPT_TO_RUN} ]]; then
echo "File does not exist: SBE_SCRIPT_TO_RUN"
echo "Please make sure to run \"hb prime\" to create it."
exit 1
fi
if [[ ! -d ${SBE_SCRIPT_PATH} ]]; then
echo "Dir does not exist: SBE_SCRIPT_PATH"
echo "Please make sure to run \"hb prime\" to create it."
exit 1
fi
# Run Simics
STARTSIMCMD=(./runsim -m ${MACHINE})
if [ -n "${HB_SIMICS_CHECKPOINT}" ]; then
STARTSIMCMD+=( -c ${HB_SIMICS_CHECKPOINT} )
fi
STARTSIMCMD+=(hb_script_to_run=${STANDALONE_SIMICS}/hbfw/startup.simics)
STARTSIMCMD+=(pnor_img=${PROJECT_ROOT}/standalone/pnor/${PNOR_LAYOUT_SELECTED}.pnor)
STARTSIMCMD+=(xive_gen=2)
STARTSIMCMD+=(bmc_files=/host/genEecache:/usr/local/share/hostfw/running/81e00679.lid)
STARTSIMCMD+=(eecacheEcc=1)
STARTSIMCMD+=(dimm_height=\"4U\")
if [ -z "${HB_USE_ODYSSEY}" ]; then
echo "Using DDR4/Explorer DDIMMs"
else
echo "Using DDR5/Odyssey DDIMMs"
STARTSIMCMD+=(dimm_type=ody)
fi
if [ -n "${STANDALONE_TEST_DD1+set}" ]; then
STARTSIMCMD+=(dd_major_ver=1)
fi
# Odyssey params/images
SBE_ODY_DIR=${PROJECT_ROOT}/src/build/tools/extern/sbe/
ODY_SBE_DEBUG_DIR=${STANDALONE_SIMICS}/odysseylab_debug_files_tools/
# Pick up cached Odyssey images unless we were told to rebuild them locally
if [[ "${HB_FAST_PRIME}" ]] && [[ -z "$HB_FORCE_REBUILD_ODY" ]];
then
# Pick up pre-built images
export SBE_SUBREPO_TOP_COMMIT=$(git submodule status $SBE_ODY_DIR | awk '{print $1}' | sed 's/^-//')
export ODYSSEY_SBE_IMAGES=${HOSTBOOT_ENVIRONMENT}/prime/sbe/main/$SBE_SUBREPO_TOP_COMMIT/
if [ -d ${ODYSSEY_SBE_IMAGES} ]; then
ODY_SBE_DEBUG_DIR=${ODYSSEY_SBE_IMAGES}/odysseylab_debug_files_tools/
else
unset ODYSSEY_SBE_IMAGES
fi
fi
# Temporary hack until we cache the correct images
if [ ! -d ${ODY_SBE_DEBUG_DIR} ];
then
echo "No odysseylab found, using non-lab"
ODY_SBE_DEBUG_DIR=${STANDALONE_SIMICS}/odyssey_debug_files_tools/
if [ ! -d ${ODY_SBE_DEBUG_DIR} ];
then
ODY_SBE_DEBUG_DIR=${ODYSSEY_SBE_IMAGES}/odyssey_debug_files_tools/
if [ ! -d ${ODY_SBE_DEBUG_DIR} ]; then
ODY_SBE_DEBUG_DIR=${HOSTBOOT_ENVIRONMENT}/prime/sbe/main/latest/odyssey_debug_files_tools/
fi
fi
fi
if [ -n "${ODYSSEY_SBE_IMAGES}" ]; then
ODYSSEY_SROM_IMG=${ODYSSEY_SBE_IMAGES}/odyssey_srom_DD1.bin
ODYSSEY_OTPROM_IMG=${ODYSSEY_SBE_IMAGES}/odyssey_otprom_DD1.bin
ODYSSEY_PNOR_IMG=${ODYSSEY_SBE_IMAGES}/odyssey_nor_DD1.img.ecc
fi
if [ -z $ODYSSEY_SROM_IMG ]; then
ODYSSEY_SROM_IMG=${SBE_ODY_DIR}/simics/sbe/odyssey_standalone/images/odyssey_srom_DD1.bin
fi
if [[ ! -f $ODYSSEY_SROM_IMG ]]; then
echo "File does not exist: ODYSSEY_SROM_IMG"
echo "Please make sure to run \"hb prime\" to create it."
exit 1
fi
if [ -z $SPPE_SCRIPTS_PATH ]; then
SPPE_SCRIPTS_PATH=/sbe/odyssey_standalone/sbeTest/
fi
if [ -z $ODYSSEY_OTPROM_IMG ]; then
ODYSSEY_OTPROM_IMG=${SBE_ODY_DIR}/images/odyssey/onetime/otprom/odyssey_otprom_DD1.bin
fi
if [[ ! -f $ODYSSEY_OTPROM_IMG ]]; then
echo "File does not exist: ODYSSEY_OTPROM_IMG"
echo "Please make sure to run \"hb prime\" to create it."
exit 1
fi
if [ -z $ODYSSEY_PNOR_IMG ]; then
ODYSSEY_PNOR_IMG=${SBE_ODY_DIR}/simics/sbe/odyssey_standalone/images/odyssey_nor_DD1.img.ecc
fi
if [[ ! -f $ODYSSEY_PNOR_IMG ]]; then
echo "File does not exist: ODYSSEY_PNOR_IMG"
echo "Please make sure to run \"hb prime\" to create it."
exit 1
fi
# Get python user site path that SBE simics scripts require
PYTHON_USER_PACKAGE_PATH=$(python3 -m site --user-site)
# We don't want to run SBE in VPO mode; pass the SBE image to
# simics in non-VPO mode
if [ -z "${VPO_COMPILE}" ]; then
STARTSIMCMD+=(sbe_seeprom_img=${SBE_STANDALONE_IMG})
STARTSIMCMD+=(sbe_meas_seeprom_img=${SBE_STANDALONE_MEASURE_IMG})
STARTSIMCMD+=(sbe_otprom_img=${SBE_STANDALONE_OTPROM_IMG})
STARTSIMCMD+=(sbe_script_to_run=${SBE_SCRIPT_TO_RUN})
STARTSIMCMD+=(sbe_scripts_path=${SBE_SCRIPT_PATH})
STARTSIMCMD+=(enable_lpc_console=TRUE)
STARTSIMCMD+=(fused_core=TRUE)
STARTSIMCMD+=(num_sockets=1)
#@FIXME-RTC:254475-Remove once this works everywhere
STARTSIMCMD+=(hb_ignoresmpfail=0)
if [ -n "${HB_USE_ODYSSEY}" ]; then
STARTSIMCMD+=(sbe_project_type=odyssey)
STARTSIMCMD+=(sbe_image_type=pnor)
STARTSIMCMD+=(paths_to_add=$ODY_SBE_DEBUG_DIR,$ODY_SBE_DEBUG_DIR/simics,$PYTHON_USER_PACKAGE_PATH)
STARTSIMCMD+=(odyssey_otprom_img=$ODYSSEY_OTPROM_IMG)
STARTSIMCMD+=(odyssey_pnor_img=$ODYSSEY_PNOR_IMG)
STARTSIMCMD+=(odyssey_srom_img=$ODYSSEY_SROM_IMG)
STARTSIMCMD+=(run_till_boot=FALSE)
STARTSIMCMD+=(min_dimm=TRUE)
fi
else
# This allows to not run SBE automatically
STARTSIMCMD+=(sbe_boot_mem=pibmem)
fi
# If '-nre' was passed in as a flag, then do not vexec
# also, if $POOL is defined, this indicates are already in
# a vexec shell so do not vexec
if [ "$*" = "-nre" ] || [ ! -z ${POOL} ]; then
VEXEC_STR=""
else
VEXEC_STR=" vexec"
fi
# For GCOV, tell simics to enable the larger backing cache.
if [[ "$HOSTBOOT_PROFILE" || "$SIMICS_MORECACHE" ]] ; then
# enable more cores for 16MB backing cache
export SIMICS_MORECACHE=1
STARTSIMCMD+=(num_cores_per_chip=8)
else
# Use more cache by default until we sort out our boot performance
STARTSIMCMD+=(num_cores_per_chip=8)
fi
# Create a file (simcmd) to run under vexec
echo "cd ${STANDALONE_SIMICS}" > ${STANDALONE_SIMICS}/simcmd
echo "${STARTSIMCMD[@]}" >> ${STANDALONE_SIMICS}/simcmd
chmod +x ${STANDALONE_SIMICS}/simcmd
cat ${STANDALONE_SIMICS}/simcmd
${VEXEC_STR} ${STANDALONE_SIMICS}/simcmd
exit 0
fi
# Starting Simics when using an ODE SB
[ -z "${SANDBOXBASE}" ] && echo "Missing SANDBOXBASE." && exit 1
[ -z "${PROJECT_ROOT}" ] && echo "Missing PROJECT_ROOT." && exit 1
# Env. vars. for startup.simics and hb-tools scripts
export HBBLPATH=${SANDBOXBASE}/obj/ppc/hbfw/img/hbbl.bin
export HBICORE_EXTENDED_PATH=${SANDBOXBASE}/src/hbfw/img/hostboot_extended.bin
if [ ! -d "${SANDBOXBASE}" ]; then
echo "Sandbox does not exist. Create with 'hb simsetup."
exit 1
fi
SBDRIVER=`cat ${SANDBOXBASE}/rc_files/sb.conf | \
grep "backing_build" | awk '{ print $3 }'`
DRIVER=`cat ${PROJECT_ROOT}/src/build/citest/etc/bbuild`
if [ ${SBDRIVER} != ${DRIVER} ]; then
echo "Driver mismatch between sandbox and src/build/citest/etc/bbuild."
echo "Sandbox at ${SBDRIVER}"
echo "Update sandbox with 'hb simsetup'."
exit 1
fi
execute_in_sandbox \
"start_simics -machine ${MACHINE} ${SIMICSOPTIONS} $*" "ppc"
}
hb_rsync_call()
{
if [ -z "${RSYNCHOST}" ]; then
rsync -av --delete ${PROJECT_ROOT}/ ${RSYNCDIR}
else
rsync -zav --delete ${PROJECT_ROOT}/ ${RSYNCHOST}:${RSYNCDIR}
fi
}
hb_rsync_helper()
{
if [ -n "${RSYNCHOST}" ]; then
echo -n "${RSYNCHOST}:"
fi
echo "${RSYNCDIR} does not look like a hostboot repo and is not empty"
read -r -p "rsync will clear out ${RSYNCDIR} then copy files into it, is this correct? [y/N] " response
case $response in
[yY][eE][sS]|[yY])
hb_rsync_call
;;
*)
echo "hb rsync cancelled"
;;
esac
}
hb_rsync()
{
[ -z "${PROJECT_ROOT}" ] && echo "Missing PROJECT_ROOT." && exit 1
[ -z "${RSYNCDIR}" ] && echo "Missing RSYNCDIR." && exit 1
# Parse arguments
case $1 in
"--force")
hb_rsync_call
;;
*)
# Check destination directory, if not empty check if looks like
# a hostboot repository, otherwise proceed
# If remote directory
if [ -n "${RSYNCHOST}" ]; then
if [ "$(ssh ${RSYNCHOST} 'if [ "$(ls -A '${RSYNCDIR}')" ]; then echo 1; fi')" ]; then
# Remote check for hb and .git
if [ "$(ssh ${RSYNCHOST} 'if [ -f '${RSYNCDIR}/hb' -a -d '${RSYNCDIR}/.git' ]; then echo 1; fi')" ]; then
hb_rsync_call;
else
hb_rsync_helper;
fi
else
hb_rsync_call;
fi
# Local check for emptiness
elif [ "$(ls -A ${RSYNCDIR})" ]; then
# Local check for hb and .git
if [ -f ${RSYNCDIR}/hb -a -d ${RSYNCDIR}/.git ]; then
hb_rsync_call;
else
hb_rsync_helper;
fi
else
hb_rsync_call;
fi
esac
}
hb_objsizes()
{
[ -z "${PROJECT_ROOT}" ] && echo "Missing PROJECT_ROOT." && exit 1
echo "Object,Text Size,RO Data Size,Data Size"
objdump -h ${PROJECT_ROOT}/img/*.elf ${PROJECT_ROOT}/img/*.so | \
grep -e ".elf" -e ".so:" -e ".text " -e ".rodata" -e ".data " | \
sed "s/.so:.*/.so/" | \
sed "s/.elf:.*/.elf/" | \
sed 's/.*\.text *\([0-9a-f]*\).*/,0x\1/' | \
sed 's/.*\.rodata *\([0-9a-f]*\).*/,0x\1/' | \
sed 's/.*\.data *\([0-9a-f]*\).*/,0x\1/' | \
sed "N ; N ; N ; s/\n//g" | \
xargs -n1 perl -e 'printf "%s,%d,%d,%d\n", map { 0 == hex $_ ? $_ : hex $_ } split /\,/,shift;' | \
sed "s/.*\///"
}
hb_copyright_check()
{
if git log -n1 | grep -c git-subtree-dir; then
echo "Skipping copyright check on commits containing git-subtree-dir tag"
else
git diff HEAD~1 --name-only | xargs addCopyright validate
fi
}
hb_errlparser()
{
[ -z "${SANDBOXBASE}" ] && echo "Missing SANDBOXBASE." && exit 1
[ -z "${SANDBOXROOT}" ] && echo "Missing SANDBOXROOT." && exit 1
[ -z "${SANDBOXNAME}" ] && echo "Missing SANDBOXNAME." && exit 1
[ -z "${PROJECT_ROOT}" ] && echo "Missing PROJECT_ROOT." && exit 1
DRIVER=`cat ${PROJECT_ROOT}/src/build/citest/etc/bbuild`
# sanity checks
if [ ! -f ${DRIVER}/src/makefile ]; then
echo "Cannot reach backing build: $DRIVER. You may need tokens."
exit 1
fi
${PROJECT_ROOT}/src/build/citest/build-errl-parsers
return $?
}
hb_cachesync()
{
[ -z "${PROJECT_ROOT}" ] && echo "Missing PROJECT_ROOT." && exit 1
rsync -av ${HOSTBOOT_ENVIRONMENT}/.binary_cache/ \
${PROJECT_ROOT}/.git/hb_cache
failure=0
for files in ${PROJECT_ROOT}/.git/hb_cache/data/*; do
echo "`basename $files` $files" | sha1sum --check >> /dev/null
if [ $? -ne 0 ]; then
echo "Failed SHA1 verification! $files"
failure=1
fi
done
exit $failure
}
hb_cacheadd()
{
[ -z "${PROJECT_ROOT}" ] && echo "Missing PROJECT_ROOT." && exit 1
CACHE_PATH=${HOSTBOOT_ENVIRONMENT}/.binary_cache/
FILE=$1
shift
if [ $FILE == "--local" ]; then
echo "Adding as local copy."
CACHE_PATH=${PROJECT_ROOT}/.git/hb_cache/
FILE=$1
shift
fi
MESSAGE=$*
[ ! -e "${FILE}" ] && echo "File $FILE does not exist." && exit 1
[ -z "${MESSAGE}" ] && echo "No message given." && exit 1
FILE_BASE=`basename $FILE`
SHA1SUM=`sha1sum -b $FILE | sed 's/ .*//'`
echo $FILE $SHA1SUM
cp $FILE $CACHE_PATH/data/$SHA1SUM
echo $SHA1SUM : `whoami` : `date` : $MESSAGE \
>> $CACHE_PATH/files/$FILE_BASE
echo "Added $FILE_BASE as $SHA1SUM"
}
hb_flags()
{
echo "Environment Variables that influence how Hostboot builds and simulates"
echo " "
echo "= Compile Options ="
echo "BUILD_VERBOSE : Print build commands before running them (="$BUILD_VERBOSE")"
echo "HOSTBOOT_DEBUG : Enable debug output, including TRACD, see src/build/mkrules/env.mk (="$HOSTBOOT_DEBUG")"
echo " "
echo "= Prime Options ="
echo "HB_FAST_PRIME (='"$HB_FAST_PRIME"'): Enable all prime optimizations - do not build submodules locally and pick the cached submodule images"
echo "HB_FORCE_REBUILD_EKB (='"$HB_FORCE_REBUILD_EKB"'): Force rebuild of hcode submodule regardless of existing images"
echo "HB_FORCE_REBUILD_ODY (='"$HB_FORCE_REBUILD_ODY"'): Force rebuild of odyssey sbe submodule regardless of existing images"
echo "HB_FORCE_REBUILD_SBE (='"$HB_FORCE_REBUILD_SBE"'): Force rebuild of proc ppe submodule regardless of existing images"
echo "HB_NFS_DIR (="$HB_NFS_DIR"): Copies FSP patch data after prime"
echo "HB_PRESERVE_SUBMODULES (='"$HB_PRESERVE_SUBMODULES"'): Set to 1 to skip submodule updates, i.e. preserves current tree"
echo "HB_SKIP_GEN_HCODE (='"$HB_SKIP_GEN_HCODE"'): Will not attempt to rebuild the ekb submodule (included in HB_FAST_PRIME)"
echo "ODYSSEY_SBE_IMAGES (='"$ODYSSEY_SBE_IMAGES"'): Point the prime to a dir with pre-compiled SPPE Odyssey images. Required images:"
echo " odyssey_srom_DD1.bin, odyssey_otprom_DD1.bin, odyssey_nor_DD1.img.ecc"
echo "PARSE_RCDL_STRICT (='"$PARSE_RCDL_STRICT"'): Validates all obj/genfiles/HB_BCxxRcdl_* files with RcdlSniffer2Perl"
echo " "
echo "= Simics Options ="
echo "HB_BREAK_ON_ERROR (='"$HB_BREAK_ON_ERROR"'): Halts simics if HB hits an exception"
echo "HB_FORCE_1PROC (='"$HB_FORCE_1PROC"'): Force single-processor mode"
echo "HB_SKIP_EECACHE (='"$HB_SKIP_EECACHE"'): Do not preload PNOR with prebuilt eecache contents"
echo "HB_SIMICS_CHECKPOINT (='"$HB_SIMICS_CHECKPOINT"'): Loads standalone simics with the supplied checkpoint."
echo "HB_USE_ODYSSEY (='"$HB_USE_ODYSSEY"'): Use DDR5/Odyssey DDIMMs"
echo " "
}
if [ 0 -eq $# ]; then
hb_helptext
exit 1
fi
FIRST_PARAM=$1
shift
case ${FIRST_PARAM} in
workon)
hb_workon $*
;;
prime)
hb_prime $*
;;
buildmodules)
hb_buildmodules $*
;;
fipssetup)
hb_fipssetup $*
;;
simsetup)
hb_simsetup $*
;;
startsimics)