diff options
Diffstat (limited to 'lcmodule/source/cnh1605551_ldr_utilities/include')
6 files changed, 993 insertions, 0 deletions
diff --git a/lcmodule/source/cnh1605551_ldr_utilities/include/r_debug_macro.h b/lcmodule/source/cnh1605551_ldr_utilities/include/r_debug_macro.h new file mode 100644 index 0000000..43f9e88 --- /dev/null +++ b/lcmodule/source/cnh1605551_ldr_utilities/include/r_debug_macro.h @@ -0,0 +1,187 @@ +/******************************************************************************* + * Copyright (C) ST-Ericsson SA 2011 + * License terms: 3-clause BSD license + ******************************************************************************/ +#ifndef _R_DEBUG_MACRO_H_ +#define _R_DEBUG_MACRO_H_ + +/** + * @addtogroup ldr_utilities + * @{ + * @addtogroup debug_macro + * @{ + */ + +/******************************************************************************* + * Includes + ******************************************************************************/ +#include "t_basicdefinitions.h" +#include "r_debug.h" +#ifdef CFG_ENABLE_PRINT_SERVER +#include "r_debug_subsystem.h" +#endif + +#define IRQ_MASK 0x00000080 +#define FIQ_MASK 0x00000040 +#define INT_MASK (IRQ_MASK | FIQ_MASK) + +#if !defined(UART_DEBUG_PORT) && defined(MACH_TYPE_STN8500) +#define UART_DEBUG_PORT 2 +#endif + +#if !defined(UART_DEBUG_PORT) && defined(MACH_TYPE_DB5700) +#define UART_DEBUG_PORT 0 +#endif + +/******************************************************************************* + * Macro for disabling ARM interrupts. Do nothing for Windows and LINT target. + ******************************************************************************/ +#if (defined(WIN32) || defined(CFG_ENABLE_LINT_TARGET_BUILD) || defined(__linux__) || defined(__CYGWIN__)) +#define INT_DISABLE() +#else +#ifdef MACH_TYPE_DB5700 +#define INT_DISABLE() \ + register int r0; \ + __asm("MRS r0, CPSR"); \ + __asm("ORR r0, r0, #INT_MASK"); \ + __asm("MSR CPSR_c, r0"); +#else +#ifdef MACH_TYPE_STN8500 +#define INT_DISABLE() \ + __asm__ __volatile__ ("MRS r0, CPSR \n\t" \ + "ORR r0, r0, %[mask] \n\t" \ + "MSR CPSR_c, r0" \ + : :[mask]"r"(INT_MASK): "r0", "cc"); +#endif +#endif +#endif + +/******************************************************************************* + * Macros for handling fatal and non - fatal errors. + ******************************************************************************/ +#ifndef ENABLE_DEBUG +#define VERIFY(Condition,ErrorCode)\ + do \ + { \ + if(!(Condition)) \ + { \ + ReturnValue = (ErrorCode); \ + goto ErrorExit; \ + } \ + } while(0) + +#define VERIFY_NO_DEBUG(Condition,ErrorCode) VERIFY(Condition,ErrorCode) + +#ifndef CFG_ENABLE_ADBG_LOADER + +#define ASSERT(Condition)\ + do \ + { \ + if(!(Condition)) \ + { \ + {\ + INT_DISABLE()\ + }\ + while(1); \ + } \ + } while(0) + +#define ASSERT_NO_DEBUG(Condition) ASSERT(Condition) + +#else//CFG_ENABLE_ADBG_LOADER + +#define ASSERT(Condition)\ + do \ + { \ + if(!(Condition)) \ + { \ + } \ + } while(0) + +#define ASSERT_NO_DEBUG(Condition) ASSERT(Condition) + +#endif //CFG_ENABLE_ADBG_LOADER + +#else //ENABLE_DEBUG + +/* VERIFY macro definition +* Verifies the condition and sets the appropriate return value +* if needed before branching the execution to ErrorExit +* This macro prints out debug info string indicating +* verification failure */ +#define VERIFY(Condition,ErrorCode)\ + do \ + { \ + if(!(Condition)) \ + { \ + ReturnValue = (ErrorCode); \ + A_(printf("%s (%d): ** Verification failed! Error:(%d) **\n",__FILE__,__LINE__,(ErrorCode));)\ + goto ErrorExit; \ + } \ + } while(0) + +/* NO-DEBUG version of the VERIFY macro + * Verifies the condition and sets the appropriate return value + * if needed before branching the execution to ErrorExit + * This macro does not print out debug info string indicating + * verification failure */ +#define VERIFY_NO_DEBUG(Condition,ErrorCode)\ + do \ + { \ + if(!(Condition)) \ + { \ + ReturnValue = (ErrorCode); \ + goto ErrorExit; \ + } \ + } while(0) + +#ifndef CFG_ENABLE_ADBG_LOADER + +#define ASSERT(Condition)\ + do \ + { \ + if(!(Condition)) \ + { \ + A_(printf("%s (%d): ** Assert failed **\n",__FILE__, __LINE__);)\ + {\ + INT_DISABLE()\ + }\ + while(1); \ + } \ + } while(0) + +#define ASSERT_NO_DEBUG(Condition)\ + do \ + { \ + if(!(Condition)) \ + { \ + {\ + INT_DISABLE()\ + }\ + while(1); \ + } \ + } while(0) + +#else//CFG_ENABLE_ADBG_LOADER + +#define ASSERT(Condition)\ + do \ + { \ + if(!(Condition))\ + { \ + A_(printf("%s (%d): ** Assert failed **\n",__FILE__, __LINE__);)\ + } \ + } while(0) + +#define ASSERT_NO_DEBUG(Condition)\ + do \ + { \ + } while(0) + +#endif //CFG_ENABLE_ADBG_LOADER + +#endif //ENABLE_DEBUG + +/** @} */ +/** @} */ +#endif /*_R_DEBUG_MACRO_H_*/ diff --git a/lcmodule/source/cnh1605551_ldr_utilities/include/r_memmory_utils.h b/lcmodule/source/cnh1605551_ldr_utilities/include/r_memmory_utils.h new file mode 100644 index 0000000..fb4d54f --- /dev/null +++ b/lcmodule/source/cnh1605551_ldr_utilities/include/r_memmory_utils.h @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (C) ST-Ericsson SA 2011 + * License terms: 3-clause BSD license + ******************************************************************************/ +#ifndef _R_MEMMORY_UTILS_H_ +#define _R_MEMMORY_UTILS_H_ + +/** + * @addtogroup ldr_utilities + * @{ + * @addtogroup memmory_utils + * @{ + */ + +/******************************************************************************* + * Includes + ******************************************************************************/ +#include <stdlib.h> +#include "error_codes.h" +#include "t_basicdefinitions.h" +#ifdef CFG_ENABLE_LOADER_TYPE +#include "cpu_support.h" + +/******************************************************************************* + * Macro that release allocated memory space in heap. + ******************************************************************************/ +#define BUFFER_FREE(Buffer) \ +if (NULL != (Buffer)) \ +{ \ + CPU_Irq_State_t IRQ_status; \ + \ + IRQ_status = CPU_IrqDisable();\ + free(Buffer); \ + (Buffer) = NULL; \ + \ + if (IRQ_status == CPU_IRQ_ENABLE)\ + {\ + CPU_IrqEnable();\ + }\ +} +#else //CFG_ENABLE_LOADER_TYPE +#define BUFFER_FREE(Buffer) \ +if (NULL != (Buffer)) \ +{ \ + free(Buffer); \ + (Buffer) = NULL; \ +} +#endif // CFG_ENABLE_LOADER_TYPE + +/** + * Macro that check alignment. If variable is not aligned it set the status + * variable ReturnValue to appropriate error code and send the function to error + * label. + * + * @param [in] x Variable for alignemend check. + * + * @sigbased No - Macro + */ +#define IS_ALIGNED(x) if(((x) & 3)) \ + { \ + ReturnValue = E_UNALIGNED_DATA; \ + goto ErrorExit; \ + } \ + +/** @} */ +/** @} */ +#endif /*_R_MEMMORY_UTILS_H_*/ diff --git a/lcmodule/source/cnh1605551_ldr_utilities/include/r_queue.h b/lcmodule/source/cnh1605551_ldr_utilities/include/r_queue.h new file mode 100644 index 0000000..06e9d17 --- /dev/null +++ b/lcmodule/source/cnh1605551_ldr_utilities/include/r_queue.h @@ -0,0 +1,275 @@ +/******************************************************************************* + * Copyright (C) ST-Ericsson SA 2011 + * License terms: 3-clause BSD license + ******************************************************************************/ +#ifndef _R_QUEUE_H_ +#define _R_QUEUE_H_ + +/** + * @addtogroup ldr_utilities + * @{ + * @addtogroup queue + * @{ + * Implementation of FIFO queue. + * Functions which names begin with Do_Fifo_* are non-reentrant. + * Functions which names begin with Do_RFifo_* are reentrant. + * Functions that are not interrupt safe are faster than the interrupt safe + * functions. + * + * @remark None of the functions check the sanity of the input parameters. + */ + +/******************************************************************************* + * Includes + ******************************************************************************/ +#include "t_queue.h" +#include "error_codes.h" + +/******************************************************************************* + * Declaration of functions + ******************************************************************************/ + +/** + * @brief Creates a queue. + * + * @param [in] Object_p Pointer to LCM instance context. + * @param [out] Queue_pp After execution points to the allocated space + * for the queue. + * @param [in] MaxLength The maximum number of entries in the queue. + * @param [in] DestroyElement Pointer to user defined function that + * deallocates resources allocated for the + * elements in the queue. NULL if there is no need + * for deallocating resource. + */ +void Do_Fifo_Create(void *Object_p, + void **const Queue_pp, + const uint32 MaxLength, + void (*DestroyElement)(void *Element_p)); + +/** + * @brief Releases any resources associated with the specified queue structure. + * + * @param [in] Object_p Pointer to LCM instance context. + * @param [in,out] Queue_pp Pointer to the queue structure to destroy. + */ +void Do_Fifo_Destroy(void *Object_p, void **const Queue_pp); + +/** + * @brief Enqueueing of pointers. + * + * @note Enqueueing and dequeueing are mutually reentrant, and all functions are + * reentrant across different queues, but enqueueing on the same queue is + * not necessarily reentrant. + * + * @param [in] Object_p - Pointer to LCM instance context. + * @param [in] Queue_p - The queue to append to. + * @param [in] Value_p - The value to enqueue. + * @return E_SUCCESS - The function completed successfully. + * + * @return E_FAILED_TO_STORE_IN_FIFO - Faliled to store data in fifo. + */ +ErrorCode_e Do_Fifo_Enqueue(void *Object_p, + void *const Queue_p, + void *const Value_p); + +/** + * @brief Dequeueing of pointers. + * + * Dequeueing function of a reentrant, interrupt-safe FIFO queue. + * + * @note Enqueueing and dequeueing are mutually reentrant, and all functions are + * reentrant across different queues, but dequeueing on the same queue is + * not necessarily reentrant. + * + * @param [in] Object_p Pointer to LCM instance context. + * @param [in] Queue_p The queue to take an item from. + * + * @return The first pointer in the queue on success or NULL if + * the queue is empty. Note that an enqueued NULL + * pointer will be de-queued as a NULL pointer. + */ +void *Do_Fifo_Dequeue(void *Object_p, void *const Queue_p); + +/** + * @brief Registers an event listener for the specified queue. + * + * @note Only one listener per queue and event type is allowed. + * @note A function invocation does not guarantee that the state of the queue is + * the same as the end-transition state, only that such a transition has + * happened. + * + * @param [in] Object_p Pointer to LCM instance context. + * @param [in] Queue_p The queue for which to register a callback. + * @param [in] Type The type of event to register the callback for. + * A value of EMPTY indicates that the specified callback + * function should be called each time queue has + * transitioned from a non-empty state to an empty state. + * A value of NONEMPTY indicates that the callback func. + * should be called each time the queue has transitioned + * from an empty to a non-empty state. + * @param [in] Callback The function to call when the specified event occurs + * or NULL to unregister a previously registered function. + * @param [in] Param_p Parameter to pass to the callback function. + * @return The previously registered callback function for this + * type. + * @return NULL If no callback was previously registered. + */ +QueueCallback_fn Do_Fifo_SetCallback(void *Object_p, void *const Queue_p, + const QueueCallbackType_e Type, + const QueueCallback_fn Callback, + void *const Param_p); + +/** + * @brief Determines the empty-status of the queue. + * + * @param [in] Object_p Pointer to LCM instance context. + * @param [in] Queue_p The queue to inspect. + * @return TRUE If Fifo is empty or + * @return FALSE If Fifo is not empty. + */ +boolean Do_Fifo_IsEmpty(void *Object_p, const void *const Queue_p); + +/** + * @brief Checks if the provided element is member of the fifo. + * + * @param [in] Object_p Pointer to LCM instance context. + * @param [in] Queue_p The queue to search for element. + * @param [in] Value_p The element to be searched in the queue. + * @param [in] Match Function that checks if two elements match. + * @retval TRUE If the element is member of the fifo. + * @retval FALSE If the element is not member of the fifo. + */ +boolean Do_Fifo_IsMember(void *Object_p, + const void *const Queue_p, + void *Value_p, + boolean(*Match)(void *Value1_p, void *Value2_p)); + +/** + * @brief Returns the number of elements in the queue. + * + * @param [in] Object_p Pointer to LCM instance context. + * @param [in] Queue_p Pointer to the queue. + * @return Number of elements in the queue. + */ +int Do_Fifo_GetNrOfElements(void *Object_p, const void *const Queue_p); + + +/** + * @brief Creates a queue. + * + * @param [in] Object_p Pointer to LCM instance context. + * @param [out] Queue_pp After execution points to the allocated + * space for the queue. + * @param [in] MaxLength The maximum number of entries in the queue. + * @param [in] DestroyElement Pointer to user defined function that deallocates + * resources allocated for the elements in the + * queue. NULL if there is no need for deallocating + * resource. + */ +void Do_RFifo_Create(void *Object_p, + void **const Queue_pp, + const uint32 MaxLength, + void (*DestroyElement)(void *Element_p)); + +/** + * @brief Releases any resources associated with the specified queue structure. + * + * @param [in] Object_p - Pointer to LCM instance context. + * @param [in,out] Queue_pp - Pointer to the queue structure to destroy. + */ +void Do_RFifo_Destroy(void *Object_p, void **const Queue_pp); + +/** + * @brief Enqueueing of pointers. + * + * Enqueueing function of a re-entrant, interrupt-safe FIFO queue. + * + * @param [in] Object_p - Pointer to LCM instance context. + * @param [in] Queue_p - The queue to append to. + * @param [in] Value_p - The value to enqueue. + * @return E_SUCCESS - The function completed successfully. + * + * @return E_FAILED_TO_STORE_IN_FIFO - Faliled to store data in fifo. + */ +ErrorCode_e Do_RFifo_Enqueue(void *Object_p, + void *const Queue_p, + void *const Value_p); + +/** + * @brief Dequeueing of pointers. + * + * Dequeueing function of a reentrant, interrupt-safe FIFO queue. + * + * @param [in] Object_p Pointer to LCM instance context. + * @param [in] Queue_p The queue to take an item from. + * @return The first pointer in the queue on success or NULL if + * the queue is empty. Note that an enqueued NULL-pointer + * will be de - queued as a NULL pointer. + */ +void *Do_RFifo_Dequeue(void *Object_p, void *const Queue_p); + +/** + * @brief Registers an event listener for the specified queue. + * + * @note Only one listener per queue and event type is allowed. + * @note A function invocation does not guarantee that the state of the queue is + * the same as the end-transition state, only that such a transition has + * happened. + * + * @param [in] Object_p Pointer to LCM instance context. + * @param [in] Queue_p The queue for which to register a callback. + * @param [in] Type The type of event to register the callback for. + * - A value of EMPTY indicates that the specified + * callback function should be called each time queue has + * transitioned from a non-empty state to an empty state. + * - A value of NONEMPTY indicates that the callback + * function should be called each time the queue has + * transitioned from an empty to a non-empty state. + * @param [in] Callback The function to call when the specified event occurs + * or NULL to unregister a previously registered func. + * @param [in] Param_p Parameter to pass to the callback function. + * @return The previously registered callback function for this + * type. + * @return NULL If no callback was previously registered. + */ +QueueCallback_fn Do_RFifo_SetCallback(void *Object_p, void *const Queue_p, + const QueueCallbackType_e Type, + const QueueCallback_fn Callback, + void *const Param_p); + +/** + * @brief Determines the empty-status of the queue. + * + * @param [in] Object_p Pointer to LCM instance context. + * @param [in] Queue_p The queue to inspect. + * @retval TRUE If Fifo is empty or FALSE if is not empty. + */ +boolean Do_RFifo_IsEmpty(void *Object_p, const void *const Queue_p); + +/** + * @brief Checks if the provided element is member of the fifo. + * + * @param [in] Object_p Pointer to LCM instance context. + * @param [in] Queue_p The queue to search for element. + * @param [in] Value_p The element to be searched in the queue. + * @param [in] Match Function that checks if two elements match. + * @retval TRUE If the element is member of the fifo. + * @retval FALSE If the element is not member of the fifo. + */ +boolean Do_RFifo_IsMember(void *Object_p, + const void *const Queue_p, + void *Value_p, + boolean(*Match)(void *Value1_p, void *Value2_p)); + +/** + * @brief Returns the number of elements in the queue. + * + * @param [in] Object_p Pointer to LCM instance context. + * @param [in] Queue_p Pointer to the queue. + * @return Number of elements in the queue. + */ +int Do_RFifo_GetNrOfElements(void *Object_p, const void *const Queue_p); + +/** @} */ +/** @} */ +#endif /*_R_QUEUE_H_*/ diff --git a/lcmodule/source/cnh1605551_ldr_utilities/include/r_serialization.h b/lcmodule/source/cnh1605551_ldr_utilities/include/r_serialization.h new file mode 100644 index 0000000..b0cebd6 --- /dev/null +++ b/lcmodule/source/cnh1605551_ldr_utilities/include/r_serialization.h @@ -0,0 +1,380 @@ +/******************************************************************************* + * Copyright (C) ST-Ericsson SA 2011 + * License terms: 3-clause BSD license + ******************************************************************************/ +#ifndef _R_SERIALIZATION_H_ +#define _R_SERIALIZATION_H_ + +/** + * @addtogroup ldr_utilities + * @{ + * @addtogroup serialization + * @{ + * This module contains functions for serialization of data. + * @n The reason for having this kind of functions is to ease the + * manipulation of data and to simplify the code. + * @n The functions are divided in three groups:@n + * @li get_* functions: + * Used for extracting data from a memory location specified + * by the input pointer. + * @li put_* functions: + * Used for placing data at the memory location specified by the input + * pointer. + * @li skip_* functions: + * Used for skipping the data, without changing it. + * @n After call to anyone of this functions the input pointer is + * incremented for the number of bytes that are extracted, placed or + * skipped. + * + * @remark None of the functions perform a sanity check of the input + * parameters. It is the responsibility of the developer to make sure + * that the arguments passed to these functions are valid. + */ + +/******************************************************************************* + * Includes + ******************************************************************************/ +#include "t_basicdefinitions.h" +#include "t_serialization.h" +#include "command_ids.h" + +/******************************************************************************* + * Declaration of functions + ******************************************************************************/ + +/** + * @brief Reads 1 byte from @p data_pp. + * + * Reads 1 byte from @p *data_pp and increases + * @p *data_pp for 1 byte. + * + * @param [in,out] data_pp Source. + * @return An @p uint8 from @p *data_pp. + */ +uint8 get_uint8(void **data_pp); + +/** + * @brief Reads 2 bytes from @p data_pp. + * + * Reads @p 2 bytes from @p *data_pp and increases + * @p *data_pp by 2 bytes. The bytes are considered to + * be in Little Endian order. + * + * @param [in,out] data_pp Source. + * @return An @p uint16 from @p *data_pp. + */ +uint16 get_uint16_le(void **data_pp); + +/** + * @brief Reads 2 bytes from @p data_pp. + * + * Reads 2 bytes from @p *data_pp and increases + * @p *data_pp by 2 bytes. The bytes are considered to + * be in Big Endian order. + * + * @param [in,out] data_pp Source. + * @return An @p uint16 from @p *data_pp. + */ +uint16 get_uint16_be(void **data_pp); + +/** + * @brief Reads 4 bytes from @p data_pp. + * + * Reads 4 bytes from @p *data_pp and increases + * @p *data_pp by 4 bytes. The bytes are considered to + * be in Little Endian order. + * + * @param [in,out] data_pp Source. + * @return An @p uint32 from @p *data_pp. + */ +uint32 get_uint32_le(void **data_pp); + +/** + * @brief Reads 4 bytes from @p data_pp. + * + * Reads 8 bytes from @p *data_pp and increases + * @p *data_pp by 8 bytes. The bytes are considered to + * be in Little Endian order. + * + * @param [in,out] data_pp Source. + * @return An @p uint64 from @p *data_pp. + */ +uint64 get_uint64_le(void **data_pp); + +/** + * @brief Reads 4 bytes from @p data_pp. + * + * Reads 4 bytes from @p *data_pp. The bytes are considered to + * be in Little Endian order. + * + * @param [in,out] data_pp Source. + * @return An @p uint32 from @p *data_pp. + */ +uint32 get_uint32_string_le(void **data_pp); + +/** + * @brief Reads 4 bytes from @p data_pp. + * + * Reads 4 bytes from @p *data_pp and increases + * @p *data_pp by 4 bytes. The bytes are considered to + * be in Big Endian order. + * + * @param [in,out] data_pp Source. + * @return An @p uint32 from @p *data_pp. + */ +uint32 get_uint32_be(void **data_pp); + +/** + * @brief Writes 1 byte to @p data_pp. + * + * Writes 1 byte to @p *data_pp and increases + * @p *data_pp by 1 byte. + * + * @param [in,out] data_pp Destination. + * @param [in] v Value. + * @return void. + */ +void put_uint8(void **data_pp, + uint8 v); + +/** + * @brief Writes 2 bytes to @p data_pp. + * + * Writes 2 byte to @p *data_pp and increases + * @p *data_pp by 2 byte. The bytes are written + * in Little Endian Order. + * + * @param [in,out] data_pp Destination. + * @param [in] v Value. + * @return void. + */ +void put_uint16_le(void **data_pp, + uint16 v); + +/** + * @brief Writes 2 bytes to @p data_pp. + * + * Writes 2 byte to @p *data_pp and increases + * @p *data_pp by 2 byte. The bytes are written + * in Big Endian Order. + * + * @param [in,out] data_pp Destination. + * @param [in] v Value. + * @return void. + */ +void put_uint16_be(void **data_pp, + uint16 v); + +/** + * @brief Writes 4 bytes to @p data_pp. + * + * Writes 4 byte to @p *data_pp and increases + * @p *data_pp by 4 byte. The bytes are written + * in Little Endian Order. + * + * @param [in,out] data_pp Destination. + * @param [in] v Value. + * @return void. + */ +void put_uint32_le(void **data_pp, + uint32 v); + +/** + * @brief Writes 4 bytes to @p data_pp. + * + * Writes 4 byte to @p *data_pp and increases + * @p *data_pp by 4 byte. The bytes are written + * in Big Endian Order. + * + * @param [in,out] data_pp Destination. + * @param [in] v Value. + * @return void. + */ +void put_uint32_be(void **data_pp, + uint32 v); + +/** + * @brief Writes 8 bytes to @p data_pp. + * + * Writes 8 byte to @p *data_pp and increases + * @p *data_pp by 4 byte. The bytes are written + * in Little Endian Order. + * + * @param [in,out] data_pp Destination. + * @param [in] v Value. + * @return void. + */ +void put_uint64_le(void **data_pp, + uint64 v); + +/** + * @brief Writes 8 bytes to @p data_pp. + * + * Writes 8 byte to @p *data_pp and increases + * @p *data_pp by 8 byte. The bytes are written + * in Big Endian Order. + * + * @param [in,out] data_pp Destination. + * @param [in] v Value. + * @return void. + */ +void put_uint64_be(void **data_pp, + uint64 v); + +/** + * @brief Skips 1 byte from @p data_pp. + * + * Skips 1 byte from data_pp, and increases @p data_pp + * for 1 byte. + * + * @param [in,out] data_pp Destination. + * @return void. + */ +void skip_uint8(void **data_pp); + +/** + * @brief Skips 2 byte from @p data_pp. + * + * Skips 2 byte from data_pp, and increases @p data_pp + * for 2 byte. + * + * @param [in,out] data_pp Destination. + * @return void. + */ +void skip_uint16(void **data_pp); + +/** + * @brief Skips 4 byte from @p data_pp. + * + * Skips 4 byte from data_pp, and increases @p data_pp + * for 4 byte. + * + * @param [in,out] data_pp Destination. + * @return void. + */ +void skip_uint32(void **data_pp); + +/** + * @brief Copies bytes from @p data_pp to @p target_p. + * + * Copies @p length bytes from @p data_pp to @p target_p, + * increasing @p data_pp by @p length. + * + * @param [in,out] data_pp Source. + * @param [out] target_p Destination. + * @param [in] length Length of block. + * @return void. + */ +void get_block(const void **data_pp, + void *target_p, + uint32 length); + +/** + * @brief Copies bytes from @p source_p to @p data_pp. + * + * Copies @p length bytes from @p source_p to @p data_pp, increasing + * @p data_pp by @p length. + * + * @param [in,out] data_pp Source. + * @param [out] source_p Destination. + * @param [in] length Length of block. + * @return void. + */ +void put_block(void **data_pp, + const void *source_p, + uint32 length); + +/** + * @brief Copies bytes from @p source_p to @p data_pp. + * + * First is copied Length of the buffer (source_p) in the data_pp then. + * is copied @p length bytes from @p source_p to @p data_pp, increasing + * @p data_pp by @p length. + * + * @param [in,out] data_pp Source. + * @param [out] source_p Destination. + * @param [in] length Length of block. + * @return void. + */ +void put_string(void **data_pp, + const void *source_p, + uint32 length); + +/** + * @brief Skips a block of length @p length from @p data_pp. + * + * Skips a block of length @p length from @p data_pp. + * + * @param [in,out] data_pp Source. + * @param [in] length Length of block. + * @return void. + */ +void skip_block(void **data_pp, + uint32 length); + +/** + * @brief Skips a block of length of the string from @p data_pp. + * + * @param [in,out] data_pp Source. + * @return Pointer to where data_pp was before calling this function. + */ +char *skip_str(void **data_pp); + + +/** + * @brief Get directory entries length...TODO: should be explained. + * + * @param [out] source_p Source. + * @param [in] DirectoryEntriesCount Entry counter. + * @return Entry length. + */ +uint32 get_directory_entries_len(const DirEntry_t *source_p, + uint32 DirectoryEntriesCount); + +/** + * @brief Serialize directory entries...TODO: should be explained. + * + * @param [out] data_pp /...TODO: should be explained. + * @param [in] source_p Source. + * @param [in] DirectoryEntriesCount Entry counter. + * @return void. + */ +void serialize_directory_entries(void **data_pp, + const DirEntry_t *source_p, + uint32 DirectoryEntriesCount); + +/** + * @brief Get device entry length...TODO: should be explained. + * + * @param [out] source_p Source. + * @param [in] DeviceEntriesCount Entry counter. + * @return Entry length. + */ +uint32 get_device_entries_len(const ListDevice_t *source_p, + uint32 DeviceEntriesCount); + +/** + * @brief Serialize device entries...TODO: should be explained. + * + * @param [out] data_pp /...TODO: should be explained. + * @param [in] source_p Source. + * @param [in] DeviceEntriesCount Entry counter. + * @return void. + */ +void serialize_device_entries(void **data_pp, + const ListDevice_t *source_p, + uint32 DeviceEntriesCount); + +/** + * @brief Serialize device entries...TODO: should be explained. + * + * @param [out] data_pp /...TODO: should be explained. + * @param [in] source_p Source. + * @param [in] length length of source string. + * @return void. + */ +void insert_string(char **data_pp, const char *source_p, uint32 length); + +/** @} */ +/** @} */ +#endif /*_R_SERIALIZATION_H_*/ diff --git a/lcmodule/source/cnh1605551_ldr_utilities/include/t_queue.h b/lcmodule/source/cnh1605551_ldr_utilities/include/t_queue.h new file mode 100644 index 0000000..f6250b6 --- /dev/null +++ b/lcmodule/source/cnh1605551_ldr_utilities/include/t_queue.h @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (C) ST-Ericsson SA 2011 + * License terms: 3-clause BSD license + ******************************************************************************/ +#ifndef _T_QUEUE_H_ +#define _T_QUEUE_H_ + +/** + * @addtogroup ldr_utilities + * @{ + * @addtogroup queue + * @{ + */ + +/******************************************************************************* + * Includes + ******************************************************************************/ +#include "t_basicdefinitions.h" + +/******************************************************************************* + * Types, constants + ******************************************************************************/ + +/** type of queue callback functions. */ +typedef enum { + QUEUE_EMPTY, + QUEUE_NONEMPTY +} QueueCallbackType_e; + +/** + * Typedef of callback function used for the queue. + * One callback function is used when the fifo is empty, + * and another when the fifo is nonempty. + * These function are set by calling Do_Fifo_SetCallback. + * + * @param [in] Queue_p pointer to a valid queue(One that is created using + * Do_Fifo_Create). + * @param [in] Param_p additional parameters to the function. + * @return None. + */ +typedef void (*QueueCallback_fn)(const void *const Queue_p, void *Param_p); + +/** @} */ +/** @} */ +#endif /*T_QUEUE_H_*/ diff --git a/lcmodule/source/cnh1605551_ldr_utilities/include/t_serialization.h b/lcmodule/source/cnh1605551_ldr_utilities/include/t_serialization.h new file mode 100644 index 0000000..0a8299e --- /dev/null +++ b/lcmodule/source/cnh1605551_ldr_utilities/include/t_serialization.h @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (C) ST-Ericsson SA 2011 + * License terms: 3-clause BSD license + ******************************************************************************/ +#ifndef _T_SERIALIZATION_H_ +#define _T_SERIALIZATION_H_ + +/** + * @addtogroup ldr_utilities + * @{ + * @addtogroup serialization + * @{ + */ + +/******************************************************************************* + * Includes + ******************************************************************************/ +#include "t_basicdefinitions.h" + +/******************************************************************************* + * Types, constants + ******************************************************************************/ + +/** By default we use Little Endian ordering, this macro is declared to simplify + the calling of the function. */ +#define get_uint16 get_uint16_le +/** By default we use Little Endian ordering, this macro is declared to simplify + the calling of the function. */ +#define get_uint32 get_uint32_le +/** By default we use Little Endian ordering, this macro is declared to simplify + the calling of the function. */ +#define put_uint16 put_uint16_le +/** By default we use Little Endian ordering, this macro is declared to simplify + the calling of the function. */ +#define put_uint32 put_uint32_le + +/** @} */ +/** @} */ +#endif /*T_SERIALIZATION_H_*/ |