From 6e99eb68149aa475023805139314a7eeddf2dd97 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Tue, 17 Nov 2015 17:51:50 -0800 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/312868 Reviewed-by: Bill Richardson --- board/cr50/tpm2/stubs.c | 26 ++++++++++++++++++++++---- 1 file 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. */ } -- cgit v1.2.1