Loading...
Searching...
No Matches
sys_arch.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 Martine Lenders <mlenders@inf.fu-berlin.de>
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
21#ifndef ARCH_SYS_ARCH_H
22#define ARCH_SYS_ARCH_H
23
24#include <stdbool.h>
25#include <stdint.h>
26
27#include "cib.h"
28#include "sched.h"
29#include "mbox.h"
30#include "mutex.h"
31#include "random.h"
32#include "sema.h"
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
41/* prefer mutexes rather than binary semaphores */
42#define LWIP_COMPAT_MUTEX (0)
43
49#define SYS_ARCH_PROTECT(x) mutex_lock(&x)
50#define SYS_ARCH_UNPROTECT(x) mutex_unlock(&x)
51#define SYS_ARCH_DECL_PROTECT(x) mutex_t x = MUTEX_INIT
61static inline bool sys_sem_valid(sys_sem_t *sem)
62{
63 return sem != NULL;
64}
65
66#define sys_sem_valid(sem) (sys_sem_valid(sem))
67
68#define sys_sem_set_invalid(sem)
78static inline bool sys_mutex_valid(sys_mutex_t *mutex)
79{
80 return mutex != NULL;
81}
82
83#define sys_mutex_valid(mutex) (sys_mutex_valid(mutex))
84#define sys_mutex_set_invalid(mutex)
92#define SYS_MBOX_SIZE (8)
93
97typedef struct {
99 msg_t msgs[SYS_MBOX_SIZE];
100} sys_mbox_t;
101
102static inline bool sys_mbox_valid(sys_mbox_t *mbox)
103{
104 return (mbox != NULL) && (mbox_size(&mbox->mbox) != 0);
105}
106
107static inline void sys_mbox_set_invalid(sys_mbox_t *mbox)
108{
109 if (mbox != NULL) {
110 mbox_unset(&mbox->mbox);
111 }
112}
113
114#define sys_mbox_valid(mbox) (sys_mbox_valid(mbox))
115#define sys_mbox_set_invalid(mbox) (sys_mbox_set_invalid(mbox))
126void sys_lock_tcpip_core(void);
127#define LOCK_TCPIP_CORE() sys_lock_tcpip_core()
128void sys_unlock_tcpip_core(void);
129#define UNLOCK_TCPIP_CORE() sys_unlock_tcpip_core()
132#ifdef MODULE_RANDOM
136#define LWIP_RAND() (random_uint32())
137#endif
138
139#ifdef __cplusplus
140}
141#endif
142
143#endif /* ARCH_SYS_ARCH_H */
Circular integer buffer interface.
static void mbox_unset(mbox_t *mbox)
Unset's the mbox, effectively deinitializing and invalidating it.
Definition mbox.h:193
static size_t mbox_size(mbox_t *mbox)
Get mbox queue size (capacity)
Definition mbox.h:169
int16_t kernel_pid_t
Unique process identifier.
Definition sched.h:139
mutex_t sys_mutex_t
Platform specific mutex type.
Definition sys_arch.h:76
sema_t sys_sem_t
Platform specific semaphore type.
Definition sys_arch.h:59
kernel_pid_t sys_thread_t
Platform specific thread type.
Definition sys_arch.h:118
kernel_pid_t lwip_tcpip_thread
PID of the lwIP TCP/IP thread.
Mailbox API.
Mutex for thread synchronization.
Common interface to the software PRNG.
Scheduler API definition.
Semaphore definitions.
Mailbox struct definition.
Definition mbox.h:41
Describes a message object which can be sent between threads.
Definition msg.h:196
Mutex structure.
Definition mutex.h:146
A Semaphore.
Definition sema.h:68
Platform specific mailbox type.
Definition sys_arch.h:97
mbox_t mbox
RIOT mbox.
Definition sys_arch.h:98