Пример #1
0
// Try to receive packet over network
static int
sys_net_try_receive(char *data, int *len)
{
	if ((uintptr_t)data >= UTOP) {
		return -E_INVAL;
	}

	*len = e1000_receive(data);
	if (*len > 0) {
		return 0;
	}
	
	return *len;
}
Пример #2
0
// Try to receive packet over network
static int
sys_net_try_receive(char *data, int *len)
{
	//cprintf("in the system call to receive from network driver\n");
        if ((uintptr_t)data >= UTOP) {
                return -E_INVAL;
        }

	//cprintf("calling e1000_receive()\n");
        *len = e1000_receive(data);
        if (*len > 0) {
		//curenv->env_status = ENV_NOT_RUNNABLE;
                return 0;
        }

        return *len;
}
Пример #3
0
static irqreturn_t e1000_interrupt_handler(int irq, void *dev_id)
{
    struct e1000_dev *e1000 = (struct e1000_dev *)dev_id;

    /* Get and clear interrupt status bits */

    int intr_cause = e1000_inl(e1000, E1000_ICR);
    e1000_outl(e1000, E1000_ICR, intr_cause);

    /* not for me */

    if (intr_cause == 0)
    {
        return IRQ_NONE;
    }

    /* Handle interrupts according to status bit settings */

    /* Link status change */

    if (intr_cause & (1 << 2))
    {
        if (e1000_inl(e1000, E1000_STATUS) & 2)
        {
            e1000->bifup = true;
        }
        else
        {
            e1000->bifup = false;
        }
    }

    /* Check if we received an incoming packet, if so, call skel_receive() */

    /* Rx-descriptor Timer expired */

    if (intr_cause & (1 << 7))
    {
        e1000_receive(e1000);
    }

    /* Tx queue empty */

    if (intr_cause & (1 << 1))
    {
        wd_cancel(e1000->txtimeout);
    }

    /* Check is a packet transmission just completed.  If so, call skel_txdone.
     * This may disable further Tx interrupts if there are no pending
     * tansmissions.
     */

    /* Tx-descriptor Written back */

    if (intr_cause & (1 << 0))
    {
        devif_poll(&e1000->netdev, e1000_txpoll);
    }


    /* Rx-Descriptors Low */

    if (intr_cause & (1 << 4))
    {
        int tail;

        tail = e1000->rx_ring.tail + e1000->rx_ring.free;
        tail %= CONFIG_E1000_N_RX_DESC;
        e1000->rx_ring.tail = tail;
        e1000->rx_ring.free = 0;
        e1000_outl(e1000, E1000_RDT, tail);
    }

    return IRQ_HANDLED;
}