os_port_none.h
Go to the documentation of this file.
1 /**
2  * @file os_port_none.h
3  * @brief RTOS-less environment
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_NONE_H
30 #define _OS_PORT_NONE_H
31 
32 //Task priority (normal)
33 #ifndef OS_TASK_PRIORITY_NORMAL
34  #define OS_TASK_PRIORITY_NORMAL 0
35 #endif
36 
37 //Task priority (high)
38 #ifndef OS_TASK_PRIORITY_HIGH
39  #define OS_TASK_PRIORITY_HIGH 0
40 #endif
41 
42 //Milliseconds to system ticks
43 #ifndef OS_MS_TO_SYSTICKS
44  #define OS_MS_TO_SYSTICKS(n) (n)
45 #endif
46 
47 //System ticks to milliseconds
48 #ifndef OS_SYSTICKS_TO_MS
49  #define OS_SYSTICKS_TO_MS(n) (n)
50 #endif
51 
52 //Task prologue
53 #define osEnterTask()
54 
55 //Interrupt service routine prologue
56 #ifndef osEnterIsr
57  #define osEnterIsr()
58 #endif
59 
60 //Interrupt service routine epilogue
61 #ifndef osExitIsr
62  #define osExitIsr(flag) (void) flag
63 #endif
64 
65 //C++ guard
66 #ifdef __cplusplus
67 extern "C" {
68 #endif
69 
70 
71 /**
72  * @brief Task object
73  **/
74 
75 typedef void OsTask;
76 
77 
78 /**
79  * @brief Event object
80  **/
81 
82 typedef uint_t OsEvent;
83 
84 
85 /**
86  * @brief Semaphore object
87  **/
88 
90 
91 
92 /**
93  * @brief Mutex object
94  **/
95 
96 typedef uint_t OsMutex;
97 
98 
99 /**
100  * @brief Task routine
101  **/
102 
103 typedef void (*OsTaskCode)(void *param);
104 
105 //Tick count
106 extern systime_t systemTicks;
107 
108 //Kernel management
109 void osInitKernel(void);
110 void osStartKernel(void);
111 
112 //Task management
113 OsTask *osCreateTask(const char_t *name, OsTaskCode taskCode,
114  void *param, size_t stackSize, int_t priority);
115 
116 void osDeleteTask(OsTask *task);
117 void osDelayTask(systime_t delay);
118 void osSwitchTask(void);
119 void osSuspendAllTasks(void);
120 void osResumeAllTasks(void);
121 
122 //Event management
124 void osDeleteEvent(OsEvent *event);
125 void osSetEvent(OsEvent *event);
126 void osResetEvent(OsEvent *event);
127 bool_t osWaitForEvent(OsEvent *event, systime_t timeout);
129 
130 //Semaphore management
131 bool_t osCreateSemaphore(OsSemaphore *semaphore, uint_t count);
132 void osDeleteSemaphore(OsSemaphore *semaphore);
133 bool_t osWaitForSemaphore(OsSemaphore *semaphore, systime_t timeout);
134 void osReleaseSemaphore(OsSemaphore *semaphore);
135 
136 //Mutex management
138 void osDeleteMutex(OsMutex *mutex);
139 void osAcquireMutex(OsMutex *mutex);
140 void osReleaseMutex(OsMutex *mutex);
141 
142 //System time
144 
145 //Memory management
146 void *osAllocMem(size_t size);
147 void osFreeMem(void *p);
148 
149 //C++ guard
150 #ifdef __cplusplus
151 }
152 #endif
153 
154 #endif
void OsTask
Task object.
Definition: os_port_none.h:75
int bool_t
Definition: compiler_port.h:49
signed int int_t
Definition: compiler_port.h:44
uint8_t p
Definition: ndp.h:298
void osStartKernel(void)
Start kernel.
Event object.
void osReleaseSemaphore(OsSemaphore *semaphore)
Release the specified semaphore object.
bool_t osCreateSemaphore(OsSemaphore *semaphore, uint_t count)
Create a semaphore object.
uint_t OsSemaphore
Semaphore object.
Definition: os_port_none.h:89
char_t name[]
void osInitKernel(void)
Kernel initialization.
void osDeleteMutex(OsMutex *mutex)
Delete a mutex object.
bool_t osCreateMutex(OsMutex *mutex)
Create a mutex object.
Semaphore object.
void osSuspendAllTasks(void)
Suspend scheduler activity.
void * osAllocMem(size_t size)
Allocate a memory block.
void osDeleteEvent(OsEvent *event)
Delete an event object.
uint_t OsEvent
Event object.
Definition: os_port_none.h:82
uint_t OsMutex
Mutex object.
Definition: os_port_none.h:96
void osDelayTask(systime_t delay)
Delay routine.
systime_t osGetSystemTime(void)
Retrieve system time.
systime_t systemTicks
Definition: os_port_none.c:47
Task object.
void osDeleteSemaphore(OsSemaphore *semaphore)
Delete a semaphore object.
void osSetEvent(OsEvent *event)
Set the specified event object to the signaled state.
void osResetEvent(OsEvent *event)
Set the specified event object to the nonsignaled state.
Mutex object.
void osFreeMem(void *p)
Release a previously allocated memory block.
bool_t osCreateEvent(OsEvent *event)
Create an event object.
char char_t
Definition: compiler_port.h:43
bool_t osWaitForEvent(OsEvent *event, systime_t timeout)
Wait until the specified event is in the signaled state.
void osDeleteTask(OsTask *task)
Delete a task.
void osSwitchTask(void)
Yield control to the next task.
bool_t osWaitForSemaphore(OsSemaphore *semaphore, systime_t timeout)
Wait for the specified semaphore to be available.
void osAcquireMutex(OsMutex *mutex)
Acquire ownership of the specified mutex object.
unsigned int uint_t
Definition: compiler_port.h:45
void(* OsTaskCode)(void *param)
Task routine.
Definition: os_port_none.h:103
uint16_t priority
Definition: dns_common.h:221
void osResumeAllTasks(void)
Resume scheduler activity.
uint32_t systime_t
Definition: compiler_port.h:46
bool_t osSetEventFromIsr(OsEvent *event)
Set an event object to the signaled state from an interrupt service routine.
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
OsTask * osCreateTask(const char_t *name, OsTaskCode taskCode, void *param, size_t stackSize, int_t priority)
Create a new task.