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-2020 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 1.9.8
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 //Task priority (normal)
45 #ifndef OS_TASK_PRIORITY_NORMAL
46  #define OS_TASK_PRIORITY_NORMAL 1
47 #endif
48 
49 //Task priority (high)
50 #ifndef OS_TASK_PRIORITY_HIGH
51  #define OS_TASK_PRIORITY_HIGH 2
52 #endif
53 
54 //Milliseconds to system ticks
55 #ifndef OS_MS_TO_SYSTICKS
56  #define OS_MS_TO_SYSTICKS(n) (n)
57 #endif
58 
59 //System ticks to milliseconds
60 #ifndef OS_SYSTICKS_TO_MS
61  #define OS_SYSTICKS_TO_MS(n) (n)
62 #endif
63 
64 //Task prologue
65 #define osEnterTask()
66 //Interrupt service routine prologue
67 #define osEnterIsr()
68 //Interrupt service routine epilogue
69 #define osExitIsr(flag)
70 
71 //C++ guard
72 #ifdef __cplusplus
73 extern "C" {
74 #endif
75 
76 
77 /**
78  * @brief Task object
79  **/
80 
81 typedef Task_Object OsTask;
82 
83 
84 /**
85  * @brief Event object
86  **/
87 
88 typedef struct
89 {
90  Event_Handle handle;
91 } OsEvent;
92 
93 
94 /**
95  * @brief Semaphore object
96  **/
97 
98 typedef struct
99 {
100  Semaphore_Handle handle;
101 } OsSemaphore;
102 
103 
104 /**
105  * @brief Mutex object
106  **/
107 
108 typedef struct
109 {
110  Semaphore_Handle handle;
111 } OsMutex;
112 
113 
114 /**
115  * @brief Task routine
116  **/
117 
118 typedef void (*OsTaskCode)(void *param);
119 
120 
121 //Kernel management
122 void osInitKernel(void);
123 void osStartKernel(void);
124 
125 //Task management
126 OsTask *osCreateTask(const char_t *name, OsTaskCode taskCode,
127  void *param, size_t stackSize, int_t priority);
128 
129 void osDeleteTask(OsTask *task);
130 void osDelayTask(systime_t delay);
131 void osSwitchTask(void);
132 void osSuspendAllTasks(void);
133 void osResumeAllTasks(void);
134 
135 //Event management
137 void osDeleteEvent(OsEvent *event);
138 void osSetEvent(OsEvent *event);
139 void osResetEvent(OsEvent *event);
140 bool_t osWaitForEvent(OsEvent *event, systime_t timeout);
142 
143 //Semaphore management
144 bool_t osCreateSemaphore(OsSemaphore *semaphore, uint_t count);
145 void osDeleteSemaphore(OsSemaphore *semaphore);
146 bool_t osWaitForSemaphore(OsSemaphore *semaphore, systime_t timeout);
147 void osReleaseSemaphore(OsSemaphore *semaphore);
148 
149 //Mutex management
151 void osDeleteMutex(OsMutex *mutex);
152 void osAcquireMutex(OsMutex *mutex);
153 void osReleaseMutex(OsMutex *mutex);
154 
155 //System time
157 
158 //Memory management
159 void *osAllocMem(size_t size);
160 void osFreeMem(void *p);
161 
162 //C++ guard
163 #ifdef __cplusplus
164 }
165 #endif
166 
167 #endif
int bool_t
Definition: compiler_port.h:49
signed int int_t
Definition: compiler_port.h:44
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[]
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
void osSwitchTask(void)
Yield control to the next task.
Semaphore object.
Task_Object OsTask
Task 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
mutex_t OsMutex
Mutex object.
binary_semaphore_t OsEvent
Event object.
Task 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.
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:43
void osDeleteMutex(OsMutex *mutex)
Delete a mutex object.
OsTask * osCreateTask(const char_t *name, OsTaskCode taskCode, void *param, size_t stackSize, int_t priority)
Create a new task.
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 osDeleteTask(OsTask *task)
Delete a task.
void osDeleteEvent(OsEvent *event)
Delete an event object.
void osFreeMem(void *p)
Release a previously allocated memory block.
unsigned int uint_t
Definition: compiler_port.h:45
uint16_t priority
Definition: dns_common.h:221
void osDeleteSemaphore(OsSemaphore *semaphore)
Delete a semaphore object.
uint32_t systime_t
Definition: compiler_port.h:46
Event_Handle handle
semaphore_t OsSemaphore
Semaphore object.