AT-NFC 2.1 (win) AT-NFC kernel set

Macros | Functions
HAL Trace Management

HAL Trace API declarations. More...

## Macros
#define | KER_DBG_LEVEL_ERR 0
#define | KER_DBG_LEVEL_WARN 2
#define | KER_DBG_LEVEL_TRACE_COMMENT 5
#define | KER_DBG_LEVEL_TAG_LIST 20
#define | KER_DBG_LEVEL_APDU 30
#define | KER_DBG_LEVEL_TAG_INFO 40
#define | KER_DBG_LEVEL_TAG_WARN 100
#define | KER_DBG_LEVEL_ALL 99

## Functions
KER_BOOL | hal_set_trace_mode (KER_CTX_PARAM KER_BYTE btTraceMode)
| Set trace mode. More...
KER_BYTE | hal_get_trace_mode (KER_CTX_SINGLE_PARAM)
| Get trace mode. More...
KER_BOOL | hal_trace_string (KER_CTX_PARAM const KER_CHAR *pchString)
| Trace povided nul-term string. More...
KER_BOOL | hal_trace_buffer (KER_CTX_PARAM const KER_BYTE *pbtDataBuffer, KER_INT16U usDataBufferSize)
| Trace povided data buffer. More...
KER_BOOL | hal_trace_time (KER_CTX_SINGLE_PARAM)
| Trace timestamp. More...
KER_BOOL | hal_keep_trace_time (KER_CTX_PARAM KER_BYTE *pbtTimeBuffer, KER_INT16U *pusTimeBufferSize)
| Keep trace timestamp. More...
KER_BOOL | hal_trace_flush (KER_CTX_SINGLE_PARAM)
| Flush trace to trace file (optional) More...
KER_BOOL | hal_error (KER_CTX_PARAM KER_INT16U usTraceLevel, KER_RES resErrCode, const KER_CHAR *pchErrorText)
| Trace error to system error journal. More...
KER_VOID | def_hal_trace_supp_app (KER_CTX_PARAM const KER_TLV *pSuppAppList)
| Default "trace supported applications" implementation.
KER_VOID | def_hal_trace_cl (KER_CTX_PARAM const KER_TLV *pCL)
| Default "trace candidate list" implementation.
KER_VOID | def_hal_trace_tag (KER_CTX_PARAM const KER_BYTE *pbtTlv, KER_INT16U usTlvLen, KER_INT16U usOrigin)
| Default "trace obtained tag" implementation.
KER_VOID | def_hal_trace_tvr (KER_CTX_PARAM const KER_CHAR *pchComment, const KER_BYTE *pbtTvr, KER_BYTE btTvrLen)
| Default "trace TVR" implementation.
#define | KER_TRACE_MODE_STD 0x00
#define | KER_TRACE_MODE_SENS 0x01
#define | KER_TRACE_APDU_REQ_TAB " "
#define | KER_TRACE_APDU_INT_REQ_TAB " Int"
#define | KER_TRACE_APDU_INT_RESP_TAB " Int"
#define | KER_TRACE_APDU_RESP_TAB " "
#define | KER_TRACE_COMB_TAB " "
#define | KER_DBG_EX(IgnoreLevel, ErrLevel) ((KER_DEBUG == KER_TRUE) && ((KER_DEBUG_LEVEL >= ErrLevel) || (KER_DEBUG_ALL == KER_TRUE) || (IgnoreLevel == KER_TRUE)))
#define | KER_DBG(ErrLevel) KER_DBG_EX(KER_FALSE,ErrLevel)
#define | KER_INFO KER_DBG_EX(KER_TRUE,0)
#define | KER_TRACE_EOL "\r\n"
#define | KER_COMMENT_HDR_NO_TIME(comment)
| Default "trace comment w/o time" macro. More...
#define | KER_COMMENT_HDR_EX(comment)
| Default "trace comment" macro. More...
#define | KER_COMMENT_FTR_EX(comment)
| Default "trace comment" macro. More...
#define | KER_COMMENT_HDR_TEXT(text) const KER_CHAR const_ch___CommentHeader[] = text
#define | KER_COMMENT_HDR(text) KER_COMMENT_HDR_TEXT(text); KER_COMMENT_HDR_EX(const_ch___CommentHeader)
#define | KER_COMMENT_FTR() KER_COMMENT_FTR_EX(const_ch___CommentHeader)
#define | KER_COMMENT_TEXT(text) hal_trace_string(KER_CTX text)
| Default "trace comment" macro. More...
#define | KER_COMMENT(comment)
| Default "trace comment" macro. More...
#define | KER_COMMENT_TEST_MODE() KER_COMMENT("########################## TEST MODE! ##########################")
#define | KER_COMMENT_TEST_MODE_DISABLED() KER_COMMENT("###################### TEST MODE DISABLED ######################")
#define | KER_TRACE_TIME() hal_trace_time(KER_CTX_SINGLE)
| Default "trace comment" macro. More...
#define | KER_COMMENT_HEX(comment_start, buff, buff_len, comment_end)
| Default "trace comment with hex data" macro. More...
#define | KER_TEXT_HEX(dest, dest_len, buff, buff_len)
| Default "fill text string with hex data" macro. More...
#define | KER_COMMENT_STR(comment_start, buff, buff_len, comment_end)
| Default "trace comment with hex data" macro. More...
#define | KER_TRACE_ERR_BUF KER_CHAR ar_ch___ErrBuffer[32];
| Default "Declare error trace buffer" macro.
#define | KER_TRACE_SYS_ERR_BUF
| Default "Declare sys error trace buffer" macro.
#define | KER_TRACE_BUF(Size) KER_CHAR ar_ch___InfBuffer[Size];
| Default "Declare trace buffer" macro.
#define | KER_RESET_TRACE_BUF KER_MEM_SET(ar_ch___InfBuffer, sizeof(ar_ch___InfBuffer), 0, sizeof(ar_ch___InfBuffer));
| Default "Reset trace buffer" macro.
#define | KER_ERROR(err_code, trace_level, comment)
| Default "trace error" macro (Release mode) More...
#define | KER_SYS_ERROR(err_code, trace_level, comment) hal_error(KER_CTX trace_level, err_code, comment)
| Default "trace system error" macro (Release mode - without extra diagnostic info - for PCI) More...
#define | KER_SYS_INFO(err_code, trace_level, comment) hal_error(KER_CTX trace_level, err_code, comment)
| Default "trace system info" macro. More...
#define | KER_TRACE_TAG_NOT_FOUND(tag, tag_length)
| Default "trace tag not found" macro. More...
#define | KER_TRACE_TAG_DUPLICATION(tag, tag_length, tlv1, tlv1_length, tlv2, tlv2_length)
| Default "tag duplication" macro. More...
#define | KER_TRACE_APDU_REQ(bInternal, btCase, btCLA, btINS, btP1, btP2, usLc, pbtData, usLe)
| Default "trace apdu request" macro. More...
#define | KER_TRACE_APDU_RESP(INTERNAL, SW1SW2, DATA, DATA_LEN)
| Default "trace apdu response" macro. More...
#define | KER_TRACE_NFC_APDU_RESP(INTERNAL, SW1SW2, EXEC_TIME, DATA, DATA_LEN)
| Default "trace nfc apdu response" macro. More...
#define | KER_TRACE_SUPP_APP_LIST_DEFAULT /* force to include default implementation - see hal_trace_def.c */
| Default "trace supported applications" macro. More...
#define | KER_TRACE_SUPP_AIDS(AidList) def_hal_trace_supp_app(KER_CTX AidList);
| Default "trace supported aids" macro.
#define | KER_TRACE_CL_DEFAULT /* force to include default implementation - see hal_trace_def.c */
| Default "trace candidate list" macro. More...
#define | KER_TRACE_CL(CL) def_hal_trace_cl(KER_CTX CL);
| Default "trace candidate list" macro.
#define | KER_TRACE_TAG_DEFAULT /* force to include default implementation - see hal_trace_def.c */
| Default "trace obtained tag " macro. More...
#define | KER_TRACE_TAG(Tlv, TlvLen, Origin) def_hal_trace_tag(KER_CTX Tlv,TlvLen,Origin)
| Default "trace tag" macro.
#define | KER_TRACE_CVM_LIST(TranPtr, TrType, TrCurr, IccCurr, AmountX, AmountY)
| Default "trace cvm list" macro. More...
#define | KER_TRACE_TVR_DEFAULT /* force to include default implementation - see hal_trace_def.c */
| Default "trace TVR/TAC/IAC " macro. More...
#define | KER_TRACE_TVR(Comment, Tvr, TvrLen) def_hal_trace_tvr(KER_CTX Comment, Tvr, TvrLen)
| Default "trace TVR" macro.
#define | KER_TRC_STD hal_set_trace_mode(KER_CTX KER_TRACE_MODE_STD);
| Set standard trace mode macro.
#define | KER_TRC_SENS hal_set_trace_mode(KER_CTX KER_TRACE_MODE_SENS);
| Set sensitive trace mode macro.
#define | KER_TRC_S hal_sprintf(KER_CTX ar_ch___InfBuffer,sizeof(ar_ch___InfBuffer),
| Open sprintf block macro.
#define | KER_TRC_E ); hal_trace_string(KER_CTX ar_ch___InfBuffer);
| Close sprintf block macro.
#define | KER_TRC_NL hal_trace_string(KER_CTX KER_TRACE_EOL);
| Trace new line macro.
#define | KER_TRC_TIME hal_trace_time(KER_CTX_SINGLE);
| Trace timestamp macro.

