hsw-nbt 1.2.0
OPTIGA Authenticate NBT Host Library for C
Macros | Typedefs | Functions
ifx-error.h File Reference

Infineon specific error code creation and parsing. More...

#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Macros

#define IFX_MODULE(library_id, module_id)    (uint16_t) (((library_id & 0x7F) << 8) | (module_id & 0xFF))
 Encoding of module id and library id into 2 bytes. Bit: 15 Set in macro IFX_ERROR to denote error identifier. Bits: 14-8 Library identifier code Bits: 7-0 Module identifier code.
 
#define IFX_SUCCESS   ((ifx_status_t) 0x00000000)
 Default status code for successful calls to any function.
 
#define IFX_ERROR_INDICATOR   ((ifx_status_t) 0x80000000u)
 Error indicator bitmask.
 
#define IFX_UNSPECIFIED_ERROR   ((uint8_t) 0xffu)
 Function independent error reason for unspecified errors.
 
#define IFX_OUT_OF_MEMORY   ((uint8_t) 0xfeu)
 Function independent error reason for out of memory errors.
 
#define IFX_ILLEGAL_ARGUMENT   ((uint8_t) 0xfdu)
 Function independent error reason for illegal argument value.
 
#define IFX_TOO_LITTLE_DATA   ((uint8_t) 0xfcu)
 Function independent error reason if too little data available.
 
#define IFX_INVALID_STATE   ((uint8_t) 0xfbu)
 Function independent error reason if any object is in an invalid state.
 
#define IFX_PROGRAMMING_ERROR   ((uint8_t) 0xfau)
 Function independent error reason for errors that should not occur because they should be prevented by the code.
 
#define IFX_ERROR(module, function, reason)
 Creates IFX encoded error code for given module, function and reason.
 

Typedefs

typedef uint32_t ifx_status_t
 Custom return code type used by all Infineon host software libraries.
 

Functions

bool ifx_error_check (ifx_status_t status_code)
 Checks if status code indicates error.
 
uint8_t ifx_error_get_library (ifx_status_t error_code)
 Extracts library identifier from error code.
 
uint8_t ifx_error_get_module (ifx_status_t error_code)
 Extracts module identifier from error code.
 
uint8_t ifx_error_get_function (ifx_status_t error_code)
 Extracts function identifier from error code.
 
uint8_t ifx_error_get_reason (ifx_status_t error_code)
 Extracts function specific reason from error code.
 

Detailed Description

Infineon specific error code creation and parsing.

Definition in file ifx-error.h.

Macro Definition Documentation

◆ IFX_ERROR

#define IFX_ERROR ( module,
function,
reason )
Value:
((ifx_status_t) (IFX_ERROR_INDICATOR | (((module >> 8) & 0x7Fu) << 24) | \
(((module) & 0xFFu) << 16) | \
(((function) & 0xFFu) << 8) | ((reason) & 0xFFu)))
uint32_t ifx_status_t
Custom return code type used by all Infineon host software libraries.
Definition ifx-error.h:91
#define IFX_ERROR_INDICATOR
Error indicator bitmask.
Definition ifx-error.h:34

Creates IFX encoded error code for given module, function and reason.

IFX error codes have the following schema:

  • bit 31 Error indicator.
  • bits 30-24 Library identifier(e.g. LIB_NBT_APDU)
  • bits 23-16 Module identifier (e.g. NBT_BUILD_CMD_ID).
  • bits 15-8 Function identifier in module (e.g. apdu_decode).
  • bits 7-0 Function specific reason (e.g. apdu_decode too little data).
Parameters
[in]moduleLibrary and module identifier.
[in]functionFunction identifier.
[in]reasonFunction specific reason.

Definition at line 83 of file ifx-error.h.

83#define IFX_ERROR(module, function, reason) \
84 ((ifx_status_t) (IFX_ERROR_INDICATOR | (((module >> 8) & 0x7Fu) << 24) | \
85 (((module) & 0xFFu) << 16) | \
86 (((function) & 0xFFu) << 8) | ((reason) & 0xFFu)))

