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>
This commit is contained in:
Vadim Bendebury
2015-11-17 17:51:50 -08:00
committed by chrome-bot
parent afaaba44f1
commit 6e99eb6814

View File

@@ -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)
const char *func,
const char *condition
)
{
ecprintf("Failure in %s, line %d, code %d\n",
s_failFunction, s_failLine, s_failCode);
/*
* 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. */
}