From a37daa7eab139979f822e8af1b1509245a095377 Mon Sep 17 00:00:00 2001 From: Stephen Cprek Date: Thu, 23 Mar 2017 17:04:01 -0500 Subject: Switch bootloader assert to do a bl_terminate Also provide options to provide a bootloader trace byte or return code Change-Id: Id1ae0fdd349258aa16f43dd25b787b005d8661d6 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/38389 Tested-by: Jenkins Server Reviewed-by: Martin Gloff Tested-by: FSP CI Jenkins Tested-by: Jenkins OP Build CI Reviewed-by: Michael Baiocchi Reviewed-by: Nicholas E. Bofferding Reviewed-by: Daniel M. Crowell --- src/include/bootloader/bootloader.H | 126 ++++++++++++++++++++++++------------ 1 file changed, 85 insertions(+), 41 deletions(-) (limited to 'src/include/bootloader/bootloader.H') diff --git a/src/include/bootloader/bootloader.H b/src/include/bootloader/bootloader.H index 74e2364ee..3c75770de 100644 --- a/src/include/bootloader/bootloader.H +++ b/src/include/bootloader/bootloader.H @@ -39,20 +39,100 @@ #include #include #include +#include +#include extern "C" void task_end_stub(); extern "C" void enterHBB(uint64_t i_hbb_hrmor, uint64_t i_hbb_offset); -#define assert(expr) \ +#define printk(format...) + +/** + * @brief Handle setting up to terminate Bootloader + * + * @param[in] i_moduleID ID for module where terminate is occurring + * @param[in] i_reasoncode Reason code for why terminating + * @param[in] i_word7 Data for SRC word 7 / @userdata2[0:31] + * (optional, default is 0) + * @param[in] i_word8 Data for SRC word 8 / @userdata2[32:63] + * (optional, default is 0) + * @param[in] i_executeTI Flag for calling terminateExecuteTI + * (optional, default is true) + * @param[in] i_failAddr Address associated with termination + * (SRC word 6 / @userdata1[32:63], + * optional, default is 0) + */ +inline void bl_terminate(uint8_t i_moduleID, + uint16_t i_reasoncode, + uint32_t i_word7 = 0, + uint32_t i_word8 = 0, + bool i_executeTI = true, + uint64_t i_failAddr = 0) +{ + termWriteSRC(TI_BOOTLOADER, + i_reasoncode, + i_failAddr); + + termModifySRC(i_moduleID, + i_word7, + i_word8); + + if(i_executeTI) + { + terminateExecuteTI(); + } +} + +/** + * @brief Macro to assert using bl_terminate + * + * Calls bl_terminate with default module id and reason code for assert + */ +#define __ASSERT() \ +{\ + bl_terminate(Bootloader::MOD_BOOTLOADER_ASSERT,Bootloader::RC_ASSERT);\ +} + +/** + * @brief Macro to assert with custom trace + * + * Calls Bootloader trace and assert macro + */ +#define __ASSERT_W_TRACE(trace) \ +{ \ + BOOTLOADER_TRACE(trace);\ + __ASSERT();\ +} + +/** + * @brief Macro to assert using bl_terminate with custom trace and reason code. + * + * Calls Bootloader trace and provides a custom reason code to bl_terminate + */ +#define __ASSERT_W_TRACE_RC(trace,rc) \ +{ \ + BOOTLOADER_TRACE(trace);\ + bl_terminate(Bootloader::MOD_BOOTLOADER_ASSERT, rc);\ +} + + +// Macro tricks to determine which assert macro to call +#define GET_MACRO(_1,_2,_3,FUNC,...) FUNC + +/** + * @brief Standard assert macro. + * + * Verifies condition, uses GET_MACRO to determine which assert macro to call. + * Supports asserting via bl_terminate with custom trace and/or reason code + */ +#define assert(expr, ...) \ {\ - if (unlikely(!(expr)))\ + if(unlikely(!(expr))) \ {\ - task_end_stub();\ + GET_MACRO(0, ##__VA_ARGS__, __ASSERT_W_TRACE_RC, __ASSERT_W_TRACE, __ASSERT)(__VA_ARGS__) \ }\ } -#define printk(format...) - namespace Bootloader{ /** * @brief Get the current HBBL HRMOR @@ -108,42 +188,6 @@ namespace Bootloader{ uint32_t i_size, MMIOLoadStoreSizes i_ld_st_size); - /** - * @brief Handle setting up to terminate Bootloader - * - * @param[in] i_moduleID ID for module where terminate is occurring - * @param[in] i_reasoncode Reason code for why terminating - * @param[in] i_word7 Data for SRC word 7 / @userdata2[0:31] - * (optional, default is 0) - * @param[in] i_word8 Data for SRC word 8 / @userdata2[32:63] - * (optional, default is 0) - * @param[in] i_executeTI Flag for calling terminateExecuteTI - * (optional, default is true) - * @param[in] i_failAddr Address associated with termination - * (SRC word 6 / @userdata1[32:63], - * optional, default is 0) - */ - inline void bl_terminate(uint8_t i_moduleID, - uint16_t i_reasoncode, - uint32_t i_word7 = 0, - uint32_t i_word8 = 0, - bool i_executeTI = true, - uint64_t i_failAddr = 0) - { - termWriteSRC(TI_BOOTLOADER, - i_reasoncode, - i_failAddr); - - termModifySRC(i_moduleID, - i_word7, - i_word8); - - if(i_executeTI) - { - terminateExecuteTI(); - } - } - /** @enum HbbLengths * @brief List of HBB lengths. * -- cgit v1.2.3