## Detailed Description

HAL Trace API declarations.

This functions should be implemented by terminal application

## Macro Definition Documentation

## ◆ KER_COMMENT

#define KER_COMMENT | ( |  | comment | ) |

Value:
do \
{ \
hal_trace_string(KER_CTX comment); \
hal_trace_string(KER_CTX KER_TRACE_EOL); \
} \
while(0)
KER_CTX
#define KER_CTX
Definition: emv_context.h:31
KER_TRACE_EOL
#define KER_TRACE_EOL
Definition: hal_trace.h:140

Default "trace comment" macro.

Redefine this macro to trace all comments (recommended for debug only)

## ◆ KER_COMMENT_FTR

#define KER_COMMENT_FTR | ( |  | ) | KER_COMMENT_FTR_EX(const_ch___CommentHeader)

default trace footer text macro

## ◆ KER_COMMENT_FTR_EX

#define KER_COMMENT_FTR_EX | ( |  | comment | ) |

Value:
do \
{ \
KER_CHAR ar_chHeader[] = "****************************************************************"; \
if ((sizeof(comment) + 12) >= sizeof(ar_chHeader)) \
{ \
hal_trace_string(KER_CTX "*end* "); \
hal_trace_string(KER_CTX comment); \
hal_trace_string(KER_CTX " *end*"); \
} \
else \
{ \
KER_BYTE btOffset = (sizeof(ar_chHeader) - (sizeof(comment) + 12)) / 2; \
KER_MEM_ADD(ar_chHeader, sizeof(ar_chHeader), btOffset, "*end* ", 6); \
KER_MEM_ADD(ar_chHeader, sizeof(ar_chHeader), btOffset + 6, comment, sizeof(comment) - 1); \
KER_MEM_ADD(ar_chHeader, sizeof(ar_chHeader), btOffset + 6 + sizeof(comment) - 1, " *end*", 6); \
hal_trace_string(KER_CTX ar_chHeader); \
} \
hal_trace_string(KER_CTX KER_TRACE_EOL KER_TRACE_EOL); \
hal_trace_flush(KER_CTX_SINGLE); \
} \
while(0)
KER_CTX_SINGLE
#define KER_CTX_SINGLE
Definition: emv_context.h:37

