Loading...
Searching...
No Matches
sys_arch.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2015 Martine Lenders <mlenders@inf.fu-berlin.de>
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
20
21#include <stdbool.h>
22#include <stdint.h>
23
24#include "cib.h"
25#include "sched.h"
26#include "mbox.h"
27#include "mutex.h"
28#include "random.h"
29#include "sema.h"
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
38/* prefer mutexes rather than binary semaphores */
39#define LWIP_COMPAT_MUTEX (0)
40
46#define SYS_ARCH_PROTECT(x) mutex_lock(&x)
47#define SYS_ARCH_UNPROTECT(x) mutex_unlock(&x)
48#define SYS_ARCH_DECL_PROTECT(x) mutex_t x = MUTEX_INIT
50
57
58static inline bool sys_sem_valid(sys_sem_t *sem)
59{
60 return sem != NULL;
61}
62
63#define sys_sem_valid(sem) (sys_sem_valid(sem))
64
65#define sys_sem_set_invalid(sem)
67
74
75static inline bool sys_mutex_valid(sys_mutex_t *mutex)
76{
77 return mutex != NULL;
78}
79
80#define sys_mutex_valid(mutex) (sys_mutex_valid(mutex))
81#define sys_mutex_set_invalid(mutex)
83
89#define SYS_MBOX_SIZE (8)
90
94typedef struct {
96 msg_t msgs[SYS_MBOX_SIZE];
98
99static inline bool sys_mbox_valid(sys_mbox_t *mbox)
100{
101 return (mbox != NULL) && (mbox_size(&mbox->mbox) != 0);
102}
103
104static inline void sys_mbox_set_invalid(sys_mbox_t *mbox)
105{
106 if (mbox != NULL) {
107 mbox_unset(&mbox->mbox);
108 }
109}
110
111#define sys_mbox_valid(mbox) (sys_mbox_valid(mbox))
112#define sys_mbox_set_invalid(mbox) (sys_mbox_set_invalid(mbox))
114
116
118
123void sys_lock_tcpip_core(void);
124#define LOCK_TCPIP_CORE() sys_lock_tcpip_core()
125void sys_unlock_tcpip_core(void);
126#define UNLOCK_TCPIP_CORE() sys_unlock_tcpip_core()
128
129#ifdef MODULE_RANDOM
133#define LWIP_RAND() (random_uint32())
134#endif
135
136#ifdef __cplusplus
137}
138#endif
139
Circular integer buffer interface.
static void mbox_unset(mbox_t *mbox)
Unset's the mbox, effectively deinitializing and invalidating it.
Definition mbox.h:191
static size_t mbox_size(mbox_t *mbox)
Get mbox queue size (capacity)
Definition mbox.h:167
int16_t kernel_pid_t
Unique process identifier.
Definition sched.h:134
mutex_t sys_mutex_t
Platform specific mutex type.
Definition sys_arch.h:73
sema_t sys_sem_t
Platform specific semaphore type.
Definition sys_arch.h:56
kernel_pid_t sys_thread_t
Platform specific thread type.
Definition sys_arch.h:115
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.
Semaphore definitions.
Mailbox struct definition.
Definition mbox.h:38
Describes a message object which can be sent between threads.
Definition msg.h:193
Mutex structure.
Definition mutex.h:36
A Semaphore.
Definition sema.h:64
Platform specific mailbox type.
Definition sys_arch.h:94
msg_t msgs[SYS_MBOX_SIZE]
queue for the mbox
Definition sys_arch.h:96
mbox_t mbox
RIOT mbox.
Definition sys_arch.h:95