xref: /haiku/src/add-ons/kernel/drivers/network/ether/dec21xxx/glue_de.c (revision 899e0ef82b5624ace2ccfa5f5a58c8ebee54aaef)
1 /*
2  * Copyright 2011, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Author(s):
6  *		Siarzhuk Zharski <imker@gmx.li>
7  */
8 
9 
10 #include <sys/bus.h>
11 #include <sys/systm.h>
12 #include <machine/bus.h>
13 #include <net/ethernet.h>
14 #include <net/if.h>
15 #include <net/if_media.h>
16 
17 #include "dc21040reg.h"
18 #include "if_devar.h"
19 
20 
21 int check_disable_interrupts_de(device_t dev);
22 void reenable_interrupts_de(device_t dev);
23 
24 
25 int
26 check_disable_interrupts_de(device_t dev)
27 {
28 	struct tulip_softc *sc = device_get_softc(dev);
29 	uint32_t status;
30 	HAIKU_INTR_REGISTER_STATE;
31 
32 	HAIKU_INTR_REGISTER_ENTER();
33 
34 	status = TULIP_CSR_READ(sc, csr_status);
35 	if (status == 0xffffffff) {
36 		HAIKU_INTR_REGISTER_LEAVE();
37 		return 0;
38 	}
39 
40 	if (status != 0 && (status & sc->tulip_intrmask) == 0) {
41 		TULIP_CSR_WRITE(sc, csr_status, status);
42 		HAIKU_INTR_REGISTER_LEAVE();
43 		return 0;
44 	}
45 
46 	if ((status & sc->tulip_intrmask) == 0) {
47 		HAIKU_INTR_REGISTER_LEAVE();
48 		return 0;
49 	}
50 
51 	TULIP_CSR_WRITE(sc, csr_intr, 0);
52 
53 	HAIKU_INTR_REGISTER_LEAVE();
54 
55 	return 1;
56 }
57 
58 
59 void
60 reenable_interrupts_de(device_t dev)
61 {
62 	struct tulip_softc *sc = device_get_softc(dev);
63 	TULIP_LOCK(sc);
64 	TULIP_CSR_WRITE(sc, csr_intr, sc->tulip_intrmask);
65 	TULIP_UNLOCK(sc);
66 }
67 
68