Default "trace comment" macro.

Redefine this macro to trace all comments (recommended for debug only)

## ◆ KER_COMMENT_HDR

#define KER_COMMENT_HDR | ( |  | text | ) | KER_COMMENT_HDR_TEXT(text); KER_COMMENT_HDR_EX(const_ch___CommentHeader)

default trace header text macro

## ◆ KER_COMMENT_HDR_EX

#define KER_COMMENT_HDR_EX | ( |  | comment | ) |

Value:
do \
{ \
KER_COMMENT_HDR_NO_TIME(comment); \
hal_trace_time(KER_CTX_SINGLE); \
hal_trace_string(KER_CTX KER_TRACE_EOL KER_TRACE_EOL); \
} \
while(0)

Default "trace comment" macro.

Redefine this macro to trace all comments (recommended for debug only)

## ◆ KER_COMMENT_HDR_NO_TIME

#define KER_COMMENT_HDR_NO_TIME | ( |  | comment | ) |

Value:
do \
{ \
KER_CHAR ar_chHeader[] = "****************************************************************"; \
hal_trace_string(KER_CTX KER_TRACE_EOL); \
if ((sizeof(comment) + 12) >= sizeof(ar_chHeader)) \
{ \
hal_trace_string(KER_CTX "***** "); \
hal_trace_string(KER_CTX comment); \
hal_trace_string(KER_CTX " *****"); \
} \
else \
{ \
KER_BYTE btOffset = (sizeof(ar_chHeader) - (sizeof(comment) + 2)) / 2; \
ar_chHeader[btOffset] = ' '; \
KER_MEM_ADD(ar_chHeader, sizeof(ar_chHeader), btOffset + 1, comment, sizeof(comment) - 1); \
ar_chHeader[btOffset + sizeof(comment)] = ' '; \
hal_trace_string(KER_CTX ar_chHeader); \
} \
hal_trace_string(KER_CTX KER_TRACE_EOL); \
} \
while(0)

