#include "lwip/debug.h"
#include "lwip/sys.h"
#include "lwip/opt.h"
#include "lwip/stats.h"
Macros | |
#define | SYS_ARCH_BLOCKING_TICKTIMEOUT ((portTickType)10000) |
Functions | |
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 "timeout" milliseconds (similar to the sys_arch_sem_wait() function). More... | |
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, it immediately returns with the code SYS_MBOX_EMPTY. More... | |
sys_prot_t | sys_arch_protect (void) |
Protect the system. More... | |
u32_t | sys_arch_sem_wait (sys_sem_t *sem, u32_t timeout) |
Blocks the thread while waiting for the semaphore to be signaled. More... | |
void | sys_arch_unprotect (sys_prot_t pval) |
Unprotect the system. More... | |
void | sys_init (void) |
Initialize the sys_arch layer. More... | |
void | sys_mbox_free (sys_mbox_t *mbox) |
Deallocates a mailbox. More... | |
err_t | sys_mbox_new (sys_mbox_t *mBoxNew, int size) |
Creates an empty mailbox for maximum "size" elements. More... | |
void | sys_mbox_post (sys_mbox_t *mbox, void *msg) |
Posts the "msg" to the mailbox. More... | |
void | sys_mbox_set_invalid (sys_mbox_t *mbox) |
Set an mbox invalid. More... | |
err_t | sys_mbox_trypost (sys_mbox_t *mbox, void *msg) |
Try to posts the "msg" to the mailbox. More... | |
int | sys_mbox_valid (sys_mbox_t *mbox) |
Check if an mbox is valid/allocated. More... | |
void | sys_mutex_free (sys_mutex_t *pxMutex) |
Delete a semaphore. More... | |
void | sys_mutex_lock (sys_mutex_t *pxMutex) |
Lock a mutex. More... | |
err_t | sys_mutex_new (sys_mutex_t *pxMutex) |
Define LWIP_COMPAT_MUTEX if the port has no mutexes and binary semaphores should be used instead. More... | |
void | sys_mutex_set_invalid (sys_mutex_t *mutex) |
Set a mutex invalid so that sys_mutex_valid returns 0. More... | |
void | sys_mutex_unlock (sys_mutex_t *pxMutex) |
Unlock a mutex. More... | |
int | sys_mutex_valid (sys_mutex_t *mutex) |
Check if a mutex is valid/allocated. More... | |
void | sys_sem_free (sys_sem_t *sem) |
Frees a semaphore created by sys_sem_new. More... | |
err_t | sys_sem_new (sys_sem_t *sem, u8_t count) |
Creates and returns a new semaphore. More... | |
void | sys_sem_set_invalid (sys_sem_t *sem) |
Set a semaphore invalid. More... | |
void | sys_sem_signal (sys_sem_t *sem) |
Signals (or releases) a semaphore. More... | |
int | sys_sem_valid (sys_sem_t *sem) |
Check if a sempahore is valid/allocated. More... | |
sys_thread_t | sys_thread_new (const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio) |
Instantiate a thread for lwIP. More... | |
Variables | |
volatile unsigned portLONG | ulCriticalNesting |
#define SYS_ARCH_BLOCKING_TICKTIMEOUT ((portTickType)10000) |
Referenced by sys_arch_mbox_fetch(), sys_arch_sem_wait(), and sys_mbox_post().
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 "timeout" milliseconds (similar to the sys_arch_sem_wait() function).
Wait for a new message to arrive in the mbox.
mbox | Pointer to the mailbox. |
msg | A result parameter that is set by the function (i.e., by doing "*msg = ptr"). The "msg" parameter maybe NULL to indicate that the message should be dropped. 0 indicates the thread should be blocked until a message arrives. |
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, it immediately returns with the code SYS_MBOX_EMPTY.
Wait for a new message to arrive in the mbox.
On success 0 is returned.
mbox | Pointer to the mailbox. |
msg | A result parameter that is set by the function (i.e., by doing "*msg = ptr"). The "msg" parameter maybe NULL to indicate that the message should be dropped. |
sys_prot_t sys_arch_protect | ( | void | ) |
Protect the system.
Blocks the thread while waiting for the semaphore to be signaled.
Wait for a semaphore for the specified timeout.
Note that there is another function sys_sem_wait in sys.c, but it is a wrapper for the sys_arch_sem_wait function. Please note that it is important for the semaphores to return an accurate count of elapsed milliseconds, since they are used to schedule timers in lwIP.
sem | Pointer to the semaphore. |
timeout | The timeout parameter specifies how many milliseconds the function should block before returning; if the function times out, it should return SYS_ARCH_TIMEOUT. If timeout=0, then the function should block indefinitely. If the function acquires the semaphore, it should return how many milliseconds expired while waiting for the semaphore. |
void sys_arch_unprotect | ( | sys_prot_t | pval | ) |
Unprotect the system.
pval | Protect value. |
void sys_init | ( | void | ) |
Initialize the sys_arch layer.
void sys_mbox_free | ( | sys_mbox_t * | mbox | ) |
Deallocates a mailbox.
Delete an mbox.
If there are messages still present in the mailbox when the mailbox is deallocated, it is an indication of a programming error in lwIP and the developer should be notified.
mbox | Pointer to the new mailbox. |
err_t sys_mbox_new | ( | sys_mbox_t * | mBoxNew, |
int | size | ||
) |
Creates an empty mailbox for maximum "size" elements.
Create a new mbox of specified size.
Elements stored in mailboxes are pointers.
mBoxNew | Pointer to the new mailbox. |
size | Maximum "size" elements. |
void sys_mbox_post | ( | sys_mbox_t * | mbox, |
void * | msg | ||
) |
Posts the "msg" to the mailbox.
Post a message to an mbox - may not fail -> blocks if full, only used from tasks not from ISR.
This function have to block until the "msg" is really posted.
mbox | Pointer to the mailbox. |
msg | Pointer to the message to be post. |
void sys_mbox_set_invalid | ( | sys_mbox_t * | mbox | ) |
Set an mbox invalid.
Set an mbox invalid so that sys_mbox_valid returns 0.
mbox | Pointer to the mailbox. |
err_t sys_mbox_trypost | ( | sys_mbox_t * | mbox, |
void * | msg | ||
) |
Try to posts the "msg" to the mailbox.
Try to post a message to an mbox - may fail if full or ISR.
mbox | Pointer to the mailbox. |
msg | Pointer to the message to be post. |
int sys_mbox_valid | ( | sys_mbox_t * | mbox | ) |
Check if an mbox is valid/allocated.
Check if an mbox is valid/allocated: return 1 for valid, 0 for invalid.
mbox | Pointer to the mailbox. |
void sys_mutex_free | ( | sys_mutex_t * | pxMutex | ) |
Delete a semaphore.
mutex | the mutex to delete. |
void sys_mutex_lock | ( | sys_mutex_t * | pxMutex | ) |
Lock a mutex.
mutex | the mutex to lock. |
err_t sys_mutex_new | ( | sys_mutex_t * | pxMutex | ) |
Define LWIP_COMPAT_MUTEX if the port has no mutexes and binary semaphores should be used instead.
Create a new mutex.
mutex | Pointer to the mutex to create. |
void sys_mutex_set_invalid | ( | sys_mutex_t * | mutex | ) |
Set a mutex invalid so that sys_mutex_valid returns 0.
mutex | Pointer to the mutex. |
void sys_mutex_unlock | ( | sys_mutex_t * | pxMutex | ) |
Unlock a mutex.
mutex | the mutex to unlock. |
int sys_mutex_valid | ( | sys_mutex_t * | mutex | ) |
Check if a mutex is valid/allocated.
Check if a mutex is valid/allocated: return 1 for valid, 0 for invalid.
mutex | Pointer to the mutex. |
void sys_sem_free | ( | sys_sem_t * | sem | ) |
Frees a semaphore created by sys_sem_new.
Delete a semaphore.
sem | Pointer to the semaphore. |
Creates and returns a new semaphore.
Create a new semaphore.
sem | Pointer to the semaphore. |
count | Initial state of the semaphore. |
void sys_sem_set_invalid | ( | sys_sem_t * | sem | ) |
Set a semaphore invalid.
Set a semaphore invalid so that sys_sem_valid returns 0.
sem | Pointer to the semaphore. |
void sys_sem_signal | ( | sys_sem_t * | sem | ) |
Signals (or releases) a semaphore.
Signals a semaphore.
sem | Pointer to the semaphore. |
int sys_sem_valid | ( | sys_sem_t * | sem | ) |
Check if a sempahore is valid/allocated.
Check if a semaphore is valid/allocated: return 1 for valid, 0 for invalid.
Check if a sempahore is valid/allocated: return 1 for valid, 0 for invalid.
sem | Pointer to the semaphore. |
sys_thread_t sys_thread_new | ( | const char * | name, |
lwip_thread_fn | thread, | ||
void * | arg, | ||
int | stacksize, | ||
int | prio | ||
) |
Instantiate a thread for lwIP.
The only thread function: Creates a new thread.
Both the id and the priority are system dependent.
name | Pointer to the thread name. |
thread | Thread function. |
arg | Argument will be passed into the thread(). |
stacksize | Stack size of the thread. |
prio | Thread priority. |
volatile unsigned portLONG ulCriticalNesting |