Debian Codegraph @

util/mma/mma_get_result.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2 #
3 # SPDX-License-Identifier: GPL-2.0-only
4
5 mma_results_op_bin="${1}"
6 mma_results_op_bin_tmp="${mma_results_op_bin}".tmp
7 mma_cbmem_id="0x4d4d4144"
8
9 show_usagescip-shell shell coreboot 25.09+dfsg-1 show_usage().() {
10 printfscip-shell system . . printf. "usage: $(basenamescip-shell system . . basename. "${0}") <output_results.bin>\n"
11 printfscip-shell system . . printf. "pass path of a bin file where you want to save results.\n"
12 }
13
14 #
15 # main entry point
16 #
17
18 mainscip-shell shell coreboot 25.09+dfsg-1 main().() {
19 if [scip-shell system . . `[`. ! "${mma_results_op_bin}" ];then
20 show_usagescip-shell shell coreboot 25.09+dfsg-1 show_usage().
21 exit -1
22 fi
23
24 printfscip-shell system . . printf. "Reading cbmem ...\n"
25 cbmem -r ${mma_cbmem_id} > "${mma_results_op_bin_tmp}" || \
26 {
27 printfscip-shell system . . printf. "error in executing cbmem utility\n" ;
28 exit -1;
29 }
30
31 #format of o/p is :
32 # <mma_signature><mma_test_header+data>
33 #
34 # where,
35 # <mma_signature> is 32bit length string "MMAD"
36 #
37 # <mma_test_header+data> is the FULL HOB which coreboot
38 # receives from FSP
39 # <mma_test_header> is 22 bytes long at the start of the HOB.
40 # MMA data starts right after 26 bytes
41 # 26 bytes = (4 bytes of "MMAD"
42 # + 22 bytes of mma_test_header)
43 #
44
45 mma_signature=$(ddscip-shell system . . dd. if="${mma_results_op_bin_tmp}" bs=1 count=4 )
46
47 if [[ ${mma_signature} != "MMAD" ]];then
48 printfscip-shell system . . printf. "MMA signature mismatch" > "${mma_results_op_bin}"
49 rmscip-shell system . . rm. -r "${mma_results_op_bin_tmp}"
50 cbmem -l >> "${mma_results_op_bin}"
51 printfscip-shell system . . printf. "MMA signature mismatch\n"
52 exit -1
53 fi
54
55 ddscip-shell system . . dd. if="${mma_results_op_bin_tmp}" of="${mma_results_op_bin}" bs=1 skip=26 || \
56 {
57 printfscip-shell system . . printf. "error in generating "${mma_results_op_bin}"\n" ;
58 exit -1;
59 }
60 rmscip-shell system . . rm. -r "${mma_results_op_bin_tmp}"
61 printfscip-shell system . . printf. "MMA data saved to "${mma_results_op_bin}"\n"
62 }
63
64 mainscip-shell shell coreboot 25.09+dfsg-1 main(). "$@"