sb/amd/{agesa,pi}/hudson: Explicitly enable LPC controller
[coreboot.git] / util / mma / mma_get_result.sh
blobf797e7f36be9027b50ab243213689b557a439965
1 #!/usr/bin/env bash
4 # This file is part of the coreboot project.
6 # Copyright (C) 2015 Intel Corporation.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; version 2 of the License.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
18 mma_results_op_bin="${1}"
19 mma_results_op_bin_tmp="${mma_results_op_bin}".tmp
20 mma_cbmem_id="0x4d4d4144"
22 show_usage() {
23 printf "usage: $(basename "${0}") <output_results.bin>\n"
24 printf "pass path of a bin file where you want to save results.\n"
28 # main entry point
31 main() {
32 if [ ! "${mma_results_op_bin}" ];then
33 show_usage
34 exit -1
37 printf "Reading cbmem ...\n"
38 cbmem -r ${mma_cbmem_id} > "${mma_results_op_bin_tmp}" || \
40 printf "error in executing cbmem utility\n" ;
41 exit -1;
44 #format of o/p is :
45 # <mma_signature><mma_test_header+data>
47 # where,
48 # <mma_signature> is 32bit length string "MMAD"
50 # <mma_test_header+data> is the FULL HOB which coreboot
51 # receives from FSP
52 # <mma_test_header> is 22 bytes long at the start of the HOB.
53 # MMA data starts right after 26 bytes
54 # 26 bytes = (4 bytes of "MMAD"
55 # + 22 bytes of mma_test_header)
58 mma_signature=$(dd if="${mma_results_op_bin_tmp}" bs=1 count=4 )
60 if [[ ${mma_signature} != "MMAD" ]];then
61 printf "MMA signature mismatch" > "${mma_results_op_bin}"
62 rm -r "${mma_results_op_bin_tmp}"
63 cbmem -l >> "${mma_results_op_bin}"
64 printf "MMA signature mismatch\n"
65 exit -1
68 dd if="${mma_results_op_bin_tmp}" of="${mma_results_op_bin}" bs=1 skip=26 || \
70 printf "error in generating "${mma_results_op_bin}"\n" ;
71 exit -1;
73 rm -r "${mma_results_op_bin_tmp}"
74 printf "MMA data saved to "${mma_results_op_bin}"\n"
77 main "$@"