blob: e26ae4a73b50c1784f6c74afa2717cf4533ea9e1 [file] [log] [blame]
Pratik Prajapati21deb062015-09-02 13:14:20 -07001#!/bin/bash
2
3#
4# This file is part of the coreboot project.
5#
6# Copyright (C) 2015 Intel Corporation.
7#
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.
11#
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.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc.
20#
21
22mma_results_op_bin="${1}"
23mma_results_op_bin_tmp="${mma_results_op_bin}".tmp
24mma_cbmem_id="0x4d4d4144"
25
26show_usage() {
27 printf "usage: $(basename "${0}") <output_results.bin>\n"
28 printf "pass path of a bin file where you want to save results.\n"
29}
30
31#
32# main entry point
33#
34
35main() {
36 if [ ! "${mma_results_op_bin}" ];then
37 show_usage
38 exit -1
39 fi
40
41 printf "Reading cbmem ...\n"
42 cbmem -r ${mma_cbmem_id} > "${mma_results_op_bin_tmp}" || \
43 {
44 printf "error in executing cbmem utility\n" ;
45 exit -1;
46 }
47
48 #format of o/p is :
49 # <mma_signature><mma_test_header+data>
50 #
51 # where,
52 # <mma_signature> is 32bit length string "MMAD"
53 #
54 # <mma_test_header+data> is the FULL HOB which coreboot
55 # receives from FSP
56 # <mma_test_header> is 22 bytes long at the start of the HOB.
57 # MMA data starts right after 26 bytes
58 # 26 bytes = (4 bytes of "MMAD"
59 # + 22 bytes of mma_test_header)
60 #
61
62 mma_signature=$(dd if="${mma_results_op_bin_tmp}" bs=1 count=4 )
63
64 if [[ ${mma_signature} != "MMAD" ]];then
65 printf "MMA signature mismatch" > "${mma_results_op_bin}"
66 rm -r "${mma_results_op_bin_tmp}"
67 cbmem -l >> "${mma_results_op_bin}"
68 printf "MMA signature mismatch\n"
69 exit -1
70 fi
71
72 dd if="${mma_results_op_bin_tmp}" of="${mma_results_op_bin}" bs=1 skip=26 || \
73 {
74 printf "error in generating "${mma_results_op_bin}"\n" ;
75 exit -1;
76 }
77 rm -r "${mma_results_op_bin_tmp}"
78 printf "MMA data saved to "${mma_results_op_bin}"\n"
79}
80
81main "$@"