diff options
author | 2015-12-08 18:46:25 +0000 | |
---|---|---|
committer | 2015-12-08 18:46:25 +0000 | |
commit | d1abe1e1208dbe0793b5c4d81ecd2f8cb0fa018b (patch) | |
tree | cee69599e4659fd17bc239c137db3067f4436bca /sys/dev/pv | |
parent | Xen basic infrastructure files and pvbus(4) attachment. (diff) | |
download | wireguard-openbsd-d1abe1e1208dbe0793b5c4d81ecd2f8cb0fa018b.tar.xz wireguard-openbsd-d1abe1e1208dbe0793b5c4d81ecd2f8cb0fa018b.zip |
Xen basic infrastructure files and pvbus(4) attachment.
With input from and OK mpi, mlarkin, reyk
Diffstat (limited to 'sys/dev/pv')
-rw-r--r-- | sys/dev/pv/files.pv | 7 | ||||
-rw-r--r-- | sys/dev/pv/xen.c | 91 |
2 files changed, 97 insertions, 1 deletions
diff --git a/sys/dev/pv/files.pv b/sys/dev/pv/files.pv index 2acad4b1f62..f5e606e9615 100644 --- a/sys/dev/pv/files.pv +++ b/sys/dev/pv/files.pv @@ -1,4 +1,4 @@ -# $OpenBSD: files.pv,v 1.2 2015/07/21 09:13:11 reyk Exp $ +# $OpenBSD: files.pv,v 1.3 2015/12/08 18:46:25 mikeb Exp $ # # Config file and device description for paravirtual devices. # Included by ports that need it. @@ -12,3 +12,8 @@ file dev/pv/pvbus.c pvbus needs-flag device vmt attach vmt at pvbus file dev/pv/vmt.c vmt needs-flag + +# Xen +device xen {} +attach xen at pvbus +file dev/pv/xen.c xen needs-flag diff --git a/sys/dev/pv/xen.c b/sys/dev/pv/xen.c new file mode 100644 index 00000000000..9ca3c571427 --- /dev/null +++ b/sys/dev/pv/xen.c @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2015 Mike Belopuhov + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/atomic.h> +#include <sys/malloc.h> +#include <sys/kernel.h> +#include <sys/device.h> + +#include <machine/bus.h> +#include <machine/cpu.h> +#include <machine/cpufunc.h> + +#include <uvm/uvm_extern.h> + +#include <dev/pv/pvvar.h> +#include <dev/pv/xenvar.h> + +struct xen_softc *xen_sc; + +int xen_match(struct device *, void *, void *); +void xen_attach(struct device *, struct device *, void *); +void xen_resume(struct device *); +int xen_activate(struct device *, int); + +const struct cfdriver xen_cd = { + NULL, "xen", DV_DULL +}; + +const struct cfattach xen_ca = { + sizeof(struct xen_softc), xen_match, xen_attach, NULL, xen_activate +}; + +int +xen_match(struct device *parent, void *match, void *aux) +{ + struct pv_attach_args *pva = aux; + struct pvbus_hv *hv = &pva->pva_hv[PVBUS_XEN]; + + if (hv->hv_base == 0) + return (0); + + return (1); +} + +void +xen_attach(struct device *parent, struct device *self, void *aux) +{ + struct pv_attach_args *pva = (struct pv_attach_args *)aux; + struct pvbus_hv *hv = &pva->pva_hv[PVBUS_XEN]; + struct xen_softc *sc = (struct xen_softc *)self; + + sc->sc_base = hv->hv_base; + + printf("\n"); + + /* Wire it up to the global */ + xen_sc = sc; +} + +void +xen_resume(struct device *self) +{ +} + +int +xen_activate(struct device *self, int act) +{ + int rv = 0; + + switch (act) { + case DVACT_RESUME: + xen_resume(self); + break; + } + return (rv); +} |