summaryrefslogtreecommitdiff
path: root/lcmodule/source/cnh1605551_ldr_utilities/debug_subsystem/r_debug_subsystem.h
blob: 8ab63cf69e1ad27dedae679bc7bc84580bac2fda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*******************************************************************************
 * Copyright (C) ST-Ericsson SA 2011
 * License terms: 3-clause BSD license
 ******************************************************************************/
#ifndef _R_DEBUG_SUBSYTEM_H_
#define _R_DEBUG_SUBSYTEM_H_

/**
 *  @addtogroup ldr_utilities
 *  @{
 *    @addtogroup debug_subsystem
 *    @{
 *      This module handles putting the debug messages into debug queue.
 *      @li Inserting messages in debug queue is re-entrant process.
 *      @li Reading from debug queue is performed by call of PC side.
 *      @li This module provide circular storage of printout messages. This
 *          means that in cases of queue overflowing the oldest messages will be
 *          overwritten by the newest messages.
 *      @li For Windows Loader this feature is currently not supported.
 */

/*******************************************************************************
 * Includes
 ******************************************************************************/
#include "t_basicdefinitions.h"
#include "t_debug_subsystem.h"

/*******************************************************************************
 * Defines
 ******************************************************************************/

#ifndef CFG_ENABLE_LOADER_TYPE
#define printf(...) lcm_printf(__VA_ARGS__)
#else
/**
 * This define replace printf function with ddebug_printf variadic macro.
 */
#define printf ddebug_printf
#endif /*CFG_ENABLE_LOADER_TYPE*/

/**
 * Function-like macro. This macro will write messages in debug queue. Also this
 * macro take care about initialization of debug queue.
 */
#define ddebug_printf(...) debug_printf(__VA_ARGS__)

/*******************************************************************************
 * Declaration of functions
 ******************************************************************************/
#ifndef CFG_ENABLE_LOADER_TYPE
void lcm_printf(const char *format, ...);
#else
/**
 * Calls function 'circular_printf'. If debug queue is not initialized this
 * function takes care for initialization and than redidrect input parameters to
 * 'circular_printf' function.
 *
 * @param [in] *format The string constant format provides a description of the
 *                     output, with placeholders marked by "%" escape
 *                     characters, to specify both the relative location and the
 *                     type of output that the function should produce.(Standard
 *                     definition for library 'printf' function).
 * @return             None.
 */
void debug_printf(const char *format, ...);

/**
 * This function collect all messages from debug queue and copy them inside one
 * memory space (buffer). First printout message in resulting buffer will be
 * first printout that is accepted and last message in buffer is last message
 * received by the time that this function is called.
 *
 * @param[in, out]  Data_pp Point to pointer that should be initialized to point
 *                          on outgoing buffer.
 *
 * @return                 Number of characters successfully readied from debug
 *                         queue.
 */
uint32 Do_ReadDebugQueue(void **Data_pp);

/**
 * This function destroys debug queue including all memory spaces allocated for
 * debug messages(printouts).
 *
 * @param[in]  Queue_pp Pointer to the debug queue structure to destroy.
 * @return none.
 */
void Do_DestroyDebugQueue(void **const Queue_pp);
#endif /*CFG_ENABLE_LOADER_TYPE*/

/** @} */
/** @} */
#endif /*_R_DEBUG_SUBSYTEM_H_*/