summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2012-12-08 20:38:11 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2012-12-08 20:38:11 +0000
commit419bf31162b38c0ade15af000eb27d0d87ba7357 (patch)
treedacc34bb012a540f8bd4cd3544764490831b73b7 /sys
parentd5bcffb4c84df8eca5b7df26fdcf5fadf0078945 (diff)
Make ldomd(8) to control the availability of virtual disks to guest domains.
This is done by opening the corresponding /dev/vdspN device file. The virtual disk will remain available until that device is closed, which happens automatically when ldomd(8) exits.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/sparc64/conf/files.sparc644
-rw-r--r--sys/arch/sparc64/dev/vdsp.c100
-rw-r--r--sys/arch/sparc64/include/conf.h11
-rw-r--r--sys/arch/sparc64/sparc64/conf.c6
4 files changed, 92 insertions, 29 deletions
diff --git a/sys/arch/sparc64/conf/files.sparc64 b/sys/arch/sparc64/conf/files.sparc64
index fb584b2baa7..f7e5dd320bc 100644
--- a/sys/arch/sparc64/conf/files.sparc64
+++ b/sys/arch/sparc64/conf/files.sparc64
@@ -1,4 +1,4 @@
-# $OpenBSD: files.sparc64,v 1.138 2012/10/17 11:52:22 kettenis Exp $
+# $OpenBSD: files.sparc64,v 1.139 2012/12/08 20:38:10 kettenis Exp $
# $NetBSD: files.sparc64,v 1.50 2001/08/10 20:53:50 eeh Exp $
# maxpartitions must be first item in files.${ARCH}
@@ -436,7 +436,7 @@ file arch/sparc64/dev/vds.c vds
# Virtual disk server port
device vdsp: ldc
attach vdsp at vds
-file arch/sparc64/dev/vdsp.c vdsp
+file arch/sparc64/dev/vdsp.c vdsp needs-flag
# Virtual disk
device vdsk: ldc, scsi
diff --git a/sys/arch/sparc64/dev/vdsp.c b/sys/arch/sparc64/dev/vdsp.c
index 009b8b8b4b9..11a00be9ffc 100644
--- a/sys/arch/sparc64/dev/vdsp.c
+++ b/sys/arch/sparc64/dev/vdsp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vdsp.c,v 1.17 2012/12/08 12:35:04 kettenis Exp $ */
+/* $OpenBSD: vdsp.c,v 1.18 2012/12/08 20:38:10 kettenis Exp $ */
/*
* Copyright (c) 2009, 2011 Mark Kettenis
*
@@ -16,6 +16,7 @@
*/
#include <sys/param.h>
+#include <sys/conf.h>
#include <sys/proc.h>
#include <sys/buf.h>
#include <sys/device.h>
@@ -28,6 +29,7 @@
#include <sys/workq.h>
#include <machine/autoconf.h>
+#include <machine/conf.h>
#include <machine/hypervisor.h>
#include <machine/mdesc.h>
@@ -277,7 +279,6 @@ void vdsp_ldc_start(struct ldc_conn *);
void vdsp_sendmsg(struct vdsp_softc *, void *, size_t, int dowait);
-void vdsp_mountroot(void *);
void vdsp_open(void *, void *);
void vdsp_close(void *, void *);
void vdsp_alloc(void *, void *);
@@ -361,7 +362,6 @@ vdsp_attach(struct device *parent, struct device *self, void *aux)
printf("\n");
- mountroothook_establish(vdsp_mountroot, sc);
return;
#if 0
@@ -865,27 +865,6 @@ vdsp_sendmsg(struct vdsp_softc *sc, void *msg, size_t len, int dowait)
}
void
-vdsp_mountroot(void *arg)
-{
- struct vdsp_softc *sc = arg;
- struct ldc_conn *lc = &sc->sc_lc;
- int err;
-
- err = hv_ldc_tx_qconf(lc->lc_id,
- lc->lc_txq->lq_map->dm_segs[0].ds_addr, lc->lc_txq->lq_nentries);
- if (err != H_EOK)
- printf("%s: hv_ldc_tx_qconf %d\n", __func__, err);
-
- err = hv_ldc_rx_qconf(lc->lc_id,
- lc->lc_rxq->lq_map->dm_segs[0].ds_addr, lc->lc_rxq->lq_nentries);
- if (err != H_EOK)
- printf("%s: hv_ldc_rx_qconf %d\n", err, __func__);
-
- cbus_intr_setenabled(sc->sc_tx_sysino, INTR_ENABLED);
- cbus_intr_setenabled(sc->sc_rx_sysino, INTR_ENABLED);
-}
-
-void
vdsp_open(void *arg1, void *arg2)
{
struct vdsp_softc *sc = arg1;
@@ -1598,3 +1577,76 @@ vdsp_ack_desc(struct vdsp_softc *sc, struct vd_desc *vd)
dm.end_idx = off / sc->sc_descriptor_size;
vdsp_sendmsg(sc, &dm, sizeof(dm), 1);
}
+
+int
+vdspopen(dev_t dev, int flag, int mode, struct proc *p)
+{
+ struct vdsp_softc *sc;
+ struct ldc_conn *lc;
+ int unit = minor(dev);
+ int err;
+
+ if (unit >= vdsp_cd.cd_ndevs)
+ return (ENXIO);
+ sc = vdsp_cd.cd_devs[unit];
+ if (sc == NULL)
+ return (ENXIO);
+
+ lc = &sc->sc_lc;
+
+ err = hv_ldc_tx_qconf(lc->lc_id,
+ lc->lc_txq->lq_map->dm_segs[0].ds_addr, lc->lc_txq->lq_nentries);
+ if (err != H_EOK)
+ printf("%s: hv_ldc_tx_qconf %d\n", __func__, err);
+
+ err = hv_ldc_rx_qconf(lc->lc_id,
+ lc->lc_rxq->lq_map->dm_segs[0].ds_addr, lc->lc_rxq->lq_nentries);
+ if (err != H_EOK)
+ printf("%s: hv_ldc_rx_qconf %d\n", err, __func__);
+
+ cbus_intr_setenabled(sc->sc_tx_sysino, INTR_ENABLED);
+ cbus_intr_setenabled(sc->sc_rx_sysino, INTR_ENABLED);
+
+ return (0);
+}
+
+int
+vdspclose(dev_t dev, int flag, int mode, struct proc *p)
+{
+ struct vdsp_softc *sc;
+ int unit = minor(dev);
+
+ if (unit >= vdsp_cd.cd_ndevs)
+ return (ENXIO);
+ sc = vdsp_cd.cd_devs[unit];
+ if (sc == NULL)
+ return (ENXIO);
+
+ cbus_intr_setenabled(sc->sc_tx_sysino, INTR_DISABLED);
+ cbus_intr_setenabled(sc->sc_rx_sysino, INTR_DISABLED);
+
+ hv_ldc_tx_qconf(sc->sc_lc.lc_id, 0, 0);
+ hv_ldc_rx_qconf(sc->sc_lc.lc_id, 0, 0);
+
+ if (sc->sc_vp) {
+ vn_close(sc->sc_vp, FREAD | FWRITE, p->p_ucred, p);
+ sc->sc_vp = NULL;
+ }
+
+ return (0);
+}
+
+int
+vdspioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
+{
+ struct vdsp_softc *sc;
+ int unit = minor(dev);
+
+ if (unit >= vdsp_cd.cd_ndevs)
+ return (ENXIO);
+ sc = vdsp_cd.cd_devs[unit];
+ if (sc == NULL)
+ return (ENXIO);
+
+ return (ENOTTY);
+}
diff --git a/sys/arch/sparc64/include/conf.h b/sys/arch/sparc64/include/conf.h
index cca4a5bb9fd..cbf5d889a22 100644
--- a/sys/arch/sparc64/include/conf.h
+++ b/sys/arch/sparc64/include/conf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.h,v 1.23 2012/10/17 11:52:22 kettenis Exp $ */
+/* $OpenBSD: conf.h,v 1.24 2012/12/08 20:38:10 kettenis Exp $ */
/* $NetBSD: conf.h,v 1.9 2001/03/26 12:33:26 lukem Exp $ */
/*-
@@ -52,6 +52,15 @@ cdev_decl(uperf);
(dev_type_stop((*))) nullop, 0, selfalse, \
(dev_type_mmap((*))) enodev }
+cdev_decl(vdsp);
+
+/* open, close, ioctl */
+#define cdev_vdsp_init(c,n) { \
+ dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
+ (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
+ (dev_type_stop((*))) nullop, 0, selfalse, \
+ (dev_type_mmap((*))) enodev }
+
#define cdev_gen_init(c,n) { \
dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) nullop, \
diff --git a/sys/arch/sparc64/sparc64/conf.c b/sys/arch/sparc64/sparc64/conf.c
index f91d6ae8f82..0b1d6b57cf9 100644
--- a/sys/arch/sparc64/sparc64/conf.c
+++ b/sys/arch/sparc64/sparc64/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.65 2012/10/17 11:52:22 kettenis Exp $ */
+/* $OpenBSD: conf.c,v 1.66 2012/12/08 20:38:10 kettenis Exp $ */
/* $NetBSD: conf.c,v 1.17 2001/03/26 12:33:26 lukem Exp $ */
/*
@@ -82,6 +82,7 @@
#include "spif.h" /* has NSTTY and NSBPP */
#include "uperf.h"
#include "vldcp.h"
+#include "vdsp.h"
#include "fdc.h" /* has NFDC and NFD; see files.sparc */
@@ -287,7 +288,8 @@ struct cdevsw cdevsw[] =
cdev_bthub_init(NBTHUB,bthub), /* 129: bluetooth hub */
cdev_disk_init(1,diskmap), /* 130: disk mapper */
cdev_pppx_init(NPPPX,pppx), /* 131: pppx */
- cdev_gen_init(NVLDCP,vldcp) /* 132: vldcp */
+ cdev_gen_init(NVLDCP,vldcp), /* 132: vldcp */
+ cdev_vdsp_init(NVDSP,vdsp) /* 133: vdsp */
};
int nchrdev = nitems(cdevsw);