/******************************************************************************* * Copyright (C) ST-Ericsson SA 2011 * License terms: 3-clause BSD license ******************************************************************************/ #ifndef _INCLUSION_GUARD_T_COMMUNICATION_SERVICE_H_ #define _INCLUSION_GUARD_T_COMMUNICATION_SERVICE_H_ /** * @addtogroup ldr_communication_serv * @{ * */ /******************************************************************************* * Includes ******************************************************************************/ #include "c_system.h" #include "t_basicdefinitions.h" #include "error_codes.h" #include "t_security_algorithms.h" #include "t_command_protocol.h" #include "t_queue.h" #include "t_time_utilities.h" #ifndef CFG_ENABLE_LOADER_TYPE #ifdef WIN32 #include #endif #endif /******************************************************************************* * Types, constants and external variables ******************************************************************************/ /* Defined protocol families */ typedef enum { R15_FAMILY = 0, /*< R15 protocol family. */ A2_FAMILY = 1, /*< A2 protocol family. */ #ifndef CFG_ENABLE_LOADER_TYPE TI_FAMILY = 2, /*< TI protocol family. */ PROTROM_FAMILY = 3, /*< PROTROM protocol family. */ Z_FAMILY = 4 /*< Z protocol family. */ #endif } Family_t; typedef void (*CommunicationCallback_t)(const void *Data_p, const uint32 Length, void *Param_p); typedef void (*HashCallback_t)(void *Data_p, const uint32 Length, uint8 *Hash_p, void *Param_p); typedef boolean(*DeviceRead_fn)(void *Data_p, uint32 Length, CommunicationCallback_t Callback_fn, void *Param_p); typedef ErrorCode_e(*DeviceWrite_fn)(void *Data_p, uint32 Length, CommunicationCallback_t Callback_fn, void *Param_p); typedef ErrorCode_e(*DeviceCancel_fn)(void *Param_p); typedef void (*HashDeviceCancel_fn)(void *Object_p, void **Param_p); typedef void (*DeviceCalculate_fn)(void *Object_p, HashType_e Type, void *Data_p, const uint32 Length, uint8 *Hash_p, HashCallback_t Callback_fn, void *Param_p); /** definition of Buffer interface functions */ typedef ErrorCode_e(*BuffersInit_t)(void *Object_p); typedef void *(*BufferAllocate_t)(void *Object_p, int BufferSize); typedef ErrorCode_e(*BufferRelease_t)(void *Object_p, void *Buffer_p, int BufferSize); typedef uint32(*BuffersAvailable_t)(void *Object_p, int BufferSize); typedef void (*BuffersDeinit_t)(void *Object_p); /** definition of Timer interface functions */ typedef ErrorCode_e(*TimersInit_t)(void *Object_p, uint32 Timers); typedef uint32(*TimerGet_t)(void *Object_p, Timer_t *Timer_p); typedef ErrorCode_e(*TimerRelease_t)(void *Object_p, uint32 TimerKey); typedef uint32(*ReadTime_t)(void *Object_p, uint32 TimerKey); typedef uint32(*GetSystemTime_t)(void *Object_p); /** definition of Queue interface functions */ typedef void (*FifoCreate_t)(void *Object_p, void **const Queue_pp, const uint32 MaxLength, void (*DestroyElement)(void *Element_p)); typedef void (*FifoDestroy_t)(void *Object_p, void **const Queue_pp); typedef ErrorCode_e(*FifoEnqueue_t)(void *Object_p, void *const Queue_p, void *const Value_p); typedef void *(*FifoDequeue_t)(void *Object_p, void *const Queue_p); typedef QueueCallback_fn(*Fifo_SetCallback_t)(void *Object_p, void *const Queue_p, const QueueCallbackType_e Type, const QueueCallback_fn Callback, void *const Param_p); typedef boolean(*Fifo_IsEmpty_t)(void *Object_p, const void *const Queue_p); typedef boolean(*Fifo_IsMember_t)(void *Object_p, const void *const Queue_p, void *Value_p, boolean(*Match)(void *Value1_p, void *Value2_p)); typedef int (*Fifo_GetNrOfElements_t)(void *Object_p, const void *const Queue_p); typedef void (*RFifoCreate_t)(void *Object_p, void **const Queue_pp, const uint32 MaxLength, void (*DestroyElement)(void *Element_p)); typedef void (*RFifoDestroy_t)(void *Object_p, void **const Queue_pp); typedef ErrorCode_e(*RFifoEnqueue_t)(void *Object_p, void *const Queue_p, void *const Value_p); typedef void *(*RFifoDequeue_t)(void *Object_p, void *const Queue_p); typedef QueueCallback_fn(*RFifo_SetCallback_t)(void *Object_p, void *const Queue_p, const QueueCallbackType_e Type, const QueueCallback_fn Callback, void *const Param_p); typedef boolean(*RFifo_IsEmpty_t)(void *Object_p, const void *const Queue_p); typedef boolean(*RFifo_IsMember_t)(void *Object_p, const void *const Queue_p, void *Value_p, boolean(*Match)(void *Value1_p, void *Value2_p)); typedef int (*RFifo_GetNrOfElements_t)(void *Object_p, const void *const Queue_p); typedef ErrorCode_e(*Do_CEH_Call_t)(void *Object_p, CommandData_t *CmdData_p); /** Structure with pointers to buffer interface functions */ typedef struct { BuffersInit_t BuffersInit_Fn; /**< Pointer to function for Buffers initialization. */ BufferAllocate_t BufferAllocate_Fn; /**< Pointer to function for Buffer allocation. */ BufferRelease_t BufferRelease_Fn; /**< Pointer to function for Buffer releasing.*/ BuffersAvailable_t BuffersAvailable_Fn; /**< Pointer to function for check for available buffers with specified size of buffers. */ BuffersDeinit_t BuffersDeinit_Fn; /**< Pointer to function for Buffers de-initialization. */ void *Object_p; /**< Pointer for instancing. It is used in the PC application, but in the loaders is always NULL */ } BuffersInterface_t; /** Structure with pointers to timer interface functions */ typedef struct { TimersInit_t TimersInit_Fn; /**< Pointer to function for Timers initialization. */ TimerGet_t TimerGet_Fn; /**< Pointer to function for creating and starting timer. */ TimerRelease_t TimerRelease_Fn; /**< Pointer to function for removing defined timer. */ ReadTime_t ReadTime_Fn; /**< Pointer to function for read time from specified timer. */ GetSystemTime_t GetSystemTime_Fn; /**< Pointer to function for read curent sytem time. */ void *Object_p; /**< Pointer for instancing. It is used in the PC application, but in the loaders is always NULL */ } TimersInterface_t; /** Structure with pointers to queue interface functions */ typedef struct { FifoCreate_t FifoCreate_Fn; /**< Pointer to function for Fifo creating.*/ FifoDestroy_t FifoDestroy_Fn; /**< Pointer to function for Fifo destroying.*/ FifoEnqueue_t FifoEnqueue_Fn; /**< Pointer to function for enqueue packet in the fifo. */ FifoDequeue_t FifoDequeue_Fn; /**< Pointer to function for dequeue packet from the fifo. */ Fifo_SetCallback_t Fifo_SetCallback_Fn; /**< Pointer to function for registers an event listener for the specified queue.*/ Fifo_IsEmpty_t Fifo_IsEmpty_Fn; /**< Pointer to function for check, is Fifo empty.*/ Fifo_IsMember_t Fifo_IsMember_Fn; /**< Pointer to function for Checks if the provided element is member of the fifo*/ Fifo_GetNrOfElements_t Fifo_GetNrOfElements_Fn; /**< Pointer to function for reading the number of elements in the Fifo.*/ RFifoCreate_t RFifoCreate_Fn; /**< Pointer to function for Fifo creating. First all interrupts are disabled, function executed and then all interrupt enabled. */ RFifoDestroy_t RFifoDestroy_Fn; /**< Pointer to function for Fifo destroing. First all interrupts are disabled, function executed and then all interrupt enabled. */ RFifoEnqueue_t RFifoEnqueue_Fn; /**< Pointer to function for enqueue packet in the fifo. First all interrupts are disabled, function executed and then all interrupt enabled. */ RFifoDequeue_t RFifoDequeue_Fn; /**< Pointer to function for dequeue packet from the fifo. First all interrupts are disabled, function executed and then all interrupt enabled. */ RFifo_SetCallback_t RFifo_SetCallback_Fn; /**< Pointer to function for setting two callback functions used by the FIFO. First all interrupts are disabled, function executed and then all interrupt enabled. */ RFifo_IsEmpty_t RFifo_IsEmpty_Fn; /**< Pointer to function for for check, is Fifo empty. First all interrupts are disabled, function executed and then all interrupt enabled. */ RFifo_IsMember_t RFifo_IsMember_Fn; /**< Pointer to function for checks if the provided element is member of the fifo. First all interrupts are disabled, function executed and then all interrupt enabled. */ RFifo_GetNrOfElements_t RFifo_GetNrOfElements_Fn; /**< Pointer to function for reading the number of elements in the Fifo. First all interrupts are disabled, function executed and then all interrupt enabled. */ void *Object_p; /**