- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

# /space/home/slher/rel/Beken/v6_4_5/macsw/modules/dbg/src/dbg_assert.c

    00001
    00020 /*
    00021  * INCLUDE FILES
    00022  ****************************************************************************************
    00023  */
    00024 #include "dbg_assert.h"
    00025 #include "dbg.h"
    00026 #include "ke_event.h"
    00027 #include "hal_machw.h"
    00028 #include "reg_sysctrl.h"
    00029
    00030 /*
    00031  * GLOBAL VARIABLES
    00032  ****************************************************************************************
    00033  */
    00035 int dbg_assert_block = 1;
    00036
    00037 /*
    00038  * FUNCTION DEFINITIONS
    00039  ****************************************************************************************
    00040  */
    00041 void dbg_assert_rec(const char *condition, const char * file, int line)
    00042 {
    00043     // Disable the interrupts
    00044     GLOBAL_INT_DISABLE();
    00045
    00046     // Display a trace message showing the error
    00047     TRACE("ASSERT recovery: %F:%d", (line >> 20) , line);
    00048     line = (line & 0xfffff);
    00049     dbg(D_ERR "ASSERT (%s) at %s:%d\n", condition, file, line);
    00050
    00051     // Check if a recovery is already pending
    00052     if (!(ke_evt_get() & KE_EVT_RESET_BIT))
    00053     {
    00054         #if NX_DEBUG_DUMP
    00055         char msg[DBG_ERROR_TRACE_SIZE];
    00056
    00057         // Write to the trigger bit to stop the internal or external logic analyzer
    00058         sysctrl_diag_trigger_set(1);
    00059
    00060         // Prepare the error trace to be forwarded to host
    00061         dbg_snprintf(msg, DBG_ERROR_TRACE_SIZE, "ASSERT (%s) at %s:%d\n", condition, file, line);
    00062
    00063         // Save the error trace
    00064         dbg_error_save(msg);
    00065
    00066         // Clear the trigger bit
    00067         sysctrl_diag_trigger_set(0);
    00068         #endif
    00069
    00070         // Disable MAC HW interrupts
    00071         hal_machw_disable_int();
    00072
    00073         // Trigger the reset procedure
    00074         ke_evt_set(KE_EVT_RESET_BIT);
    00075     }
    00076
    00077     // Restore the interrupts
    00078     GLOBAL_INT_RESTORE();
    00079 }
    00080
    00081 void dbg_assert_err(const char *condition, const char * file, int line)
    00082 {
    00083     #if NX_DEBUG_DUMP
    00084     char msg[DBG_ERROR_TRACE_SIZE];
    00085     #endif
    00086
    00087     TRACE("ASSERT error: %F:%d", (line >> 20) , line);
    00088     line = (line & 0xfffff);
    00089
    00090     // Stop the interrupts
    00091     GLOBAL_INT_STOP();
    00092
    00093     // Write to the trigger bit to stop the internal logic analyzer
    00094     sysctrl_diag_trigger_set(1);
    00095
    00096     // Stop the HW to keep it as close as possible to the error state
    00097     nxmac_next_state_setf(HW_IDLE);
    00098
    00099     // Display a trace message showing the error
    00100     dbg(D_ERR "ASSERT (%s) at %s:%d\n", condition, file, line);
    00101
    00102     #if NX_DEBUG_DUMP
    00103     // Prepare the error trace to be forwarded to host
    00104     dbg_snprintf(msg, DBG_ERROR_TRACE_SIZE, "ASSERT (%s) at %s:%d\n", condition, file, line);
    00105
    00106     // Forward the error indication to the host
    00107     dbg_error_ind(msg, DBG_ERROR_FATAL);
    00108     #endif
    00109
    00110     while(dbg_assert_block);
    00111 }
    00112
    00113 void dbg_assert_warn(const char *condition, const char * file, int line)
    00114 {
    00115     TRACE("ASSERT warning: %F:%d", (line >> 20) , line);
    00116     line = (line & 0xfffff);
    00117     dbg(D_ERR "WARNING (%s) at %s:%d\n", condition, file, line);
    00118 }
    00119
    00120 void dbg_force_trigger(const char *msg)
    00121 {
    00122     #if NX_DEBUG_DUMP && defined(CFG_RWTL)
    00123     char msgbuf[256];
    00124     uint8_t *buf = (uint8_t *)msgbuf;
    00125     uint32_t addr = CPU2HW(msg);
    00126     uint8_t val;
    00127     #endif
    00128
    00129     // Stop the interrupts
    00130     GLOBAL_INT_DISABLE();
    00131
    00132     #if NX_DEBUG_DUMP && defined(CFG_RWTL)
    00133     // Unpack the string
    00134     do
    00135     {
    00136         val = co_read8p(addr++);
    00137         *buf++ = val;
    00138     } while(val != 0);
    00139     msg = (const char *)msgbuf;
    00140     #endif
    00141
    00142     // Write to the trigger bit to stop the internal logic analyzer
    00143     sysctrl_diag_trigger_set(1);
    00144
    00145     // Clear the trigger bit immediately as the LA will be restarted in
    00146     // dbg_error_ind()
    00147     sysctrl_diag_trigger_set(0);
    00148
    00149     #if NX_DEBUG_DUMP
    00150     // Get HW diagnostic port state
    00151     hal_machw_get_diag_state();
    00152
    00153     // Forward the error indication to the host
    00154     dbg_error_ind((char *) msg, DBG_ERROR_RECOVERABLE);
    00155     #endif
    00156
    00157     // Restore the interrupts
    00158     GLOBAL_INT_RESTORE();
    00159 }
    00160
    00161