TIOVX User Guide
tivx_target.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 
66 #ifndef TIVX_TARGET_H_
67 #define TIVX_TARGET_H_
68 
69 
70 #ifdef __cplusplus
71 extern "C" {
72 #endif
73 
74 #include <TI/tivx_config.h>
75 
85 #define TIVX_TARGET_INST_MASK (0xFFu)
86 
91 #define TIVX_TARGET_INST_SHIFT (0x0u)
92 
100 #define TIVX_CPU_ID_MASK (0xFu)
101 
106 #define TIVX_CPU_ID_SHIFT (0x8)
107 
111 #define TIVX_TARGET_ID_MASK (((uint32_t)TIVX_CPU_ID_MASK << (uint32_t)TIVX_CPU_ID_SHIFT) | \
112  ((uint32_t)TIVX_TARGET_INST_MASK << (uint32_t)TIVX_TARGET_INST_SHIFT))
113 
117 #define TIVX_TARGET_ID_SHIFT (TIVX_TARGET_INST_SHIFT)
118 
127 #define TIVX_MAKE_TARGET_ID(cpu, target_inst) (((((uint32_t)(((uint32_t)cpu) & (uint32_t)TIVX_CPU_ID_MASK)) << (uint32_t)TIVX_CPU_ID_SHIFT) |(((uint32_t)(((uint32_t)target_inst)&(uint32_t)TIVX_TARGET_INST_MASK)) << (uint32_t)TIVX_TARGET_INST_SHIFT)))
128 
135 #define TIVX_GET_CPU_ID(target) ((((uint32_t)(target) >> (uint32_t)TIVX_CPU_ID_SHIFT) & (uint32_t)TIVX_CPU_ID_MASK))
136 
143 #define TIVX_GET_TARGET_INST(target) ((uint16_t)(((uint16_t)(target) >> TIVX_TARGET_INST_SHIFT)) & TIVX_TARGET_INST_MASK)
144 
145 
149 #define TIVX_TARGET_ID_INVALID (0xFFFFFFFFU)
150 
154 #define TIVX_CPU_ID_INVALID (0xFFFFFFFFu)
155 
156 
158 #define TIVX_TARGET_MAX_TASK_NAME (12u)
159 
166 #define TIVX_TARGET_MAX_JOB_QUEUE_DEPTH (96u)
167 
171 typedef enum _tivx_target_cmd_e {
172 
174  TIVX_CMD_NODE_CREATE = 0x00000001u,
176  TIVX_CMD_NODE_DELETE = 0x00000002u,
178  TIVX_CMD_NODE_CONTROL = 0x00000003u,
184 
186 typedef struct _tivx_target *tivx_target;
187 
193 typedef struct _tivx_target {
194 
197 
200 
204 
207 
209  uintptr_t job_queue_memory[TIVX_TARGET_MAX_JOB_QUEUE_DEPTH];
210 
213 
216 
221 } tivx_target_t;
222 
228 typedef struct _tivx_target_create_params
229 {
233  uint8_t *task_stack_ptr;
234 
237  uint32_t task_stack_size;
238 
245 
250  uint32_t task_priority;
251 
253  char task_name[TIVX_TARGET_MAX_TASK_NAME];
254 
256 
265 typedef void(*own_execute_user_kernel_f)(tivx_obj_desc_node_t *node_obj_desc, uint16_t prm_obj_desc_id[]);
266 
274 typedef void(*own_target_cmd_desc_handler_f)(const tivx_obj_desc_cmd_t *cmd_obj_desc);
275 
285  void ownRegisterFunctionsForHost(void);
286 
298 
311 vx_status ownTargetQueueObjDesc(vx_enum target_id, uint16_t obj_desc_id);
312 
317 void ownTargetTriggerNode(uint16_t node_obj_desc_id);
318 
319 
325  uint16_t prm_obj_desc_id[], vx_bool *is_node_blocked);
326 
327 
333  uint16_t prm_obj_desc_id[]);
334 
339 void ownTargetNodeDescReleaseAllParameters(tivx_obj_desc_node_t *node_obj_desc, uint16_t prm_obj_desc_id[]);
340 
349 
362 
363 
374 
382 void ownTargetInit(void);
383 
391 void ownTargetDeInit(void);
392 
393 
400  const tivx_obj_desc_node_t *node_obj_desc, tivx_obj_desc_t *obj_desc[]);
401 
402 #ifdef __cplusplus
403 }
404 #endif
405 
406 #endif
Target object internal state.
Definition: tivx_target.h:193
vx_bool
Object descriptor.
struct _tivx_target * tivx_target
Target Object.
Definition: tivx_target.h:186
void(* own_execute_user_kernel_f)(tivx_obj_desc_node_t *node_obj_desc, uint16_t prm_obj_desc_id[])
The pointer to the user kernel wrapper within the tiovx framework. This is only executable on the hos...
Definition: tivx_target.h:265
void ownTargetSetTimestamp(const tivx_obj_desc_node_t *node_obj_desc, tivx_obj_desc_t *obj_desc[])
Propagates time stamp of input parameters of a kernel to output parameters.
void ownTargetDeInit(void)
De-Init global state of target module.
void ownTargetNodeDescReleaseAllParameters(tivx_obj_desc_node_t *node_obj_desc, uint16_t prm_obj_desc_id[])
Release parameters that were previously acquired.
uint32_t task_stack_size
Task stack size, if 0, OS allocates stack with default size.
Definition: tivx_target.h:237
vx_enum ownTargetGetCpuId(vx_enum target_id)
Get CPU ID associated with given target ID.
int32_t vx_enum
#define TIVX_TARGET_MAX_TASK_NAME
Max size of target name string.
Definition: tivx_target.h:158
uint32_t task_priority
task priority for task associated with this target TIVX_TASK_PRI_HIGHEST is highest priority...
Definition: tivx_target.h:250
uint32_t task_core_affinity
If task runs on a SMP CPU then this value tells the affinity of task to a given core, Valid values are 0 .. max cores in the SMP CPU. when TIVX_TASK_AFFINITY_ANY is used OS decides the task affinity.
Definition: tivx_target.h:244
void(* own_target_cmd_desc_handler_f)(const tivx_obj_desc_cmd_t *cmd_obj_desc)
The pointer to the handler of a subset of cases that the target command handler needs to service on t...
Definition: tivx_target.h:274
void ownTargetSetDefaultCreateParams(tivx_target_create_params_t *params)
Used to set default target create parameters in parameter structure.
#define TIVX_TARGET_MAX_JOB_QUEUE_DEPTH
Max depth of queue associated with target.
Definition: tivx_target.h:166
Parameters that can be set during target creation.
Definition: tivx_target.h:228
Command to call a user callback, on node execution complete.
Definition: tivx_target.h:180
tivx_target_cmd_e
Command ID for commands that can be send to a target.
Definition: tivx_target.h:171
tivx_queue job_queue_handle
handle to job queue associated with this target
Definition: tivx_target.h:206
Typedef for a queue.
Definition: tivx_queue.h:103
vx_bool targetExitRequest
Flag to request target to exit main so that it can be deleted.
Definition: tivx_target.h:215
Command to delete a node on target.
Definition: tivx_target.h:176
vx_enum vx_status
vx_status ownTargetQueueObjDesc(vx_enum target_id, uint16_t obj_desc_id)
Queue object descriptor to a given target.
vx_status ownTargetDelete(vx_enum target_id)
Delete a target object.
tivx_task_create_params_t task_params
Parameters of task associated with this target.
Definition: tivx_target.h:203
void ownRegisterFunctionsForHost(void)
Register Various functions within target files to be linked for host usage.
Parameters that can be set during task creation.
Definition: tivx_task.h:164
void ownTargetNodeDescAcquireAllParameters(tivx_obj_desc_node_t *node_obj_desc, uint16_t prm_obj_desc_id[], vx_bool *is_node_blocked)
Acquire parameters for node execution.
void(VX_CALLBACK * tivx_task_main_f)(void *app_var)
Entry point of task.
Definition: tivx_task.h:111
vx_enum target_id
ID of this target.
Definition: tivx_target.h:196
Typedef for a task.
Definition: tivx_task.h:119
Command object descriptor.
void ownTargetNodeDescAcquireAllParametersForPipeup(tivx_obj_desc_node_t *node_obj_desc, uint16_t prm_obj_desc_id[])
Acquire parameters for node execution during pipeup phase.
void ownTargetInit(void)
Init global state of target module.
Command to create a node on target.
Definition: tivx_target.h:174
Command to inform host that a ref is consumed and is available for user dequeue.
Definition: tivx_target.h:182
tivx_task task_handle
Handle to underlying task associate with this target.
Definition: tivx_target.h:199
vx_status ownTargetCreate(vx_enum target_id, const tivx_target_create_params_t *params)
Create a target object and associate with given target ID.
vx_bool targetExitDone
Flag to indicate target exited its processing loop and is about to exit its main function.
Definition: tivx_target.h:220
void ownTargetTriggerNode(uint16_t node_obj_desc_id)
Trigger execution of a node obj desc.
Command to control a node on target.
Definition: tivx_target.h:178
Node object descriptor.
tivx_task_main_f target_main
target main
Definition: tivx_target.h:212
uint8_t * task_stack_ptr
Pointer to task stack, if NULL then task stack is allcoated by OS and not supplied by user...
Definition: tivx_target.h:233