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