AM65x MCU+ SDK  09.01.00
TaskP.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018-2023 Texas Instruments Incorporated
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  */
32 
33 #ifndef TASKP_H
34 #define TASKP_H
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 #include <stdint.h>
41 #include <kernel/dpl/SystemP.h>
42 
55 typedef void (*TaskP_FxnMain)(void *args);
56 
60 #define TaskP_PRIORITY_LOWEST (0u)
61 
65 #define TaskP_PRIORITY_HIGHEST (31u)
66 
70 #define TaskP_LOAD_UPDATE_WINDOW_MSEC (500u)
71 
72 
76 typedef struct {
77 
78  const char *name;
79  uint64_t runTime;
80  uint64_t totalTime;
81  uint32_t cpuLoad;
83 } TaskP_Load;
84 
88 #define TaskP_OBJECT_SIZE_MAX (160u)
89 
92 typedef struct TaskP_Object_ {
93 
94  /* uintptr_t translates to uint64_t for A53 and uint32_t for R5 and M4 */
95  /* This accounts for the 64bit pointer in A53 and 32bit pointer in R5 and M4 */
96  uintptr_t rsv[TaskP_OBJECT_SIZE_MAX/sizeof(uint32_t)];
98 } TaskP_Object;
99 
103 typedef struct TaskP_Params_ {
104 
105  const char *name;
106  uint32_t stackSize;
107  uint8_t *stack;
108  uint32_t priority;
109  void *args;
111  uintptr_t coreAffinity;
113 } TaskP_Params;
114 
123 
133 
140 
141 
150 
154 void TaskP_yield(void);
155 
163 void TaskP_exit(void);
164 
171 void TaskP_loadGet(TaskP_Object *obj, TaskP_Load *taskLoad);
172 
184 
191 
192 
199 
202 #ifdef __cplusplus
203 }
204 #endif
205 
206 #endif /* TASKP_H */
TaskP_FxnMain
void(* TaskP_FxnMain)(void *args)
Entry point to the task.
Definition: TaskP.h:55
TaskP_Params
Parameters passed during TaskP_construct.
Definition: TaskP.h:103
TaskP_Load
Task load statistics.
Definition: TaskP.h:76
SystemP.h
TaskP_Load::name
const char * name
Definition: TaskP.h:78
TaskP_Object
Opaque task object used with the task APIs.
Definition: TaskP.h:92
TaskP_loadResetAll
void TaskP_loadResetAll(void)
Reset task load statistics.
TaskP_Params::args
void * args
Definition: TaskP.h:109
TaskP_construct
int32_t TaskP_construct(TaskP_Object *obj, TaskP_Params *params)
Create a task object.
TaskP_Params::name
const char * name
Definition: TaskP.h:105
TaskP_loadUpdateAll
void TaskP_loadUpdateAll(void)
Updated task load statistics.
TaskP_Params::taskMain
TaskP_FxnMain taskMain
Definition: TaskP.h:110
TaskP_exit
void TaskP_exit(void)
Exit current task.
TaskP_yield
void TaskP_yield(void)
Yield current task.
TaskP_Params::stackSize
uint32_t stackSize
Definition: TaskP.h:106
TaskP_getHndl
void * TaskP_getHndl(TaskP_Object *obj)
Return OS defined task handle.
TaskP_Load::cpuLoad
uint32_t cpuLoad
Definition: TaskP.h:81
TaskP_Params::priority
uint32_t priority
Definition: TaskP.h:108
TaskP_loadGetTotalCpuLoad
uint32_t TaskP_loadGetTotalCpuLoad(void)
Get total CPU load including all task and ISR execution time.
TaskP_Load::runTime
uint64_t runTime
Definition: TaskP.h:79
TaskP_loadGet
void TaskP_loadGet(TaskP_Object *obj, TaskP_Load *taskLoad)
Get task load.
TaskP_Params::coreAffinity
uintptr_t coreAffinity
Definition: TaskP.h:111
TaskP_Load::totalTime
uint64_t totalTime
Definition: TaskP.h:80
TaskP_OBJECT_SIZE_MAX
#define TaskP_OBJECT_SIZE_MAX
Max size of task object across all OS's.
Definition: TaskP.h:88
TaskP_Params::stack
uint8_t * stack
Definition: TaskP.h:107
TaskP_Params_init
void TaskP_Params_init(TaskP_Params *params)
Set default values to TaskP_Params.
TaskP_destruct
void TaskP_destruct(TaskP_Object *obj)
Cleanup, delete, destruct a task object.