Default "trace comment w/o time" macro.

Redefine this macro to trace all comments (recommended for debug only)

## ◆ KER_COMMENT_HDR_TEXT

#define KER_COMMENT_HDR_TEXT | ( |  | text | ) | const KER_CHAR const_ch___CommentHeader[] = text

default trace header text macro

## ◆ KER_COMMENT_HEX

#define KER_COMMENT_HEX | ( |  | comment_start,
|  |  | buff,
|  |  | buff_len,
|  |  | comment_end
| ) |  |

Value:
do \
{ \
hal_trace_string(KER_CTX comment_start); \
hal_trace_buffer(KER_CTX buff, buff_len); \
hal_trace_string(KER_CTX comment_end); \
} \
while(0)

Default "trace comment with hex data" macro.

Redefine this macro to trace all comments (recommended for debug only)

## ◆ KER_COMMENT_STR

#define KER_COMMENT_STR | ( |  | comment_start,
|  |  | buff,
|  |  | buff_len,
|  |  | comment_end
| ) |  |

Value:
do \
{ \
KER_CHAR ar_ch___Buffer[8]; \
KER_INT16U us___Pos; \
hal_trace_string(KER_CTX comment_start); \
for (us___Pos = 0; us___Pos < (buff_len); us___Pos++) \
{ \
if ((buff)[us___Pos] >= 0x20) \
hal_sprintf(KER_CTX ar_ch___Buffer, sizeof(ar_ch___Buffer), "%c", (KER_CHAR)((buff)[us___Pos])); \
else \
hal_sprintf(KER_CTX ar_ch___Buffer, sizeof(ar_ch___Buffer), "[%02X]", (KER_NATIVE_UINT)((buff)[us___Pos])); \
hal_trace_string(KER_CTX ar_ch___Buffer); \
} \
hal_trace_string(KER_CTX comment_end); \
} \
while(0)
KER_NATIVE_UINT
unsigned int KER_NATIVE_UINT
Definition: emv_platform.h:75
KER_CHAR
char KER_CHAR
Definition: emv_platform.h:65
hal_sprintf
KER_INT32U KER_CDECL hal_sprintf(KER_CTX_PARAM KER_CHAR *pchDestBuffer, KER_INT16U usDestBufferSize, const KER_CHAR *pchFormat,...)
sprintf_s analog

Default "trace comment with hex data" macro.

Redefine this macro to trace all comments (recommended for debug only)

## ◆ KER_COMMENT_TEST_MODE

#define KER_COMMENT_TEST_MODE | ( |  | ) | KER_COMMENT("########################## TEST MODE! ##########################")

default test mode text macro

## ◆ KER_COMMENT_TEST_MODE_DISABLED

#define KER_COMMENT_TEST_MODE_DISABLED | ( |  | ) | KER_COMMENT("###################### TEST MODE DISABLED ######################")

default test mode disabled text macro

## ◆ KER_COMMENT_TEXT

#define KER_COMMENT_TEXT | ( |  | text | ) | hal_trace_string(KER_CTX text)

Default "trace comment" macro.

Redefine this macro to trace all comments (recommended for debug only)

## ◆ KER_DBG

#define KER_DBG | ( |  | ErrLevel | ) | KER_DBG_EX(KER_FALSE,ErrLevel)

check trace level simplified macro

## ◆ KER_DBG_EX

#define KER_DBG_EX | ( |  | IgnoreLevel,
|  |  | ErrLevel
| ) |  | ((KER_DEBUG == KER_TRUE) && ((KER_DEBUG_LEVEL >= ErrLevel) || (KER_DEBUG_ALL == KER_TRUE) || (IgnoreLevel == KER_TRUE)))

check trace level macro

## ◆ KER_DBG_LEVEL_ALL

#define KER_DBG_LEVEL_ALL 99

Trace all

## ◆ KER_DBG_LEVEL_APDU

#define KER_DBG_LEVEL_APDU 30

Trace APDU

## ◆ KER_DBG_LEVEL_ERR

#define KER_DBG_LEVEL_ERR 0

Trace errors

## ◆ KER_DBG_LEVEL_TAG_INFO

#define KER_DBG_LEVEL_TAG_INFO 40

Trace tag related info

