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-2024 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.4.4
27  **/
28 
29 #ifndef _OS_PORT_NONE_H
30 #define _OS_PORT_NONE_H
31 
32 //Invalid task identifier
33 #define OS_INVALID_TASK_ID 0
34 //Self task identifier
35 #define OS_SELF_TASK_ID 0
36 
37 //Task priority (normal)
38 #ifndef OS_TASK_PRIORITY_NORMAL
39  #define OS_TASK_PRIORITY_NORMAL 0
40 #endif
41 
42 //Task priority (high)
43 #ifndef OS_TASK_PRIORITY_HIGH
44  #define OS_TASK_PRIORITY_HIGH 0
45 #endif
46 
47 //Milliseconds to system ticks
48 #ifndef OS_MS_TO_SYSTICKS
49  #define OS_MS_TO_SYSTICKS(n) (n)
50 #endif
51 
52 //System ticks to milliseconds
53 #ifndef OS_SYSTICKS_TO_MS
54  #define OS_SYSTICKS_TO_MS(n) (n)
55 #endif
56 
57 //Retrieve 64-bit system time (not implemented)
58 #ifndef osGetSystemTime64
59  #define osGetSystemTime64() osGetSystemTime()
60 #endif
61 
62 //Task prologue
63 #define osEnterTask()
64 //Task epilogue
65 #define osExitTask()
66 
67 //Interrupt service routine prologue
68 #ifndef osEnterIsr
69  #define osEnterIsr()
70 #endif
71 
72 //Interrupt service routine epilogue
73 #ifndef osExitIsr
74  #define osExitIsr(flag) (void) flag
75 #endif
76 
77 //C++ guard
78 #ifdef __cplusplus
79 extern "C" {
80 #endif
81 
82 
83 /**
84  * @brief System time
85  **/
86 
87 typedef uint32_t systime_t;
88 
89 
90 /**
91  * @brief Task identifier
92  **/
93 
94 typedef uint_t OsTaskId;
95 
96 
97 /**
98  * @brief Task parameters
99  **/
100 
101 typedef struct
102 {
103  size_t stackSize;
106 
107 
108 /**
109  * @brief Event object
110  **/
111 
112 typedef uint_t OsEvent;
113 
114 
115 /**
116  * @brief Semaphore object
117  **/
118 
120 
121 
122 /**
123  * @brief Mutex object
124  **/
125 
126 typedef uint_t OsMutex;
127 
128 
129 /**
130  * @brief Task routine
131  **/
132 
133 typedef void (*OsTaskCode)(void *arg);
134 
135 //Tick count
136 extern volatile systime_t systemTicks;
137 
138 //Default task parameters
140 
141 //Kernel management
142 void osInitKernel(void);
143 void osStartKernel(void);
144 
145 //Task management
146 OsTaskId osCreateTask(const char_t *name, OsTaskCode taskCode, void *arg,
147  const OsTaskParameters *params);
148 
149 void osDeleteTask(OsTaskId taskId);
150 void osDelayTask(systime_t delay);
151 void osSwitchTask(void);
152 void osSuspendAllTasks(void);
153 void osResumeAllTasks(void);
154 
155 //Event management
157 void osDeleteEvent(OsEvent *event);
158 void osSetEvent(OsEvent *event);
159 void osResetEvent(OsEvent *event);
160 bool_t osWaitForEvent(OsEvent *event, systime_t timeout);
162 
163 //Semaphore management
164 bool_t osCreateSemaphore(OsSemaphore *semaphore, uint_t count);
165 void osDeleteSemaphore(OsSemaphore *semaphore);
166 bool_t osWaitForSemaphore(OsSemaphore *semaphore, systime_t timeout);
167 void osReleaseSemaphore(OsSemaphore *semaphore);
168 
169 //Mutex management
171 void osDeleteMutex(OsMutex *mutex);
172 void osAcquireMutex(OsMutex *mutex);
173 void osReleaseMutex(OsMutex *mutex);
174 
175 //System time
177 
178 //Memory management
179 void *osAllocMem(size_t size);
180 void osFreeMem(void *p);
181 
182 //C++ guard
183 #ifdef __cplusplus
184 }
185 #endif
186 
187 #endif
int bool_t
Definition: compiler_port.h:53
OsTaskId osCreateTask(const char_t *name, OsTaskCode taskCode, void *arg, const OsTaskParameters *params)
Create a task.
uint_t OsTaskId
Task identifier.
Definition: os_port_none.h:94
uint8_t p
Definition: ndp.h:300
void osStartKernel(void)
Start kernel.
Event object.
void osReleaseSemaphore(OsSemaphore *semaphore)
Release the specified semaphore object.
volatile systime_t systemTicks
Definition: os_port_none.c:47
bool_t osCreateSemaphore(OsSemaphore *semaphore, uint_t count)
Create a semaphore object.
uint_t OsSemaphore
Semaphore object.
Definition: os_port_none.h:119
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:112
uint_t OsMutex
Mutex object.
Definition: os_port_none.h:126
void osDelayTask(systime_t delay)
Delay routine.
systime_t osGetSystemTime(void)
Retrieve system time.
void(* OsTaskCode)(void *arg)
Task routine.
Definition: os_port_none.h:133
void osDeleteSemaphore(OsSemaphore *semaphore)
Delete a semaphore object.
Task parameters.
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.
uint32_t systime_t
System time.
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:48
bool_t osWaitForEvent(OsEvent *event, systime_t timeout)
Wait until the specified event is in the signaled state.
const OsTaskParameters OS_TASK_DEFAULT_PARAMS
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.
thread_t * OsTaskId
Task identifier.
void osAcquireMutex(OsMutex *mutex)
Acquire ownership of the specified mutex object.
unsigned int uint_t
Definition: compiler_port.h:50
void osDeleteTask(OsTaskId taskId)
Delete a task.
uint16_t priority
Definition: dns_common.h:265
uint32_t systime_t
System time.
Definition: os_port_none.h:87
void osResumeAllTasks(void)
Resume scheduler activity.
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.