예제 #1
0
static int cs89x0_send_packet(struct net_device *ndev, struct sock_buff *skb)
{
	int i;
	__u16 isq_stat;
	const __u16 *buff;
	__UNUSED__ __u32 psr;

	lock_irq_psr(psr);

	writew(VA(CS8900_IOBASE + CS_TxCMD), 0x00);
	writew(VA(CS8900_IOBASE + CS_TxLen), skb->size);

	while (1) {
		isq_stat = cs8900_inw(PP_BusST);
		if (isq_stat & Rdy4TxNow)
			break;

		printf("BusST = 0x%04x\n", isq_stat);
	}

	buff = (const __u16 *)skb->data;

	for (i = 0; i < skb->size; i += 2) {
		writew(VA(CS8900_IOBASE + CS_DATA0), *buff);
		buff++;
	}

	ndev->stat.tx_packets++;

	unlock_irq_psr(psr);

	return 0;
}
예제 #2
0
파일: socket.c 프로젝트: RocsanWei/g-bios
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;
	}