## ◆ KER_DBG_LEVEL_TAG_LIST

#define KER_DBG_LEVEL_TAG_LIST 20

Trace tag list

## ◆ KER_DBG_LEVEL_TAG_WARN

#define KER_DBG_LEVEL_TAG_WARN 100

Trace/convert tag warnings

## ◆ KER_DBG_LEVEL_TRACE_COMMENT

#define KER_DBG_LEVEL_TRACE_COMMENT 5

Trace comments

## ◆ KER_DBG_LEVEL_WARN

#define KER_DBG_LEVEL_WARN 2

Trace warnings

## ◆ KER_ERROR

#define KER_ERROR | ( |  | err_code,
|  |  | trace_level,
|  |  | comment
| ) |  |

Value:
do \
{ \
if ((KER_DEBUG == KER_TRUE) && (trace_level <= KER_DEBUG_LEVEL)) \
{ \
/* trace comment firstly*/ \
if (comment != KER_NULL) \
{ \
/* trace to erl */ \
hal_error(KER_CTX trace_level, err_code, comment); \
/* trace to emv */ \
hal_trace_string(KER_CTX comment); \
} \
/* trace error */ \
hal_sprintf(KER_CTX ar_ch___ErrBuffer, sizeof(ar_ch___ErrBuffer), " Error: %08lX" KER_TRACE_EOL, (KER_NATIVE_ULONG)(err_code)); \
/* trace to emv */ \
hal_trace_string(KER_CTX ar_ch___ErrBuffer); \
} \
} \
while(0)
KER_TRUE
#define KER_TRUE
Definition: emv_platform.h:78
KER_NATIVE_ULONG
unsigned long KER_NATIVE_ULONG
Definition: emv_platform.h:74
KER_NULL
#define KER_NULL
Definition: emv_platform.h:80
KER_DEBUG
#define KER_DEBUG
Definition: emv_custom.h:32
KER_DEBUG_LEVEL
#define KER_DEBUG_LEVEL
Definition: emv_custom.h:34

Default "trace error" macro (Release mode)

Default trace error with ansi string comment buffer macro (without diagnostic info - for PCI)

## ◆ KER_INFO

#define KER_INFO KER_DBG_EX(KER_TRUE,0)

check info trace macro

## ◆ KER_SYS_ERROR

#define KER_SYS_ERROR | ( |  | err_code,
|  |  | trace_level,
|  |  | comment
| ) |  | hal_error(KER_CTX trace_level, err_code, comment)

Default "trace system error" macro (Release mode - without extra diagnostic info - for PCI)

Default trace system error with ansi string comment buffer macro Do not trace anything to transaction log (it may not exist yet)!

## ◆ KER_SYS_INFO

#define KER_SYS_INFO | ( |  | err_code,
|  |  | trace_level,
|  |  | comment
| ) |  | hal_error(KER_CTX trace_level, err_code, comment)

Default "trace system info" macro.

Default trace system info with ansi string comment buffer macro Do not trace anything to transaction log (it may not exist yet)!

## ◆ KER_TEXT_HEX

#define KER_TEXT_HEX | ( |  | dest,
|  |  | dest_len,
|  |  | buff,
|  |  | buff_len
| ) |  |

Value:
do \
{ \
KER_INT16U usI; \
KER_CHAR ar_chBuff[8]; \
KER_MEM_SET(dest, dest_len, 0, dest_len); \
for (usI = 0; usI < (KER_BYTE)(buff_len); usI++) \
{ \
hal_sprintf(KER_CTX ar_chBuff, sizeof(ar_chBuff), "%02X", (KER_NATIVE_UINT)buff[usI]); \
KER_MEM_ADD(dest, dest_len, usI * 2, ar_chBuff, 2); \
} \
} \
while(0)
KER_BYTE
uint8_t KER_BYTE
Definition: emv_platform.h:70

Default "fill text string with hex data" macro.

## ◆ KER_TRACE_APDU_INT_REQ_TAB

#define KER_TRACE_APDU_INT_REQ_TAB " Int"

APDU request trace shift

## ◆ KER_TRACE_APDU_INT_RESP_TAB

#define KER_TRACE_APDU_INT_RESP_TAB " Int"

APDU response trace shift

## ◆ KER_TRACE_APDU_REQ

#define KER_TRACE_APDU_REQ | ( |  | bInternal,
|  |  | btCase,
|  |  | btCLA,
|  |  | btINS,
|  |  | btP1,
|  |  | btP2,
|  |  | usLc,
|  |  | pbtData,
|  |  | usLe
| ) |  |

