[processor-sdk/pdk.git] / packages / ti / drv / ipc / examples / rtos / ipc_perf_test / ipc_apputils.h
1 /*
2 * Copyright (c) Texas Instruments Incorporated 2019
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the
14 * distribution.
15 *
16 * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
33 /**
34 * \file ipc_apputils.h
35 *
36 * \brief Common IPC application utility used in all IPC example.
37 *
38 * NOTE: This library is meant only for IPC examples. Customers are not
39 * encouraged to use this layer as these are very specific to the examples
40 * written and the API behaviour and signature can change at any time to
41 * suit the examples.
42 *
43 */
45 #ifndef IPC_APPUTILS_H_
46 #define IPC_APPUTILS_H_
48 /* ========================================================================== */
49 /* Include Files */
50 /* ========================================================================== */
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
56 /* ========================================================================== */
57 /* Macros & Typedefs */
58 /* ========================================================================== */
60 /* None */
62 /* ========================================================================== */
63 /* Structure Declarations */
64 /* ========================================================================== */
66 /* None */
68 /* ========================================================================== */
69 /* Function Declarations */
70 /* ========================================================================== */
72 /**
73 * \brief Perform cache WB operation based on whether cache is
74 * coherent or not
75 *
76 * This internally uses the OSAL API.
77 *
78 * \param addr Start address of the cache line/s
79 * \param size Size (in bytes) of the memory to be written back
80 *
81 */
82 void Ipc_appUtilsCacheWb(const void *addr, int32_t size);
84 /**
85 * \brief Perform cache invalidate operation based on whether cache is
86 * coherent or not
87 *
88 * This internally uses the OSAL API.
89 *
90 * \param addr Start address of the cache line/s
91 * \param size Size (in bytes) of the memory to invalidate
92 *
93 */
94 void Ipc_appUtilsCacheInv(const void * addr, int32_t size);
96 /**
97 * \brief Perform cache writeback and invalidate operation based on
98 * whether cache is coherent or not
99 *
100 * This internally uses the OSAL API.
101 *
102 * \param addr Start address of the cache line/s
103 * \param size Size (in bytes) of the memory to writeback and invalidate
104 *
105 */
106 void Ipc_appUtilsCacheWbInv(const void * addr, int32_t size);
108 /**
109 * \brief Virtual to physical translation function.
110 *
111 * \param virtAddr [IN] Virtual address
112 * \param chNum [IN] Channel number passed during channel open.
113 * Note: When called for functions which is not channel
114 * dependent (like ring alloc), this parameter will
115 * be set to #IPC_DMA_CH_INVALID.
116 * \param appData [IN] Callback pointer passed during channel open.
117 * Note: When called for functions which is not channel
118 * dependent (like ring alloc), this parameter will
119 * be set to NULL.
120 *
121 * \return Corresponding physical address
122 */
123 uint64_t Ipc_appVirtToPhyFxn(const void *virtAddr, uint32_t chNum, void *appData);
125 /**
126 * \brief Physical to virtual translation function.
127 *
128 * \param phyAddr [IN] Physical address
129 * \param chNum [IN] Channel number passed during channel open.
130 * Note: When called for functions which is not channel
131 * dependent (like ring alloc), this parameter will
132 * be set to #IPC_DMA_CH_INVALID.
133 * \param appData [IN] Callback pointer passed during channel open.
134 * Note: When called for functions which is not channel
135 * dependent (like ring alloc), this parameter will
136 * be set to NULL.
137 *
138 * \return Corresponding virtual address
139 */
140 void *Ipc_appPhyToVirtFxn(uint64_t phyAddr, uint32_t chNum, void *appData);
142 /**
143 * \brief Returns if print can be supported for a platform/build
144 *
145 * \return TRUE if print can be supported for a platform. Else FALSE
146 */
147 uint32_t Ipc_appIsPrintSupported(void);
149 /**
150 * brief Get timestamp in micro-second
151 *
152 * \returns timestamp
153 * */
154 uint64_t Ipc_getTimeInUsec(void);
156 #ifdef __cplusplus
157 }
158 #endif
160 #endif /* #define IPC_APPUTILS_H_ */