ref: c404fd9d6f46f90e4420d0b268215ef719e25796
parent: e0c221eea6b68c87f89eb073d7204851398fc5d8
author: cinap_lenrek <[email protected]>
date: Mon Dec 22 11:16:36 EST 2014
sdvirtio: provide enable() and disable() functions so it can be switched off
--- a/sys/src/9/pc/sdvirtio.c
+++ b/sys/src/9/pc/sdvirtio.c
@@ -563,13 +563,31 @@
SDifc sdvirtioifc;
-static void
-vdevenable(Vdev *vd)
+static int
+vioenable(SDev *sd)
{
- intrenable(vd->pci->intl, viointerrupt, vd, vd->pci->tbdf, "virtio");
+ char name[32];
+ Vdev *vd;
+
+ vd = sd->ctlr;
+ snprint(name, sizeof(name), "%s (%s)", sd->name, sd->ifc->name);
+ intrenable(vd->pci->intl, viointerrupt, vd, vd->pci->tbdf, name);
outb(vd->port+Status, inb(vd->port+Status) | DriverOk);
+ return 0;
}
+static int
+viodisable(SDev *sd)
+{
+ char name[32];
+ Vdev *vd;
+
+ vd = sd->ctlr;
+ snprint(name, sizeof(name), "%s (%s)", sd->name, sd->ifc->name);
+ intrdisable(vd->pci->intl, viointerrupt, vd, vd->pci->tbdf, name);
+ return 0;
+}
+
static SDev*
viopnp(void)
{
@@ -584,8 +602,6 @@
if(vd->nqueue != 1)
continue;
- vdevenable(vd);
-
if((s = malloc(sizeof(*s))) == nil)
break;
s->ctlr = vd;
@@ -630,8 +646,6 @@
continue;
}
vd->cfg = cfg;
-
- vdevenable(vd);
if((s = malloc(sizeof(*s))) == nil)
break;
@@ -654,8 +668,8 @@
viopnp, /* pnp */
nil, /* legacy */
- nil, /* enable */
- nil, /* disable */
+ vioenable, /* enable */
+ viodisable, /* disable */
vioverify, /* verify */
vioonline, /* online */