diff options
-rw-r--r-- | sys/arch/amd64/conf/GENERIC | 4 | ||||
-rw-r--r-- | sys/dev/pv/files.pv | 7 | ||||
-rw-r--r-- | sys/dev/pv/xen.c | 91 | ||||
-rw-r--r-- | sys/dev/pv/xenvar.h | 25 |
4 files changed, 125 insertions, 2 deletions
diff --git a/sys/arch/amd64/conf/GENERIC b/sys/arch/amd64/conf/GENERIC index 2e4f9797307..177d76ba3dd 100644 --- a/sys/arch/amd64/conf/GENERIC +++ b/sys/arch/amd64/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.401 2015/11/23 22:57:12 deraadt Exp $ +# $OpenBSD: GENERIC,v 1.402 2015/12/08 18:46:25 mikeb Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -68,6 +68,8 @@ ipmi0 at mainbus? disable # IPMI vmt0 at pvbus? # VMware Tools +#xen0 at pvbus? # Xen HVM domU + option PCIVERBOSE option USBVERBOSE 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); +} diff --git a/sys/dev/pv/xenvar.h b/sys/dev/pv/xenvar.h new file mode 100644 index 00000000000..76061ee1db5 --- /dev/null +++ b/sys/dev/pv/xenvar.h @@ -0,0 +1,25 @@ +/* + * 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. + */ + +#ifndef _XENVAR_H_ +#define _XENVAR_H_ + +struct xen_softc { + struct device sc_dev; + uint32_t sc_base; +}; + +#endif /* _XENVAR_H_ */ |