◆ IFX_ERROR_INDICATOR

#define IFX_ERROR_INDICATOR   ((ifx_status_t) 0x80000000u)

Error indicator bitmask.

Definition at line 34 of file ifx-error.h.

◆ IFX_ILLEGAL_ARGUMENT

#define IFX_ILLEGAL_ARGUMENT   ((uint8_t) 0xfdu)

Function independent error reason for illegal argument value.

Definition at line 49 of file ifx-error.h.

◆ IFX_INVALID_STATE

#define IFX_INVALID_STATE   ((uint8_t) 0xfbu)

Function independent error reason if any object is in an invalid state.

Definition at line 60 of file ifx-error.h.

◆ IFX_MODULE

#define IFX_MODULE ( library_id,
module_id )    (uint16_t) (((library_id & 0x7F) << 8) | (module_id & 0xFF))

Encoding of module id and library id into 2 bytes. Bit: 15 Set in macro IFX_ERROR to denote error identifier. Bits: 14-8 Library identifier code Bits: 7-0 Module identifier code.

Definition at line 23 of file ifx-error.h.

23#define IFX_MODULE(library_id, module_id) \
24 (uint16_t) (((library_id & 0x7F) << 8) | (module_id & 0xFF))

◆ IFX_OUT_OF_MEMORY

#define IFX_OUT_OF_MEMORY   ((uint8_t) 0xfeu)

Function independent error reason for out of memory errors.

Definition at line 44 of file ifx-error.h.

◆ IFX_PROGRAMMING_ERROR

#define IFX_PROGRAMMING_ERROR   ((uint8_t) 0xfau)

Function independent error reason for errors that should not occur because they should be prevented by the code.

Definition at line 66 of file ifx-error.h.

◆ IFX_SUCCESS

#define IFX_SUCCESS   ((ifx_status_t) 0x00000000)

Default status code for successful calls to any function.

Definition at line 29 of file ifx-error.h.

◆ IFX_TOO_LITTLE_DATA

#define IFX_TOO_LITTLE_DATA   ((uint8_t) 0xfcu)

Function independent error reason if too little data available.

Definition at line 54 of file ifx-error.h.

◆ IFX_UNSPECIFIED_ERROR

#define IFX_UNSPECIFIED_ERROR   ((uint8_t) 0xffu)

Function independent error reason for unspecified errors.

Definition at line 39 of file ifx-error.h.

Typedef Documentation

◆ ifx_status_t

typedef uint32_t ifx_status_t

Custom return code type used by all Infineon host software libraries.

Definition at line 91 of file ifx-error.h.

Function Documentation

◆ ifx_error_check()

bool ifx_error_check ( ifx_status_t status_code)

Checks if status code indicates error.

Parameters
[in]status_codeStatus code to be checked.
Returns
bool true if status_code indicates error.

◆ ifx_error_get_function()

uint8_t ifx_error_get_function ( ifx_status_t error_code)

Extracts function identifier from error code.

No checks for error indicator are performed, so ifx_error_check() must have been called beforehand.

Parameters
[in]error_codeError code to extract function identifier from.
Returns
uint8_t Function identifier.

◆ ifx_error_get_library()

uint8_t ifx_error_get_library ( ifx_status_t error_code)

Extracts library identifier from error code.

No checks for error indicator are performed, so ifx_error_check() must have been called beforehand.

Parameters
[in]error_codeError code to extract module identifier from.
Returns
uint8_t Library identifier.

◆ ifx_error_get_module()

uint8_t ifx_error_get_module ( ifx_status_t error_code)

Extracts module identifier from error code.

No checks for error indicator are performed, so ifx_error_check() must have been called beforehand.

Parameters
[in]error_codeError code to extract module identifier from.
Returns
uint8_t Module identifier.

◆ ifx_error_get_reason()

uint8_t ifx_error_get_reason ( ifx_status_t error_code)

Extracts function specific reason from error code.

No checks for error indicator are performed, so ifx_error_check() must have been called beforehand.

Parameters
[in]error_codeError code to extract function specific reason from.
Returns
uint8_t Function specific reason.