AM263x MCU+ SDK  10.00.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 #ifdef INCLUDE_FREERTOS_FAT
89 #define TaskP_OBJECT_SIZE_MAX (172u) /* Minimun requirement for FreeRTOS FATFS to work */
90 #else
91 #define TaskP_OBJECT_SIZE_MAX (160u)
92 #endif
93 
96 typedef struct TaskP_Object_ {
97 
98  /* uintptr_t translates to uint64_t for A53 and uint32_t for R5 and M4 */
99  /* This accounts for the 64bit pointer in A53 and 32bit pointer in R5 and M4 */
100  uintptr_t rsv[TaskP_OBJECT_SIZE_MAX/sizeof(uint32_t)];
102 } TaskP_Object;
103 
107 typedef struct TaskP_Params_ {
108 
109  const char *name;
110  uint32_t stackSize;
111  uint8_t *stack;
112  uint32_t priority;
113  void *args;
115  uintptr_t coreAffinity;
117 } TaskP_Params;
118 
127 
137 
144 
145 
154 
158 void TaskP_yield(void);
159 
167 void TaskP_exit(void);
168 
175 void TaskP_loadGet(TaskP_Object *obj, TaskP_Load *taskLoad);
176 
188 
195 
196 
203 
206 #ifdef __cplusplus
207 }
208 #endif
209 
210 #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:107
args
void * args
Definition: hsmclient_msg.h:4
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:96
TaskP_loadResetAll
void TaskP_loadResetAll(void)
Reset task load statistics.
TaskP_Params::args
void * args
Definition: TaskP.h:113
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:109
TaskP_loadUpdateAll
void TaskP_loadUpdateAll(void)
Updated task load statistics.
TaskP_Params::taskMain
TaskP_FxnMain taskMain
Definition: TaskP.h:114
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:110
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:112
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:115
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:91
TaskP_Params::stack
uint8_t * stack
Definition: TaskP.h:111
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.