Home | History | Annotate | Line # | Download | only in x86
xen_mainbus.c revision 1.6.12.1
      1  1.6.12.1  bouyer /*	$NetBSD: xen_mainbus.c,v 1.6.12.1 2020/04/16 08:46:35 bouyer Exp $	*/
      2       1.2  cherry /*	NetBSD: mainbus.c,v 1.19 2017/05/23 08:54:39 nonaka Exp 	*/
      3       1.1  cherry /*	NetBSD: mainbus.c,v 1.53 2003/10/27 14:11:47 junyoung Exp 	*/
      4       1.1  cherry 
      5       1.1  cherry /*
      6       1.1  cherry  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
      7       1.1  cherry  *
      8       1.1  cherry  * Redistribution and use in source and binary forms, with or without
      9       1.1  cherry  * modification, are permitted provided that the following conditions
     10       1.1  cherry  * are met:
     11       1.1  cherry  * 1. Redistributions of source code must retain the above copyright
     12       1.1  cherry  *    notice, this list of conditions and the following disclaimer.
     13       1.1  cherry  * 2. Redistributions in binary form must reproduce the above copyright
     14       1.1  cherry  *    notice, this list of conditions and the following disclaimer in the
     15       1.1  cherry  *    documentation and/or other materials provided with the distribution.
     16       1.1  cherry  * 3. All advertising materials mentioning features or use of this software
     17       1.1  cherry  *    must display the following acknowledgement:
     18       1.1  cherry  *      This product includes software developed by Christopher G. Demetriou
     19       1.1  cherry  *	for the NetBSD Project.
     20       1.1  cherry  * 4. The name of the author may not be used to endorse or promote products
     21       1.1  cherry  *    derived from this software without specific prior written permission
     22       1.1  cherry  *
     23       1.1  cherry  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     24       1.1  cherry  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     25       1.1  cherry  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     26       1.1  cherry  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     27       1.1  cherry  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     28       1.1  cherry  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     29       1.1  cherry  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     30       1.1  cherry  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     31       1.1  cherry  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     32       1.1  cherry  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     33       1.1  cherry  */
     34       1.1  cherry 
     35       1.1  cherry #include <sys/cdefs.h>
     36  1.6.12.1  bouyer __KERNEL_RCSID(0, "$NetBSD: xen_mainbus.c,v 1.6.12.1 2020/04/16 08:46:35 bouyer Exp $");
     37       1.1  cherry 
     38       1.1  cherry #include <sys/param.h>
     39       1.1  cherry #include <sys/systm.h>
     40       1.1  cherry #include <sys/device.h>
     41       1.1  cherry 
     42       1.1  cherry #include <sys/bus.h>
     43       1.1  cherry 
     44       1.1  cherry #include "hypervisor.h"
     45       1.1  cherry #include "pci.h"
     46       1.1  cherry 
     47       1.1  cherry #include "opt_xen.h"
     48       1.1  cherry #include "opt_mpbios.h"
     49       1.1  cherry #include "opt_pcifixup.h"
     50       1.1  cherry 
     51       1.1  cherry #include "acpica.h"
     52       1.1  cherry #include "ioapic.h"
     53       1.1  cherry 
     54       1.1  cherry #include "ipmi.h"
     55       1.1  cherry 
     56       1.1  cherry #include <machine/cpuvar.h>
     57       1.1  cherry #include <machine/i82093var.h>
     58       1.1  cherry 
     59       1.1  cherry #include <xen/xen.h>
     60       1.1  cherry #include <xen/hypervisor.h>
     61       1.1  cherry 
     62       1.1  cherry #if NIPMI > 0
     63       1.1  cherry #include <x86/ipmivar.h>
     64       1.1  cherry #endif
     65       1.1  cherry 
     66       1.1  cherry #if NPCI > 0
     67       1.1  cherry #include <dev/pci/pcivar.h>
     68       1.1  cherry #if NACPICA > 0
     69       1.1  cherry #include <dev/acpi/acpivar.h>
     70       1.4    maxv #include <xen/mpacpi.h>
     71       1.1  cherry #endif /* NACPICA > 0 */
     72       1.1  cherry #ifdef MPBIOS
     73       1.4    maxv #include <machine/mpbiosvar.h>
     74       1.1  cherry #endif /* MPBIOS */
     75       1.1  cherry #ifdef PCI_BUS_FIXUP
     76       1.1  cherry #include <arch/x86/pci/pci_bus_fixup.h>
     77       1.1  cherry #ifdef PCI_ADDR_FIXUP
     78       1.1  cherry #include <arch/x86/pci/pci_addr_fixup.h>
     79       1.4    maxv #endif
     80       1.1  cherry #endif
     81       1.1  cherry 
     82       1.6  cherry #if defined(XENPV) && (defined(MPBIOS) || NACPICA > 0)
     83       1.1  cherry struct mp_bus *mp_busses;
     84       1.1  cherry int mp_nbus;
     85       1.1  cherry struct mp_intr_map *mp_intrs;
     86       1.1  cherry int mp_nintr;
     87       1.4    maxv 
     88       1.4    maxv int mp_isa_bus = -1;	/* XXX */
     89       1.4    maxv int mp_eisa_bus = -1;	/* XXX */
     90       1.1  cherry 
     91       1.1  cherry #ifdef MPVERBOSE
     92       1.1  cherry int mp_verbose = 1;
     93       1.1  cherry #else /* MPVERBOSE */
     94       1.1  cherry int mp_verbose = 0;
     95       1.1  cherry #endif /* MPVERBOSE */
     96       1.1  cherry #endif /* defined(MPBIOS) || NACPICA > 0 */
     97       1.1  cherry #endif /* NPCI > 0 */
     98       1.1  cherry 
     99       1.3  cherry extern bool acpi_present;
    100       1.3  cherry extern bool mpacpi_active;
    101       1.1  cherry 
    102       1.3  cherry void	xen_mainbus_attach(device_t, device_t, void *);
    103  1.6.12.1  bouyer static int	xen_mainbus_print(void *, const char *);
    104       1.1  cherry 
    105       1.3  cherry union xen_mainbus_attach_args {
    106       1.1  cherry 	const char *mba_busname;		/* first elem of all */
    107       1.1  cherry 	struct cpu_attach_args mba_caa;
    108       1.1  cherry #if NHYPERVISOR > 0
    109       1.1  cherry 	struct hypervisor_attach_args mba_haa;
    110       1.1  cherry #endif
    111       1.1  cherry #if NIPMI > 0
    112       1.1  cherry 	struct ipmi_attach_args mba_ipmi;
    113       1.1  cherry #endif
    114       1.1  cherry };
    115       1.1  cherry 
    116       1.1  cherry /*
    117       1.1  cherry  * Attach the mainbus.
    118       1.1  cherry  */
    119       1.1  cherry void
    120       1.3  cherry xen_mainbus_attach(device_t parent, device_t self, void *aux)
    121       1.1  cherry {
    122       1.3  cherry 	union xen_mainbus_attach_args mba;
    123       1.1  cherry 
    124  1.6.12.1  bouyer #if NIPMI > 0 && defined(XENPV)
    125       1.1  cherry 	memset(&mba.mba_ipmi, 0, sizeof(mba.mba_ipmi));
    126       1.1  cherry 	mba.mba_ipmi.iaa_iot = x86_bus_space_io;
    127       1.1  cherry 	mba.mba_ipmi.iaa_memt = x86_bus_space_mem;
    128       1.1  cherry 	if (ipmi_probe(&mba.mba_ipmi))
    129       1.1  cherry 		config_found_ia(self, "ipmibus", &mba.mba_ipmi, 0);
    130       1.1  cherry #endif
    131       1.1  cherry 
    132       1.1  cherry 	mba.mba_haa.haa_busname = "hypervisor";
    133       1.3  cherry 	config_found_ia(self, "hypervisorbus", &mba.mba_haa, xen_mainbus_print);
    134       1.1  cherry 
    135       1.1  cherry 	/* save/restore for Xen */
    136       1.1  cherry 	if (!pmf_device_register(self, NULL, NULL))
    137       1.1  cherry 		aprint_error_dev(self, "couldn't establish power handler\n");
    138       1.1  cherry }
    139       1.1  cherry 
    140  1.6.12.1  bouyer static int
    141       1.3  cherry xen_mainbus_print(void *aux, const char *pnp)
    142       1.1  cherry {
    143       1.3  cherry 	union xen_mainbus_attach_args *mba = aux;
    144       1.1  cherry 
    145       1.1  cherry 	if (pnp)
    146       1.1  cherry 		aprint_normal("%s at %s", mba->mba_busname, pnp);
    147       1.4    maxv 	return UNCONF;
    148       1.1  cherry }
    149