Value:
do \
{ \
hal_sprintf(KER_CTX ar_ch___InfBuffer, sizeof(ar_ch___InfBuffer), "%sRequest: <%02X><%02X><%02X><%02X><%02X> ", \
(bInternal)?KER_TRACE_APDU_INT_REQ_TAB:KER_TRACE_APDU_REQ_TAB,(KER_NATIVE_UINT)(btCLA),(KER_NATIVE_UINT)(btINS),(KER_NATIVE_UINT)(btP1),(KER_NATIVE_UINT)(btP2),(KER_NATIVE_UINT)(usLc)); \
hal_trace_string(KER_CTX ar_ch___InfBuffer); \
if ((hal_get_trace_mode(KER_CTX_SINGLE) == KER_TRACE_MODE_SENS) || (((btCLA) == EMV_APDU_CLA_UNI) && ((btINS) == EMV_APDU_INS_SELECT)))\
hal_trace_buffer(KER_CTX pbtData, usLc); \
else \
hal_trace_string(KER_CTX "..."); \
if (usLe != KER_EMVL1_LE_NULL) \
hal_sprintf(KER_CTX ar_ch___InfBuffer, sizeof(ar_ch___InfBuffer), " <%02X> [Case%u]" KER_TRACE_EOL, (KER_NATIVE_UINT)(usLe), (KER_NATIVE_UINT)(btCase)); \
else \
hal_sprintf(KER_CTX ar_ch___InfBuffer, sizeof(ar_ch___InfBuffer), " [Case%u]" KER_TRACE_EOL, (KER_NATIVE_UINT)(btCase)); \
hal_trace_string(KER_CTX ar_ch___InfBuffer); \
} \
while (0)
KER_EMVL1_LE_NULL
#define KER_EMVL1_LE_NULL
Definition: hal_emvl1.h:34
KER_TRACE_APDU_INT_REQ_TAB
#define KER_TRACE_APDU_INT_REQ_TAB
Definition: hal_trace.h:122
KER_TRACE_APDU_REQ_TAB
#define KER_TRACE_APDU_REQ_TAB
Definition: hal_trace.h:121
hal_trace_string
KER_BOOL hal_trace_string(KER_CTX_PARAM const KER_CHAR *pchString)
Trace povided nul-term string.
hal_get_trace_mode
KER_BYTE hal_get_trace_mode(KER_CTX_SINGLE_PARAM)
Get trace mode.
KER_TRACE_MODE_SENS
#define KER_TRACE_MODE_SENS
Definition: hal_trace.h:119

Default "trace apdu request" macro.

Redefine this macro to trace all apdu requests, which were sent by kernel (for debug only)

Warning
  Data may have sensitive data which are not allowed to trace in production mode!

## ◆ KER_TRACE_APDU_REQ_TAB

#define KER_TRACE_APDU_REQ_TAB " "

APDU request trace shift

## ◆ KER_TRACE_APDU_RESP

#define KER_TRACE_APDU_RESP | ( |  | INTERNAL,
|  |  | SW1SW2,
|  |  | DATA,
|  |  | DATA_LEN
| ) |  |

Value:
do \
{ \
hal_sprintf(KER_CTX ar_ch___InfBuffer, sizeof(ar_ch___InfBuffer), "%sResponse: Len = %u Sw1Sw2 = <%04X> ", (INTERNAL)?KER_TRACE_APDU_INT_RESP_TAB:KER_TRACE_APDU_RESP_TAB,(KER_NATIVE_UINT)(DATA_LEN),(KER_NATIVE_UINT)(SW1SW2)); \
hal_trace_string(KER_CTX ar_ch___InfBuffer); \
if (hal_get_trace_mode(KER_CTX_SINGLE) == KER_TRACE_MODE_SENS) \
hal_trace_buffer(KER_CTX (DATA), (DATA_LEN)); \
hal_trace_string(KER_CTX KER_TRACE_EOL); \
} \
while (0)
KER_TRACE_APDU_RESP_TAB
#define KER_TRACE_APDU_RESP_TAB
Definition: hal_trace.h:124
KER_TRACE_APDU_INT_RESP_TAB
#define KER_TRACE_APDU_INT_RESP_TAB
Definition: hal_trace.h:123

Default "trace apdu response" macro.

Redefine this macro to trace all apdu responses, which were sent by card (for debug only)

Warning
  Data may have sensitive data which are not allowed to trace in production mode!

## ◆ KER_TRACE_APDU_RESP_TAB

#define KER_TRACE_APDU_RESP_TAB " "

