summaryrefslogtreecommitdiff
path: root/board/cr50
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2015-11-17 17:51:50 -0800
committerchrome-bot <chrome-bot@chromium.org>2015-11-21 13:12:24 -0800
commit6e99eb68149aa475023805139314a7eeddf2dd97 (patch)
tree6d7cf0a02a9ac4e3074c7f380595d7097a24dacf /board/cr50
parentafaaba44f13e7982e68b503123d48f912f3fd5eb (diff)
downloadchrome-ec-6e99eb68149aa475023805139314a7eeddf2dd97.tar.gz
cr50: fix assert_func stub prototype
__assert_func() is modified to match prototype defined in the global include file. TPM2 library handling of asserts will have to be modified later. BRANCH=none BUG=chrome-os-partner:43025, chromium:559344 TEST=assert message now include valid pertinent information about the point of failure. Change-Id: I8050c018c36d5d98b879daa2b600fc7c76ef9126 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/312868 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'board/cr50')
-rw-r--r--board/cr50/tpm2/stubs.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/board/cr50/tpm2/stubs.c b/board/cr50/tpm2/stubs.c
index b723c529b9..abfe07185c 100644
--- a/board/cr50/tpm2/stubs.c
+++ b/board/cr50/tpm2/stubs.c
@@ -3,6 +3,7 @@
* found in the LICENSE file.
*/
+#define TPM_FAIL_C
#include "Global.h"
#include "CryptoEngine.h"
@@ -450,10 +451,27 @@ int _math__uComp(
void __assert_func(
const char *file,
int line,
- const char *func)
-{
- ecprintf("Failure in %s, line %d, code %d\n",
- s_failFunction, s_failLine, s_failCode);
+ const char *func,
+ const char *condition
+)
+{
+ /*
+ * TPM2 library invokes assert from a common wrapper, which first sets
+ * global variables describing the failure point and then invokes the
+ * assert() macro which ends up calling this function as defined by the gcc
+ * toolchain.
+ *
+ * For some weird reason (or maybe this is a bug), s_FailFunction is defined
+ * in the tpm2 library as a 32 bit int, but on a failure the name of the
+ * failing function (its first four bytes) are copiied into this variable.
+ *
+ * TODO(vbendeb): investigate and fix TPM2 library assert handling.
+ */
+ ecprintf("Failure in %s, func %s, line %d:\n%s\n",
+ file,
+ s_failFunction ? (const char *)&s_failFunction : func,
+ s_failLine ? s_failLine : line,
+ condition);
while (1)
; /* Let the watchdog doo the rest. */
}