os_port_windows.h
Go to the documentation of this file.
1 /**
2  * @file os_port_windows.h
3  * @brief RTOS abstraction layer (Windows)
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2019 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.6
27  **/
28 
29 #ifndef _OS_PORT_WINDOWS_H
30 #define _OS_PORT_WINDOWS_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 //Interrupt service routine prologue
55 #define osEnterIsr()
56 //Interrupt service routine epilogue
57 #define osExitIsr(flag)
58 
59 //C++ guard
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63 
64 
65 /**
66  * @brief Task object
67  **/
68 
69 typedef void OsTask;
70 
71 
72 /**
73  * @brief Event object
74  **/
75 
76 typedef struct
77 {
78  void *handle;
79 } OsEvent;
80 
81 
82 /**
83  * @brief Semaphore object
84  **/
85 
86 typedef struct
87 {
88  void *handle;
89 } OsSemaphore;
90 
91 
92 /**
93  * @brief Mutex object
94  **/
95 
96 typedef struct
97 {
98  void *handle;
99 } OsMutex;
100 
101 
102 /**
103  * @brief Task routine
104  **/
105 
106 typedef void (*OsTaskCode)(void *param);
107 
108 
109 //Kernel management
110 void osInitKernel(void);
111 void osStartKernel(void);
112 
113 //Task management
114 OsTask *osCreateTask(const char_t *name, OsTaskCode taskCode,
115  void *param, size_t stackSize, int_t priority);
116 
117 void osDeleteTask(OsTask *task);
118 void osDelayTask(systime_t delay);
119 void osSwitchTask(void);
120 void osSuspendAllTasks(void);
121 void osResumeAllTasks(void);
122 
123 //Event management
125 void osDeleteEvent(OsEvent *event);
126 void osSetEvent(OsEvent *event);
127 void osResetEvent(OsEvent *event);
128 bool_t osWaitForEvent(OsEvent *event, systime_t timeout);
130 
131 //Semaphore management
132 bool_t osCreateSemaphore(OsSemaphore *semaphore, uint_t count);
133 void osDeleteSemaphore(OsSemaphore *semaphore);
134 bool_t osWaitForSemaphore(OsSemaphore *semaphore, systime_t timeout);
135 void osReleaseSemaphore(OsSemaphore *semaphore);
136 
137 //Mutex management
139 void osDeleteMutex(OsMutex *mutex);
140 void osAcquireMutex(OsMutex *mutex);
141 void osReleaseMutex(OsMutex *mutex);
142 
143 //System time
145 
146 //Memory management
147 void *osAllocMem(size_t size);
148 void osFreeMem(void *p);
149 
150 //Miscellaneous definitions
151 #define strlwr _strlwr
152 #define strcasecmp _stricmp
153 #define strncasecmp _strnicmp
154 #define strtok_r(str, delim, p) strtok(str, delim)
155 
156 //C++ guard
157 #ifdef __cplusplus
158 }
159 #endif
160 
161 #endif
void osDeleteMutex(OsMutex *mutex)
Delete a mutex object.
int bool_t
Definition: compiler_port.h:49
signed int int_t
Definition: compiler_port.h:44
uint8_t p
Definition: ndp.h:298
Event object.
OsTask * osCreateTask(const char_t *name, OsTaskCode taskCode, void *param, size_t stackSize, int_t priority)
Create a new 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.
char_t name[]
void osSetEvent(OsEvent *event)
Set the specified event object to the signaled state.
Semaphore object.
void osDelayTask(systime_t delay)
Delay routine.
bool_t osCreateSemaphore(OsSemaphore *semaphore, uint_t count)
Create a semaphore object.
void osInitKernel(void)
Kernel initialization.
void * handle
mutex_t OsMutex
Mutex object.
void * handle
void osReleaseSemaphore(OsSemaphore *semaphore)
Release the specified semaphore object.
binary_semaphore_t OsEvent
Event object.
bool_t osSetEventFromIsr(OsEvent *event)
Set an event object to the signaled state from an interrupt service routine.
Task object.
bool_t osCreateEvent(OsEvent *event)
Create an event object.
void osSwitchTask(void)
Yield control to the next task.
void osFreeMem(void *p)
Release a previously allocated memory block.
void osSuspendAllTasks(void)
Suspend scheduler activity.
Mutex object.
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
bool_t osCreateMutex(OsMutex *mutex)
Create a mutex object.
char char_t
Definition: compiler_port.h:43
void osDeleteTask(OsTask *task)
Delete a task.
systime_t osGetSystemTime(void)
Retrieve system time.
void osDeleteSemaphore(OsSemaphore *semaphore)
Delete a semaphore object.
void osResumeAllTasks(void)
Resume scheduler activity.
void * osAllocMem(size_t size)
Allocate a memory block.
void osResetEvent(OsEvent *event)
Set the specified event object to the nonsignaled state.
void osDeleteEvent(OsEvent *event)
Delete an event object.
unsigned int uint_t
Definition: compiler_port.h:45
void(* OsTaskCode)(void *param)
Task routine.
uint16_t priority
Definition: dns_common.h:221
void OsTask
Task object.
uint32_t systime_t
Definition: compiler_port.h:46
void osStartKernel(void)
Start kernel.
bool_t osWaitForEvent(OsEvent *event, systime_t timeout)
Wait until the specified event is in the signaled state.
semaphore_t OsSemaphore
Semaphore object.