TIOVX User Guide
tivx_target_kernel.h
Go to the documentation of this file.
1 /*
2 *
3 * Copyright (c) 2017 Texas Instruments Incorporated
4 *
5 * All rights reserved not granted herein.
6 *
7 * Limited License.
8 *
9 * Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive
10 * license under copyrights and patents it now or hereafter owns or controls to make,
11 * have made, use, import, offer to sell and sell ("Utilize") this software subject to the
12 * terms herein. With respect to the foregoing patent license, such license is granted
13 * solely to the extent that any such patent is necessary to Utilize the software alone.
14 * The patent license shall not apply to any combinations which include this software,
15 * other than combinations with devices manufactured by or for TI ("TI Devices").
16 * No hardware patent is licensed hereunder.
17 *
18 * Redistributions must preserve existing copyright notices and reproduce this license
19 * (including the above copyright notice and the disclaimer and (if applicable) source
20 * code license limitations below) in the documentation and/or other materials provided
21 * with the distribution
22 *
23 * Redistribution and use in binary form, without modification, are permitted provided
24 * that the following conditions are met:
25 *
26 * * No reverse engineering, decompilation, or disassembly of this software is
27 * permitted with respect to any software provided in binary form.
28 *
29 * * any redistribution and use are licensed by TI for use only with TI Devices.
30 *
31 * * Nothing shall obligate TI to provide you with source code for the software
32 * licensed and provided to you in object code.
33 *
34 * If software source code is provided to you, modification and redistribution of the
35 * source code are permitted provided that the following conditions are met:
36 *
37 * * any redistribution and use of the source code, including any resulting derivative
38 * works, are licensed by TI for use only with TI Devices.
39 *
40 * * any redistribution and use of any object code compiled from the source code
41 * and any resulting derivative works, are licensed by TI for use only with TI Devices.
42 *
43 * Neither the name of Texas Instruments Incorporated nor the names of its suppliers
44 *
45 * may be used to endorse or promote products derived from this software without
46 * specific prior written permission.
47 *
48 * DISCLAIMER.
49 *
50 * THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS
51 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
52 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
53 * IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT,
54 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
55 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
56 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
57 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
58 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
59 * OF THE POSSIBILITY OF SUCH DAMAGE.
60 *
61 */
62 
63 
64 
65 #ifndef TIVX_TARGET_KERNEL_H_
66 #define TIVX_TARGET_KERNEL_H_
67 
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
71 
77 #include <TI/tivx_obj_desc.h>
78 
83 typedef struct _tivx_target_kernel *tivx_target_kernel;
84 
89 typedef struct _tivx_target_kernel_instance *tivx_target_kernel_instance;
90 
107 typedef vx_status(VX_CALLBACK *tivx_target_kernel_f)(tivx_target_kernel_instance kernel, tivx_obj_desc_t *obj_desc[], uint16_t num_params, void *priv_arg);
108 
109 
128  tivx_target_kernel_instance kernel, uint32_t node_cmd_id,
129  tivx_obj_desc_t *obj_desc[], uint16_t num_params, void *priv_arg);
130 
147  vx_enum kernel_id,
148  const char *target_name,
149  tivx_target_kernel_f process_func,
150  tivx_target_kernel_f create_func,
151  tivx_target_kernel_f delete_func,
152  tivx_target_kernel_control_f control_func,
153  void *priv_arg);
154 
164  const char *kernel_name,
165  const char *target_name,
166  tivx_target_kernel_f process_func,
167  tivx_target_kernel_f create_func,
168  tivx_target_kernel_f delete_func,
169  tivx_target_kernel_control_f control_func,
170  void *priv_arg);
171 
172 
180  tivx_target_kernel target_kernel);
181 
191 
200  tivx_target_kernel_instance target_kernel_instance,
201  void *kernel_context, uint32_t kernel_context_size);
202 
211  tivx_target_kernel_instance target_kernel_instance,
212  void **kernel_context, uint32_t *kernel_context_size);
213 
222  tivx_target_kernel_instance target_kernel_instance,
223  vx_enum *state);
224 
233  tivx_target_kernel_instance target_kernel_instance,
234  uint32_t *targetId);
235 
243 VX_API_ENTRY void tivxGetTargetKernelInstanceBorderMode(
244  tivx_target_kernel_instance target_kernel_instance,
245  vx_border_t *border_mode);
246 
254 
261 
262 static inline vx_bool tivxFlagIsBitSet(uint32_t flag_var, uint32_t flag_val);
263 static inline void tivxFlagBitSet(volatile uint32_t *flag_var, uint32_t flag_val);
264 static inline void tivxFlagBitClear(volatile uint32_t *flag_var, uint32_t flag_val);
265 
269 static inline vx_bool tivxFlagIsBitSet(uint32_t flag_var, uint32_t flag_val)
270 {
271  vx_bool result = (((flag_var & flag_val) == flag_val)? 1 : 0);
272  return result;
273 }
274 
278 static inline void tivxFlagBitSet(volatile uint32_t *flag_var, uint32_t flag_val)
279 {
280  *flag_var |= flag_val;
281 }
282 
286 static inline void tivxFlagBitClear(volatile uint32_t *flag_var, uint32_t flag_val)
287 {
288  uint32_t value = *flag_var;
289 
290  value = value & ~flag_val;
291 
292  *flag_var = value;
293 }
294 
312 void tivxLogRtTraceKernelInstanceAddEvent(vx_node node, uint16_t event_index, char *event_name);
313 
327 void tivxLogRtTraceKernelInstanceRemoveEvent(vx_node node, uint16_t event_index);
328 
340 void tivxLogRtTraceKernelInstanceExeStart(tivx_target_kernel_instance kernel, uint16_t event_index);
341 
353 void tivxLogRtTraceKernelInstanceExeEnd(tivx_target_kernel_instance kernel, uint16_t event_index);
354 
370 void tivxLogRtTraceKernelInstanceExeStartTimestamp(tivx_target_kernel_instance kernel, uint16_t event_index, uint64_t timestamp);
371 
387 void tivxLogRtTraceKernelInstanceExeEndTimestamp(tivx_target_kernel_instance kernel, uint16_t event_index, uint64_t timestamp);
388 
389 #ifdef __cplusplus
390 }
391 #endif
392 
393 #endif
vx_bool
Object descriptor.
VX_API_ENTRY vx_status VX_API_CALL tivxQueryNumTargetKernel(vx_uint32 *ptr)
Queries the framework to determine the number of target kernels on the target from which it is called...
void tivxLogRtTraceKernelInstanceExeEnd(tivx_target_kernel_instance kernel, uint16_t event_index)
Log trace on target kernel instance execute end.
VX_API_ENTRY vx_status VX_API_CALL tivxGetTargetKernelTargetId(tivx_target_kernel_instance target_kernel_instance, uint32_t *targetId)
Get a kernel target id with a target kernel instance.
int32_t vx_enum
struct _tivx_target_kernel * tivx_target_kernel
Handle to kernel on a target.
VX_API_ENTRY vx_status VX_API_CALL tivxGetTargetKernelInstanceState(tivx_target_kernel_instance target_kernel_instance, vx_enum *state)
Get a kernel state with a target kernel instance.
VX_API_ENTRY void tivxGetTargetKernelInstanceBorderMode(tivx_target_kernel_instance target_kernel_instance, vx_border_t *border_mode)
Get the border mode for the target kernel instance.
vx_enum vx_status
tivx_target_kernel tivxTargetKernelInstanceGetKernel(tivx_target_kernel_instance target_kernel_instance)
Get target kernel for a given target kernel instance.
Interface to object descriptor.
struct _tivx_target_kernel_instance * tivx_target_kernel_instance
Handle to instance of kernel on a target.
static vx_bool tivxFlagIsBitSet(uint32_t flag_var, uint32_t flag_val)
Macro to check if flag is set, flag MUST be of bit type.
vx_status(VX_CALLBACK * tivx_target_kernel_control_f)(tivx_target_kernel_instance kernel, uint32_t node_cmd_id, tivx_obj_desc_t *obj_desc[], uint16_t num_params, void *priv_arg)
The target kernel callback for control command.
VX_API_ENTRY tivx_target_kernel VX_API_CALL tivxAddTargetKernelByName(const char *kernel_name, const char *target_name, tivx_target_kernel_f process_func, tivx_target_kernel_f create_func, tivx_target_kernel_f delete_func, tivx_target_kernel_control_f control_func, void *priv_arg)
Allows users to add native kernels implementation to specific targets.
static void tivxFlagBitSet(volatile uint32_t *flag_var, uint32_t flag_val)
Macro to set flag value, flag MUST be of bit type.
VX_API_ENTRY vx_bool tivxIsTargetKernelInstanceReplicated(tivx_target_kernel_instance kernel_instance)
Checks if supplied node is replicated. Returns vx_true if the given node is replicated and vx_false i...
static void tivxFlagBitClear(volatile uint32_t *flag_var, uint32_t flag_val)
Macro to clear flag value, flag MUST be of bit type.
void tivxLogRtTraceKernelInstanceExeEndTimestamp(tivx_target_kernel_instance kernel, uint16_t event_index, uint64_t timestamp)
Log trace on target kernel instance execute end with timestamp given externally.
#define VX_CALLBACK
uint32_t vx_uint32
vx_status(VX_CALLBACK * tivx_target_kernel_f)(tivx_target_kernel_instance kernel, tivx_obj_desc_t *obj_desc[], uint16_t num_params, void *priv_arg)
The target kernel callback.
VX_API_ENTRY vx_status VX_API_CALL tivxRemoveTargetKernel(tivx_target_kernel target_kernel)
Allows users to remove native kernels implementation to specific targets.
void tivxLogRtTraceKernelInstanceExeStart(tivx_target_kernel_instance kernel, uint16_t event_index)
Log trace on target kernel instance execute start.
VX_API_ENTRY vx_status VX_API_CALL tivxGetTargetKernelInstanceContext(tivx_target_kernel_instance target_kernel_instance, void **kernel_context, uint32_t *kernel_context_size)
Get a kernel function context or handle with a target kernel instance.
struct _vx_node * vx_node
VX_API_ENTRY vx_status VX_API_CALL tivxSetTargetKernelInstanceContext(tivx_target_kernel_instance target_kernel_instance, void *kernel_context, uint32_t kernel_context_size)
Associate a kernel function context or handle with a target kernel instance.
void tivxLogRtTraceKernelInstanceRemoveEvent(vx_node node, uint16_t event_index)
Remove real-time log event in host side deinitilize callback for user kernel.
void tivxLogRtTraceKernelInstanceAddEvent(vx_node node, uint16_t event_index, char *event_name)
Add real-time log event in host side initialize callback for user kernel.
vx_status(* VX_API_CALL)(vx_reference *ref)
Callback type used to register release callbacks from object derived from references.
Definition: vx_reference.h:56
VX_API_ENTRY tivx_target_kernel VX_API_CALL tivxAddTargetKernel(vx_enum kernel_id, const char *target_name, tivx_target_kernel_f process_func, tivx_target_kernel_f create_func, tivx_target_kernel_f delete_func, tivx_target_kernel_control_f control_func, void *priv_arg)
Allows users to add native kernels implementation to specific targets.
void tivxLogRtTraceKernelInstanceExeStartTimestamp(tivx_target_kernel_instance kernel, uint16_t event_index, uint64_t timestamp)
Log trace on target kernel instance execute start with timestamp given externally.