APDU response trace shift

## ◆ KER_TRACE_CL_DEFAULT

#define KER_TRACE_CL_DEFAULT /* force to include default implementation - see hal_trace_def.c */

Default "trace candidate list" macro.

Redefine this macro to trace cl

## ◆ KER_TRACE_COMB_TAB

#define KER_TRACE_COMB_TAB " "

Combination related info trace shift

## ◆ KER_TRACE_CVM_LIST

#define KER_TRACE_CVM_LIST | ( |  | TranPtr,
|  |  | TrType,
|  |  | TrCurr,
|  |  | IccCurr,
|  |  | AmountX,
|  |  | AmountY
| ) |  |

Value:
do \
{ \
hal_sprintf(KER_CTX ar_ch___InfBuffer, sizeof(ar_ch___InfBuffer), "CVM List processing: TrType:%02lX Curr:%03lu/%03lu TrAmount:%lu%s CashbackAmount:%lu%s Amount X:%lu Amount Y:%lu StartPos:%lu" KER_TRACE_EOL, \
(KER_NATIVE_ULONG)(TrType), (KER_NATIVE_ULONG)(TrCurr), (KER_NATIVE_ULONG)(IccCurr), \
(KER_NATIVE_ULONG)(TranPtr->ulAmountAuthLO), (TranPtr->ulAmountAuthHI > 0)?"(!)":"", \
(KER_NATIVE_ULONG)(TranPtr->ulAmountOtherLO), (TranPtr->ulAmountOtherHI > 0)?"(!)":"", \
(KER_NATIVE_ULONG)(AmountX), (KER_NATIVE_ULONG)(AmountY), (KER_NATIVE_ULONG)((TranPtr->usCvmOffset - 8)/2)); \
hal_trace_string(KER_CTX ar_ch___InfBuffer); \
} \
while (0)

Default "trace cvm list" macro.

Redefine this macro to trace cvm list from icc

## ◆ KER_TRACE_EOL

#define KER_TRACE_EOL "\r\n"

default eol macro

## ◆ KER_TRACE_MODE_SENS

#define KER_TRACE_MODE_SENS 0x01

Trace sensitive data

## ◆ KER_TRACE_MODE_STD

#define KER_TRACE_MODE_STD 0x00

STD Trace (skip sensitive data)

## ◆ KER_TRACE_NFC_APDU_RESP

#define KER_TRACE_NFC_APDU_RESP | ( |  | INTERNAL,
|  |  | SW1SW2,
|  |  | EXEC_TIME,
|  |  | DATA,
|  |  | DATA_LEN
| ) |  |

Value:
do \
{ \
hal_sprintf(KER_CTX ar_ch___InfBuffer, sizeof(ar_ch___InfBuffer), "%sResponse: Time = %lu Len = %u Sw1Sw2 = <%04X> ", \
(INTERNAL)?KER_TRACE_APDU_INT_RESP_TAB:KER_TRACE_APDU_RESP_TAB, (KER_NATIVE_ULONG)(EXEC_TIME), (KER_NATIVE_UINT)(DATA_LEN), (KER_NATIVE_UINT)(SW1SW2)); \
hal_trace_string(KER_CTX ar_ch___InfBuffer); \
if (hal_get_trace_mode(KER_CTX_SINGLE) == KER_TRACE_MODE_SENS) \
hal_trace_buffer(KER_CTX (DATA), (DATA_LEN)); \
hal_trace_string(KER_CTX KER_TRACE_EOL); \
} \
while (0)

Default "trace nfc apdu response" macro.

Redefine this macro to trace all apdu responses, which were sent by card (for debug only)

Warning
  Data may have sensitive data which are not allowed to trace in production mode!

## ◆ KER_TRACE_SUPP_APP_LIST_DEFAULT

#define KER_TRACE_SUPP_APP_LIST_DEFAULT /* force to include default implementation - see hal_trace_def.c */

Default "trace supported applications" macro.

Redefine this macro to trace all supported by terminal applications

## ◆ KER_TRACE_TAG_DEFAULT

#define KER_TRACE_TAG_DEFAULT /* force to include default implementation - see hal_trace_def.c */

Default "trace obtained tag " macro.

Redefine this macro to trace tag added

## ◆ KER_TRACE_TAG_DUPLICATION

#define KER_TRACE_TAG_DUPLICATION | ( |  | tag,
|  |  | tag_length,
|  |  | tlv1,
|  |  | tlv1_length,
|  |  | tlv2,
|  |  | tlv2_length
| ) |  |

