Prusa MINI Firmware overview
|
|
static void | tcpip_thread (void *arg) |
|
err_t | tcpip_inpkt (struct pbuf *p, struct netif *inp, netif_input_fn input_fn) |
|
err_t | tcpip_input (struct pbuf *p, struct netif *inp) |
|
err_t | tcpip_callback_with_block (tcpip_callback_fn function, void *ctx, u8_t block) |
|
err_t | tcpip_send_msg_wait_sem (tcpip_callback_fn fn, void *apimsg, sys_sem_t *sem) |
|
err_t | tcpip_api_call (tcpip_api_call_fn fn, struct tcpip_api_call_data *call) |
|
struct tcpip_callback_msg * | tcpip_callbackmsg_new (tcpip_callback_fn function, void *ctx) |
|
void | tcpip_callbackmsg_delete (struct tcpip_callback_msg *msg) |
|
err_t | tcpip_trycallback (struct tcpip_callback_msg *msg) |
|
void | tcpip_init (tcpip_init_done_fn initfunc, void *arg) |
|
static void | pbuf_free_int (void *p) |
|
err_t | pbuf_free_callback (struct pbuf *p) |
|
err_t | mem_free_callback (void *m) |
|
Sequential API Main thread module
◆ TCPIP_MSG_VAR_REF
◆ TCPIP_MSG_VAR_DECLARE
◆ TCPIP_MSG_VAR_ALLOC
◆ TCPIP_MSG_VAR_FREE
#define TCPIP_MSG_VAR_FREE |
( |
|
name | ) |
API_VAR_FREE(MEMP_TCPIP_MSG_API, name) |
◆ TCPIP_MBOX_FETCH
◆ tcpip_thread()
The main lwIP thread. This thread has exclusive access to lwIP core functions (unless access to them is not locked). Other threads communicate with this thread using message boxes.
It also starts all the timers to make sure they are running in the right thread context.
- Parameters
-
109 #if !LWIP_TCPIP_CORE_LOCKING
112 msg->msg.api_msg.function(
msg->msg.api_msg.msg);
116 msg->msg.api_call.arg->err =
msg->msg.api_call.function(
msg->msg.api_call.arg);
121 #if !LWIP_TCPIP_CORE_LOCKING_INPUT
124 msg->msg.inp.input_fn(
msg->msg.inp.p,
msg->msg.inp.netif);
129 #if LWIP_TCPIP_TIMEOUT && LWIP_TIMERS
130 case TCPIP_MSG_TIMEOUT:
132 sys_timeout(
msg->msg.tmo.msecs,
msg->msg.tmo.h,
msg->msg.tmo.arg);
135 case TCPIP_MSG_UNTIMEOUT:
137 sys_untimeout(
msg->msg.tmo.h,
msg->msg.tmo.arg);
144 msg->msg.cb.function(
msg->msg.cb.ctx);
150 msg->msg.cb.function(
msg->msg.cb.ctx);
◆ tcpip_inpkt()
Pass a received packet to tcpip_thread for input processing
- Parameters
-
p | the received packet |
inp | the network interface on which the packet was received |
input_fn | input function to call |
171 #if LWIP_TCPIP_CORE_LOCKING_INPUT
◆ tcpip_input()
Pass a received packet to tcpip_thread for input processing with ethernet_input or ip_input. Don't call directly, pass to netif_add() and call netif->input().
- Parameters
-
p | the received packet, p->payload pointing to the Ethernet header or to an IP header (if inp doesn't have NETIF_FLAG_ETHARP or NETIF_FLAG_ETHERNET flags) |
inp | the network interface on which the packet was received |
◆ tcpip_callback_with_block()
Call a specific function in the thread context of tcpip_thread for easy access synchronization. A function called in that way may access lwIP core code without fearing concurrent access.
- Parameters
-
function | the function to call |
ctx | parameter passed to f |
block | 1 to block until the request is posted, 0 to non-blocking mode |
- Returns
- ERR_OK if the function was called, another err_t if not
246 msg->msg.cb.function =
function;
◆ tcpip_send_msg_wait_sem()
Sends a message to TCPIP thread to call a function. Caller thread blocks on on a provided semaphore, which ist NOT automatically signalled by TCPIP thread, this has to be done by the user. It is recommended to use LWIP_TCPIP_CORE_LOCKING since this is the way with least runtime overhead.
- Parameters
-
fn | function to be called from TCPIP thread |
apimsg | argument to API function |
sem | semaphore to wait on |
- Returns
- ERR_OK if the function was called, another err_t if not
331 #if LWIP_TCPIP_CORE_LOCKING
◆ tcpip_api_call()
Synchronously calls function in TCPIP thread and waits for its completion. It is recommended to use LWIP_TCPIP_CORE_LOCKING (preferred) or LWIP_NETCONN_SEM_PER_THREAD. If not, a semaphore is created and destroyed on every call which is usually an expensive/slow operation.
- Parameters
-
fn | Function to call |
call | Call parameters |
- Returns
- Return value from tcpip_api_call_fn
367 #if LWIP_TCPIP_CORE_LOCKING
376 #if !LWIP_NETCONN_SEM_PER_THREAD
389 #if LWIP_NETCONN_SEM_PER_THREAD
398 #if !LWIP_NETCONN_SEM_PER_THREAD
◆ tcpip_callbackmsg_new()
Allocate a structure for a static callback message and initialize it. This is intended to be used to send "static" messages from interrupt context.
- Parameters
-
function | the function to call |
ctx | parameter passed to function |
- Returns
- a struct pointer to pass to tcpip_trycallback().
422 msg->msg.cb.function =
function;
424 return (
struct tcpip_callback_msg*)
msg;
◆ tcpip_callbackmsg_delete()
void tcpip_callbackmsg_delete |
( |
struct tcpip_callback_msg * |
msg | ) |
|
◆ tcpip_trycallback()
err_t tcpip_trycallback |
( |
struct tcpip_callback_msg * |
msg | ) |
|
Try to post a callback-message to the tcpip_thread mbox This is intended to be used to send "static" messages from interrupt context.
- Parameters
-
msg | pointer to the message to post |
- Returns
- sys_mbox_trypost() return code
◆ tcpip_init()
Initialize this module:
- initialize all sub modules
- start the tcpip_thread
- Parameters
-
initfunc | a function to call when tcpip_thread is running and finished initializing |
arg | argument to pass to initfunc |
469 LWIP_ASSERT(
"failed to create tcpip_thread mbox", 0);
471 #if LWIP_TCPIP_CORE_LOCKING
473 LWIP_ASSERT(
"failed to create lock_tcpip_core", 0);
◆ pbuf_free_int()
Simple callback function used with tcpip_callback to free a pbuf (pbuf_free has a wrong signature for tcpip_callback)
- Parameters
-
p | The pbuf (chain) to be dereferenced. |
◆ pbuf_free_callback()
A simple wrapper function that allows you to free a pbuf from interrupt context.
- Parameters
-
p | The pbuf (chain) to be dereferenced. |
- Returns
- ERR_OK if callback could be enqueued, an err_t if not
◆ mem_free_callback()
A simple wrapper function that allows you to free heap memory from interrupt context.
- Parameters
-
- Returns
- ERR_OK if callback could be enqueued, an err_t if not
◆ tcpip_init_done
◆ tcpip_init_done_arg
void* tcpip_init_done_arg |
|
static |
◆ mbox
#define sys_mbox_valid_val(mbox)
Definition: sys.h:311
err_t tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block)
Definition: tcpip.c:234
#define TCPIP_MSG_VAR_DECLARE(name)
Definition: tcpip.c:54
sys_sem_t * sem
Definition: tcpip_priv.h:133
void * memp_malloc(memp_t type)
Definition: memp.c:385
void lwip_init(void)
Definition: init.c:337
#define LWIP_TCPIP_THREAD_ALIVE()
Definition: opt.h:1574
#define TCPIP_DEBUG
Definition: opt.h:2814
#define LWIP_ASSERT(message, assertion)
Definition: debug.h:116
void memp_free(memp_t type, void *mem)
Definition: memp.c:469
Definition: tcpip_priv.h:114
err_t sys_mbox_new(sys_mbox_t *mbox, int size)
Definition: sys_arch.c:50
static sys_mbox_t mbox
Definition: tcpip.c:61
err_t err
Definition: tcpip_priv.h:100
static void * tcpip_init_done_arg
Definition: tcpip.c:60
#define NETIF_FLAG_ETHARP
Definition: netif.h:91
#define UNLOCK_TCPIP_CORE()
Definition: tcpip.h:61
u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
Definition: sys_arch.c:251
u8_t pbuf_free(struct pbuf *p)
Definition: pbuf.c:715
sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio)
Definition: sys_arch.c:376
#define NULL
Definition: usbd_def.h:53
void sys_mbox_post(sys_mbox_t *mbox, void *msg)
Definition: sys_arch.c:96
void * msg
Definition: tcpip_priv.h:128
sys_sem_t sem
Definition: tcpip_priv.h:102
#define TCPIP_MSG_VAR_REF(name)
Definition: tcpip.c:53
#define TCPIP_MBOX_FETCH(mbox, msg)
Definition: tcpip.c:73
#define TCPIP_MSG_VAR_ALLOC(name)
Definition: tcpip.c:55
static void tcpip_thread(void *arg)
Definition: tcpip.c:87
#define TCPIP_MBOX_SIZE
Definition: opt.h:1566
netif_input_fn input_fn
Definition: tcpip_priv.h:138
#define LWIP_UNUSED_ARG(x)
Definition: arch.h:308
err_t tcpip_inpkt(struct pbuf *p, struct netif *inp, netif_input_fn input_fn)
Definition: tcpip.c:169
void sys_sem_signal(sys_sem_t *sem)
Definition: sys_arch.c:275
struct tcpip_msg::@61::@64 inp
err_t sys_mutex_new(sys_mutex_t *mutex)
Definition: sys_arch.c:319
Definition: tcpip_priv.h:120
Definition: tcpip_priv.h:123
err_t sys_sem_new(sys_sem_t *sem, u8_t count)
Definition: sys_arch.c:206
s8_t err_t
Definition: err.h:57
#define NETIF_FLAG_ETHERNET
Definition: netif.h:95
#define TCPIP_THREAD_PRIO
Definition: opt.h:1557
Definition: tcpip_priv.h:112
Definition: tcpip_priv.h:113
void * ctx
Definition: tcpip_priv.h:142
static void pbuf_free_int(void *p)
Definition: tcpip.c:487
#define TCPIP_THREAD_NAME
Definition: opt.h:1539
err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg)
Definition: sys_arch.c:104
#define TCPIP_MSG_VAR_FREE(name)
Definition: tcpip.c:56
#define TCPIP_THREAD_STACKSIZE
Definition: opt.h:1548
struct pbuf * p
Definition: tcpip_priv.h:136
void mem_free(void *rmem)
Definition: mem.c:419
int sys_sem_valid(sys_sem_t *sem)
Definition: sys_arch.c:291
#define LWIP_DEBUGF(debug, message)
Definition: debug.h:164
static tcpip_init_done_fn tcpip_init_done
Definition: tcpip.c:59
#define LOCK_TCPIP_CORE()
Definition: tcpip.h:60
Definition: tcpip_priv.h:119
struct tcpip_api_call_data * arg
Definition: tcpip_priv.h:132
void sys_sem_free(sys_sem_t *sem)
Definition: sys_arch.c:282