-/* $OpenBSD: cbus.c,v 1.13 2014/11/24 12:47:14 kettenis Exp $ */
+/* $OpenBSD: cbus.c,v 1.14 2015/01/25 21:42:13 kettenis Exp $ */
/*
* Copyright (c) 2008 Mark Kettenis
*
#include <sparc64/dev/cbusvar.h>
#include <sparc64/dev/vbusvar.h>
-#define CBUS_HANDLE(x) ((x) & ~0xff)
-#define CBUS_INO(x) ((x) & 0xff)
-
struct cbus_softc {
struct device sc_dv;
bus_space_tag_t sc_bustag;
bus_dma_tag_t sc_dmatag;
+ uint64_t sc_devhandle;
+
/* Machine description. */
int sc_idx;
};
struct cbus_softc *sc = (struct cbus_softc *)self;
struct vbus_attach_args *va = aux;
int node;
+ int reg;
sc->sc_bustag = cbus_alloc_bus_tag(sc, va->va_bustag);
sc->sc_dmatag = va->va_dmatag;
+ if (OF_getprop(va->va_node, "reg", ®, sizeof(reg)) != sizeof(reg))
+ return;
+ sc->sc_devhandle = reg;
+
printf("\n");
sc->sc_idx = mdesc_find(va->va_name, va->va_reg[0]);
}
int
-cbus_intr_map(int node, int ino, uint64_t *sysino)
-{
- int parent;
- int reg;
-
- parent = OF_parent(node);
- if (OF_getprop(parent, "reg", ®, sizeof(reg)) != sizeof(reg))
- return (-1);
-
- *sysino = CBUS_HANDLE(reg) | CBUS_INO(ino);
- return (0);
-}
-
-int
-cbus_intr_setstate(uint64_t sysino, uint64_t state)
+cbus_intr_setstate(bus_space_tag_t t, uint64_t devino, uint64_t state)
{
- uint64_t devhandle = CBUS_HANDLE(sysino);
- uint64_t devino = CBUS_INO(sysino);
+ struct cbus_softc *sc = t->cookie;
+ uint64_t devhandle = sc->sc_devhandle;
int err;
err = hv_vintr_setstate(devhandle, devino, state);
}
int
-cbus_intr_setenabled(uint64_t sysino, uint64_t enabled)
+cbus_intr_setenabled(bus_space_tag_t t, uint64_t devino, uint64_t enabled)
{
- uint64_t devhandle = CBUS_HANDLE(sysino);
- uint64_t devino = CBUS_INO(sysino);
+ struct cbus_softc *sc = t->cookie;
+ uint64_t devhandle = sc->sc_devhandle;
int err;
err = hv_vintr_setenabled(devhandle, devino, enabled);
cbus_intr_establish(bus_space_tag_t t, bus_space_tag_t t0, int ihandle,
int level, int flags, int (*handler)(void *), void *arg, const char *what)
{
- uint64_t devhandle = CBUS_HANDLE(ihandle);
- uint64_t devino = CBUS_INO(ihandle);
+ struct cbus_softc *sc = t0->cookie;
+ uint64_t devhandle = sc->sc_devhandle;
+ uint64_t devino = ihandle;
struct intrhand *ih;
int err;
void
cbus_intr_ack(struct intrhand *ih)
{
- uint64_t devhandle = CBUS_HANDLE(ih->ih_number);
- uint64_t devino = CBUS_INO(ih->ih_number);
+ bus_space_tag_t t = ih->ih_bus;
+ struct cbus_softc *sc = t->cookie;
+ uint64_t devhandle = sc->sc_devhandle;
+ uint64_t devino = ih->ih_number;
hv_vintr_setstate(devhandle, devino, INTR_IDLE);
}
-/* $OpenBSD: cbusvar.h,v 1.4 2009/12/14 16:06:35 kettenis Exp $ */
+/* $OpenBSD: cbusvar.h,v 1.5 2015/01/25 21:42:13 kettenis Exp $ */
/*
* Copyright (c) 2008 Mark Kettenis
*
};
int cbus_print(void *, const char *);
-int cbus_intr_map(int, int, uint64_t *);
-int cbus_intr_setstate(uint64_t, uint64_t);
-int cbus_intr_setenabled(uint64_t, uint64_t);
+int cbus_intr_setstate(bus_space_tag_t, uint64_t, uint64_t);
+int cbus_intr_setenabled(bus_space_tag_t, uint64_t, uint64_t);
#endif
-/* $OpenBSD: vcctty.c,v 1.11 2014/05/10 11:49:31 kettenis Exp $ */
+/* $OpenBSD: vcctty.c,v 1.12 2015/01/25 21:42:13 kettenis Exp $ */
/*
* Copyright (c) 2009 Mark Kettenis
*
bus_space_tag_t sc_bustag;
bus_dma_tag_t sc_dmatag;
+ uint64_t sc_tx_ino;
+ uint64_t sc_rx_ino;
void *sc_tx_ih;
void *sc_rx_ih;
- uint64_t sc_tx_sysino;
- uint64_t sc_rx_sysino;
struct ldc_conn sc_lc;
sc->sc_bustag = ca->ca_bustag;
sc->sc_dmatag = ca->ca_dmatag;
+ sc->sc_tx_ino = ca->ca_tx_ino;
+ sc->sc_rx_ino = ca->ca_rx_ino;
- if (cbus_intr_map(ca->ca_node, ca->ca_tx_ino, &sc->sc_tx_sysino) ||
- cbus_intr_map(ca->ca_node, ca->ca_rx_ino, &sc->sc_rx_sysino)) {
- printf(": can't map interrupt\n");
- return;
- }
- printf(": ivec 0x%llx, 0x%llx", sc->sc_tx_sysino, sc->sc_rx_sysino);
+ printf(": ivec 0x%llx, 0x%llx", sc->sc_tx_ino, sc->sc_rx_ino);
/*
* Un-configure queues before registering interrupt handlers,
hv_ldc_tx_qconf(ca->ca_id, 0, 0);
hv_ldc_rx_qconf(ca->ca_id, 0, 0);
- sc->sc_tx_ih = bus_intr_establish(ca->ca_bustag, sc->sc_tx_sysino,
+ sc->sc_tx_ih = bus_intr_establish(ca->ca_bustag, sc->sc_tx_ino,
IPL_TTY, 0, vcctty_tx_intr, sc, sc->sc_dv.dv_xname);
- sc->sc_rx_ih = bus_intr_establish(ca->ca_bustag, sc->sc_rx_sysino,
+ sc->sc_rx_ih = bus_intr_establish(ca->ca_bustag, sc->sc_rx_ino,
IPL_TTY, 0, vcctty_rx_intr, sc, sc->sc_dv.dv_xname);
if (sc->sc_tx_ih == NULL || sc->sc_rx_ih == NULL) {
printf(", can't establish interrupt\n");
if (err != H_EOK)
printf("%s: hv_ldc_rx_qconf %d\n", __func__, err);
- cbus_intr_setenabled(sc->sc_tx_sysino, INTR_ENABLED);
- cbus_intr_setenabled(sc->sc_rx_sysino, INTR_ENABLED);
+ cbus_intr_setenabled(sc->sc_bustag, sc->sc_tx_ino, INTR_ENABLED);
+ cbus_intr_setenabled(sc->sc_bustag, sc->sc_rx_ino, INTR_ENABLED);
printf(" domain \"%s\"\n", ca->ca_name);
return;
vccttyhwiflow(struct tty *tp, int stop)
{
struct vcctty_softc *sc = vcctty_cd.cd_devs[minor(tp->t_dev)];
+ uint64_t state = stop ? INTR_DISABLED : INTR_ENABLED;
- if (stop) {
- cbus_intr_setenabled(sc->sc_tx_sysino, INTR_DISABLED);
- cbus_intr_setenabled(sc->sc_rx_sysino, INTR_DISABLED);
- } else {
- cbus_intr_setenabled(sc->sc_tx_sysino, INTR_ENABLED);
- cbus_intr_setenabled(sc->sc_rx_sysino, INTR_ENABLED);
- }
+ cbus_intr_setenabled(sc->sc_bustag, sc->sc_tx_ino, state);
+ cbus_intr_setenabled(sc->sc_bustag, sc->sc_rx_ino, state);
return (1);
}
-/* $OpenBSD: vdsk.c,v 1.45 2014/09/21 14:52:37 kettenis Exp $ */
+/* $OpenBSD: vdsk.c,v 1.46 2015/01/25 21:42:13 kettenis Exp $ */
/*
* Copyright (c) 2009, 2011 Mark Kettenis
*
struct cbus_attach_args *ca = aux;
struct scsibus_attach_args saa;
struct ldc_conn *lc;
- uint64_t sysino[2];
int err, s;
int timeout;
sc->sc_bustag = ca->ca_bustag;
sc->sc_dmatag = ca->ca_dmatag;
- if (cbus_intr_map(ca->ca_node, ca->ca_tx_ino, &sysino[0]) ||
- cbus_intr_map(ca->ca_node, ca->ca_rx_ino, &sysino[1])) {
- printf(": can't map interrupt\n");
- return;
- }
- printf(": ivec 0x%llx, 0x%llx", sysino[0], sysino[1]);
+ printf(": ivec 0x%llx, 0x%llx", ca->ca_tx_ino, ca->ca_rx_ino);
/*
* Un-configure queues before registering interrupt handlers,
hv_ldc_tx_qconf(ca->ca_id, 0, 0);
hv_ldc_rx_qconf(ca->ca_id, 0, 0);
- sc->sc_tx_ih = bus_intr_establish(ca->ca_bustag, sysino[0], IPL_BIO,
- 0, vdsk_tx_intr, sc, sc->sc_dv.dv_xname);
- sc->sc_rx_ih = bus_intr_establish(ca->ca_bustag, sysino[1], IPL_BIO,
- 0, vdsk_rx_intr, sc, sc->sc_dv.dv_xname);
+ sc->sc_tx_ih = bus_intr_establish(ca->ca_bustag, ca->ca_tx_ino,
+ IPL_BIO, 0, vdsk_tx_intr, sc, sc->sc_dv.dv_xname);
+ sc->sc_rx_ih = bus_intr_establish(ca->ca_bustag, ca->ca_rx_ino,
+ IPL_BIO, 0, vdsk_rx_intr, sc, sc->sc_dv.dv_xname);
if (sc->sc_tx_ih == NULL || sc->sc_rx_ih == NULL) {
printf(", can't establish interrupt\n");
return;
if (err != H_EOK)
printf("hv_ldc_rx_qconf %d\n", err);
- cbus_intr_setenabled(sysino[0], INTR_ENABLED);
- cbus_intr_setenabled(sysino[1], INTR_ENABLED);
+ cbus_intr_setenabled(sc->sc_bustag, ca->ca_tx_ino, INTR_ENABLED);
+ cbus_intr_setenabled(sc->sc_bustag, ca->ca_rx_ino, INTR_ENABLED);
ldc_send_vers(lc);
-/* $OpenBSD: vdsp.c,v 1.35 2015/01/23 12:41:23 dlg Exp $ */
+/* $OpenBSD: vdsp.c,v 1.36 2015/01/25 21:42:13 kettenis Exp $ */
/*
* Copyright (c) 2009, 2011, 2014 Mark Kettenis
*
bus_space_tag_t sc_bustag;
bus_dma_tag_t sc_dmatag;
- uint64_t sc_tx_sysino;
- uint64_t sc_rx_sysino;
+ uint64_t sc_tx_ino;
+ uint64_t sc_rx_ino;
void *sc_tx_ih;
void *sc_rx_ih;
sc->sc_idx = ca->ca_idx;
sc->sc_bustag = ca->ca_bustag;
sc->sc_dmatag = ca->ca_dmatag;
+ sc->sc_tx_ino = ca->ca_tx_ino;
+ sc->sc_rx_ino = ca->ca_rx_ino;
- if (cbus_intr_map(ca->ca_node, ca->ca_tx_ino, &sc->sc_tx_sysino) ||
- cbus_intr_map(ca->ca_node, ca->ca_rx_ino, &sc->sc_rx_sysino)) {
- printf(": can't map interrupt\n");
- return;
- }
- printf(": ivec 0x%llx, 0x%llx", sc->sc_tx_sysino, sc->sc_rx_sysino);
+ printf(": ivec 0x%llx, 0x%llx", sc->sc_tx_ino, sc->sc_rx_ino);
mtx_init(&sc->sc_desc_mtx, IPL_BIO);
hv_ldc_tx_qconf(ca->ca_id, 0, 0);
hv_ldc_rx_qconf(ca->ca_id, 0, 0);
- sc->sc_tx_ih = bus_intr_establish(ca->ca_bustag, sc->sc_tx_sysino,
+ sc->sc_tx_ih = bus_intr_establish(ca->ca_bustag, sc->sc_tx_ino,
IPL_BIO, BUS_INTR_ESTABLISH_MPSAFE, vdsp_tx_intr, sc,
sc->sc_dv.dv_xname);
- sc->sc_rx_ih = bus_intr_establish(ca->ca_bustag, sc->sc_rx_sysino,
+ sc->sc_rx_ih = bus_intr_establish(ca->ca_bustag, sc->sc_rx_ino,
IPL_BIO, BUS_INTR_ESTABLISH_MPSAFE, vdsp_rx_intr, sc,
sc->sc_dv.dv_xname);
if (sc->sc_tx_ih == NULL || sc->sc_rx_ih == NULL) {
if (err != H_EOK)
printf("%s: hv_ldc_rx_qconf %d\n", __func__, err);
- cbus_intr_setenabled(sc->sc_tx_sysino, INTR_ENABLED);
- cbus_intr_setenabled(sc->sc_rx_sysino, INTR_ENABLED);
+ cbus_intr_setenabled(sc->sc_bustag, sc->sc_tx_ino, INTR_ENABLED);
+ cbus_intr_setenabled(sc->sc_bustag, sc->sc_rx_ino, INTR_ENABLED);
return (0);
}
if (sc == NULL)
return (ENXIO);
- cbus_intr_setenabled(sc->sc_tx_sysino, INTR_DISABLED);
- cbus_intr_setenabled(sc->sc_rx_sysino, INTR_DISABLED);
+ cbus_intr_setenabled(sc->sc_bustag, sc->sc_tx_ino, INTR_DISABLED);
+ cbus_intr_setenabled(sc->sc_bustag, sc->sc_rx_ino, INTR_DISABLED);
hv_ldc_tx_qconf(sc->sc_lc.lc_id, 0, 0);
hv_ldc_rx_qconf(sc->sc_lc.lc_id, 0, 0);
-/* $OpenBSD: vldcp.c,v 1.9 2014/07/12 18:44:43 tedu Exp $ */
+/* $OpenBSD: vldcp.c,v 1.10 2015/01/25 21:42:13 kettenis Exp $ */
/*
* Copyright (c) 2009, 2012 Mark Kettenis
*
bus_space_tag_t sc_bustag;
bus_dma_tag_t sc_dmatag;
+ uint64_t sc_tx_ino;
+ uint64_t sc_rx_ino;
void *sc_tx_ih;
void *sc_rx_ih;
- uint64_t sc_tx_sysino;
- uint64_t sc_rx_sysino;
struct ldc_conn sc_lc;
sc->sc_bustag = ca->ca_bustag;
sc->sc_dmatag = ca->ca_dmatag;
+ sc->sc_tx_ino = ca->ca_tx_ino;
+ sc->sc_rx_ino = ca->ca_rx_ino;
- if (cbus_intr_map(ca->ca_node, ca->ca_tx_ino, &sc->sc_tx_sysino) ||
- cbus_intr_map(ca->ca_node, ca->ca_rx_ino, &sc->sc_rx_sysino)) {
- printf(": can't map interrupt\n");
- return;
- }
- printf(": ivec 0x%llx, 0x%llx", sc->sc_tx_sysino, sc->sc_rx_sysino);
+ printf(": ivec 0x%llx, 0x%llx", sc->sc_tx_ino, sc->sc_rx_ino);
/*
* Un-configure queues before registering interrupt handlers,
hv_ldc_tx_qconf(ca->ca_id, 0, 0);
hv_ldc_rx_qconf(ca->ca_id, 0, 0);
- sc->sc_tx_ih = bus_intr_establish(ca->ca_bustag, sc->sc_tx_sysino,
+ sc->sc_tx_ih = bus_intr_establish(ca->ca_bustag, sc->sc_tx_ino,
IPL_TTY, 0, vldcp_tx_intr, sc, sc->sc_dv.dv_xname);
- sc->sc_rx_ih = bus_intr_establish(ca->ca_bustag, sc->sc_rx_sysino,
+ sc->sc_rx_ih = bus_intr_establish(ca->ca_bustag, sc->sc_rx_ino,
IPL_TTY, 0, vldcp_rx_intr, sc, sc->sc_dv.dv_xname);
if (sc->sc_tx_ih == NULL || sc->sc_rx_ih == NULL) {
printf(", can't establish interrupt\n");
lc->lc_tx_state = tx_state;
}
- cbus_intr_setenabled(sc->sc_tx_sysino, INTR_DISABLED);
+ cbus_intr_setenabled(sc->sc_bustag, sc->sc_tx_ino, INTR_DISABLED);
selwakeup(&sc->sc_wsel);
wakeup(lc->lc_txq);
return (1);
break;
}
lc->lc_rx_state = rx_state;
- cbus_intr_setenabled(sc->sc_rx_sysino, INTR_DISABLED);
+ cbus_intr_setenabled(sc->sc_bustag, sc->sc_rx_ino,
+ INTR_DISABLED);
selwakeup(&sc->sc_rsel);
wakeup(lc->lc_rxq);
return (1);
if (rx_head == rx_tail)
return (0);
- cbus_intr_setenabled(sc->sc_rx_sysino, INTR_DISABLED);
+ cbus_intr_setenabled(sc->sc_bustag, sc->sc_rx_ino, INTR_DISABLED);
selwakeup(&sc->sc_rsel);
wakeup(lc->lc_rxq);
return (1);
if (sc == NULL)
return (ENXIO);
- cbus_intr_setenabled(sc->sc_tx_sysino, INTR_DISABLED);
- cbus_intr_setenabled(sc->sc_rx_sysino, INTR_DISABLED);
+ cbus_intr_setenabled(sc->sc_bustag, sc->sc_tx_ino, INTR_DISABLED);
+ cbus_intr_setenabled(sc->sc_bustag, sc->sc_rx_ino, INTR_DISABLED);
hv_ldc_tx_qconf(sc->sc_lc.lc_id, 0, 0);
hv_ldc_rx_qconf(sc->sc_lc.lc_id, 0, 0);
DPRINTF(("rx head %llx, rx tail %llx\n", rx_head, rx_tail));
if (rx_head == rx_tail) {
- cbus_intr_setenabled(sc->sc_rx_sysino, INTR_ENABLED);
+ cbus_intr_setenabled(sc->sc_bustag, sc->sc_rx_ino,
+ INTR_ENABLED);
ret = tsleep(lc->lc_rxq, PWAIT | PCATCH, "hvrd", 0);
if (ret) {
splx(s);
next_tx_tail &= ((lc->lc_txq->lq_nentries * 64) - 1);
if (tx_head == next_tx_tail) {
- cbus_intr_setenabled(sc->sc_tx_sysino, INTR_ENABLED);
+ cbus_intr_setenabled(sc->sc_bustag, sc->sc_tx_ino,
+ INTR_ENABLED);
ret = tsleep(lc->lc_txq, PWAIT | PCATCH, "hvwr", 0);
if (ret) {
splx(s);
}
if (revents == 0) {
if (events & (POLLIN | POLLRDNORM)) {
- cbus_intr_setenabled(sc->sc_rx_sysino, INTR_ENABLED);
+ cbus_intr_setenabled(sc->sc_bustag, sc->sc_rx_ino,
+ INTR_ENABLED);
selrecord(p, &sc->sc_rsel);
}
if (events & (POLLOUT | POLLWRNORM)) {
- cbus_intr_setenabled(sc->sc_tx_sysino, INTR_ENABLED);
+ cbus_intr_setenabled(sc->sc_bustag, sc->sc_tx_ino,
+ INTR_ENABLED);
selrecord(p, &sc->sc_wsel);
}
}
-/* $OpenBSD: vnet.c,v 1.36 2014/12/22 02:26:54 tedu Exp $ */
+/* $OpenBSD: vnet.c,v 1.37 2015/01/25 21:42:13 kettenis Exp $ */
/*
* Copyright (c) 2009 Mark Kettenis
*
bus_space_tag_t sc_bustag;
bus_dma_tag_t sc_dmatag;
- uint64_t sc_tx_sysino;
- uint64_t sc_rx_sysino;
+ uint64_t sc_tx_ino;
+ uint64_t sc_rx_ino;
void *sc_tx_ih;
void *sc_rx_ih;
sc->sc_bustag = ca->ca_bustag;
sc->sc_dmatag = ca->ca_dmatag;
+ sc->sc_tx_ino = ca->ca_tx_ino;
+ sc->sc_rx_ino = ca->ca_rx_ino;
- if (cbus_intr_map(ca->ca_node, ca->ca_tx_ino, &sc->sc_tx_sysino) ||
- cbus_intr_map(ca->ca_node, ca->ca_rx_ino, &sc->sc_rx_sysino)) {
- printf(": can't map interrupt\n");
- return;
- }
- printf(": ivec 0x%llx, 0x%llx", sc->sc_tx_sysino, sc->sc_rx_sysino);
+ printf(": ivec 0x%llx, 0x%llx", sc->sc_tx_ino, sc->sc_rx_ino);
/*
* Un-configure queues before registering interrupt handlers,
hv_ldc_tx_qconf(ca->ca_id, 0, 0);
hv_ldc_rx_qconf(ca->ca_id, 0, 0);
- sc->sc_tx_ih = bus_intr_establish(ca->ca_bustag, sc->sc_tx_sysino,
+ sc->sc_tx_ih = bus_intr_establish(ca->ca_bustag, sc->sc_tx_ino,
IPL_NET, 0, vnet_tx_intr, sc, sc->sc_dv.dv_xname);
- sc->sc_rx_ih = bus_intr_establish(ca->ca_bustag, sc->sc_rx_sysino,
+ sc->sc_rx_ih = bus_intr_establish(ca->ca_bustag, sc->sc_rx_ino,
IPL_NET, 0, vnet_rx_intr, sc, sc->sc_dv.dv_xname);
if (sc->sc_tx_ih == NULL || sc->sc_rx_ih == NULL) {
printf(", can't establish interrupt\n");
if (err != H_EOK)
printf("hv_ldc_rx_qconf %d\n", err);
- cbus_intr_setenabled(sc->sc_tx_sysino, INTR_ENABLED);
- cbus_intr_setenabled(sc->sc_rx_sysino, INTR_ENABLED);
+ cbus_intr_setenabled(sc->sc_bustag, sc->sc_tx_ino, INTR_ENABLED);
+ cbus_intr_setenabled(sc->sc_bustag, sc->sc_rx_ino, INTR_ENABLED);
ldc_send_vers(lc);
ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
ifp->if_timer = 0;
- cbus_intr_setenabled(sc->sc_tx_sysino, INTR_DISABLED);
- cbus_intr_setenabled(sc->sc_rx_sysino, INTR_DISABLED);
+ cbus_intr_setenabled(sc->sc_bustag, sc->sc_tx_ino, INTR_DISABLED);
+ cbus_intr_setenabled(sc->sc_bustag, sc->sc_rx_ino, INTR_DISABLED);
hv_ldc_tx_qconf(lc->lc_id, 0, 0);
hv_ldc_rx_qconf(lc->lc_id, 0, 0);