-
Notifications
You must be signed in to change notification settings - Fork 27
/
bfcfg
executable file
·3275 lines (2852 loc) · 112 KB
/
bfcfg
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
# Copyright (c) 2020, Mellanox Technologies
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and documentation are those
# of the authors and should not be interpreted as representing official policies,
# either expressed or implied, of the FreeBSD Project.
# shellcheck disable=SC2059
true
${BFDBG}
TMP_DIR=$(mktemp -d)
trap "rm -rf $TMP_DIR" EXIT
trap "rm -rf $TMP_DIR; exit 1" TERM INT
bfcfg_version=4.3
bfcfg_rc=0
cfg_file=/etc/bf.cfg
log_file=/tmp/bfcfg.log
# Config dump levels (the higher the number the more information is dumped).
# dump_level defaults to an empty string and is set based on bfcfg input arguments.
DUMP_LEVEL_NONE=0
DUMP_LEVEL_DEFAULT=1
DUMP_LEVEL_EXTRA=2
DUMP_LEVEL_MAX=${DUMP_LEVEL_EXTRA}
dump_level=
mlxmkcap=/lib/firmware/mellanox/boot/capsule/scripts/mlx-mkcap
bfcf_acpi_table=/sys/firmware/acpi/tables/BFCF
efivars=/sys/firmware/efi/efivars
sys_cfg_sysfs=${efivars}/BfSysCfg-9c759c02-e5a3-45e4-acfc-c34a500628a6
redfish_cfg_sysfs=${efivars}/BfRedfish-ce3e5882-6770-4d5e-aa45-90f909da2446
redfish_state_cfg_sysfs=${efivars}/BfRedfishState-ce3e5882-6770-4d5e-aa45-90f909da2446
sb_state_sysfs=${efivars}/SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c
sb_setup_mode_sysfs=${efivars}/SetupMode-8be4df61-93ca-11d2-aa0d-00e098032b8c
efi_global_var_guid=8be4df61-93ca-11d2-aa0d-00e098032b8c
efi_bfcfg_var_guid=487ff588-fb71-4b19-9100-ebe067aa1af0
efi_vlan_var_guid=9e23d768-d2f3-4366-9fc3-3a7aba864374
rshim_efi_mac_sysfs=${efivars}/RshimMacAddr-${efi_global_var_guid}
pxe_dhcp_class_id_sysfs=${efivars}/DhcpClassId-${efi_global_var_guid}
bf_bundle_version_sysfs=${efivars}/BfBundleVer-${efi_bfcfg_var_guid}
sb_custom_mode_sysfs=${efivars}/BfCfgSbCustomMode-${efi_bfcfg_var_guid}
pass_settings_sysfs=${efivars}/BfCfgPassSettings-${efi_bfcfg_var_guid}
bf_modes_sysfs=${efivars}/BfCfgBfModes-${efi_bfcfg_var_guid}
mfg_sysfs_dir=/sys/bus/platform/devices/MLNXBF04:00/driver
if [ ! -e $mfg_sysfs_dir/oob_mac ]; then
mfg_sysfs_dir=/sys/bus/platform/devices/MLNXBF04:00
fi
oob_mac_sysfs=${mfg_sysfs_dir}/oob_mac
large_icm_sysfs=${mfg_sysfs_dir}/large_icm
ECHO=${ECHO:-echo}
log_msg()
{
echo "$@" >> ${log_file}
}
mfg_lock()
{
log_msg "mfg: lock the partition"
echo 1 > ${mfg_sysfs_dir}/mfg_lock 2>>${log_file}
}
delete_efi_var()
{
local in_efivarfs=$1
[ ${dump_level} -gt ${DUMP_LEVEL_NONE} ] && return
if [ -e "${in_efivarfs}" ]; then
log_msg "mfg: delete ${in_efivarfs}"
chattr -i ${in_efivarfs}
rm -f ${in_efivarfs}
fi
}
mfg_reset_deps()
{
# Cleanup configuration dependencies if needed
if [ ${has_sys_cfg} -eq 0 ]; then
# Delete SYS Config data
delete_efi_var "${sys_cfg_sysfs}"
fi
if [ ${has_redfish_cfg} -eq 0 ]; then
# Delete RDF Config
delete_efi_var "${redfish_cfg_sysfs}"
fi
}
mfg_sysfs_cfg()
{
local tmp_file=${TMP_DIR}/.bfcfg-mfg-data
local opn_sysfs=${mfg_sysfs_dir}/opn
local sku_sysfs=${mfg_sysfs_dir}/sku
local modl_sysfs=${mfg_sysfs_dir}/modl
local sn_sysfs=${mfg_sysfs_dir}/sn
local uuid_sysfs=${mfg_sysfs_dir}/uuid
local rev_sysfs=${mfg_sysfs_dir}/rev
local oob_efi_mac_sysfs=${efivars}/OobMacAddr-${efi_global_var_guid}
local mac_err opn_err mac
[ ${dump_level} -gt ${DUMP_LEVEL_NONE} ] && return
if [ -z "${MFG_OOB_MAC}" ] || [ -z "${MFG_OPN}" ] || [ -z "${MFG_SKU}" ] ||
[ -z "${MFG_MODL}" ] || [ -z "${MFG_SN}" ] || [ -z "${MFG_UUID}" ] ||
[ -z "${MFG_REV}" ] ; then
log_msg "mfg: skip mfg since one or more of the following are unspecified:"
log_msg "MFG_OOB_MAC, MFG_OPN, MFG_SKU, MFG_MODL, MFG_SN, MFG_UUID, MFG_REV"
return
fi
if [ -n "${MFG_OOB_MAC}" ] && [ -e "${oob_mac_sysfs}" ]; then
log_msg "mfg: OOB_MAC=${MFG_OOB_MAC}"
echo "${MFG_OOB_MAC}" > ${oob_mac_sysfs} 2>>${log_file}
mac_err=$?
if [ ${mac_err} -eq 0 ]; then
log_msg "mfg: oob_mac written"
# Update the MAC address in UEFI variable.
# Somehow 'printf' into the sysfs file doesn't always work, probably
# due to length check of each write. A temporary file is used here
# to workaround such issue.
mac="${MFG_OOB_MAC//:/\\x}"
mac="\\x07\\x00\\x00\\x00\\x${mac}"
printf "${mac}" > ${tmp_file}
chattr -i ${oob_efi_mac_sysfs} 2>/dev/null
cp ${tmp_file} ${oob_efi_mac_sysfs}
rm -f ${tmp_file}
else
log_msg "mfg: mac_err=${mac_err}"
return
fi
fi
if [ -n "${MFG_OPN}" ] && [ -e "${opn_sysfs}" ]; then
log_msg "mfg: OPN=${MFG_OPN}"
echo "${MFG_OPN}" > ${opn_sysfs} 2>>${log_file}
opn_err=$?
if [ ${opn_err} -eq 0 ]; then
log_msg "mfg: opn written"
else
log_msg "mfg: opn_err=${opn_err}"
return
fi
fi
if [ -n "${MFG_SKU}" ] && [ -e "${sku_sysfs}" ]; then
log_msg "mfg: SKU=${MFG_SKU}"
echo "${MFG_SKU}" > ${sku_sysfs} 2>>${log_file}
sku_err=$?
if [ ${sku_err} -eq 0 ]; then
log_msg "mfg: sku written"
else
log_msg "mfg: sku_err=${sku_err}"
return
fi
fi
if [ -n "${MFG_MODL}" ] && [ -e "${modl_sysfs}" ]; then
log_msg "mfg: MODL=${MFG_MODL}"
echo "${MFG_MODL}" > ${modl_sysfs} 2>>${log_file}
modl_err=$?
if [ ${modl_err} -eq 0 ]; then
log_msg "mfg: modl written"
else
log_msg "mfg: modl_err=${modl_err}"
return
fi
fi
if [ -n "${MFG_SN}" ] && [ -e "${sn_sysfs}" ]; then
log_msg "mfg: SN=${MFG_SN}"
echo "${MFG_SN}" > ${sn_sysfs} 2>>${log_file}
sn_err=$?
if [ ${sn_err} -eq 0 ]; then
log_msg "mfg: sn written"
else
log_msg "mfg: sn_err=${sn_err}"
return
fi
fi
if [ -n "${MFG_UUID}" ] && [ -e "${uuid_sysfs}" ]; then
log_msg "mfg: UUID=${MFG_UUID}"
echo "${MFG_UUID}" > ${uuid_sysfs} 2>>${log_file}
uuid_err=$?
if [ ${uuid_err} -eq 0 ]; then
log_msg "mfg: uuid written"
else
log_msg "mfg: uuid_err=${uuid_err}"
return
fi
fi
if [ -n "${MFG_REV}" ] && [ -e "${rev_sysfs}" ]; then
log_msg "mfg: REV=${MFG_REV}"
echo "${MFG_REV}" > ${rev_sysfs} 2>>${log_file}
rev_err=$?
if [ ${rev_err} -eq 0 ]; then
log_msg "mfg: rev written"
else
log_msg "mfg: rev_err=${rev_err}"
return
fi
fi
mfg_lock
mfg_sysfs_cfg_done=1
mfg_reset_deps
}
mfg_cfg_set_bytes()
{
local out_file=$1
local name=$2
local offset=$3
local size=$4
local value=$5
[ ${dump_level} -gt ${DUMP_LEVEL_NONE} ] && return
if [ -n "${value}" ] && [ -f "${out_file}" ]; then
# Most of the fields are of type strings, thus check the number
# of characters per string. Only exception for the OOB MAC.
# The OOB MAC is stored in hex format; e.g., \xAA\xBB\xCC\xDD\xEE\xFF,
# total of 24 charcters
if [ ${#value} -gt ${size} ] && [ "${name}" != "MFG_OOB_MAC" ]; then
log_msg "mfg: ${name} exceeding max length ${size}"
return
elif [ ${#value} -gt 24 ] && [ "${name}" == "MFG_OOB_MAC" ]; then
log_msg "mfg: MFG_OOB_MAC exceeding max length 6 bytes"
return
else
printf "${value}" | dd of="${out_file}" seek="${offset}" bs=1 count=${size} conv=notrunc 2> /dev/null
err=$?
if [ ${err} -eq 0 ]; then
log_msg "mfg: ${name} written, value=${value}"
else
log_msg "mfg: modl_err=${err}"
return
fi
has_cfg=1
fi
fi
}
copy_efi_var_data()
{
local out_file=$1
local in_efivarfs=$2
local offset=$3
local size=$4
[ ${dump_level} -gt ${DUMP_LEVEL_NONE} ] && return
if [ -e "${in_efivarfs}" ] && [ -f "${out_file}" ]; then
chattr -i ${in_efivarfs}
# Copy the EFI variable data, skip variable header (4 bytes)
dd if="${in_efivarfs}" of="${out_file}" seek="${offset}" skip=4 bs=1 count=${size} conv=notrunc 2> /dev/null
err=$?
if [ ${err} -eq 0 ]; then
log_msg "mfg: ${in_efivarfs} data written to ${out_file}"
else
log_msg "mfg: failed to write ${in_efivarfs} data to ${out_file}"
log_msg "mfg: modl_err=${err}"
return
fi
fi
}
mfg_cfg_set_bf_modes()
{
local out_file=$1
local name=$2
local offset=$3
local size=$4
local value=$5
local bin_value
[ ${dump_level} -gt ${DUMP_LEVEL_NONE} ] && return
if [ -z "${value}" ] || [ ! -f "${out_file}" ]; then
return
fi
#
# This must be consistent with the UEFI PMI library
# implementation.
#
if [ "${name}" == "MFG_PLAT_MODE" ]; then
if [ "${value^^}" == "DPU" ]; then
bin_value='\x01'
elif [ "${value^^}" == "NIC" ]; then
bin_value='\x02'
else
log_msg "mfg: ${name}, unsupported value ${value}"
return
fi
printf "${bin_value}" | dd of="${out_file}" seek="${offset}" bs=1 count=${size} conv=notrunc 2> /dev/null
err=$?
if [ ${err} -eq 0 ]; then
log_msg "mfg: ${name}=${value}"
else
log_msg "mfg: modl_err=${err}"
return
fi
has_cfg=1
else
log_msg "mfg: ${name} is not supported"
return
fi
}
mfg_cfg_to_bin()
{
local bin_file=$1
[ -f "${bin_file}" ] && rm -f ${bin_file}
# Create empty MFG blob; it contains MFG data and MFG extended data
# and occupies 16 pages of 256 bytes within the EEPROM
#
# Layout:
# MFG Data (off: 0, len: 256 bytes)
# MFG Extension (off: 256, len:2048 bytes)
# SYS Config (off:2304, len: 64 bytes)
# RDF Config (off:2368, len: 32 bytes)
# BF Modes (off:2400, len: 4 bytes)
# Reserved (off:2404, len:1692 bytes)
#
dd if=/dev/zero of=${bin_file} count=16 bs=256
has_cfg=0
[ ! -f "${bin_file}" ] && return
if [ -z "${MFG_OOB_MAC}" ] || [ -z "${MFG_OPN}" ] || [ -z "${MFG_SKU}" ] ||
[ -z "${MFG_MODL}" ] || [ -z "${MFG_SN}" ] || [ -z "${MFG_UUID}" ] ||
[ -z "${MFG_REV}" ] ; then
log_msg "mfg: bin: skip mfg since one or more of the following are unspecified:"
log_msg "MFG_OOB_MAC, MFG_OPN, MFG_SKU, MFG_MODL, MFG_SN, MFG_UUID, MFG_REV"
elif [ ${mfg_sysfs_cfg_done} -eq 0 ]; then
#
# MFG Layout (1x 256B)
#
# OOB_MAC (off: 0, len: 8 bytes)
# OPN (off: 8, len:24 bytes)
# SKU (off: 32, len:24 bytes)
# MODL (off: 56, len:24 bytes)
# SN (off: 80, len:24 bytes)
# UUID (off:104, len:40 bytes)
# REV (off:144, len: 8 bytes)
mfg_cfg_set_bytes ${bin_file} "MFG_OOB_MAC" 0 8 "\\x${MFG_OOB_MAC//:/\\x}"
mfg_cfg_set_bytes ${bin_file} "MFG_OPN" 8 24 "${MFG_OPN}"
mfg_cfg_set_bytes ${bin_file} "MFG_SKU" 32 24 "${MFG_SKU}"
mfg_cfg_set_bytes ${bin_file} "MFG_MODL" 56 24 "${MFG_MODL}"
mfg_cfg_set_bytes ${bin_file} "MFG_SN" 80 24 "${MFG_SN}"
mfg_cfg_set_bytes ${bin_file} "MFG_UUID" 104 80 "${MFG_UUID}"
mfg_cfg_set_bytes ${bin_file} "MFG_REV" 144 8 "${MFG_REV}"
# Append MFG configuration dependenices, if needed.
if [ ${has_cfg} -eq 1 ]; then
if [ ${has_sys_cfg} -eq 1 ]; then
# Copy SYS Config data
copy_efi_var_data ${bin_file} "${sys_cfg_sysfs}" 2304 64
fi
if [ ${has_redfish_cfg} -eq 1 ]; then
# Copy RDF Config
copy_efi_var_data ${bin_file} "${redfish_cfg_sysfs}" 2368 32
fi
fi
elif [ ${mfg_sysfs_cfg_done} -eq 1 ]; then
log_msg "mfg: bin: skip mfg since configured via sysfs"
fi
if [ -z "${MFG_SYS_MFR}" ] && [ -z "${MFG_SYS_PDN}" ] && [ -z "${MFG_SYS_VER}" ] &&
[ -z "${MFG_BSB_MFR}" ] && [ -z "${MFG_BSB_PDN}" ] && [ -z "${MFG_BSB_VER}" ] &&
[ -z "${MFG_BSB_SN}" ] ; then
log_msg "mfg: bin: skip mfg extension since none of the following are specified:"
log_msg "MFG_SYS_MFR, MFG_SYS_PDN, MFG_SYS_VER, MFG_BSB_MFR, MFG_BSB_PDN, MFG_BSB_VER, MFG_BSB_SN"
else
#
# MFG Extension Layout (8x 256B)
#
# SYS_MFR (off: 0 + 256, len:24 bytes)
# SYS_PDN (off: 24 + 256, len:24 bytes)
# SYS_VER (off: 48 + 256, len:512 bytes)
# BSB_MFR (off:560 + 256, len:24 bytes)
# BSB_PDN (off:584 + 256, len:24 bytes)
# BSB_VER (off:608 + 256, len:24 bytes)
# BSB_SN (off:632 + 256, len:24 bytes)
mfg_cfg_set_bytes ${bin_file} "MFG_SYS_MFR" 256 24 "${MFG_SYS_MFR}"
mfg_cfg_set_bytes ${bin_file} "MFG_SYS_PDN" 280 24 "${MFG_SYS_PDN}"
mfg_cfg_set_bytes ${bin_file} "MFG_SYS_VER" 304 512 "${MFG_SYS_VER}"
mfg_cfg_set_bytes ${bin_file} "MFG_BSB_MFR" 816 24 "${MFG_BSB_MFR}"
mfg_cfg_set_bytes ${bin_file} "MFG_BSB_PDN" 840 24 "${MFG_BSB_PDN}"
mfg_cfg_set_bytes ${bin_file} "MFG_BSB_VER" 864 24 "${MFG_BSB_VER}"
mfg_cfg_set_bytes ${bin_file} "MFG_BSB_SN" 888 24 "${MFG_BSB_SN}"
fi
if [ -n "${MFG_PLAT_MODE}" ]; then
#
# BF Modes (4 Bytes)
#
# SYS_IN_CPU_MODEL (off: 2400, len:1 byte)
# MFG_HOST_PRIV_MODE (off: 2401, len:1 byte)
# MFG_PLAT_MODE (off: 2402, len:1 byte)
#
# For now, support platform mode only. If needed enhance it
# to support 'Internal CPU Model' and 'Host Privilege Level'.
mfg_cfg_set_bf_modes ${bin_file} "MFG_PLAT_MODE" 2402 1 "${MFG_PLAT_MODE}"
fi
if [ ${has_cfg} -eq 0 ]; then
log_msg "mfg: bin: configuration unspecified or incomplete. Skip binary generation."
rm -f ${bin_file}
return
else
log_msg "mfg: bin: configuration written to ${bin_file}"
fi
}
mfg_cfg_bin_to_cap()
{
local bin_file=$1
local cap_file=$2
mfg_cfg_to_bin ${bin_file}
has_bin=0
[ -f "${bin_file}" ] && has_bin=1
if [ ${has_bin} -eq 0 ]; then
log_msg "mfg: capsule: configuration blob not found. Skip capsule generation"
return
fi
if command -v python >/dev/null ; then
${mlxmkcap} --cfg-data ${bin_file} ${cap_file}
if [ $? -eq 0 ]; then
log_msg "mfg: capsule: file created at ${cap_file}"
else
log_msg "mfg: capsule: failed to create capsule file"
return
fi
else
# BFB might be missing commands and modules needed to generate
# the EFI capsule, thus push the bin file content to the payload
# of the pregenerated capsule file.
dummy_cap=/lib/firmware/mellanox/boot/capsule/.efi_bfcfg.cap
bin_size=$(stat -c%s ${bin_file})
if [ ! -f "${dummy_cap}" ]; then
log_msg "mfg: capsule: missing artifacts. Skip capsule generation"
return
fi
cp -f ${dummy_cap} ${cap_file}
# Skip the EFI capsule header; the header remains unchanged.
# Re-write the payload starting from offset A8 (168).
dd if="${bin_file}" of="${cap_file}" seek=168 bs=1 count=${bin_size} conv=notrunc 2> /dev/null
if [ $? -eq 0 ]; then
log_msg "mfg: capsule: payload updated"
log_msg "mfg: capsule: file created at ${cap_file}"
else
log_msg "mfg: capsule: failed to update capsule payload"
rm -f ${cap_file}
return
fi
fi
}
mfg_cap_cfg()
{
local bin_file=${TMP_DIR}/.bfcfg-mfg.bin
local cap_file=${TMP_DIR}/.bfcfg-mfg.cap
[ ${dump_level} -gt ${DUMP_LEVEL_NONE} ] && return
mfg_cfg_bin_to_cap ${bin_file} ${cap_file}
has_cap=0
[ -f "${cap_file}" ] && has_cap=1
if [ ${has_cap} -eq 0 ]; then
log_msg "mfg: update: capsule file not found. Skip capsule update."
return
fi
#
# MFG capsule must be applied first, before secure boot capsule
# otherwise the signature verification would fail.
#
# Note that capsules are sorted by name and processed in order.
# Thus it is important to get the MFG capsule executed first and
# the capsule file name starts with '.'; it is not expected that
# the remaining capsule files generated outside of bfcfg command
# would have the '.' prefix in the filename.
#
bfrec --capsule ${cap_file} 2>&1 > /dev/null
if [ $? -eq 0 ]; then
log_msg "mfg: update: MFG will be updated via capsule"
else
log_msg "mfg: update: failed to update MFG via capsule"
fi
rm -f ${bin_file} ${cap_file}
}
mfg_cfg()
{
# Update the MFG fields with corresponding EFI variables
local oob_mac=${efivars}/BfCfgOobMac-${efi_bfcfg_var_guid}
local opn_sysfs=${efivars}/BfCfgOpn-${efi_bfcfg_var_guid}
local sku_sysfs=${efivars}/BfCfgSku-${efi_bfcfg_var_guid}
local modl_sysfs=${efivars}/BfCfgModl-${efi_bfcfg_var_guid}
local sn_sysfs=${efivars}/BfCfgSn-${efi_bfcfg_var_guid}
local uuid_sysfs=${efivars}/BfCfgUuid-${efi_bfcfg_var_guid}
local rev_sysfs=${efivars}/BfCfgRev-${efi_bfcfg_var_guid}
# The efi variables have a 4 byte attribute header we won't display.
# If we fetch the data from the MFG, that header does not exist.
local skip_bytes_mfg=4
local skip_bytes_ext_mfg=4
if [ -z "${oob_mac}" ] || [ -z "${opn_sysfs}" ] || [ -z "${sku_sysfs}" ] ||
[ -z "${modl_sysfs}" ] || [ -z "${sn_sysfs}" ] || [ -z "${uuid_sysfs}" ] ||
[ -z "${rev_sysfs}" ] ; then
#
# One or more EFI variables representing MFG fields are empty
# Use the sysfs version of MFG fields
#
oob_mac=${mfg_sysfs_dir}/oob_mac
opn_sysfs=${mfg_sysfs_dir}/opn
sku_sysfs=${mfg_sysfs_dir}/sku
modl_sysfs=${mfg_sysfs_dir}/modl
sn_sysfs=${mfg_sysfs_dir}/sn
uuid_sysfs=${mfg_sysfs_dir}/uuid
rev_sysfs=${mfg_sysfs_dir}/rev
skip_bytes_mfg=0
fi
# Use the EFI variable for all extended MFG fields
local sys_mfr_sysfs=${efivars}/BfCfgSysMfr-${efi_bfcfg_var_guid}
local sys_pdn_sysfs=${efivars}/BfCfgSysPdn-${efi_bfcfg_var_guid}
local sys_ver_sysfs=${efivars}/BfCfgSysVer-${efi_bfcfg_var_guid}
local bsb_mfr_sysfs=${efivars}/BfCfgBsbMfr-${efi_bfcfg_var_guid}
local bsb_pdn_sysfs=${efivars}/BfCfgBsbPdn-${efi_bfcfg_var_guid}
local bsb_ver_sysfs=${efivars}/BfCfgBsbVer-${efi_bfcfg_var_guid}
local bsb_sn_sysfs=${efivars}/BfCfgBsbSn-${efi_bfcfg_var_guid}
if [ ${dump_level} -gt ${DUMP_LEVEL_NONE} ]; then
# W/A: always read the OOB MAC from kernel sysfs.
# Note: The 'BfCfgOobMac' EFI variable might contain incorrect
# OOB MAC.
[ -e "${oob_mac_sysfs}" ] && echo "mfg: MFG_OOB_MAC=$(cat ${oob_mac_sysfs} 2>/dev/null)"
[ -e "${opn_sysfs}" ] && echo "mfg: MFG_OPN=$(cat ${opn_sysfs} 2>/dev/null | sed "s/^.\{$skip_bytes_mfg\}//")"
[ -e "${sku_sysfs}" ] && echo "mfg: MFG_SKU=$(cat ${sku_sysfs} 2>/dev/null | sed "s/^.\{$skip_bytes_mfg\}//")"
[ -e "${modl_sysfs}" ] && echo "mfg: MFG_MODL=$(cat ${modl_sysfs} 2>/dev/null | sed "s/^.\{$skip_bytes_mfg\}//")"
[ -e "${sn_sysfs}" ] && echo "mfg: MFG_SN=$(cat ${sn_sysfs} 2>/dev/null | sed "s/^.\{$skip_bytes_mfg\}//")"
[ -e "${uuid_sysfs}" ] && echo "mfg: MFG_UUID=$(cat ${uuid_sysfs} 2>/dev/null | sed "s/^.\{$skip_bytes_mfg\}//")"
[ -e "${rev_sysfs}" ] && echo "mfg: MFG_REV=$(cat ${rev_sysfs} 2>/dev/null | sed "s/^.\{$skip_bytes_mfg\}//")"
[ -e "${sys_mfr_sysfs}" ] && echo "mfg: MFG_SYS_MFR=$(cat ${sys_mfr_sysfs} 2>/dev/null | sed "s/^.\{$skip_bytes_ext_mfg\}//")"
[ -e "${sys_pdn_sysfs}" ] && echo "mfg: MFG_SYS_PDN=$(cat ${sys_pdn_sysfs} 2>/dev/null | sed "s/^.\{$skip_bytes_ext_mfg\}//")"
[ -e "${sys_ver_sysfs}" ] && echo "mfg: MFG_SYS_VER=$(cat ${sys_ver_sysfs} 2>/dev/null | sed "s/^.\{$skip_bytes_ext_mfg\}//")"
[ -e "${bsb_mfr_sysfs}" ] && echo "mfg: MFG_BSB_MFR=$(cat ${bsb_mfr_sysfs} 2>/dev/null | sed "s/^.\{$skip_bytes_ext_mfg\}//")"
[ -e "${bsb_pdn_sysfs}" ] && echo "mfg: MFG_BSB_PDN=$(cat ${bsb_pdn_sysfs} 2>/dev/null | sed "s/^.\{$skip_bytes_ext_mfg\}//")"
[ -e "${bsb_ver_sysfs}" ] && echo "mfg: MFG_BSB_VER=$(cat ${bsb_ver_sysfs} 2>/dev/null | sed "s/^.\{$skip_bytes_ext_mfg\}//")"
[ -e "${bsb_sn_sysfs}" ] && echo "mfg: MFG_BSB_SN=$(cat ${bsb_sn_sysfs} 2>/dev/null | sed "s/^.\{$skip_bytes_ext_mfg\}//")"
return
fi
mfg_sysfs_cfg_done=0
mfg_sysfs_cfg
mfg_cap_cfg
}
icm_cfg()
{
if [ ${dump_level} -gt ${DUMP_LEVEL_NONE} ]; then
[ -e "${large_icm_sysfs}" ] && echo "icm: LARGE_ICM_SIZE=$(cat ${large_icm_sysfs} 2>/dev/null)"
return
fi
if [ -n "${LARGE_ICM_SIZE}" ] && [ -e "${large_icm_sysfs}" ]; then
log_msg "icm: LARGE_ICM_SIZE=${LARGE_ICM_SIZE}"
echo "${LARGE_ICM_SIZE}" > ${large_icm_sysfs} 2>>${log_file}
large_icm_err=$?
if [ ${large_icm_err} -eq 0 ]; then
log_msg "icm: large_icm written"
else
log_msg "icm: large_icm_err=${large_icm_err}"
return
fi
fi
}
#
# Set or dump a value at the specified offset in a file.
#
sys_cfg_one_byte()
{
local tmp_file=$1
local name=$2
local offset=$3
local value=$4
local bin_value
if [ ${dump_level} -gt ${DUMP_LEVEL_NONE} ]; then
value=0
if [ -e ${tmp_file} ]; then
value=$(hexdump -s "${offset}" -n 1 -e '/1 "%d" "\n"' "${tmp_file}")
fi
echo "sys: ${name}=${value}"
elif [ -n "${value}" ]; then
bin_value=$(echo "${value}" | tr '[:lower:]' '[:upper:]')
if [ ."$value" = ."TRUE" ]; then
bin_value='\x01'
else
bin_value='\x00'
fi
printf "${bin_value}" | dd of="${tmp_file}" seek="${offset}" bs=1 count=1 conv=notrunc 2> /dev/null
has_change=1
log_msg "sys: ${name}=${value}"
fi
}
#
# Dump a multi-byte value at the specified offset in a file.
#
sys_cfg_multi_byte()
{
local tmp_file=$1
local name=$2
local offset=$3
local num_bytes=$4
local value=$5
if [ ${dump_level} -eq ${DUMP_LEVEL_NONE} ]; then
return
fi
value=0
if [ -e ${tmp_file} ]; then
value=$(hexdump -s "${offset}" -n "${num_bytes}" -e '"0x%X" "\n"' "${tmp_file}")
fi
echo "sys: ${name}=${value}"
}
#
# This function reads the BfModes EFI struct from a UEFI variable directly.
# Below are the offsets defined in UEFI which is 4(fixed header) plus the offset
# of the variable within the BfModes struct. These offsets are not supposed to
# change in order to be backward compatible with previous releases.
# VARIABLE(Name) OFFSET(Byte) SIZE(Byte)
# INTERNAL_CPU_MODEL 4 1
# HOST_PRIV_LEVEL 5 1
# NIC_MODE 6 1
#
sysfs_dump_bf_modes()
{
local tmp_file=${TMP_DIR}/.bfcfg-bfmodes-data
local internal_cpu_model internal_cpu_model_str
local host_priv_level host_priv_level_str
local nic_mode nic_mode_str
if [ ${dump_level} -eq ${DUMP_LEVEL_NONE} ]; then
return
fi
if [ ! -e "${bf_modes_sysfs}" ]; then
log_msg "misc: failed to find the ${bf_modes_sysfs} EFI variable"
return
fi
# shellcheck disable=SC2216
yes | cp -f ${bf_modes_sysfs} ${tmp_file}
internal_cpu_model=$(hexdump -s 4 -n 1 -e '/1 "%d" "\n"' ${tmp_file})
# shellcheck disable=SC2216
yes | cp -f ${bf_modes_sysfs} ${tmp_file}
host_priv_level=$(hexdump -s 5 -n 1 -e '/1 "%d" "\n"' ${tmp_file})
# shellcheck disable=SC2216
yes | cp -f ${bf_modes_sysfs} ${tmp_file}
nic_mode=$(hexdump -s 6 -n 1 -e '/1 "%d" "\n"' ${tmp_file})
if [ "${internal_cpu_model}" -eq 0 ]; then
internal_cpu_model_str="SEPARATED"
elif [ "${internal_cpu_model}" -eq 1 ]; then
internal_cpu_model_str="EMBEDDED"
else
internal_cpu_model_str="UNKNOWN"
fi
if [ "${host_priv_level}" -eq 0 ]; then
host_priv_level_str="PRIVILEGED"
elif [ "${host_priv_level}" -eq 1 ]; then
host_priv_level_str="RESTRICTED"
else
host_priv_level_str="UNKNOWN"
fi
if [ "${nic_mode}" -eq 0 ]; then
nic_mode_str="DPU_MODE"
elif [ "${nic_mode}" -eq 1 ]; then
nic_mode_str="NIC_MODE"
else
nic_mode_str="UNKNOWN"
fi
echo "misc: INTERNAL_CPU_MODEL=${internal_cpu_model_str}"
echo "misc: HOST_PRIV_LEVEL=${host_priv_level_str}"
echo "misc: NIC_MODE=${nic_mode_str}"
}
sysfs_dump_pass_settings()
{
local tmp_file=${TMP_DIR}/.bfcfg-pass-settings
local default_pass_policy
if [ ${dump_level} -eq ${DUMP_LEVEL_NONE} ]; then
return
fi
if [ ! -e "${pass_settings_sysfs}" ]; then
log_msg "misc: failed to find the ${pass_settings_sysfs} EFI variable"
return
fi
# shellcheck disable=SC2216
yes | cp -f ${pass_settings_sysfs} ${tmp_file}
default_pass_policy=$(hexdump -s 4 -n 1 -e '/1 "%d" "\n"' ${tmp_file})
echo "misc: UEFI_DEFAULT_PASS_POLICY_ENABLE=${default_pass_policy}"
}
#
# This function writes to the BfSysCfg UEFI variable directly.
# Below are the offsets defined in UEFI which is 4(fixed header) plus the offset
# of the variable within the BfSysCfg struct. These offsets are not supposed to
# change in order to be backward compatible with previous releases.
# VARIABLE(Name) OFFSET(Byte) SIZE(Byte)
# SYS_ENABLE_SMMU 24 1
# SYS_DISABLE_SPMI 25 1
# SYS_ENABLE_2ND_EMMC 26 1
# SYS_BOOT_PROTECT 27 1
# SYS_ENABLE_SPCR 32 1
# SYS_DISABLE_PCIE 33 1
# SYS_ENABLE_OPTEE 34 1
# SYS_DISABLE_TMFF 35 1
# SYS_ENABLE_I2C0 36 1
# SYS_DISABLE_FORCE_PXE_RETRY 37 1
# SYS_ENABLE_BMC_FIELD_MODE 38 1
# SYS_DISABLE_HEST 49 1
# SYS_L3_CACHE_PART_LEVEL 50 2
# SYS_ENABLE_I2C3 52 1
# SYS_ENABLE_FORCE_BOOT_RETRY 53 1
# SYS_ENABLE_OEM_MFG_CONFIG 54 1
# SYS_DISABLE_I2C1 55 1
# SYS_DISABLE_AUTO_BOOT_REFRESH 66 1
# SYS_DISPLAY_BMC_NET_CONFIG 67 1
#
sys_cfg()
{
local tmp_file=${TMP_DIR}/.bfcfg-sysfs-data
has_sys_cfg=0
if [ ! -e "${sys_cfg_sysfs}" ]; then
log_msg "sys: failed to find the ${sys_cfg_sysfs} EFI variable"
return
fi
# shellcheck disable=SC2216
yes | cp -f ${sys_cfg_sysfs} ${tmp_file}
has_change=0
sys_cfg_one_byte ${tmp_file} "ENABLE_SMMU" 24 "${SYS_ENABLE_SMMU}"
sys_cfg_one_byte ${tmp_file} "DISABLE_SPMI" 25 "${SYS_DISABLE_SPMI}"
sys_cfg_one_byte ${tmp_file} "ENABLE_2ND_EMMC" 26 "${SYS_ENABLE_2ND_EMMC}"
sys_cfg_one_byte ${tmp_file} "BOOT_PROTECT" 27 "${SYS_BOOT_PROTECT}"
sys_cfg_one_byte ${tmp_file} "ENABLE_SPCR" 32 "${SYS_ENABLE_SPCR}"
sys_cfg_one_byte ${tmp_file} "DISABLE_PCIE" 33 "${SYS_DISABLE_PCIE}"
sys_cfg_one_byte ${tmp_file} "ENABLE_OPTEE" 34 "${SYS_ENABLE_OPTEE}"
sys_cfg_one_byte ${tmp_file} "DISABLE_TMFF" 35 "${SYS_DISABLE_TMFF}"
sys_cfg_one_byte ${tmp_file} "ENABLE_I2C0" 36 "${SYS_ENABLE_I2C0}"
sys_cfg_one_byte ${tmp_file} "DISABLE_FORCE_PXE_RETRY" 37 "${SYS_DISABLE_FORCE_PXE_RETRY}"
sys_cfg_one_byte ${tmp_file} "ENABLE_BMC_FIELD_MODE" 38 "${SYS_ENABLE_BMC_FIELD_MODE}"
sys_cfg_multi_byte ${tmp_file} "LARGE_ICMC_SIZE" 39 4 "${SYS_LARGE_ICMC_SIZE}"
sys_cfg_multi_byte ${tmp_file} "CE_THRESHOLD" 45 4 "${SYS_CE_THRESHOLD}"
sys_cfg_one_byte ${tmp_file} "DISABLE_HEST" 49 "${SYS_DISABLE_HEST}"
sys_cfg_one_byte ${tmp_file} "L3_CACHE_PARTITION_LEVEL" 50 "${SYS_L3_CACHE_PARTITION_LEVEL}"
sys_cfg_one_byte ${tmp_file} "ENABLE_I2C3" 52 "${SYS_ENABLE_I2C3}"
sys_cfg_one_byte ${tmp_file} "ENABLE_FORCE_BOOT_RETRY" 53 "${SYS_ENABLE_FORCE_BOOT_RETRY}"
sys_cfg_one_byte ${tmp_file} "ENABLE_OEM_MFG_CONFIG" 54 "${SYS_ENABLE_OEM_MFG_CONFIG}"
sys_cfg_one_byte ${tmp_file} "DISABLE_I2C1" 55 "${SYS_DISABLE_I2C1}"
sys_cfg_one_byte ${tmp_file} "DISABLE_AUTO_BOOT_REFRESH" 66 "${SYS_DISABLE_AUTO_BOOT_REFRESH}"
sys_cfg_one_byte ${tmp_file} "DISPLAY_BMC_NET_CONFIG" 67 "${SYS_DISPLAY_BMC_NET_CONFIG}"
if [ ${has_change} -eq 1 ]; then
chattr -i ${sys_cfg_sysfs}
cp ${tmp_file} ${sys_cfg_sysfs}
sync
has_sys_cfg=1
fi
rm -f ${tmp_file}
}
#
# This function reads the BfRedfishState UEFI variable directly.
# Below are the offsets defined in UEFI which is 4(fixed header) plus the offset
# of the variable within the BfRedfish struct. These offsets are not supposed to
# change in order to be backward compatible with previous releases.
# VARIABLE(Name) OFFSET(Byte) SIZE(Byte)
# CFG_SKIP_REDFISH 4 1
#
sys_redfish_cfg_dump()
{
local tmp_file=${TMP_DIR}/.bfcfg-redfishfs-state-data
if [ ${dump_level} -eq ${DUMP_LEVEL_NONE} ]; then
return
fi
if [ ! -e "${redfish_state_cfg_sysfs}" ]; then
log_msg "sys: failed to find the ${redfish_state_cfg_sysfs} EFI variable"
return
fi
# shellcheck disable=SC2216
yes | cp -f ${redfish_state_cfg_sysfs} ${tmp_file}
has_change=0
sys_cfg_one_byte ${tmp_file} "SKIP_REDFISH" 4 "${SYS_SKIP_REDFISH}"
if [ ${has_change} -eq 1 ]; then
log_msg "sys: changes to volatile ${redfish_state_cfg_sysfs} EFI variable will not take effect"
fi
}
#
# This function writes to the BfRedfish UEFI variable directly.
# Below are the offsets defined in UEFI which is 4(fixed header) plus the offset
# of the variable within the BfRedfish struct. These offsets are not supposed to
# change in order to be backward compatible with previous releases.
# VARIABLE(Name) OFFSET(Byte) SIZE(Byte)
# CFG_ENABLE_REDFISH 4 1
# CFG_RTCSYNC 5 1
#
sys_redfish_cfg()
{
local tmp_file=${TMP_DIR}/.bfcfg-redfishfs-data
if [ ${dump_level} -gt ${DUMP_LEVEL_NONE} ]; then
sys_redfish_cfg_dump
fi
has_redfish_cfg=0
if [ ! -e "${redfish_cfg_sysfs}" ]; then
log_msg "sys: failed to find the ${redfish_cfg_sysfs} EFI variable"
return
fi
# shellcheck disable=SC2216
yes | cp -f ${redfish_cfg_sysfs} ${tmp_file}
has_change=0
sys_cfg_one_byte ${tmp_file} "ENABLE_REDFISH" 4 "${SYS_ENABLE_REDFISH}"
sys_cfg_one_byte ${tmp_file} "RTCSYNC" 5 "${SYS_RTCSYNC}"
if [ ${has_change} -eq 1 ]; then
chattr -i ${redfish_cfg_sysfs}
cp ${tmp_file} ${redfish_cfg_sysfs}
sync
has_redfish_cfg=1
fi
rm -f ${tmp_file}
}
misc_cfg()
{
local mac value
local tmp_file=${TMP_DIR}/.bfcfg-misc-data
if [ ${dump_level} -gt ${DUMP_LEVEL_NONE} ]; then
# BF modes & password settings
sysfs_dump_bf_modes
sysfs_dump_pass_settings
# Rshim MAC address.
mac=$(hexdump -v -e '/1 "%02x"' ${rshim_efi_mac_sysfs})
mac="${mac:8:2}:${mac:10:2}:${mac:12:2}:${mac:14:2}:${mac:16:2}:${mac:18:2}"
echo "misc: NET_RSHIM_MAC=${mac}"
# PXE DHCP Class Identifier.
value=""
if [ -f "${pxe_dhcp_class_id_sysfs}" ]; then
value=$(xxd -s 4 -p ${pxe_dhcp_class_id_sysfs} 2>/dev/null | xxd -r -p)
fi
echo "misc: PXE_DHCP_CLASS_ID=${value}"
# BF bundle version.
value=""
if [ -f "${bf_bundle_version_sysfs}" ]; then
value=$(xxd -s 4 -p ${bf_bundle_version_sysfs} 2>/dev/null | xxd -r -p)
fi
echo "misc: BF_BUNDLE_VERSION=${value}"
else
# Rshim MAC address.
if [ -n "${NET_RSHIM_MAC}" ]; then
mac="${NET_RSHIM_MAC//:/\\x}"
mac="\\x07\\x00\\x00\\x00\\x${mac}"
printf "${mac}" > ${tmp_file}
chattr -i ${rshim_efi_mac_sysfs}
cp ${tmp_file} ${rshim_efi_mac_sysfs}
rm -f ${tmp_file}
log_msg "misc: NET_RSHIM_MAC=${NET_RSHIM_MAC}"
fi
# PXE DHCP Class Identifier.
if [ -n "${PXE_DHCP_CLASS_ID}" ]; then
value="\\x07\\x00\\x00\\x00${PXE_DHCP_CLASS_ID}"
printf "${value}" > ${tmp_file}
if [ -f "${pxe_dhcp_class_id_sysfs}" ]; then
chattr -i ${pxe_dhcp_class_id_sysfs}
fi
cp ${tmp_file} ${pxe_dhcp_class_id_sysfs}
rm -f ${tmp_file}
log_msg "misc: PXE_DHCP_CLASS_ID=${PXE_DHCP_CLASS_ID}"
fi
# BF bundle version.
if [ -n "${BF_BUNDLE_VERSION}" ]; then
value="\\x07\\x00\\x00\\x00${BF_BUNDLE_VERSION}"
printf "${value}" > ${tmp_file}
if [ -f "${bf_bundle_version_sysfs}" ]; then
chattr -i ${bf_bundle_version_sysfs}
fi
cp ${tmp_file} ${bf_bundle_version_sysfs}
rm -f ${tmp_file}
log_msg "misc: BF_BUNDLE_VERSION=${BF_BUNDLE_VERSION}"
fi
fi
}
#
# Parse the partition configuration and export $EFI_PART, $ROOT_PART and
# $PERSIST_PART
#
part_info()
{
local disk part value
# Source the configuration if exists.
# shellcheck source=/dev/null
[ -e "${cfg_file}" ] && . ${cfg_file}