Beispiel #1
0
static int tcp_wait_for_state(const struct socket *sock, enum tcp_state state)
{
	int to;

	for (to = 0; to < 100; to++) {
		ndev_poll();
		if (sock->state == state)
			return 0;

		mdelay(100);
	}

	return -ETIMEDOUT;
}
Beispiel #2
0
static char shell_getchar(void)
{
	char ch;

	while (1) {
		int ret;

		ret = uart_read(CONFIG_UART_INDEX, (__u8 *)&ch, 1, WAIT_ASYNC);
		if (ret > 0)
			break;

		// TODO: replace with tasklet
		ndev_poll();
		device_monitor();
	}

	return ch;
}
Beispiel #3
0
static struct sock_buff *sock_recv_packet(struct socket *sock)
{
	__UNUSED__ __u32 psr;
	struct sock_buff *skb;
	struct list_node *first;
	int to = 10000; // timeout
	int ret;
	char key;

	while (1) {
		ret = uart_read(CONFIG_UART_INDEX, (__u8 *)&key, 1, WAIT_ASYNC);
		if (ret > 0 && key == CHAR_CTRL_C)
			return NULL;

		ndev_poll();

		lock_irq_psr(psr);
		if (!list_is_empty(&sock->rx_qu)) {
			unlock_irq_psr(psr);
			break;
		}
		unlock_irq_psr(psr);

		if (sock->obstruct_flags == 1) {
			to--;
			if (to == 0)
				break;
		}

		udelay(1000);
	}

	if (to > 0) {
		lock_irq_psr(psr);
		first = sock->rx_qu.next;
		list_del_node(first);
		unlock_irq_psr(psr);

		skb = container_of(first, struct sock_buff, node);
		return skb;
	}