xref: /haiku/src/add-ons/kernel/drivers/network/ether/rtl8139/glue.c (revision 13581b3d2a71545960b98fefebc5225b5bf29072)
1 #include <sys/bus.h>
2 #include <sys/mutex.h>
3 #include <sys/systm.h>
4 #include <sys/taskqueue.h>
5 
6 #include <machine/bus.h>
7 
8 #include <net/if.h>
9 #include <net/if_var.h>
10 
11 #include <dev/rl/if_rlreg.h>
12 
13 HAIKU_FBSD_DRIVER_GLUE(rtl8139, rl, pci);
14 HAIKU_FBSD_MII_DRIVER(rlphy);
15 HAIKU_DRIVER_REQUIREMENTS(0);
16 
17 
18 int
19 HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev)
20 {
21 	struct rl_softc *sc = device_get_softc(dev);
22 	uint16_t status;
23 
24 	status = CSR_READ_2(sc, RL_ISR);
25 	if (status == 0xffff)
26 		return 0;
27 	if (status != 0 && (status & RL_INTRS) == 0) {
28 		CSR_WRITE_2(sc, RL_ISR, status);
29 		return 0;
30 	}
31 	if ((status & RL_INTRS) == 0)
32 		return 0;
33 
34 	CSR_WRITE_2(sc, RL_IMR, 0);
35 	return 1;
36 }
37 
38 
39 void
40 HAIKU_REENABLE_INTERRUPTS(device_t dev)
41 {
42 	struct rl_softc *sc = device_get_softc(dev);
43 	RL_LOCK(sc);
44 	CSR_WRITE_2(sc, RL_IMR, RL_INTRS);
45 	RL_UNLOCK(sc);
46 }
47