diff --git a/sys/arch/xen/conf/files.compat b/sys/arch/xen/conf/files.compat index 893574609bdd..40172a14d66f 100644 --- a/sys/arch/xen/conf/files.compat +++ b/sys/arch/xen/conf/files.compat @@ -1,4 +1,4 @@ -# $NetBSD: files.compat,v 1.10 2006/01/15 22:09:51 bouyer Exp $ +# $NetBSD: files.compat,v 1.11 2006/04/09 19:28:00 bouyer Exp $ # NetBSD: files.x86,v 1.10 2003/10/08 17:30:00 bouyer Exp # options for MP configuration through the MP spec @@ -27,7 +27,6 @@ defflag vesabios.h XXXVESABIOS defflag bioscall.h XXXBIOSCALL defflag opt_pcibios.h XXXOPT_PCIBIOS defflag opt_pcifixup.h XXXOPT_PCIFIXUP -defflag acpi.h XXXACPI defflag opt_mpacpi.h XXXOPT_MPACPI defflag opt_mpbios.h XXXOPT_MPBIOS diff --git a/sys/arch/xen/conf/files.xen b/sys/arch/xen/conf/files.xen index 698026ed8356..118be52750f2 100644 --- a/sys/arch/xen/conf/files.xen +++ b/sys/arch/xen/conf/files.xen @@ -1,4 +1,4 @@ -# $NetBSD: files.xen,v 1.39 2006/04/04 03:13:12 gdamore Exp $ +# $NetBSD: files.xen,v 1.40 2006/04/09 19:28:01 bouyer Exp $ # NetBSD: files.x86,v 1.10 2003/10/08 17:30:00 bouyer Exp # NetBSD: files.i386,v 1.254 2004/03/25 23:32:10 jmc Exp @@ -22,6 +22,12 @@ defflag opt_beep.h BEEP_ONHALT defparam opt_beep.h BEEP_ONHALT_COUNT defparam opt_beep.h BEEP_ONHALT_PITCH BEEP_ONHALT_PERIOD +# PCI fixup options +defflag opt_pcifixup.h PCI_ADDR_FIXUP PCI_BUS_FIXUP + PCI_INTR_FIXUP PCI_INTR_FIXUP_FORCE + +defparam PCI_CONF_MODE + file arch/xen/i386/autoconf.c file arch/i386/i386/db_dbgreg.S ddb | kstack_check_dr0 file arch/i386/i386/db_disasm.c ddb @@ -116,7 +122,7 @@ attach mainbus at root file arch/xen/i386/mainbus.c mainbus # Xen hypervisor -device hypervisor { }: isabus, pcibus, sysmon_power, xendevbus +device hypervisor { }: isabus, pcibus, sysmon_power, xendevbus, acpibus attach hypervisor at hypervisorbus file arch/xen/xen/hypervisor.c hypervisor needs-flag @@ -185,6 +191,16 @@ include "dev/usb/files.usb" include "dev/ieee1394/files.ieee1394" +device fdc {drive = -1} #XXX + +include "dev/acpi/files.acpi" +file arch/xen/xen/xen_acpi_machdep.c acpi +file arch/x86/x86/acpi_machdep.c acpi +file arch/x86/x86/i8259.c acpi + +file arch/i386/pci/pci_bus_fixup.c pci_bus_fixup +file arch/i386/pci/pci_addr_fixup.c pci_addr_fixup + # PCI-Host bridge chipsets device pchb: pcibus, agpbus, agp_ali, agp_amd, agp_i810, agp_intel, agp_sis, agp_via @@ -278,7 +294,9 @@ file arch/xen/xen/privcmd.c dom0ops file arch/xen/i386/xen_shm_machdep.c dom0ops file arch/xen/xen/xbdback.c dom0ops & !xen3 file arch/xen/xen/xennetback.c dom0ops & !xen3 -file arch/xen/xen/pci_machdep.c hypervisor & pci +file arch/xen/xen/pci_machdep.c hypervisor & pci & !xen3 +file arch/x86/pci/pci_machdep.c hypervisor & pci & xen3 +file arch/xen/xen/pci_intr_machdep.c hypervisor & pci file arch/xen/xen/isa_machdep.c hypervisor & dom0ops file arch/xen/xen/xenevt.c xenevt & dom0ops diff --git a/sys/arch/xen/i386/machdep.c b/sys/arch/xen/i386/machdep.c index 13519cd193e8..059006993385 100644 --- a/sys/arch/xen/i386/machdep.c +++ b/sys/arch/xen/i386/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.26 2006/03/23 04:14:33 jld Exp $ */ +/* $NetBSD: machdep.c,v 1.27 2006/04/09 19:28:01 bouyer Exp $ */ /* NetBSD: machdep.c,v 1.559 2004/07/22 15:12:46 mycroft Exp */ /*- @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.26 2006/03/23 04:14:33 jld Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.27 2006/04/09 19:28:01 bouyer Exp $"); #include "opt_beep.h" #include "opt_compat_ibcs2.h" @@ -162,20 +162,12 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.26 2006/03/23 04:14:33 jld Exp $"); #include #endif -#include "acpi.h" -#include "apm.h" #include "bioscall.h" #if NBIOSCALL > 0 #include #endif -#if NACPI > 0 -#include -#define ACPI_MACHDEP_PRIVATE -#include -#endif - #if NAPM > 0 #include #endif @@ -838,13 +830,6 @@ haltsys: #endif if ((howto & RB_POWERDOWN) == RB_POWERDOWN) { -#if NACPI > 0 - if (acpi_softc != NULL) { - delay(500000); - acpi_enter_sleep_state(acpi_softc, ACPI_STATE_S5); - printf("WARNING: ACPI powerdown failed!\n"); - } -#endif #if NAPM > 0 && !defined(APM_NO_POWEROFF) /* turn off, if we can. But try to turn disk off and * wait a bit first--some disk drives are slow to clean up @@ -1582,11 +1567,6 @@ init386(paddr_t first_avail) realmode_reserved_size = MP_TRAMPOLINE; /* XXX */ needs_earlier_install_pte0 = 1; /* XXX */ #endif /* XXX */ -#if NACPI > 0 - /* trampoline code for wake handler */ - realmode_reserved_size += ptoa(acpi_md_get_npages_of_wakecode()+1); - needs_earlier_install_pte0 = 1; -#endif if (needs_earlier_install_pte0) { /* page table for directory entry 0 */ realmode_reserved_size += PAGE_SIZE; @@ -1953,40 +1933,6 @@ init386(paddr_t first_avail) realmode_reserved_start += PAGE_SIZE; #endif -#if NACPI > 0 - /* - * Steal memory for the acpi wake code - */ - { - paddr_t paddr, p; - psize_t sz; - int npg; - - paddr = realmode_reserved_start; - npg = acpi_md_get_npages_of_wakecode(); - sz = ptoa(npg); -#ifdef DIAGNOSTIC - if (realmode_reserved_size < sz) { - panic("cannot steal memory for ACPI wake code."); - } -#endif - - /* identical mapping */ - p = paddr; - for (x=0; x -__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.7 2005/12/11 12:19:48 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.8 2006/04/09 19:28:01 bouyer Exp $"); #include #include @@ -40,53 +40,12 @@ __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.7 2005/12/11 12:19:48 christos Exp $") #include -#include -#include -#include - -#include /* for ISA_HOLE_VADDR */ - -#include "pci.h" -#include "eisa.h" -#include "isa.h" -#include "isadma.h" -#include "mca.h" -#include "apm.h" -#include "pnpbios.h" -#include "acpi.h" -#include "vesabios.h" #include "hypervisor.h" -#include "opt_mpacpi.h" -#include "opt_mpbios.h" #include "opt_xen.h" #include #include -#include -#include - -#if NAPM > 0 -#include -#include -#endif - -#if NPNPBIOS > 0 -#include -#endif - -#if NACPI > 0 -#include -#include -#endif - -#if NMCA > 0 -#include -#endif - -#if NVESABIOS > 0 -#include -#endif #ifdef XEN #include @@ -103,26 +62,7 @@ int mainbus_print(void *, const char *); union mainbus_attach_args { const char *mba_busname; /* first elem of all */ - struct pcibus_attach_args mba_pba; - struct eisabus_attach_args mba_eba; - struct isabus_attach_args mba_iba; -#if NMCA > 0 - struct mcabus_attach_args mba_mba; -#endif -#if NAPM > 0 - struct apm_attach_args mba_aaa; -#endif -#if NPNPBIOS > 0 - struct pnpbios_attach_args mba_paa; -#endif struct cpu_attach_args mba_caa; - struct apic_attach_args aaa_caa; -#if NACPI > 0 - struct acpibus_attach_args mba_acpi; -#endif -#if NVESABIOS > 0 - struct vesabios_attach_args mba_vba; -#endif #if NHYPERVISOR > 0 struct hypervisor_attach_args mba_haa; #endif @@ -189,178 +129,15 @@ mainbus_attach(parent, self, aux) void *aux; { union mainbus_attach_args mba; -#if NACPI > 0 - int acpi_present = 0; -#endif -#ifdef MPBIOS - int mpbios_present = 0; -#endif - int mpacpi_active = 0; printf("\n"); -#ifdef MPBIOS - mpbios_present = mpbios_probe(self); -#endif - -#if XXXNPCI > 0 - /* - * ACPI needs to be able to access PCI configuration space. - */ - pci_mode = pci_mode_detect(); -#endif - -#if NACPI > 0 - acpi_present = acpi_probe(); -#ifdef MPACPI - /* - * First, see if the MADT contains CPUs, and possibly I/O APICs. - * Building the interrupt routing structures can only - * be done later (via a callback). - */ - if (acpi_present) - mpacpi_active = mpacpi_scan_apics(self); -#endif -#endif - - if (!mpacpi_active) { -#ifdef MPBIOS - if (mpbios_present) - mpbios_scan(self); - else -#endif - { - struct cpu_attach_args caa; - - memset(&caa, 0, sizeof(caa)); - caa.caa_name = "cpu"; - caa.cpu_number = 0; - caa.cpu_role = CPU_ROLE_SP; - caa.cpu_func = 0; - - config_found_ia(self, "cpubus", &caa, mainbus_print); - } - } - -#if NVESABIOS > 0 - if (vbeprobe()) { - mba.mba_vba.vaa_busname = "vesabios"; - config_found_ia(self, "vesabiosbus", &mba.mba_vba, mainbus_print); - } -#endif - -#if NISADMA > 0 && (NACPI > 0 || NPNPBIOS > 0) - /* - * ACPI and PNPBIOS need ISA DMA initialized before they start probing. - */ - isa_dmainit(&x86_isa_chipset, X86_BUS_SPACE_IO, &isa_bus_dma_tag, - self); -#endif - -#if NACPI > 0 - if (acpi_present) { - mba.mba_acpi.aa_busname = "acpi"; - mba.mba_acpi.aa_iot = X86_BUS_SPACE_IO; - mba.mba_acpi.aa_memt = X86_BUS_SPACE_MEM; - mba.mba_acpi.aa_pc = NULL; - mba.mba_acpi.aa_pciflags = - PCI_FLAGS_IO_ENABLED | PCI_FLAGS_MEM_ENABLED | - PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | - PCI_FLAGS_MWI_OKAY; - mba.mba_acpi.aa_ic = &x86_isa_chipset; - config_found_ia(self, "acpibus", &mba.mba_acpi, mainbus_print); -#if 0 /* XXXJRT not yet */ - if (acpi_active) { - /* - * ACPI already did all the work for us, there - * is nothing more for us to do. - */ - return; - } -#endif - } -#endif - -#if NPNPBIOS > 0 -#if NACPI > 0 - if (acpi_active == 0) -#endif - if (pnpbios_probe()) { - mba.mba_paa.paa_busname = "pnpbios"; - mba.mba_paa.paa_ic = &x86_isa_chipset; - config_found_ia(self, "pnpbuisbus", &mba.mba_paa, - mainbus_print); - } -#endif - - /* - * XXX Note also that the presence of a PCI bus should - * XXX _always_ be checked, and if present the bus should be - * XXX 'found'. However, because of the structure of the code, - * XXX that's not currently possible. - */ -#if XXXNPCI > 0 - if (pci_mode != 0) { - mba.mba_pba.pba_iot = X86_BUS_SPACE_IO; - mba.mba_pba.pba_memt = X86_BUS_SPACE_MEM; - mba.mba_pba.pba_dmat = &pci_bus_dma_tag; - mba.mba_pba.pba_dmat64 = NULL; - mba.mba_pba.pba_pc = NULL; - mba.mba_pba.pba_flags = pci_bus_flags(); - mba.mba_pba.pba_bus = 0; - mba.mba_pba.pba_bridgetag = NULL; -#if defined(MPACPI) && defined(MPACPI_SCANPCI) - if (mpacpi_active) - mpacpi_scan_pci(self, &mba.mba_pba, pcibusprint); - else -#endif -#if defined(MPBIOS) && defined(MPBIOS_SCANPCI) - if (mpbios_scanned != 0) - mpbios_scan_pci(self, &mba.mba_pba, pcibusprint); - else -#endif - config_found_ia(self, "pcibus", &mba.mba_pba, pcibusprint); - } -#endif - -#if NMCA > 0 - /* Note: MCA bus probe is done in i386/machdep.c */ - if (MCA_system) { - mba.mba_mba.mba_iot = X86_BUS_SPACE_IO; - mba.mba_mba.mba_memt = X86_BUS_SPACE_MEM; - mba.mba_mba.mba_dmat = &mca_bus_dma_tag; - mba.mba_mba.mba_mc = NULL; - mba.mba_mba.mba_bus = 0; - config_found_ia(self, "mcabus", &mba.mba_mba, mcabusprint); - } -#endif - -#ifndef XEN - if (memcmp(ISA_HOLE_VADDR(EISA_ID_PADDR), EISA_ID, EISA_ID_LEN) == 0 && - eisa_has_been_seen == 0) { - mba.mba_eba.eba_iot = X86_BUS_SPACE_IO; - mba.mba_eba.eba_memt = X86_BUS_SPACE_MEM; -#if NEISA > 0 - mba.mba_eba.eba_dmat = &eisa_bus_dma_tag; -#endif - config_found_ia(self, "eisabus", &mba.mba_eba, eisabusprint); - } -#endif - -#if XXXNISA > 0 - if (isa_has_been_seen == 0) - config_found_ia(self, "isabus", &mba_iba, isabusprint); -#endif - -#if NAPM > 0 -#if NACPI > 0 - if (acpi_active == 0) -#endif - if (apm_busprobe()) { - mba.mba_aaa.aaa_busname = "apm"; - config_found_ia(self, "apmbus", &mba.mba_aaa, mainbus_print); - } -#endif + memset(&mba.mba_caa, 0, sizeof(mba.mba_caa)); + mba.mba_caa.caa_name = "cpu"; + mba.mba_caa.cpu_number = 0; + mba.mba_caa.cpu_role = CPU_ROLE_SP; + mba.mba_caa.cpu_func = 0; + config_found_ia(self, "cpubus", &mba.mba_caa, mainbus_print); #if NHYPERVISOR > 0 mba.mba_haa.haa_busname = "hypervisor"; diff --git a/sys/arch/xen/include/acpi_func.h b/sys/arch/xen/include/acpi_func.h new file mode 100644 index 000000000000..6b5c3049290a --- /dev/null +++ b/sys/arch/xen/include/acpi_func.h @@ -0,0 +1,3 @@ +/* $NetBSD: acpi_func.h,v 1.1 2006/04/09 19:28:01 bouyer Exp $ */ + +#include diff --git a/sys/arch/xen/include/acpi_machdep.h b/sys/arch/xen/include/acpi_machdep.h new file mode 100644 index 000000000000..c3d9bb43c1ab --- /dev/null +++ b/sys/arch/xen/include/acpi_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: acpi_machdep.h,v 1.1 2006/04/09 19:28:01 bouyer Exp $ */ + +#include diff --git a/sys/arch/xen/include/intr.h b/sys/arch/xen/include/intr.h index 89e14d8ffa0f..40ba90d99802 100644 --- a/sys/arch/xen/include/intr.h +++ b/sys/arch/xen/include/intr.h @@ -1,4 +1,4 @@ -/* $NetBSD: intr.h,v 1.9 2006/02/16 20:17:15 perry Exp $ */ +/* $NetBSD: intr.h,v 1.10 2006/04/09 19:28:01 bouyer Exp $ */ /* NetBSD intr.h,v 1.15 2004/10/31 10:39:34 yamt Exp */ /*- @@ -46,6 +46,13 @@ #include #include +#include "opt_xen.h" + +#ifdef XEN3 +/* for x86 compatibility */ +extern struct intrstub i8259_stubs[]; +#endif + /* * Struct describing an event channel. */ @@ -209,6 +216,7 @@ struct pcibus_attach_args; void intr_default_setup(void); int x86_nmi(void); void intr_calculatemasks(struct evtsource *); + void *intr_establish(int, struct pic *, int, int, int, int (*)(void *), void *); void intr_disestablish(struct intrhand *); const char *intr_string(int); @@ -217,6 +225,7 @@ void cpu_intr_init(struct cpu_info *); void intr_printconfig(void); #endif + #endif /* !_LOCORE */ /* diff --git a/sys/arch/xen/include/intrdefs.h b/sys/arch/xen/include/intrdefs.h index 5e1dab5e42f4..3d38870c42ac 100644 --- a/sys/arch/xen/include/intrdefs.h +++ b/sys/arch/xen/include/intrdefs.h @@ -1,4 +1,4 @@ -/* $NetBSD: intrdefs.h,v 1.4 2005/12/11 12:19:48 christos Exp $ */ +/* $NetBSD: intrdefs.h,v 1.5 2006/04/09 19:28:01 bouyer Exp $ */ /* NetBSD intrdefs.h,v 1.3 2003/06/16 20:01:06 thorpej Exp */ #ifndef _XEN_INTRDEFS_H @@ -59,4 +59,6 @@ #define IST_EDGE 2 /* edge-triggered */ #define IST_LEVEL 3 /* level-triggered */ +#define NUM_LEGACY_IRQS 16 + #endif /* _XEN_INTRDEFS_H */ diff --git a/sys/arch/xen/include/pci_machdep.h b/sys/arch/xen/include/pci_machdep.h index c64000923b20..39c539240c54 100644 --- a/sys/arch/xen/include/pci_machdep.h +++ b/sys/arch/xen/include/pci_machdep.h @@ -1,7 +1,7 @@ -/* $NetBSD: pci_machdep.h,v 1.5 2005/12/11 12:19:48 christos Exp $ */ +/* $NetBSD: pci_machdep.h,v 1.6 2006/04/09 19:28:01 bouyer Exp $ */ /* - * Copyright (c) 2005 Manuel Bouyer. + * Copyright (c) 2006 Manuel Bouyer. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,15 +30,65 @@ * */ +/* + * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. + * Copyright (c) 1994 Charles M. Hannum. 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 Charles M. Hannum. + * 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. + */ + #ifndef _XEN_PCI_MACHDEP_H_ #define _XEN_PCI_MACHDEP_H_ +#include "opt_xen.h" + extern struct x86_bus_dma_tag pci_bus_dma_tag; -extern u_int32_t pci_bus_attached[]; +#ifdef _LP64 +extern struct x86_bus_dma_tag pci_bus_dma64_tag; +#endif /* Some values appropriate for x86, from x86/include/pci_machdep.h */ #define __HAVE_PCIIDE_MACHDEP_COMPAT_INTR_ESTABLISH #define PCI_PREFER_IOSPACE + +#ifdef XEN3 +union x86_pci_tag_u { + u_int32_t mode1; + struct { + u_int16_t port; + u_int8_t enable; + u_int8_t forward; + } mode2; +}; + +typedef union x86_pci_tag_u pcitag_t; + +#else /* XEN3 */ + +extern u_int32_t pci_bus_attached[]; + #define PCI_MACHDEP_ENUMERATE_BUS xen_pci_enumerate_bus /* types provided to MI PCI */ @@ -49,13 +99,16 @@ struct xen_pci_tag { u_int8_t _pad; /* pad to 32bits */ }; +typedef struct xen_pci_tag pcitag_t; +#endif /* !XEN3 */ + +typedef void *pci_chipset_tag_t; + struct xen_intr_handle { int pirq; int evtch; }; -typedef struct xen_pci_tag pcitag_t; -typedef void *pci_chipset_tag_t; typedef struct xen_intr_handle pci_intr_handle_t; /* functions provided to MI PCI */ @@ -85,4 +138,20 @@ int xen_pci_enumerate_bus(struct pci_softc *, const int *, * controller on a PC. */ #define X86_PCI_INTERRUPT_LINE_NO_CONNECTION 0xff + +extern int pci_mode; +int pci_mode_detect(void); +int pci_bus_flags(void); + +void pci_device_foreach(pci_chipset_tag_t, int, + void (*)(pci_chipset_tag_t, pcitag_t, void*), + void *); + +void pci_device_foreach_min(pci_chipset_tag_t, int, int, + void (*)(pci_chipset_tag_t, pcitag_t, void*), + void *); + +void pci_bridge_foreach(pci_chipset_tag_t, int, int, + void (*) (pci_chipset_tag_t, pcitag_t, void *), void *); + #endif /* _XEN_PCI_MACHDEP_H_ */ diff --git a/sys/arch/xen/x86/intr.c b/sys/arch/xen/x86/intr.c index 29b5a737c6d1..8a642f0a1e3c 100644 --- a/sys/arch/xen/x86/intr.c +++ b/sys/arch/xen/x86/intr.c @@ -103,10 +103,12 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.7 2005/12/11 12:19:50 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.8 2006/04/09 19:28:01 bouyer Exp $"); #include "opt_multiprocessor.h" #include "opt_xen.h" +#include "isa.h" +#include "pci.h" #include #include @@ -122,6 +124,15 @@ __KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.7 2005/12/11 12:19:50 christos Exp $"); #include #include #include +#include + +#ifdef XEN3 +#include "acpi.h" +#if NACPI > 0 +/* for x86/i8259.c */ +struct intrstub i8259_stubs[NUM_LEGACY_IRQS] = {{0}}; +#endif +#endif /* * Recalculate the interrupt from scratch for an event source. @@ -229,9 +240,28 @@ cpu_intr_init(struct cpu_info *ci) evcnt_attach_dynamic(&softxenevt_evtcnt, EVCNT_TYPE_INTR, NULL, ci->ci_dev->dv_xname, "xenevt"); #endif /* defined(DOM0OPS) */ - } +#if NPCI > 0 || NISA > 0 +void * +intr_establish(int legacy_irq, struct pic *pic, int pin, + int type, int level, int (*handler)(void *) , void *arg) +{ + struct pintrhand *ih; + + ih = pirq_establish(legacy_irq, bind_pirq_to_evtch(legacy_irq), + handler, arg, level); + return ih; +} + +void +intr_disestablish(struct intrhand *ih) +{ + printf("intr_disestablish irq\n"); +} +#endif + + #ifdef INTRDEBUG void intr_printconfig(void) diff --git a/sys/arch/xen/xen/hypervisor.c b/sys/arch/xen/xen/hypervisor.c index 5f41582907b5..fda9e0caab9f 100644 --- a/sys/arch/xen/xen/hypervisor.c +++ b/sys/arch/xen/xen/hypervisor.c @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor.c,v 1.22 2006/03/19 15:11:50 bouyer Exp $ */ +/* $NetBSD: hypervisor.c,v 1.23 2006/04/09 19:28:01 bouyer Exp $ */ /* * Copyright (c) 2005 Manuel Bouyer. @@ -63,7 +63,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.22 2006/03/19 15:11:50 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.23 2006/04/09 19:28:01 bouyer Exp $"); #include #include @@ -78,6 +78,7 @@ __KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.22 2006/03/19 15:11:50 bouyer Exp $ #include "npx.h" #include "isa.h" #include "pci.h" +#include "acpi.h" #include "opt_xen.h" @@ -88,7 +89,7 @@ __KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.22 2006/03/19 15:11:50 bouyer Exp $ #include #endif -#ifdef DOM0OPS +#if defined(DOM0OPS) || defined(XEN3) #include #include #include @@ -97,9 +98,26 @@ __KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.22 2006/03/19 15:11:50 bouyer Exp $ #include #include #include +#endif /* DOM0OPS || XEN3 */ +#ifdef XEN3 +#include #endif #if NPCI > 0 #include +#if NACPI > 0 +#include +#include +#endif +#ifdef PCI_BUS_FIXUP +#include +#ifdef PCI_ADDR_FIXUP +#include +#endif +#endif +#endif /* NPCI */ + +#if NXENBUS > 0 +#include #endif #ifdef XEN3 #include @@ -148,6 +166,15 @@ union hypervisor_attach_cookie { #if NNPX > 0 struct xen_npx_attach_args hac_xennpx; #endif +#if NPCI > 0 + struct pcibus_attach_args hac_pba; +#if defined(DOM0OPS) && NISA > 0 + struct isabus_attach_args hac_iba; +#endif +#if NACPI > 0 + struct acpibus_attach_args hac_acpi; +#endif +#endif /* NPCI */ }; /* @@ -198,16 +225,18 @@ hypervisor_attach(parent, self, aux) struct device *parent, *self; void *aux; { -#if NPCI > 0 - struct pcibus_attach_args pba; -#if defined(DOM0OPS) && NISA > 0 - struct isabus_attach_args iba; -#endif +#if NPCI >0 #ifndef XEN3 physdev_op_t physdev_op; int i, j, busnum; #endif +#if NACPI > 0 + int acpi_present = 0; #endif +#ifdef PCI_BUS_FIXUP + int pci_maxbus = 0; +#endif +#endif /* NPCI */ union hypervisor_attach_cookie hac; printf("\n"); @@ -221,7 +250,6 @@ hypervisor_attach(parent, self, aux) hac.hac_xenbus.xa_device = "xenbus"; config_found_ia(self, "xendevbus", &hac.hac_xenbus, hypervisor_print); #endif - #if NXENCONS > 0 hac.hac_xencons.xa_device = "xencons"; config_found_ia(self, "xendevbus", &hac.hac_xencons, hypervisor_print); @@ -240,14 +268,39 @@ hypervisor_attach(parent, self, aux) #endif #if NPCI > 0 #ifdef XEN3 - pba.pba_iot = X86_BUS_SPACE_IO; - pba.pba_memt = X86_BUS_SPACE_MEM; - pba.pba_dmat = &pci_bus_dma_tag; - pba.pba_dmat64 = 0; - pba.pba_flags = PCI_FLAGS_MEM_ENABLED | PCI_FLAGS_IO_ENABLED; - pba.pba_bridgetag = NULL; - pba.pba_bus = 0; - config_found_ia(self, "pcibus", &pba, pcibusprint); + pci_mode = pci_mode_detect(); +#ifdef PCI_BUS_FIXUP + pci_maxbus = pci_bus_fixup(NULL, 0); + aprint_debug("PCI bus max, after pci_bus_fixup: %i\n", pci_maxbus); +#ifdef PCI_ADDR_FIXUP + pciaddr.extent_port = NULL; + pciaddr.extent_mem = NULL; + pci_addr_fixup(NULL, pci_maxbus); +#endif +#endif + +#if NACPI > 0 + acpi_present = acpi_probe(); + if (acpi_present) { + hac.hac_acpi.aa_iot = X86_BUS_SPACE_IO; + hac.hac_acpi.aa_memt = X86_BUS_SPACE_MEM; + hac.hac_acpi.aa_pc = NULL; + hac.hac_acpi.aa_pciflags = + PCI_FLAGS_IO_ENABLED | PCI_FLAGS_MEM_ENABLED | + PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | + PCI_FLAGS_MWI_OKAY; + hac.hac_acpi.aa_ic = &x86_isa_chipset; + config_found_ia(self, "acpibus", &hac.hac_acpi, 0); + } +#endif /* NACPI */ + hac.hac_pba.pba_iot = X86_BUS_SPACE_IO; + hac.hac_pba.pba_memt = X86_BUS_SPACE_MEM; + hac.hac_pba.pba_dmat = &pci_bus_dma_tag; + hac.hac_pba.pba_dmat64 = 0; + hac.hac_pba.pba_flags = PCI_FLAGS_MEM_ENABLED | PCI_FLAGS_IO_ENABLED; + hac.hac_pba.pba_bridgetag = NULL; + hac.hac_pba.pba_bus = 0; + config_found_ia(self, "pcibus", &hac.hac_pba, pcibusprint); #else physdev_op.cmd = PHYSDEVOP_PCI_PROBE_ROOT_BUSES; if ((i = HYPERVISOR_physdev_op(&physdev_op)) < 0) { @@ -271,15 +324,15 @@ hypervisor_attach(parent, self, aux) busnum); continue; } - pba.pba_iot = X86_BUS_SPACE_IO; - pba.pba_memt = X86_BUS_SPACE_MEM; - pba.pba_dmat = &pci_bus_dma_tag; - pba.pba_dmat64 = 0; - pba.pba_flags = PCI_FLAGS_MEM_ENABLED | + hac.hac_pba.pba_iot = X86_BUS_SPACE_IO; + hac.hac_pba.pba_memt = X86_BUS_SPACE_MEM; + hac.hac_pba.pba_dmat = &pci_bus_dma_tag; + hac.hac_pba.pba_dmat64 = 0; + hac.hac_pba.pba_flags = PCI_FLAGS_MEM_ENABLED | PCI_FLAGS_IO_ENABLED; - pba.pba_bridgetag = NULL; - pba.pba_bus = busnum; - config_found_ia(self, "pcibus", &pba, + hac.hac_pba.pba_bridgetag = NULL; + hac.hac_pba.pba_bus = busnum; + config_found_ia(self, "pcibus", &hac.hac_pba, pcibusprint); } } @@ -287,19 +340,23 @@ hypervisor_attach(parent, self, aux) #endif /* XEN3 */ #if defined(DOM0OPS) && NISA > 0 if (isa_has_been_seen == 0) { - iba._iba_busname = "isa"; - iba.iba_iot = X86_BUS_SPACE_IO; - iba.iba_memt = X86_BUS_SPACE_MEM; - iba.iba_dmat = &isa_bus_dma_tag; - iba.iba_ic = NULL; /* No isa DMA yet */ - config_found_ia(self, "isabus", &iba, isabusprint); + hac.hac_iba._iba_busname = "isa"; + hac.hac_iba.iba_iot = X86_BUS_SPACE_IO; + hac.hac_iba.iba_memt = X86_BUS_SPACE_MEM; + hac.hac_iba.iba_dmat = &isa_bus_dma_tag; + hac.hac_iba.iba_ic = NULL; /* No isa DMA yet */ + config_found_ia(self, "isabus", &hac.hac_iba, isabusprint); } #endif #endif /* NPCI */ +#if defined(DOM0OPS) && !defined(XEN3) + if (xen_start_info.flags & SIF_PRIVILEGED) + xenkernfs_init(); +#endif + #ifdef DOM0OPS if (xen_start_info.flags & SIF_PRIVILEGED) { - xenkernfs_init(); xenprivcmd_init(); xen_shm_init(); #ifndef XEN3 @@ -331,7 +388,7 @@ hypervisor_print(aux, parent) return (UNCONF); } -#ifdef DOM0OPS +#if defined(DOM0OPS) || defined(XEN3) #define DIR_MODE (S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) @@ -347,7 +404,7 @@ xenkernfs_init() kernfs_addentry(NULL, dkt); kernxen_pkt = KERNFS_ENTOPARENTDIR(dkt); } -#endif +#endif /* DOM0OPS || XEN3 */ #ifndef XEN3 /* handler for the shutdown messages */ diff --git a/sys/arch/xen/xen/pci_intr_machdep.c b/sys/arch/xen/xen/pci_intr_machdep.c new file mode 100644 index 000000000000..09052c8e9ecb --- /dev/null +++ b/sys/arch/xen/xen/pci_intr_machdep.c @@ -0,0 +1,124 @@ +/* $NetBSD: pci_intr_machdep.c,v 1.1 2006/04/09 19:28:01 bouyer Exp $ */ + +/* + * Copyright (c) 2005 Manuel Bouyer. + * + * 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 Manuel Bouyer. + * 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 +#include +#include + +#include +#include + +#include +#include + +#include + +#include "locators.h" +#include "opt_ddb.h" + +int +pci_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp) +{ + pcireg_t intr; + int pin; + int line; + +#ifndef XEN3 + physdev_op_t physdev_op; + /* initialise device, to get the real IRQ */ + physdev_op.cmd = PHYSDEVOP_PCI_INITIALISE_DEVICE; + physdev_op.u.pci_initialise_device.bus = pa->pa_bus; + physdev_op.u.pci_initialise_device.dev = pa->pa_device; + physdev_op.u.pci_initialise_device.func = pa->pa_function; + if (HYPERVISOR_physdev_op(&physdev_op) < 0) + panic("HYPERVISOR_physdev_op(PHYSDEVOP_PCI_INITIALISE_DEVICE)"); +#endif /* !XEN3 */ + + intr = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_INTERRUPT_REG); + pin = pa->pa_intrpin; + pa->pa_intrline = line = PCI_INTERRUPT_LINE(intr); +#if 0 /* XXXX why is it always 0 ? */ + if (pin == 0) { + /* No IRQ used */ + goto bad; + } +#endif + if (pin > PCI_INTERRUPT_PIN_MAX) { + printf("pci_intr_map: bad interrupt pin %d\n", pin); + goto bad; + } + + if (line == 0 || line == X86_PCI_INTERRUPT_LINE_NO_CONNECTION) { + printf("pci_intr_map: no mapping for pin %c (line=%02x)\n", + '@' + pin, line); + goto bad; + } + + ihp->pirq = line; + ihp->evtch = bind_pirq_to_evtch(ihp->pirq); + if (ihp->evtch == -1) + goto bad; + + return 0; + +bad: + ihp->pirq = -1; + ihp->evtch = -1; + return 1; +} +const char +*pci_intr_string(pci_chipset_tag_t pc, pci_intr_handle_t ih) +{ + static char buf[64]; + snprintf(buf, 64, "irq %d, event channel %d", + ih.pirq, ih.evtch); + return buf; + +} + +const struct evcnt* +pci_intr_evcnt(pci_chipset_tag_t pcitag, pci_intr_handle_t intrh) +{ + return NULL; +} + +void * +pci_intr_establish(pci_chipset_tag_t pcitag, pci_intr_handle_t intrh, + int level, int (*func)(void *), void *arg) +{ + return (void *)pirq_establish(intrh.pirq, intrh.evtch, func, arg, level); +} + +void +pci_intr_disestablish(pci_chipset_tag_t pcitag, void *cookie) +{ +} diff --git a/sys/arch/xen/xen/pci_machdep.c b/sys/arch/xen/xen/pci_machdep.c index b733ca0ddc5f..097efbbd4c1d 100644 --- a/sys/arch/xen/xen/pci_machdep.c +++ b/sys/arch/xen/xen/pci_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: pci_machdep.c,v 1.7 2006/01/15 22:09:52 bouyer Exp $ */ +/* $NetBSD: pci_machdep.c,v 1.8 2006/04/09 19:28:01 bouyer Exp $ */ /* * Copyright (c) 2005 Manuel Bouyer. @@ -40,8 +40,6 @@ #include #include -#include - #include "locators.h" #include "opt_ddb.h" @@ -104,40 +102,9 @@ pci_decompose_tag(pci_chipset_tag_t pcitag, pcitag_t tag, *funcp = tag.function; } -#ifdef XEN3 -struct simplelock pci_conf_slock = SIMPLELOCK_INITIALIZER; -#define PCI_CONF_LOCK(s) \ -do { \ - (s) = splhigh(); \ - simple_lock(&pci_conf_slock); \ -} while (0) - -#define PCI_CONF_UNLOCK(s) \ -do { \ - simple_unlock(&pci_conf_slock); \ - splx((s)); \ -} while (0) -#define PCI_MODE1_ENABLE 0x80000000UL -#define PCI_MODE1_ADDRESS_REG 0x0cf8 -#define PCI_MODE1_DATA_REG 0x0cfc -#endif /* XEN3 */ - - - pcireg_t pci_conf_read(pci_chipset_tag_t pcitag, pcitag_t dev, int reg) { -#ifdef XEN3 - pcireg_t data; - int s; - PCI_CONF_LOCK(s); - outl(PCI_MODE1_ADDRESS_REG, PCI_MODE1_ENABLE | - (dev.bus << 16) | (dev.device << 11) | (dev.function << 8) | reg); - data = inl(PCI_MODE1_DATA_REG); - outl(PCI_MODE1_ADDRESS_REG, 0); - PCI_CONF_UNLOCK(s); - return data; -#else /* XEN3 */ physdev_op_t physdev_op; physdev_op.cmd = PHYSDEVOP_PCI_CFGREG_READ; @@ -156,22 +123,11 @@ pci_conf_read(pci_chipset_tag_t pcitag, pcitag_t dev, int reg) return 0xffffffff; } return physdev_op.u.pci_cfgreg_read.value; -#endif /* XEN3 */ } void pci_conf_write(pci_chipset_tag_t pcitag, pcitag_t dev, int reg, pcireg_t val) { -#ifdef XEN3 - int s; - PCI_CONF_LOCK(s); - outl(PCI_MODE1_ADDRESS_REG, PCI_MODE1_ENABLE | - (dev.bus << 16) | (dev.device << 11) | (dev.function << 8) | reg); - outl(PCI_MODE1_DATA_REG, val); - outl(PCI_MODE1_ADDRESS_REG, 0); - PCI_CONF_UNLOCK(s); - return; -#else /* XEN3 */ physdev_op_t physdev_op; physdev_op.cmd = PHYSDEVOP_PCI_CFGREG_WRITE; @@ -188,85 +144,6 @@ pci_conf_write(pci_chipset_tag_t pcitag, pcitag_t dev, int reg, pcireg_t val) Debugger(); #endif } -#endif /* XEN3 */ -} - -int -pci_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp) -{ - pcireg_t intr; - int pin; - int line; - -#ifndef XEN3 - physdev_op_t physdev_op; - /* initialise device, to get the real IRQ */ - physdev_op.cmd = PHYSDEVOP_PCI_INITIALISE_DEVICE; - physdev_op.u.pci_initialise_device.bus = pa->pa_bus; - physdev_op.u.pci_initialise_device.dev = pa->pa_device; - physdev_op.u.pci_initialise_device.func = pa->pa_function; - if (HYPERVISOR_physdev_op(&physdev_op) < 0) - panic("HYPERVISOR_physdev_op(PHYSDEVOP_PCI_INITIALISE_DEVICE)"); -#endif /* !XEN3 */ - - intr = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_INTERRUPT_REG); - pin = pa->pa_intrpin; - pa->pa_intrline = line = PCI_INTERRUPT_LINE(intr); -#if 0 /* XXXX why is it always 0 ? */ - if (pin == 0) { - /* No IRQ used */ - goto bad; - } -#endif - if (pin > PCI_INTERRUPT_PIN_MAX) { - printf("pci_intr_map: bad interrupt pin %d\n", pin); - goto bad; - } - - if (line == 0 || line == X86_PCI_INTERRUPT_LINE_NO_CONNECTION) { - printf("pci_intr_map: no mapping for pin %c (line=%02x)\n", - '@' + pin, line); - goto bad; - } - - ihp->pirq = line; - ihp->evtch = bind_pirq_to_evtch(ihp->pirq); - if (ihp->evtch == -1) - goto bad; - - return 0; - -bad: - ihp->pirq = -1; - ihp->evtch = -1; - return 1; -} -const char -*pci_intr_string(pci_chipset_tag_t pc, pci_intr_handle_t ih) -{ - static char buf[64]; - snprintf(buf, 64, "irq %d, event channel %d", - ih.pirq, ih.evtch); - return buf; - -} - -const struct evcnt* -pci_intr_evcnt(pci_chipset_tag_t pcitag, pci_intr_handle_t intrh) -{ - return NULL; -} - -void * -pci_intr_establish(pci_chipset_tag_t pcitag, pci_intr_handle_t intrh, - int level, int (*func)(void *), void *arg) -{ - return (void *)pirq_establish(intrh.pirq, intrh.evtch, func, arg, level); -} - -void -pci_intr_disestablish(pci_chipset_tag_t pcitag, void *cookie) -{ } /* diff --git a/sys/arch/xen/xen/xen_acpi_machdep.c b/sys/arch/xen/xen/xen_acpi_machdep.c new file mode 100644 index 000000000000..3ca441ac5a86 --- /dev/null +++ b/sys/arch/xen/xen/xen_acpi_machdep.c @@ -0,0 +1,15 @@ +/* $NetBSD: xen_acpi_machdep.c,v 1.1 2006/04/09 19:28:01 bouyer Exp $ */ + +#include "acpi.h" + +#include +#include +#define ACPI_MACHDEP_PRIVATE +#include + +int +acpi_md_sleep(int state) +{ + printf("acpi: sleep not implemented\n"); + return (-1); +}