MeterLogger
Macros | Typedefs | Functions
sys.h File Reference
#include "lwip/opt.h"
#include "eagle_soc.h"
#include "lwip/err.h"
#include "arch/sys_arch.h"
Include dependency graph for sys.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SYS_ARCH_TIMEOUT   0xffffffffUL
 
#define SYS_MBOX_EMPTY   SYS_ARCH_TIMEOUT
 
#define sys_sem_wait(sem)   sys_arch_sem_wait(sem, 0)
 
#define sys_mbox_tryfetch(mbox, msg)   sys_arch_mbox_tryfetch(mbox, msg)
 
#define sys_mbox_fetch(mbox, msg)   sys_arch_mbox_fetch(mbox, msg, 0)
 
#define SYS_ARCH_DECL_PROTECT(lev)
 
#define SYS_ARCH_PROTECT(lev)   lev = os_intr_lock()
 
#define SYS_ARCH_UNPROTECT(lev)   lev = os_intr_unlock()
 
#define SYS_ARCH_INC(var, val)
 
#define SYS_ARCH_DEC(var, val)
 
#define SYS_ARCH_GET(var, ret)
 
#define SYS_ARCH_SET(var, val)
 

Typedefs

typedef void(* lwip_thread_fn) (void *arg)
 

Functions

err_t sys_mutex_new (sys_mutex_t *mutex)
 
void sys_mutex_lock (sys_mutex_t *mutex)
 
void sys_mutex_unlock (sys_mutex_t *mutex)
 
void sys_mutex_free (sys_mutex_t *mutex)
 
int sys_mutex_valid (sys_mutex_t *mutex)
 
void sys_mutex_set_invalid (sys_mutex_t *mutex)
 
err_t sys_sem_new (sys_sem_t *sem, u8_t count)
 
void sys_sem_signal (sys_sem_t *sem)
 
u32_t sys_arch_sem_wait (sys_sem_t *sem, u32_t timeout)
 
void sys_sem_free (sys_sem_t *sem)
 
int sys_sem_valid (sys_sem_t *sem)
 
void sys_sem_set_invalid (sys_sem_t *sem)
 
void sys_msleep (u32_t ms)
 
err_t sys_mbox_new (sys_mbox_t *mbox, int size)
 
void sys_mbox_post (sys_mbox_t *mbox, void *msg)
 
err_t sys_mbox_trypost (sys_mbox_t *mbox, void *msg)
 
u32_t sys_arch_mbox_fetch (sys_mbox_t *mbox, void **msg, u32_t timeout)
 
u32_t sys_arch_mbox_tryfetch (sys_mbox_t *mbox, void **msg)
 
void sys_mbox_free (sys_mbox_t *mbox)
 
int sys_mbox_valid (sys_mbox_t *mbox)
 
void sys_mbox_set_invalid (sys_mbox_t *mbox)
 
sys_thread_t sys_thread_new (const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio)
 
void sys_init (void) ICACHE_FLASH_ATTR
 
u32_t sys_jiffies (void) ICACHE_FLASH_ATTR
 
static u32_t sys_now (void) ICACHE_FLASH_ATTR
 

Macro Definition Documentation

◆ SYS_ARCH_DEC

#define SYS_ARCH_DEC (   var,
  val 
)
Value:
do { \
SYS_ARCH_DECL_PROTECT(old_level); \
SYS_ARCH_PROTECT(old_level); \
var -= val; \
SYS_ARCH_UNPROTECT(old_level); \
} while(0)

Definition at line 306 of file sys.h.

◆ SYS_ARCH_DECL_PROTECT

#define SYS_ARCH_DECL_PROTECT (   lev)

SYS_LIGHTWEIGHT_PROT define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection for certain critical regions during buffer allocation, deallocation and memory allocation and deallocation.

Definition at line 283 of file sys.h.

◆ SYS_ARCH_GET

#define SYS_ARCH_GET (   var,
  ret 
)
Value:
do { \
SYS_ARCH_DECL_PROTECT(old_level); \
SYS_ARCH_PROTECT(old_level); \
ret = var; \
SYS_ARCH_UNPROTECT(old_level); \
} while(0)

Definition at line 315 of file sys.h.

◆ SYS_ARCH_INC

#define SYS_ARCH_INC (   var,
  val 
)
Value:
do { \
SYS_ARCH_DECL_PROTECT(old_level); \
SYS_ARCH_PROTECT(old_level); \
var += val; \
SYS_ARCH_UNPROTECT(old_level); \
} while(0)

Definition at line 297 of file sys.h.

◆ SYS_ARCH_PROTECT

#define SYS_ARCH_PROTECT (   lev)    lev = os_intr_lock()

Definition at line 284 of file sys.h.

◆ SYS_ARCH_SET

