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