示例#1
0
文件: e1000.c 项目: Hooman3/minix
/*
 * Handle an interrupt.
 */
static void
e1000_intr(unsigned int __unused mask)
{
	e1000_t *e;
	u32_t cause;

	E1000_DEBUG(3, ("e1000: interrupt\n"));

	e = &e1000_state;

	/* Reenable interrupts. */
	if (sys_irqenable(&e->irq_hook) != OK)
		panic("failed to re-enable IRQ");

	/* Read the Interrupt Cause Read register. */
	if ((cause = e1000_reg_read(e, E1000_REG_ICR)) != 0) {
		if (cause & E1000_REG_ICR_LSC)
			e1000_link_changed(e);

		if (cause & (E1000_REG_ICR_RXO | E1000_REG_ICR_RXT))
			netdriver_recv();

		if (cause & (E1000_REG_ICR_TXQE | E1000_REG_ICR_TXDW))
			netdriver_send();
	}
}
示例#2
0
static void
virtio_net_check_pending(void)
{

	/* Pending read and something in recv_list? */
	if (!STAILQ_EMPTY(&recv_list))
		netdriver_recv();

	if (!STAILQ_EMPTY(&free_list))
		netdriver_send();
}
/*============================================================================*
 *				lan8710a_intr				      *
 *============================================================================*/
static void
lan8710a_intr(unsigned int mask)
{
	u32_t dma_status;

	/* Check the card for interrupt reason(s). */
	u32_t rx_stat = lan8710a_reg_read(CPSW_WR_C0_RX_STAT);
	u32_t tx_stat = lan8710a_reg_read(CPSW_WR_C0_TX_STAT);
	u32_t cp;

	/* Handle interrupts. */
	if (rx_stat) {
		cp = lan8710a_reg_read(CPDMA_STRAM_RX_CP(0));

		netdriver_recv();

		lan8710a_reg_write(CPDMA_STRAM_RX_CP(0), cp);
		lan8710a_reg_write(CPDMA_EOI_VECTOR, RX_INT);
	}
	if (tx_stat) {
		cp = lan8710a_reg_read(CPDMA_STRAM_TX_CP(0));

		/* Disabling channels, where Tx interrupt occurred */
		lan8710a_reg_set(CPDMA_TX_INTMASK_CLEAR, tx_stat);

		netdriver_send();

		lan8710a_reg_write(CPDMA_STRAM_TX_CP(0), cp);
		lan8710a_reg_write(CPDMA_EOI_VECTOR, TX_INT);
	}

	dma_status = lan8710a_reg_read(CPDMA_STATUS);

	if (dma_status & CPDMA_ERROR) {
		LAN8710A_DEBUG_PRINT(("CPDMA error: 0x%X, reset", dma_status));
		lan8710a_dma_reset_init();
	}

	/* Re-enable Rx interrupt. */
	if (mask & (1 << RX_INT))
		lan8710a_enable_interrupt(RX_INT);

	/* Re-enable Tx interrupt. */
	if (mask & (1 << TX_INT))
		lan8710a_enable_interrupt(TX_INT);
}