Add ``hypervisor at mainbus'' and attach all devices provided by the

hypervisor to it instead of mainbus.
This commit is contained in:
cl 2004-04-24 17:45:38 +00:00
parent ef3c59b551
commit d843f649c6
1 changed files with 147 additions and 0 deletions

View File

@ -0,0 +1,147 @@
/* $NetBSD: hypervisor.c,v 1.1 2004/04/24 17:45:38 cl Exp $ */
/*
*
* Copyright (c) 2004 Christian Limpach.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Christian Limpach.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.1 2004/04/24 17:45:38 cl Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include "xenc.h"
#include "xennet.h"
#include "xbd.h"
#include "npx.h"
#include "opt_xen.h"
#include <machine/xen.h>
#include <machine/hypervisor.h>
#if NXENNET > 0
#include <net/if.h>
#include <net/if_ether.h>
#include <net/if_media.h>
#include <machine/if_xennetvar.h>
#endif
#if NXBD > 0
#include <sys/buf.h>
#include <sys/disk.h>
#include <dev/dkvar.h>
#include <machine/xbdvar.h>
#endif
int hypervisor_match(struct device *, struct cfdata *, void *);
void hypervisor_attach(struct device *, struct device *, void *);
CFATTACH_DECL(hypervisor, sizeof(struct device),
hypervisor_match, hypervisor_attach, NULL, NULL);
int hypervisor_print(void *, const char *);
union hypervisor_attach_cookie {
const char *hac_device; /* first elem of all */
#if NXENC > 0
struct xenc_attach_args hac_xenc;
#endif
#if NXENNET > 0
struct xennet_attach_args hac_xennet;
#endif
#if NXBD > 0
struct xbd_attach_args hac_xbd;
#endif
#if NNPX > 0
struct xen_npx_attach_args hac_xennpx;
#endif
};
/*
* Probe for the hypervisor; always succeeds.
*/
int
hypervisor_match(parent, match, aux)
struct device *parent;
struct cfdata *match;
void *aux;
{
struct hypervisor_attach_args *haa = aux;
if (strcmp(haa->haa_busname, "hypervisor") == 0)
return 1;
return 0;
}
/*
* Attach the hypervisor.
*/
void
hypervisor_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
union hypervisor_attach_cookie hac;
printf("\n");
#if NXENC > 0
hac.hac_xenc.xa_device = "xenc";
config_found(self, &hac.hac_xenc, hypervisor_print);
#endif
#if NXENNET > 0
hac.hac_xennet.xa_device = "xennet";
xennet_scan(self, &hac.hac_xennet, hypervisor_print);
#endif
#if NXBD > 0
hac.hac_xbd.xa_device = "xbd";
xbd_scan(self, &hac.hac_xbd, hypervisor_print);
#endif
#if NNPX > 0
hac.hac_xennpx.xa_device = "npx";
config_found(self, &hac.hac_xennpx, hypervisor_print);
#endif
}
int
hypervisor_print(aux, pnp)
void *aux;
const char *pnp;
{
union hypervisor_attach_cookie *hac = aux;
if (pnp)
aprint_normal("XXXXXXXXx %s at %s", hac->hac_device, pnp);
return (UNCONF);
}