Beispiel #1
0
u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg) {
    if (!trydown(&mbox->read_sem))
	return SYS_MBOX_EMPTY;

    do_mbox_fetch(mbox, msg);
    return 0;
}
Beispiel #2
0
/*
 * Gets a free TX request for copying data to backend
 */
static inline struct netif_tx_request *netfront_get_page(struct netfront_dev *dev)
{
	struct netif_tx_request *tx;
	unsigned short id;
	struct net_txbuffer* buf;
	int flags;

	local_irq_save(flags);
	if (unlikely(!trydown(&dev->tx_sem))) {
		local_irq_restore(flags);
		return NULL; /* we run out of available pages */
	}
	id = get_id_from_freelist(dev->tx_freelist);
	buf = &dev->tx_buffers[id];
	local_irq_restore(flags);

	tx = RING_GET_REQUEST(&dev->tx, dev->tx.req_prod_pvt++);
	tx->offset = 0;
	tx->size = 0;
	tx->id = id;
	tx->flags = 0;
#ifdef CONFIG_NETFRONT_PERSISTENT_GRANTS
	tx->gref = buf->gref;
#else
	tx->gref = buf->gref = GRANT_INVALID_REF;
#endif
#ifdef HAVE_LWIP
	buf->pbuf = NULL;
#endif
	return tx;
}
Beispiel #3
0
/* Try to post the "msg" to the mailbox. */
err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg)
{
    if (!trydown(&mbox->write_sem))
        return ERR_MEM;
    do_mbox_post(mbox, msg);
    return ERR_OK;
}