Value:
do \
{ \
hal_trace_string(KER_CTX "Tag ["); \
hal_trace_buffer(KER_CTX tag, tag_length); \
hal_trace_string(KER_CTX "] duplication!" KER_TRACE_EOL); \
} \
while (0)

Default "tag duplication" macro.

Redefine this macro to trace duplicated tags (recommended for debug only)

Warning
  Warning, tlv buffers may contain sensitive data!!!

## ◆ KER_TRACE_TAG_NOT_FOUND

#define KER_TRACE_TAG_NOT_FOUND | ( |  | tag,
|  |  | tag_length
| ) |  |

Value:
do \
{ \
hal_trace_string(KER_CTX "Tag ["); \
hal_trace_buffer(KER_CTX tag, tag_length); \
hal_trace_string(KER_CTX "] not found!" KER_TRACE_EOL); \
} \
while (0)

Default "trace tag not found" macro.

Redefine this macro to trace all tags, which were not found by kernel (recommended for debug only)

## ◆ KER_TRACE_TIME

#define KER_TRACE_TIME | ( |  | ) | hal_trace_time(KER_CTX_SINGLE)

Default "trace comment" macro.

Redefine this macro to trace current time (recommended for debug only)

## ◆ KER_TRACE_TVR_DEFAULT

#define KER_TRACE_TVR_DEFAULT /* force to include default implementation - see hal_trace_def.c */

Default "trace TVR/TAC/IAC " macro.

Redefine this macro to trace TVR/TAC/IAC

## Function Documentation

## ◆ hal_error()

KER_BOOL hal_error | ( | KER_CTX_PARAM KER_INT16U | usTraceLevel,
|  | KER_RES | resErrCode,
|  | const KER_CHAR * | pchErrorText
| ) |  |

Trace error to system error journal.

Parameters

  [in] | usTraceLevel | trace level (KER_DBG_LEVEL_ERR, etc..)
  [in] | resErrCode | error code
  [in] | pchErrorText | nul-term string to trace

Returns
  KER_TRUE Success
  KER_FALSE Trace failure

## ◆ hal_get_trace_mode()

KER_BYTE hal_get_trace_mode | ( | KER_CTX_SINGLE_PARAM |  | ) |

Get trace mode.

Returns
  Trace mode value set by hal_set_trace_mode

## ◆ hal_keep_trace_time()

KER_BOOL hal_keep_trace_time | ( | KER_CTX_PARAM KER_BYTE * | pbtTimeBuffer,
|  | KER_INT16U * | pusTimeBufferSize
| ) |  |

Keep trace timestamp.

Parameters

  [in] | pbtTimeBuffer | Buffer to trace
  [in,out] | pusTimeBufferSize | pbtTimeBuffer size as input, stored time length as output

Returns
  KER_TRUE Success
  KER_FALSE Trace failure

## ◆ hal_set_trace_mode()

KER_BOOL hal_set_trace_mode | ( | KER_CTX_PARAM KER_BYTE | btTraceMode | ) |

Set trace mode.

Parameters

  [in] | btTraceMode | pass KER_TRACE_MODE_STD to trace standard data and KER_TRACE_MODE_SENS to trace sensitive data

Returns
  KER_TRUE Success
  KER_FALSE Trace failure

## ◆ hal_trace_buffer()

KER_BOOL hal_trace_buffer | ( | KER_CTX_PARAM const KER_BYTE * | pbtDataBuffer,
|  | KER_INT16U | usDataBufferSize
| ) |  |

Trace povided data buffer.

Parameters

  [in] | pbtDataBuffer | Buffer to trace
  [in] | usDataBufferSize | pbtDataBuffer size

Returns
  KER_TRUE Success
  KER_FALSE Trace failure

## ◆ hal_trace_flush()

KER_BOOL hal_trace_flush | ( | KER_CTX_SINGLE_PARAM |  | ) |

Flush trace to trace file (optional)

Returns
  KER_TRUE Success
  KER_FALSE Flush failure

## ◆ hal_trace_string()

KER_BOOL hal_trace_string | ( | KER_CTX_PARAM const KER_CHAR * | pchString | ) |

Trace povided nul-term string.

Parameters

  [in] | pchString | nul-term string to trace

Returns
  KER_TRUE Success
  KER_FALSE Trace failure

## ◆ hal_trace_time()

KER_BOOL hal_trace_time | ( | KER_CTX_SINGLE_PARAM |  | ) |

Trace timestamp.

Returns
  KER_TRUE Success
  KER_FALSE Trace failure