Implemented interrupt handling for the 3com driver; unfortunately, it does not work unchanged:

turning off interrupts on the device doesn't seem to work, and when one only acknowledges the
interrupts, they are also removed from XL_STATUS register.
The driver now starts to work: it can send and receive packets, though it currently only seem
to receive broadcast packets.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22771 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2007-10-30 16:53:16 +00:00
parent 6b3123cf2f
commit d8ff7084f2
3 changed files with 43 additions and 5 deletions
@@ -1,11 +1,23 @@
/*
* Copyright 2007, Hugo Santos. All Rights Reserved.
* Copyright 2007, Axel Dörfler, [email protected]. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#include <sys/bus.h>
#include "if_xlreg.h"
HAIKU_FBSD_DRIVER_GLUE(3com, xl, pci);
extern driver_t *DRIVER_MODULE_NAME(bmtphy, miibus);
extern driver_t *DRIVER_MODULE_NAME(xlphy, miibus);
driver_t *__haiku_select_miibus_driver(device_t dev)
driver_t *
__haiku_select_miibus_driver(device_t dev)
{
driver_t *drivers[] = {
DRIVER_MODULE_NAME(bmtphy, miibus),
@@ -15,8 +27,26 @@ driver_t *__haiku_select_miibus_driver(device_t dev)
return __haiku_probe_miibus(dev, drivers, 2);
}
/* TODO interrupt handling */
NO_HAIKU_CHECK_DISABLE_INTERRUPTS();
NO_HAIKU_REENABLE_INTERRUPTS();
int
__haiku_disable_interrupts(device_t dev)
{
struct xl_softc *sc = device_get_softc(dev);
u_int16_t status = CSR_READ_2(sc, XL_STATUS);
if (status == 0xffff || (status & XL_INTRS) == 0)
return 0;
atomic_or(&sc->xl_intr_status, status);
CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_INTR_ACK | (status & XL_INTRS));
return 1;
}
void
__haiku_reenable_interrupts(device_t dev)
{
}
HAIKU_DRIVER_REQUIREMENTS(FBSD_TASKQUEUES | FBSD_SWI_TASKQUEUE);
@@ -2286,11 +2286,16 @@ xl_intr(void *arg)
}
#endif
#ifndef __HAIKU__
while ((status = CSR_READ_2(sc, XL_STATUS)) & XL_INTRS &&
status != 0xFFFF) {
CSR_WRITE_2(sc, XL_COMMAND,
XL_CMD_INTR_ACK|(status & XL_INTRS));
#else
status = atomic_and(&sc->xl_intr_status, 0);
dprintf("GOT %x\n", status & XL_INTRS);
if ((status & XL_INTRS) != 0 && status != 0xFFFF) {
#endif
if (status & XL_STAT_UP_COMPLETE) {
int curpkts;
@@ -611,6 +611,9 @@ struct xl_softc {
#ifdef DEVICE_POLLING
int rxcycles;
#endif
#ifdef __HAIKU__
u_int32_t xl_intr_status;
#endif
};
#define XL_LOCK(_sc) mtx_lock(&(_sc)->xl_mtx)