AM263Px MCU+ SDK: TaskP.h Source File

| AM263Px MCU+ SDK 26.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 #if defined(__ARM_ARCH_7R__)
43 #include <kernel/dpl/MpuP_armv7.h>
44 #endif
45
58 typedef void (*TaskP_FxnMain)(void *args);
59
63 #define TaskP_PRIORITY_LOWEST (0u)
64
68 #define TaskP_PRIORITY_HIGHEST (31u)
69
73 #define TaskP_LOAD_UPDATE_WINDOW_MSEC (500u)
74
75
79 typedef struct {
80
81 const char *name;
82 uint64_t runTime;
83 uint64_t totalTime;
84 uint32_t cpuLoad;
86 } TaskP_Load;
87
92 #if defined (OS_FREERTOS) || defined (OS_FREERTOS_SMP) || defined (OS_FREERTOS_MPU)
93
94 #include <FreeRTOS.h>
95 #include <task.h>
96
97 typedef struct TaskP_Object_ {
98
99 StaticTask_t taskTcb;
100 TaskHandle_t taskHndl;
101 uint32_t lastRunTime;
102 uint64_t accRunTime;
103
104 } TaskP_Object;
105
106 #elif defined (OS_SAFERTOS)
107
108 #include <SafeRTOS.h>
109 #include <task.h>
110
111 typedef struct TaskP_Object_ {
112
113 xTCB taskTcb;
114 portTaskHandleType taskHndl;
115 uint32_t lastRunTime;
116 uint64_t accRunTime;
117
118 } TaskP_Object;
119
120 #elif defined (OS_NORTOS)
121
125 typedef struct TaskP_Object_ {
126
127 uint32_t rsv;
128
129 } TaskP_Object;
130
131 #else
132
133 #error "Define OS_FREERTOS or OS_FREERTOS_SMP or OS_FREERTOS_MPU or OS_SAFERTOS or OS_NORTOS"
134
135 #endif
136
140 typedef struct TaskP_Params_ {
141
142 const char *name;
143 uint32_t stackSize;
144 uint8_t *stack;
145 uint32_t priority;
146 void *args;
147 TaskP_FxnMain taskMain;
148 uintptr_t coreAffinity;
150 } TaskP_Params;
151
152 #if defined(__ARM_ARCH_7R__)
153
158 typedef struct TaskP_MpuRegionConfig_ {
159 uint32_t baseAddr;
160 uint32_t sizeBytes;
170 MpuP_RegionAttrs attrs;
171 } TaskP_MpuRegionConfig;
172
178 typedef struct TaskP_ParamsRestricted_ {
179 TaskP_Params params;
180 TaskP_MpuRegionConfig regionConfig[7U];
181 // TODO: Replace with below after TaskP refactor to include FreeRTOS headers and structs directly.
182 // TaskP_MpuRegionConfig regionConfig[portNUM_CONFIGURABLE_REGIONS]; /**< MPU region configurations */
183 } TaskP_ParamsRestricted;
184 #endif
185
193 void TaskP_Params_init(TaskP_Params *params);
194
206 int32_t TaskP_construct(TaskP_Object *obj, const TaskP_Params *params);
207
208 #if defined(__ARM_ARCH_7R__)
209
218 void TaskP_ParamsRestricted_init(TaskP_ParamsRestricted *params);
219
230 int32_t TaskP_constructRestricted(TaskP_Object *obj, const TaskP_ParamsRestricted *params);
231 #endif
232
238 void TaskP_destruct(TaskP_Object *obj);
239
240
248 void* TaskP_getHndl(TaskP_Object *obj);
249
253 void TaskP_yield(void);
254
265 void TaskP_exit(void);
266
273 void TaskP_loadGet(TaskP_Object *obj, TaskP_Load *taskLoad);
274
285 void TaskP_loadUpdateAll(void);
286
292 void TaskP_loadResetAll(void);
293
294
300 uint32_t TaskP_loadGetTotalCpuLoad(void);
301
304 #ifdef __cplusplus
305 }
306 #endif
307
308 #endif /* TASKP_H */
TaskP_FxnMain
void(* TaskP_FxnMain)(void *args)
Entry point to the task.
Definition: TaskP.h:58
TaskP_Params
Opaque task object used with the task APIs.
Definition: TaskP.h:140
args
void * args
Definition: hsmclient_msg.h:4
TaskP_Load
Task load statistics.
Definition: TaskP.h:79
SystemP.h
TaskP_Load::name
const char * name
Definition: TaskP.h:81
TaskP_loadResetAll
void TaskP_loadResetAll(void)
Reset task load statistics.
TaskP_Params::args
void * args
Definition: TaskP.h:146
TaskP_Params::name
const char * name
Definition: TaskP.h:142
TaskP_loadUpdateAll
void TaskP_loadUpdateAll(void)
Updated task load statistics.
TaskP_Params::taskMain
TaskP_FxnMain taskMain
Definition: TaskP.h:147
TaskP_exit
void TaskP_exit(void)
Exit current task.
MpuP_armv7.h
TaskP_yield
void TaskP_yield(void)
Yield current task.
TaskP_Params::stackSize
uint32_t stackSize
Definition: TaskP.h:143
TaskP_getHndl
void * TaskP_getHndl(TaskP_Object *obj)
Return OS defined task handle.
TaskP_Load::cpuLoad
uint32_t cpuLoad
Definition: TaskP.h:84
TaskP_Params::priority
uint32_t priority
Definition: TaskP.h:145
TaskP_construct
int32_t TaskP_construct(TaskP_Object *obj, const TaskP_Params *params)
Create a task object.
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:82
TaskP_loadGet
void TaskP_loadGet(TaskP_Object *obj, TaskP_Load *taskLoad)
Get task load.
MpuP_RegionAttrs
Attribute's to apply for a MPU region.
Definition: MpuP_armv7.h:115
TaskP_Params::coreAffinity
uintptr_t coreAffinity
Definition: TaskP.h:148
TaskP_Load::totalTime
uint64_t totalTime
Definition: TaskP.h:83
TaskP_Params::stack
uint8_t * stack
Definition: TaskP.h:144
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.