os_port_sys_bios.h
Go to the documentation of this file.
1 /**
2  * @file os_port_sys_bios.h
3  * @brief RTOS abstraction layer (SYS/BIOS)
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2023 Oryx Embedded SARL. All rights reserved.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24  *
25  * @author Oryx Embedded SARL (www.oryx-embedded.com)
26  * @version 2.2.4
27  **/
28 
29 #ifndef _OS_PORT_SYS_BIOS_H
30 #define _OS_PORT_SYS_BIOS_H
31 
32 //Dependencies
33 #include <xdc/std.h>
34 #include <xdc/runtime/error.h>
35 #include <xdc/runtime/system.h>
36 #include <xdc/runtime/memory.h>
37 #include <ti/sysbios/bios.h>
38 #include <ti/sysbios/knl/task.h>
39 #include <ti/sysbios/knl/event.h>
40 #include <ti/sysbios/knl/semaphore.h>
41 #include <ti/sysbios/knl/clock.h>
42 #include <ti/sysbios/hal/hwi.h>
43 
44 //Use dynamic memory allocation for tasks
45 #define OS_STATIC_TASK_SUPPORT DISABLED
46 
47 //Invalid task identifier
48 #define OS_INVALID_TASK_ID NULL
49 //Self task identifier
50 #define OS_SELF_TASK_ID NULL
51 
52 //Task priority (normal)
53 #ifndef OS_TASK_PRIORITY_NORMAL
54  #define OS_TASK_PRIORITY_NORMAL 1
55 #endif
56 
57 //Task priority (high)
58 #ifndef OS_TASK_PRIORITY_HIGH
59  #define OS_TASK_PRIORITY_HIGH 2
60 #endif
61 
62 //Milliseconds to system ticks
63 #ifndef OS_MS_TO_SYSTICKS
64  #define OS_MS_TO_SYSTICKS(n) (n)
65 #endif
66 
67 //System ticks to milliseconds
68 #ifndef OS_SYSTICKS_TO_MS
69  #define OS_SYSTICKS_TO_MS(n) (n)
70 #endif
71 
72 //Retrieve 64-bit system time (not implemented)
73 #ifndef osGetSystemTime64
74  #define osGetSystemTime64() osGetSystemTime()
75 #endif
76 
77 //Task prologue
78 #define osEnterTask()
79 //Task epilogue
80 #define osExitTask()
81 //Interrupt service routine prologue
82 #define osEnterIsr()
83 //Interrupt service routine epilogue
84 #define osExitIsr(flag)
85 
86 //C++ guard
87 #ifdef __cplusplus
88 extern "C" {
89 #endif
90 
91 
92 /**
93  * @brief System time
94  **/
95 
96 typedef uint32_t systime_t;
97 
98 
99 /**
100  * @brief Task identifier
101  **/
102 
103 typedef Task_Handle OsTaskId;
104 
105 
106 /**
107  * @brief Event object
108  **/
109 
110 typedef struct
111 {
112  Event_Handle handle;
113 } OsEvent;
114 
115 
116 /**
117  * @brief Semaphore object
118  **/
119 
120 typedef struct
121 {
122  Semaphore_Handle handle;
123 } OsSemaphore;
124 
125 
126 /**
127  * @brief Mutex object
128  **/
129 
130 typedef struct
131 {
132  Semaphore_Handle handle;
133 } OsMutex;
134 
135 
136 /**
137  * @brief Task routine
138  **/
139 
140 typedef void (*OsTaskCode)(void *param);
141 
142 
143 //Kernel management
144 void osInitKernel(void);
145 void osStartKernel(void);
146 
147 //Task management
148 OsTaskId osCreateTask(const char_t *name, OsTaskCode taskCode,
149  void *param, size_t stackSize, int_t priority);
150 
151 void osDeleteTask(OsTaskId taskId);
152 void osDelayTask(systime_t delay);
153 void osSwitchTask(void);
154 void osSuspendAllTasks(void);
155 void osResumeAllTasks(void);
156 
157 //Event management
159 void osDeleteEvent(OsEvent *event);
160 void osSetEvent(OsEvent *event);
161 void osResetEvent(OsEvent *event);
162 bool_t osWaitForEvent(OsEvent *event, systime_t timeout);
164 
165 //Semaphore management
166 bool_t osCreateSemaphore(OsSemaphore *semaphore, uint_t count);
167 void osDeleteSemaphore(OsSemaphore *semaphore);
168 bool_t osWaitForSemaphore(OsSemaphore *semaphore, systime_t timeout);
169 void osReleaseSemaphore(OsSemaphore *semaphore);
170 
171 //Mutex management
173 void osDeleteMutex(OsMutex *mutex);
174 void osAcquireMutex(OsMutex *mutex);
175 void osReleaseMutex(OsMutex *mutex);
176 
177 //System time
179 
180 //Memory management
181 void *osAllocMem(size_t size);
182 void osFreeMem(void *p);
183 
184 //C++ guard
185 #ifdef __cplusplus
186 }
187 #endif
188 
189 #endif
int bool_t
Definition: compiler_port.h:53
signed int int_t
Definition: compiler_port.h:49
void osDelayTask(systime_t delay)
Delay routine.
uint8_t p
Definition: ndp.h:298
Semaphore_Handle handle
Event object.
bool_t osWaitForSemaphore(OsSemaphore *semaphore, systime_t timeout)
Wait for the specified semaphore to be available.
char_t name[]
uint32_t systime_t
System time.
void osDeleteTask(OsTaskId taskId)
Delete a task.
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
void osSwitchTask(void)
Yield control to the next task.
Semaphore object.
void osAcquireMutex(OsMutex *mutex)
Acquire ownership of the specified mutex object.
bool_t osCreateSemaphore(OsSemaphore *semaphore, uint_t count)
Create a semaphore object.
void osReleaseSemaphore(OsSemaphore *semaphore)
Release the specified semaphore object.
Semaphore_Handle handle
Task_Handle OsTaskId
Task identifier.
mutex_t OsMutex
Mutex object.
OsTaskId osCreateTask(const char_t *name, OsTaskCode taskCode, void *param, size_t stackSize, int_t priority)
Create a task.
binary_semaphore_t OsEvent
Event object.
void osInitKernel(void)
Kernel initialization.
void * osAllocMem(size_t size)
Allocate a memory block.
void osSuspendAllTasks(void)
Suspend scheduler activity.
void osStartKernel(void)
Start kernel.
bool_t osCreateEvent(OsEvent *event)
Create an event object.
Mutex object.
uint32_t systime_t
System time.
void(* OsTaskCode)(void *param)
Task routine.
bool_t osSetEventFromIsr(OsEvent *event)
Set an event object to the signaled state from an interrupt service routine.
bool_t osCreateMutex(OsMutex *mutex)
Create a mutex object.
char char_t
Definition: compiler_port.h:48
void osDeleteMutex(OsMutex *mutex)
Delete a mutex object.
void osResumeAllTasks(void)
Resume scheduler activity.
void osResetEvent(OsEvent *event)
Set the specified event object to the nonsignaled state.
void osSetEvent(OsEvent *event)
Set the specified event object to the signaled state.
bool_t osWaitForEvent(OsEvent *event, systime_t timeout)
Wait until the specified event is in the signaled state.
systime_t osGetSystemTime(void)
Retrieve system time.
void osDeleteEvent(OsEvent *event)
Delete an event object.
void osFreeMem(void *p)
Release a previously allocated memory block.
thread_t * OsTaskId
Task identifier.
unsigned int uint_t
Definition: compiler_port.h:50
uint16_t priority
Definition: dns_common.h:249
void osDeleteSemaphore(OsSemaphore *semaphore)
Delete a semaphore object.
Event_Handle handle
semaphore_t OsSemaphore
Semaphore object.