#define SYS_ARCH_SET (   var,
  val 
)
Value:
do { \
SYS_ARCH_DECL_PROTECT(old_level); \
SYS_ARCH_PROTECT(old_level); \
var = val; \
SYS_ARCH_UNPROTECT(old_level); \
} while(0)

Definition at line 324 of file sys.h.

◆ SYS_ARCH_TIMEOUT

#define SYS_ARCH_TIMEOUT   0xffffffffUL

Return code for timeouts from sys_arch_mbox_fetch and sys_arch_sem_wait

Definition at line 74 of file sys.h.

◆ SYS_ARCH_UNPROTECT

#define SYS_ARCH_UNPROTECT (   lev)    lev = os_intr_unlock()

Definition at line 285 of file sys.h.

◆ SYS_MBOX_EMPTY

#define SYS_MBOX_EMPTY   SYS_ARCH_TIMEOUT

sys_mbox_tryfetch() returns SYS_MBOX_EMPTY if appropriate. For now we use the same magic value, but we allow this to change in future.

Definition at line 79 of file sys.h.

◆ sys_mbox_fetch

#define sys_mbox_fetch (   mbox,
  msg 
)    sys_arch_mbox_fetch(mbox, msg, 0)

Definition at line 203 of file sys.h.

◆ sys_mbox_tryfetch

#define sys_mbox_tryfetch (   mbox,
  msg 
)    sys_arch_mbox_tryfetch(mbox, msg)

For now, we map straight to sys_arch implementation.

Definition at line 199 of file sys.h.

◆ sys_sem_wait

#define sys_sem_wait (   sem)    sys_arch_sem_wait(sem, 0)

Wait for a semaphore - forever/no timeout

Definition at line 149 of file sys.h.

Referenced by tcpip_callback_with_block().

Typedef Documentation

◆ lwip_thread_fn

typedef void(* lwip_thread_fn) (void *arg)

Function prototype for thread functions

Definition at line 85 of file sys.h.

Function Documentation

◆ sys_arch_mbox_fetch()

u32_t sys_arch_mbox_fetch ( sys_mbox_t *  mbox,
void **  msg,
u32_t  timeout 
)

Wait for a new message to arrive in the mbox

Parameters
mboxmbox to get a message from
msgpointer where the message is stored
timeoutmaximum time (in milliseconds) to wait for a message
Returns
time (in milliseconds) waited for a message, may be 0 if not waited or SYS_ARCH_TIMEOUT on timeout The returned time has to be accurate to prevent timer jitter!

◆ sys_arch_mbox_tryfetch()

u32_t sys_arch_mbox_tryfetch ( sys_mbox_t *  mbox,
void **  msg 
)

Wait for a new message to arrive in the mbox

Parameters
mboxmbox to get a message from
msgpointer where the message is stored
timeoutmaximum time (in milliseconds) to wait for a message
Returns
0 (milliseconds) if a message has been received or SYS_MBOX_EMPTY if the mailbox is empty

◆ sys_arch_sem_wait()

u32_t sys_arch_sem_wait ( sys_sem_t *  sem,
u32_t  timeout 
)

Wait for a semaphore for the specified timeout

Parameters
semthe semaphore to wait for
timeouttimeout in milliseconds to wait (0 = wait forever)
Returns
time (in milliseconds) waited for the semaphore or SYS_ARCH_TIMEOUT on timeout

Referenced by sys_msleep(), and tcpip_callback_with_block().

Here is the caller graph for this function:

◆ sys_init()

void sys_init ( void  )

Referenced by lwip_init().

Here is the caller graph for this function:

◆ sys_jiffies()

u32_t sys_jiffies ( void  )

Ticks/jiffies since power up.

◆ sys_mbox_free()

void sys_mbox_free ( sys_mbox_t *  mbox)

Delete an mbox

Parameters
mboxmbox to delete

◆ sys_mbox_new()

err_t sys_mbox_new ( sys_mbox_t *  mbox,
int  size 
)

Create a new mbox of specified size

Parameters
mboxpointer to the mbox to create
size(miminum) number of messages in this mbox
Returns
ERR_OK if successful, another err_t otherwise

Referenced by tcpip_init().

Here is the caller graph for this function:

◆ sys_mbox_post()

void sys_mbox_post ( sys_mbox_t *  mbox,
void *  msg 
)

Post a message to an mbox - may not fail -> blocks if full, only used from tasks not from ISR

Parameters
mboxmbox to posts the message
msgmessage to post (ATTENTION: can be NULL)

Referenced by tcpip_callback_with_block().

Here is the caller graph for this function:

◆ sys_mbox_set_invalid()

void sys_mbox_set_invalid ( sys_mbox_t *  mbox)

Set an mbox invalid so that sys_mbox_valid returns 0

◆ sys_mbox_trypost()

err_t sys_mbox_trypost ( sys_mbox_t *  mbox,
void *  msg 
)

Try to post a message to an mbox - may fail if full or ISR

Parameters
mboxmbox to posts the message
msgmessage to post (ATTENTION: can be NULL)

