ConOpSys V2970
P004.07
ANVILEX control operating system
|
Go to the source code of this file.
Macros | |
#define | LOCK_TCPIP_CORE() |
#define | UNLOCK_TCPIP_CORE() |
#define | tcpip_callback_with_block(function, ctx, block) ((block != 0)? tcpip_callback(function, ctx) : tcpip_try_callback(function, ctx)) |
Typedefs | |
typedef void(* | tcpip_init_done_fn) (void *arg) |
typedef void(* | tcpip_callback_fn) (void *ctx) |
Functions | |
void | tcpip_init (tcpip_init_done_fn tcpip_init_done, 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_try_callback (tcpip_callback_fn function, void *ctx) |
err_t | tcpip_callback (tcpip_callback_fn function, void *ctx) |
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_callbackmsg_trycallback (struct tcpip_callback_msg *msg) |
err_t | tcpip_callbackmsg_trycallback_fromisr (struct tcpip_callback_msg *msg) |
err_t | pbuf_free_callback (struct pbuf *p) |
err_t | mem_free_callback (void *m) |
Functions to sync with TCPIP thread
#define LOCK_TCPIP_CORE | ( | ) |
#define tcpip_callback_with_block | ( | function, | |
ctx, | |||
block | |||
) | ((block != 0)? tcpip_callback(function, ctx) : tcpip_try_callback(function, ctx)) |
#define UNLOCK_TCPIP_CORE | ( | ) |
typedef void(* tcpip_callback_fn) (void *ctx) |
Function prototype for functions passed to tcpip_callback()
typedef void(* tcpip_init_done_fn) (void *arg) |
Function prototype for the init_done function passed to tcpip_init
err_t mem_free_callback | ( | void * | m | ) |
A simple wrapper function that allows you to free heap memory from interrupt context.
m | the heap memory to free |
References mem_free(), and tcpip_try_callback().
A simple wrapper function that allows you to free a pbuf from interrupt context.
p | The pbuf (chain) to be dereferenced. |
References pbuf_free_int(), and tcpip_try_callback().
err_t tcpip_callback | ( | tcpip_callback_fn | function, |
void * | ctx | ||
) |
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. Blocks until the request is posted. Must not be called from interrupt context!
function | the function to call |
ctx | parameter passed to f |
References tcpip_msg::ctx, ERR_MEM, ERR_OK, LWIP_ASSERT, memp_malloc(), tcpip_msg::msg, NULL, sys_mbox_post(), sys_mbox_valid_val, tcpip_mbox, and TCPIP_MSG_CALLBACK.
void tcpip_callbackmsg_delete | ( | struct tcpip_callback_msg * | msg | ) |
Free a callback message allocated by tcpip_callbackmsg_new().
msg | the message to free |
References memp_free(), and tcpip_msg::msg.
struct tcpip_callback_msg* tcpip_callbackmsg_new | ( | tcpip_callback_fn | function, |
void * | ctx | ||
) |
Allocate a structure for a static callback message and initialise it. The message has a special type such that lwIP never frees it. This is intended to be used to send "static" messages from interrupt context, e.g. the message is allocated once and posted several times from an IRQ using tcpip_callbackmsg_trycallback(). Example usage: Trigger execution of an ethernet IRQ DPC routine in lwIP thread context.
function | the function to call |
ctx | parameter passed to function |
References tcpip_msg::ctx, memp_malloc(), tcpip_msg::msg, NULL, and TCPIP_MSG_CALLBACK_STATIC.
err_t tcpip_callbackmsg_trycallback | ( | struct tcpip_callback_msg * | msg | ) |
Try to post a callback-message to the tcpip_thread tcpip_mbox.
msg | pointer to the message to post |
References LWIP_ASSERT, tcpip_msg::msg, sys_mbox_trypost(), sys_mbox_valid_val, and tcpip_mbox.
err_t tcpip_callbackmsg_trycallback_fromisr | ( | struct tcpip_callback_msg * | msg | ) |
Try to post a callback-message to the tcpip_thread mbox. Same as tcpip_callbackmsg_trycallback but calls sys_mbox_trypost_fromisr(), mainly to help FreeRTOS, where calls differ between task level and ISR level.
msg | pointer to the message to post |
References LWIP_ASSERT, tcpip_msg::msg, sys_mbox_trypost_fromisr(), sys_mbox_valid_val, and tcpip_mbox.
void tcpip_init | ( | tcpip_init_done_fn | initfunc, |
void * | arg | ||
) |
initialise this module:
initfunc | a function to call when tcpip_thread is running and finished initialising |
arg | argument to pass to initfunc |
References tcpip_msg::arg, ERR_OK, LWIP_ASSERT, lwip_init(), NULL, sys_mbox_new(), sys_mutex_new(), sys_thread_new(), tcpip_init_done, tcpip_init_done_arg, tcpip_mbox, TCPIP_MBOX_SIZE, tcpip_thread(), TCPIP_THREAD_NAME, TCPIP_THREAD_PRIO, and TCPIP_THREAD_STACKSIZE.
err_t tcpip_inpkt | ( | struct pbuf * | p, |
struct netif * | inp, | ||
netif_input_fn | input_fn | ||
) |
Pass a received packet to tcpip_thread for input processing
p | the received packet |
inp | the network interface on which the packet was received |
input_fn | input function to call |
References ERR_MEM, ERR_OK, tcpip_msg::inp, tcpip_msg::input_fn, LOCK_TCPIP_CORE, LWIP_ASSERT, LWIP_DEBUGF, memp_free(), memp_malloc(), tcpip_msg::msg, NULL, tcpip_msg::p, sys_mbox_trypost(), sys_mbox_valid_val, TCPIP_DEBUG, tcpip_mbox, TCPIP_MSG_INPKT, and UNLOCK_TCPIP_CORE.
Referenced by 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().
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 |
References tcpip_msg::inp, NETIF_FLAG_ETHARP, NETIF_FLAG_ETHERNET, tcpip_msg::p, and tcpip_inpkt().
Referenced by netif_init().
err_t tcpip_try_callback | ( | tcpip_callback_fn | function, |
void * | ctx | ||
) |
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. Does NOT block when the request cannot be posted because the tcpip_mbox is full, but returns ERR_MEM instead. Can be called from interrupt context.
function | the function to call |
ctx | parameter passed to f |
References tcpip_msg::ctx, ERR_MEM, ERR_OK, LWIP_ASSERT, memp_free(), memp_malloc(), tcpip_msg::msg, NULL, sys_mbox_trypost(), sys_mbox_valid_val, tcpip_mbox, and TCPIP_MSG_CALLBACK.
Referenced by mem_free_callback(), and pbuf_free_callback().