Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Fix compilation: remove GCC warning to comply with mbedtls 2.24 #45

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion optiga/cmd/CommandLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,12 @@ typedef enum eFragSeq_d
eContinue = 0x02
}eFragSeq_d;

volatile static host_lib_status_t optiga_comms_status;
static volatile host_lib_status_t optiga_comms_status;

//lint --e{715, 818} suppress "This is ignored as app_event_handler_t handler function prototype requires this argument.This will be used for object based implementation"
static void optiga_comms_event_handler(void* upper_layer_ctx, host_lib_status_t event)
{
(void)upper_layer_ctx;
optiga_comms_status = event;
}

Expand Down
3 changes: 3 additions & 0 deletions optiga/common/Logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ pFWriteData pfWriter = (pFWriteData)UartWriteData;
static int32_t WriteData(uint32_t PdwHandle, const uint8_t* PprgbBuf, uint32_t PdwDataLen)
{
//lint --e{715} suppress "The parameters are not used as this is filler function"
(void)PdwHandle;
(void)PprgbBuf;
(void)PdwDataLen;
return 1;
}
pFWriteData pfWriter = (pFWriteData)WriteData;
Expand Down
11 changes: 9 additions & 2 deletions optiga/comms/ifx_i2c/ifx_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ host_lib_status_t ifx_i2c_set_slave_address(ifx_i2c_context_t *p_ctx, uint8_t sl
//lint --e{715} suppress "This is ignored as ifx_i2c_event_handler_t handler function prototype requires this argument"
void ifx_i2c_tl_event_handler(ifx_i2c_context_t* p_ctx,host_lib_status_t event, const uint8_t* p_data, uint16_t data_len)
{
(void)p_data;
(void)data_len;
// If there is no upper layer handler, don't do anything and return
if (NULL != p_ctx->upper_layer_event_handler)
{
Expand All @@ -374,6 +376,11 @@ void ifx_i2c_tl_event_handler(ifx_i2c_context_t* p_ctx,host_lib_status_t event,
}
}

static host_lib_status_t ifx_i2c_init(ifx_i2c_context_t* p_ifx_i2c_context);
static void ifx_i2c_init_cb(void * p_ifx_i2c_context)
{
(void)ifx_i2c_init((ifx_i2c_context_t *) p_ifx_i2c_context);
}

static host_lib_status_t ifx_i2c_init(ifx_i2c_context_t* p_ifx_i2c_context)
{
Expand All @@ -392,7 +399,7 @@ static host_lib_status_t ifx_i2c_init(ifx_i2c_context_t* p_ifx_i2c_context)
}
pal_gpio_set_low(p_ifx_i2c_context->p_slave_reset_pin);
p_ifx_i2c_context->reset_state = IFX_I2C_STATE_RESET_PIN_HIGH;
pal_os_event_register_callback_oneshot((register_callback)ifx_i2c_init,
pal_os_event_register_callback_oneshot((register_callback)ifx_i2c_init_cb,
(void *)p_ifx_i2c_context, RESET_LOW_TIME_MSEC);
api_status = IFX_I2C_STACK_SUCCESS;
break;
Expand All @@ -405,7 +412,7 @@ static host_lib_status_t ifx_i2c_init(ifx_i2c_context_t* p_ifx_i2c_context)
}
pal_gpio_set_high(p_ifx_i2c_context->p_slave_reset_pin);
p_ifx_i2c_context->reset_state = IFX_I2C_STATE_RESET_INIT;
pal_os_event_register_callback_oneshot((register_callback)ifx_i2c_init,
pal_os_event_register_callback_oneshot((register_callback)ifx_i2c_init_cb,
(void *)p_ifx_i2c_context, STARTUP_TIME_MSEC);
api_status = IFX_I2C_STACK_SUCCESS;
break;
Expand Down
33 changes: 33 additions & 0 deletions optiga/comms/ifx_i2c/ifx_i2c_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,39 @@ ifx_i2c_context_t ifx_i2c_context_0 =
&optiga_reset_0,
/// optiga pal i2c context
&optiga_pal_i2c_context_0,

/// Upper layer event handler
NULL,
/// Upper layer context
NULL,
/// Pointer to upper layer rx buffer
NULL,
/// Pointer to length of upper layer rx buffer
NULL,

/// Protocol variables
/// ifx i2c wrapper apis state
0,
/// ifx i2c wrapper api status
0,
/// reset states
0,
/// type of reset
0,
/// init pal
0,

/// Transport layer context
{ },
/// Datalink layer context
{ },
/// Physical layer context
{ },

/// IFX I2C tx frame of max length
{ 0, },
/// IFX I2C rx frame of max length
{ 0, },
};

/***********************************************************************************************************************
Expand Down
1 change: 1 addition & 0 deletions optiga/comms/ifx_i2c/ifx_i2c_physical_layer.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,7 @@ static void ifx_i2c_pl_soft_reset(ifx_i2c_context_t *p_ctx)
//lint --e{818} suppress "This is ignored as upper layer handler function prototype requires this argument"
static void ifx_i2c_pl_pal_slave_addr_event_handler(void *p_ctx, host_lib_status_t event)
{
(void)p_ctx;
pal_event_status = event;
}

3 changes: 3 additions & 0 deletions optiga/crypt/optiga_crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,9 @@ optiga_lib_status_t optiga_crypt_tls_prf_sha256(uint16_t secret,
sDeriveKeyOptions_d derivekey_options;
sbBlob_d derivekey_output_buffer;

(void)label;
(void)label_length;

derivekey_options.eKDM = eTLS_PRF_SHA256;
derivekey_options.sSeed.prgbStream = seed;
derivekey_options.sSeed.wLen = seed_length;
Expand Down
3 changes: 3 additions & 0 deletions optiga/include/optiga/pal/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ typedef uint16_t pal_status_t;
* API Prototypes
*********************************************************************************************************************/

pal_status_t pal_init(void);
pal_status_t pal_deinit(void);

#endif /* _PAL_H_ */

/**
Expand Down
3 changes: 3 additions & 0 deletions optiga/include/optiga/pal/pal_gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ void pal_gpio_set_high(const pal_gpio_t* p_gpio_context);
*/
void pal_gpio_set_low(const pal_gpio_t* p_gpio_context);

pal_status_t pal_gpio_init(const pal_gpio_t * p_gpio_context);
pal_status_t pal_gpio_deinit(const pal_gpio_t * p_gpio_context);

#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 2 additions & 0 deletions optiga/include/optiga/pal/pal_os_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ pal_status_t pal_os_event_init(void);
*/
void pal_os_event_register_callback_oneshot(register_callback callback, void* callback_args, uint32_t time_us);

pal_status_t pal_os_event_init(void);
pal_status_t pal_os_event_stop(void);


#endif //_PAL_OS_EVENT_H_
Expand Down
3 changes: 2 additions & 1 deletion optiga/util/optiga_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@
///Length of metadata
#define LENGTH_METADATA 0x1C

volatile static host_lib_status_t optiga_comms_status;
static volatile host_lib_status_t optiga_comms_status;

#ifdef MODULE_ENABLE_READ_WRITE

static void __optiga_util_comms_event_handler(void* upper_layer_ctx, host_lib_status_t event)
{
(void)upper_layer_ctx;
optiga_comms_status = event;
}

Expand Down
8 changes: 6 additions & 2 deletions pal/linux/pal_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ GPIODirection(int pin, int dir)
{
static const char s_directions_str[] = "in\0out";

#define DIRECTION_MAX 34
#define DIRECTION_MAX 48
char path[DIRECTION_MAX];
int fd;

Expand Down Expand Up @@ -136,9 +136,11 @@ GPIOWrite(pal_linux_gpio_t* pin, int value)
//lint --e{714,715} suppress "This function is used for to support multiple platforms "
pal_status_t pal_gpio_init(const pal_gpio_t * p_gpio_context)
{
#define VALUE_MAX 30
#define VALUE_MAX 48
char path[VALUE_MAX] = {0};

(void)p_gpio_context;

if (optiga_reset_0.p_gpio_hw != NULL)
{
pal_linux_gpio_t* gpio_reset = optiga_reset_0.p_gpio_hw;
Expand Down Expand Up @@ -199,6 +201,8 @@ pal_status_t pal_gpio_init(const pal_gpio_t * p_gpio_context)
//lint --e{714,715} suppress "This function is used for to support multiple platforms "
pal_status_t pal_gpio_deinit(const pal_gpio_t * p_gpio_context)
{
(void)p_gpio_context;

if (optiga_reset_0.p_gpio_hw != NULL)
{
pal_linux_gpio_t* gpio = (pal_linux_gpio_t*)(optiga_reset_0.p_gpio_hw);
Expand Down
39 changes: 4 additions & 35 deletions pal/linux/pal_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ static pal_i2c_t * gp_pal_i2c_current_ctx;
//lint --e{715} suppress the unused p_i2c_context variable lint error , since this is kept for future enhancements
static pal_status_t pal_i2c_acquire(const void * p_i2c_context)
{
(void)p_i2c_context;
if (0 == g_entry_count)
{
g_entry_count++;
Expand All @@ -87,6 +88,7 @@ static pal_status_t pal_i2c_acquire(const void * p_i2c_context)
//lint --e{715} suppress the unused p_i2c_context variable lint, since this is kept for future enhancements
static void pal_i2c_release(const void* p_i2c_context)
{
(void)p_i2c_context;
g_entry_count = 0;
}
/// @endcond
Expand Down Expand Up @@ -117,47 +119,13 @@ void i2c_master_end_of_receive_callback(void)
invoke_upper_layer_callback(gp_pal_i2c_current_ctx, PAL_I2C_EVENT_SUCCESS);
}

// I2C error callback function
void i2c_master_error_detected_callback(void)
{
//I2C_MASTER_t *p_i2c_master;
//
//p_i2c_master = gp_pal_i2c_current_ctx->p_i2c_hw_config;
//if (I2C_MASTER_IsTxBusy(p_i2c_master))
//{
// //lint --e{534} suppress "Return value is not required to be checked"
// I2C_MASTER_AbortTransmit(p_i2c_master);
// while (I2C_MASTER_IsTxBusy(p_i2c_master)){}
//}

//if (I2C_MASTER_IsRxBusy(p_i2c_master))
//{
// //lint --e{534} suppress "Return value is not required to be checked"
// I2C_MASTER_AbortReceive(p_i2c_master);
// while (I2C_MASTER_IsRxBusy(p_i2c_master)){}
//}

invoke_upper_layer_callback(gp_pal_i2c_current_ctx, PAL_I2C_EVENT_ERROR);
}


void i2c_master_nack_received_callback(void)
{
i2c_master_error_detected_callback();
}

void i2c_master_arbitration_lost_callback(void)
{
i2c_master_error_detected_callback();
}


/// @endcond

pal_status_t pal_i2c_init(const pal_i2c_t* p_i2c_context)
{
int32_t ret = PAL_I2C_EVENT_ERROR;
pal_linux_t *pal_linux;
(void)p_i2c_context;
do
{
pal_linux = (pal_linux_t*) p_i2c_context->p_i2c_hw_config;
Expand All @@ -182,6 +150,7 @@ pal_status_t pal_i2c_deinit(const pal_i2c_t* p_i2c_context)
{
LOG_HAL("pal_i2c_deinit\n. ");

(void)p_i2c_context;
return PAL_STATUS_SUCCESS;
}

Expand Down
4 changes: 4 additions & 0 deletions pal/linux/pal_os_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ static void handler(int sig, siginfo_t *si, void *uc)
{
register_callback callback;

(void)sig;
(void)si;
(void)uc;

if (pal_os_event_0.callback_registered)
{
callback = pal_os_event_0.callback_registered;
Expand Down
2 changes: 1 addition & 1 deletion pal/linux/pal_os_lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ typedef struct pal_os_lock
uint8_t lock;
} pal_os_lock_t;

volatile static pal_os_lock_t pal_os_lock = {.lock = 0};
static volatile pal_os_lock_t pal_os_lock = {.lock = 0};

pal_status_t pal_os_lock_acquire(void)
{
Expand Down