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
21int check_disable_interrupts_de(device_t dev);
22void reenable_interrupts_de(device_t dev);
23
24
25int
26check_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
59void
60reenable_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