Loading...
Searching...
No Matches
os.h
Go to the documentation of this file.
1
39#ifndef OS_OS_H
40#define OS_OS_H
41
42#include <assert.h>
43#include <stdint.h>
44
45#include "irq.h"
46#include "os/os_types.h"
47#include "os/os_error.h"
48
49#ifdef __cplusplus
50extern "C" {
51#endif
52
62#ifndef min
63#define min(a, b) ((a)<(b)?(a):(b))
64#endif
65
66#ifndef max
67#define max(a, b) ((a)>(b)?(a):(b))
68#endif
69
70#define OS_ALIGN(__n, __a) ( \
71 (((__n) & ((__a) - 1)) == 0) ? \
72 (__n) : \
73 ((__n) + ((__a) - ((__n) & ((__a) - 1)))) \
74 )
75#define OS_ALIGNMENT (4)
81typedef uint32_t os_sr_t;
82
87#define OS_ENTER_CRITICAL(_sr) (_sr = os_hw_enter_critical())
88#define OS_EXIT_CRITICAL(_sr) (os_hw_exit_critical(_sr))
89#define OS_ASSERT_CRITICAL() assert(os_hw_is_in_critical())
97static inline uint32_t os_hw_enter_critical(void)
98{
99 uint32_t ctx = irq_disable();
100 return ctx;
101}
102
108static inline void os_hw_exit_critical(uint32_t ctx)
109{
110 irq_restore((unsigned)ctx);
111}
112
118static inline bool os_hw_is_in_critical(void)
119{
120 return (irq_is_in() || !irq_is_enabled());
121}
122
123/* Mynewt components (not abstracted in NPL or DPL) */
124#include "os/endian.h"
125#include "os/os_callout.h"
126#include "os/os_cputime.h"
127#include "os/os_dev.h"
128#include "os/os_eventq.h"
129#include "os/os_mbuf.h"
130#include "os/os_mempool.h"
131#include "os/os_mutex.h"
132#include "os/os_sem.h"
133#include "os/os_task.h"
134#include "os/os_time.h"
135#include "os/os_trace_api.h"
136#include "os/queue.h"
137
138#if IS_USED(MODULE_NIMBLE)
139#include "nimble/nimble_npl.h"
140#endif
141
142#ifdef __cplusplus
143}
144#endif
145
146#endif /* OS_OS_H */
POSIX.1-2008 compliant version of the assert macro.
MAYBE_INLINE void irq_restore(unsigned state)
This function restores the IRQ disable bit in the status register to the value contained within passe...
MAYBE_INLINE unsigned irq_disable(void)
This function sets the IRQ disable bit in the status register.
MAYBE_INLINE bool irq_is_enabled(void)
Test if IRQs are currently enabled.
MAYBE_INLINE bool irq_is_in(void)
Check whether called from interrupt service routine.
IRQ driver interface.
static bool os_hw_is_in_critical(void)
Check if is in critical section.
Definition os.h:118
static void os_hw_exit_critical(uint32_t ctx)
Restores ISR context.
Definition os.h:108
static uint32_t os_hw_enter_critical(void)
Disable ISRs.
Definition os.h:97
uint32_t os_sr_t
CPU status register.
Definition os.h:81
Abstraction layer for RIOT adaption.
mynewt-core event and event queue abstraction
mynewt-core time abstraction
mynewt-core types