37 #ifndef LWIP_HDR_SYS_H 38 #define LWIP_HDR_SYS_H 54 #define sys_sem_new(s, c) ERR_OK 55 #define sys_sem_signal(s) 56 #define sys_sem_wait(s) 57 #define sys_arch_sem_wait(s,t) 58 #define sys_sem_free(s) 59 #define sys_sem_valid(s) 0 60 #define sys_sem_valid_val(s) 0 61 #define sys_sem_set_invalid(s) 62 #define sys_sem_set_invalid_val(s) 63 #define sys_mutex_new(mu) ERR_OK 64 #define sys_mutex_lock(mu) 65 #define sys_mutex_unlock(mu) 66 #define sys_mutex_free(mu) 67 #define sys_mutex_valid(mu) 0 68 #define sys_mutex_set_invalid(mu) 69 #define sys_mbox_new(m, s) ERR_OK 70 #define sys_mbox_fetch(m,d) 71 #define sys_mbox_tryfetch(m,d) 72 #define sys_mbox_post(m,d) 73 #define sys_mbox_trypost(m,d) 74 #define sys_mbox_free(m) 75 #define sys_mbox_valid(m) 76 #define sys_mbox_valid_val(m) 77 #define sys_mbox_set_invalid(m) 78 #define sys_mbox_set_invalid_val(m) 80 #define sys_thread_new(n,t,a,s,p) 87 #define SYS_ARCH_TIMEOUT 0xffffffffUL 92 #define SYS_MBOX_EMPTY SYS_ARCH_TIMEOUT 95 #include "arch/sys_arch.h" 107 #ifndef LWIP_COMPAT_MUTEX 108 #define LWIP_COMPAT_MUTEX 0 111 #if LWIP_COMPAT_MUTEX 113 #define sys_mutex_t sys_sem_t 114 #define sys_mutex_new(mutex) sys_sem_new(mutex, 1) 115 #define sys_mutex_lock(mutex) sys_sem_wait(mutex) 116 #define sys_mutex_unlock(mutex) sys_sem_signal(mutex) 117 #define sys_mutex_free(mutex) sys_sem_free(mutex) 118 #define sys_mutex_valid(mutex) sys_sem_valid(mutex) 119 #define sys_mutex_set_invalid(mutex) sys_sem_set_invalid(mutex) 156 #ifndef sys_mutex_valid 166 #ifndef sys_mutex_set_invalid 227 #define sys_sem_wait(sem) sys_arch_sem_wait(sem, 0) 228 #ifndef sys_sem_valid 238 #ifndef sys_sem_set_invalid 248 #ifndef sys_sem_valid_val 252 #define sys_sem_valid_val(sem) sys_sem_valid(&(sem)) 254 #ifndef sys_sem_set_invalid_val 258 #define sys_sem_set_invalid_val(sem) sys_sem_set_invalid(&(sem)) 338 #ifndef sys_arch_mbox_tryfetch 360 #define sys_mbox_tryfetch(mbox, msg) sys_arch_mbox_tryfetch(mbox, msg) 370 #define sys_mbox_fetch(mbox, msg) sys_arch_mbox_fetch(mbox, msg, 0) 371 #ifndef sys_mbox_valid 381 #ifndef sys_mbox_set_invalid 391 #ifndef sys_mbox_valid_val 395 #define sys_mbox_valid_val(mbox) sys_mbox_valid(&(mbox)) 397 #ifndef sys_mbox_set_invalid_val 401 #define sys_mbox_set_invalid_val(mbox) sys_mbox_set_invalid(&(mbox)) 453 #ifndef SYS_ARCH_PROTECT 459 #if SYS_LIGHTWEIGHT_PROT 468 #define SYS_ARCH_DECL_PROTECT(lev) sys_prot_t lev 480 #define SYS_ARCH_PROTECT(lev) lev = sys_arch_protect() 491 #define SYS_ARCH_UNPROTECT(lev) sys_arch_unprotect(lev) 492 sys_prot_t sys_arch_protect(
void);
493 void sys_arch_unprotect(sys_prot_t pval);
497 #define SYS_ARCH_DECL_PROTECT(lev) 498 #define SYS_ARCH_PROTECT(lev) 499 #define SYS_ARCH_UNPROTECT(lev) 511 #define SYS_ARCH_INC(var, val) do { \ 512 SYS_ARCH_DECL_PROTECT(old_level); \ 513 SYS_ARCH_PROTECT(old_level); \ 515 SYS_ARCH_UNPROTECT(old_level); \ 520 #define SYS_ARCH_DEC(var, val) do { \ 521 SYS_ARCH_DECL_PROTECT(old_level); \ 522 SYS_ARCH_PROTECT(old_level); \ 524 SYS_ARCH_UNPROTECT(old_level); \ 529 #define SYS_ARCH_GET(var, ret) do { \ 530 SYS_ARCH_DECL_PROTECT(old_level); \ 531 SYS_ARCH_PROTECT(old_level); \ 533 SYS_ARCH_UNPROTECT(old_level); \ 538 #define SYS_ARCH_SET(var, val) do { \ 539 SYS_ARCH_DECL_PROTECT(old_level); \ 540 SYS_ARCH_PROTECT(old_level); \ 542 SYS_ARCH_UNPROTECT(old_level); \ 546 #ifndef SYS_ARCH_LOCKED 547 #define SYS_ARCH_LOCKED(code) do { \ 548 SYS_ARCH_DECL_PROTECT(old_level); \ 549 SYS_ARCH_PROTECT(old_level); \ 551 SYS_ARCH_UNPROTECT(old_level); \
sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio)
The only thread function: Starts a new thread named "name" with priority "prio" that will begin its e...
err_t sys_mutex_new(sys_mutex_t *mutex)
Create a new mutex.
u32_t sys_now(void)
Returns the current time in milliseconds, may be the same as sys_jiffies or at least based on it...
int sys_mbox_valid(sys_mbox_t *mbox)
Returns 1 if the mailbox is valid, 0 if it is not valid.
void sys_mutex_unlock(sys_mutex_t *mutex)
Releases the mutex previously locked through 'sys_mutex_lock()'.
void sys_mutex_lock(sys_mutex_t *mutex)
Blocks the thread until the mutex can be grabbed.
void sys_sem_set_invalid(sys_sem_t *sem)
Invalidate a semaphore so that sys_sem_valid() returns 0.
u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
Blocks the thread until a message arrives in the mailbox, but does not block the thread longer than "...
lwIP Options Configuration
void sys_mutex_set_invalid(sys_mutex_t *mutex)
Invalidate a mutex so that sys_mutex_valid() returns 0.
void sys_sem_free(sys_sem_t *sem)
Deallocates a semaphore.
err_t sys_sem_new(sys_sem_t *sem, u8_t count)
Create a new semaphore Creates a new semaphore.
u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg)
This is similar to sys_arch_mbox_fetch, however if a message is not present in the mailbox...
int sys_sem_valid(sys_sem_t *sem)
Returns 1 if the semaphore is valid, 0 if it is not valid.
err_t sys_mbox_new(sys_mbox_t *mbox, int size)
Creates an empty mailbox for maximum "size" elements.
void(* lwip_thread_fn)(void *arg)
Function prototype for thread functions.
int sys_mutex_valid(sys_mutex_t *mutex)
Returns 1 if the mutes is valid, 0 if it is not valid.
void sys_mutex_free(sys_mutex_t *mutex)
Deallocates a mutex.
u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
Blocks the thread while waiting for the semaphore to be signaled.
err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg)
Try to post a message to an mbox - may fail if full.
u32_t sys_jiffies(void)
Ticks/jiffies since power up.
void sys_msleep(u32_t ms)
Sleep for specified number of ms.
void sys_mbox_post(sys_mbox_t *mbox, void *msg)
Post a message to an mbox - may not fail -> blocks if full, only to be used from tasks NOT from ISR! ...
void sys_sem_signal(sys_sem_t *sem)
Signals a semaphore.
void sys_mbox_set_invalid(sys_mbox_t *mbox)
Invalidate a mailbox so that sys_mbox_valid() returns 0.
void sys_init(void)
sys_init() must be called before anything else.
void sys_mbox_free(sys_mbox_t *mbox)
Deallocates a mailbox.
err_t sys_mbox_trypost_fromisr(sys_mbox_t *mbox, void *msg)
Try to post a message to an mbox - may fail if full.