Referenced by tcpip_callback_with_block(), and tcpip_input().

Here is the caller graph for this function:

◆ sys_mbox_valid()

int sys_mbox_valid ( sys_mbox_t *  mbox)

Check if an mbox is valid/allocated: return 1 for valid, 0 for invalid

Referenced by tcpip_callback_with_block(), and tcpip_input().

Here is the caller graph for this function:

◆ sys_msleep()

void sys_msleep ( u32_t  ms)

Sleep for some ms. Timeouts are NOT processed while sleeping.

Parameters
msnumber of milliseconds to sleep

Definition at line 54 of file sys.c.

References ERR_OK, sys_arch_sem_wait(), sys_sem_free(), and sys_sem_new().

55 {
56  if (ms > 0) {
57  sys_sem_t delaysem;
58  err_t err = sys_sem_new(&delaysem, 0);
59  if (err == ERR_OK) {
60  sys_arch_sem_wait(&delaysem, ms);
61  sys_sem_free(&delaysem);
62  }
63  }
64 }
void sys_sem_free(sys_sem_t *sem)
err_t sys_sem_new(sys_sem_t *sem, u8_t count)
#define ERR_OK
Definition: err.h:52
s8_t err_t
Definition: err.h:47
u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
Here is the call graph for this function:

◆ sys_mutex_free()

void sys_mutex_free ( sys_mutex_t *  mutex)

Delete a semaphore

Parameters
mutexthe mutex to delete

◆ sys_mutex_lock()

void sys_mutex_lock ( sys_mutex_t *  mutex)

Lock a mutex

Parameters
mutexthe mutex to lock

Referenced by mem_malloc().

Here is the caller graph for this function:

◆ sys_mutex_new()

err_t sys_mutex_new ( sys_mutex_t *  mutex)

Define LWIP_COMPAT_MUTEX if the port has no mutexes and binary semaphores should be used instead Create a new mutex

Parameters
mutexpointer to the mutex to create
Returns
a new mutex

Referenced by mem_init(), and tcpip_init().

Here is the caller graph for this function:

◆ sys_mutex_set_invalid()

void sys_mutex_set_invalid ( sys_mutex_t *  mutex)

Set a mutex invalid so that sys_mutex_valid returns 0

◆ sys_mutex_unlock()

void sys_mutex_unlock ( sys_mutex_t *  mutex)

Unlock a mutex

Parameters
mutexthe mutex to unlock

Referenced by mem_malloc().

Here is the caller graph for this function:

◆ sys_mutex_valid()

int sys_mutex_valid ( sys_mutex_t *  mutex)

Check if a mutex is valid/allocated: return 1 for valid, 0 for invalid

◆ sys_now()

static u32_t sys_now ( void  )
inlinestatic

Returns the current time in milliseconds, may be the same as sys_jiffies or at least based on it.

Definition at line 235 of file sys.h.

References ICACHE_FLASH_ATTR, NOW, and TIMER_CLK_FREQ.

Referenced by ip_router().

236 {
237  return NOW()/(TIMER_CLK_FREQ/1000);
238 }
#define TIMER_CLK_FREQ
Definition: eagle_soc.h:79
#define NOW()
Definition: eagle_soc.h:173
Here is the caller graph for this function:

◆ sys_sem_free()

void sys_sem_free ( sys_sem_t *  sem)

Delete a semaphore

Parameters
semsemaphore to delete

Referenced by sys_msleep(), and tcpip_callback_with_block().

Here is the caller graph for this function:

◆ sys_sem_new()

err_t sys_sem_new ( sys_sem_t *  sem,
u8_t  count 
)

Create a new semaphore

Parameters
sempointer to the semaphore to create
countinitial count of the semaphore
Returns
ERR_OK if successful, another err_t otherwise

Referenced by sys_msleep(), and tcpip_callback_with_block().

Here is the caller graph for this function:

◆ sys_sem_set_invalid()

void sys_sem_set_invalid ( sys_sem_t *  sem)

Set a semaphore invalid so that sys_sem_valid returns 0

◆ sys_sem_signal()

void sys_sem_signal ( sys_sem_t *  sem)

Signals a semaphore

Parameters
semthe semaphore to signal

◆ sys_sem_valid()

int sys_sem_valid ( sys_sem_t *  sem)

Check if a sempahore is valid/allocated: return 1 for valid, 0 for invalid

◆ sys_thread_new()

sys_thread_t sys_thread_new ( const char *  name,
lwip_thread_fn  thread,
void *  arg,
int  stacksize,
int  prio 
)

The only thread function: Creates a new thread

Parameters
namehuman-readable name for the thread (used for debugging purposes)
threadthread-function
argparameter passed to 'thread'
stacksizestack size in bytes for the new thread (may be ignored by ports)
priopriority of the new thread (may be ignored by ports)

Referenced by tcpip_init().

Here is the caller graph for this function: