AM64x MCU+ SDK  08.02.00
TaskP.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018-2021 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 (15u)
66 
67 
68 
72 #define TaskP_LOAD_UPDATE_WINDOW_MSEC (500u)
73 
74 
78 typedef struct {
79 
80  const char *name;
81  uint64_t runTime;
82  uint64_t totalTime;
83  uint32_t cpuLoad;
85 } TaskP_Load;
86 
90 #define TaskP_OBJECT_SIZE_MAX (160u)
91 
94 typedef struct TaskP_Object_ {
95 
96  /* uintptr_t translates to uint64_t for A53 and uint32_t for R5 and M4 */
97  /* This accounts for the 64bit pointer in A53 and 32bit pointer in R5 and M4 */
98  uintptr_t rsv[TaskP_OBJECT_SIZE_MAX/sizeof(uint32_t)];
100 } TaskP_Object;
101 
105 typedef struct TaskP_Params_ {
106 
107  const char *name;
108  uint32_t stackSize;
109  uint8_t *stack;
110  uint32_t priority;
111  void *args;
113  uintptr_t coreAffinity;
115 } TaskP_Params;
116 
125 
135 
142 
143 
152 
156 void TaskP_yield();
157 
165 void TaskP_exit();
166 
173 void TaskP_loadGet(TaskP_Object *obj, TaskP_Load *taskLoad);
174 
186 
193 
194 
201 
204 #ifdef __cplusplus
205 }
206 #endif
207 
208 #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:105
TaskP_loadGetTotalCpuLoad
uint32_t TaskP_loadGetTotalCpuLoad()
Get total CPU load including all task and ISR execution time.
TaskP_Load
Task load statistics.
Definition: TaskP.h:78
SystemP.h
TaskP_loadUpdateAll
void TaskP_loadUpdateAll()
Updated task load statistics.
TaskP_Load::name
const char * name
Definition: TaskP.h:80
TaskP_Object
Opaque task object used with the task APIs.
Definition: TaskP.h:94
TaskP_Params::args
void * args
Definition: TaskP.h:111
TaskP_loadResetAll
void TaskP_loadResetAll()
Reset task load statistics.
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:107
TaskP_Params::taskMain
TaskP_FxnMain taskMain
Definition: TaskP.h:112
TaskP_yield
void TaskP_yield()
Yield current task.
TaskP_Params::stackSize
uint32_t stackSize
Definition: TaskP.h:108
TaskP_getHndl
void * TaskP_getHndl(TaskP_Object *obj)
Return OS defined task handle.
TaskP_Load::cpuLoad
uint32_t cpuLoad
Definition: TaskP.h:83
TaskP_Params::priority
uint32_t priority
Definition: TaskP.h:110
TaskP_Load::runTime
uint64_t runTime
Definition: TaskP.h:81
TaskP_loadGet
void TaskP_loadGet(TaskP_Object *obj, TaskP_Load *taskLoad)
Get task load.
TaskP_exit
void TaskP_exit()
Exit current task.
TaskP_Params::coreAffinity
uintptr_t coreAffinity
Definition: TaskP.h:113
TaskP_Load::totalTime
uint64_t totalTime
Definition: TaskP.h:82
TaskP_OBJECT_SIZE_MAX
#define TaskP_OBJECT_SIZE_MAX
Max size of task object across all OS's.
Definition: TaskP.h:90
TaskP_Params::stack
uint8_t * stack
Definition: TaskP.h:109
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.