mptable.c revision 186557
1182902Skmacy/*- 2182902Skmacy * Copyright (c) 2003 John Baldwin <jhb@FreeBSD.org> 3182902Skmacy * Copyright (c) 1996, by Steve Passe 4182902Skmacy * All rights reserved. 5182902Skmacy * 6182902Skmacy * Redistribution and use in source and binary forms, with or without 7182902Skmacy * modification, are permitted provided that the following conditions 8182902Skmacy * are met: 9182902Skmacy * 1. Redistributions of source code must retain the above copyright 10182902Skmacy * notice, this list of conditions and the following disclaimer. 11182902Skmacy * 2. The name of the developer may NOT be used to endorse or promote products 12182902Skmacy * derived from this software without specific prior written permission. 13182902Skmacy * 14182902Skmacy * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15182902Skmacy * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16182902Skmacy * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17182902Skmacy * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18182902Skmacy * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19182902Skmacy * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20182902Skmacy * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21182902Skmacy * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22182902Skmacy * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23182902Skmacy * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24182902Skmacy * SUCH DAMAGE. 25182902Skmacy */ 26182902Skmacy 27182902Skmacy#include <sys/cdefs.h> 28182902Skmacy__FBSDID("$FreeBSD: head/sys/i386/xen/mptable.c 186557 2008-12-29 06:31:03Z kmacy $"); 29182902Skmacy 30182902Skmacy#include <sys/param.h> 31182902Skmacy#include <sys/systm.h> 32182902Skmacy#include <sys/bus.h> 33182902Skmacy#include <sys/kernel.h> 34182902Skmacy#include <sys/malloc.h> 35182902Skmacy 36182902Skmacy#include <vm/vm.h> 37182902Skmacy#include <vm/vm_param.h> 38182902Skmacy#include <vm/pmap.h> 39182902Skmacy 40182902Skmacy#include <machine/apicreg.h> 41182902Skmacy#include <machine/frame.h> 42182902Skmacy#include <machine/intr_machdep.h> 43182902Skmacy#include <machine/apicvar.h> 44182902Skmacy#include <machine/md_var.h> 45182902Skmacy#include <machine/mptable.h> 46182902Skmacy#include <machine/specialreg.h> 47182902Skmacy 48186557Skmacy#include <xen/hypervisor.h> 49182902Skmacy#include <machine/xen/xen-os.h> 50182902Skmacy#include <machine/smp.h> 51182902Skmacy#include <xen/interface/vcpu.h> 52182902Skmacy 53182902Skmacy 54182902Skmacystatic int mptable_probe(void); 55182902Skmacystatic int mptable_probe_cpus(void); 56182902Skmacystatic void mptable_register(void *dummy); 57182902Skmacystatic int mptable_setup_local(void); 58182902Skmacystatic int mptable_setup_io(void); 59182902Skmacy 60182902Skmacystatic struct apic_enumerator mptable_enumerator = { 61182902Skmacy "MPTable", 62182902Skmacy mptable_probe, 63182902Skmacy mptable_probe_cpus, 64182902Skmacy mptable_setup_local, 65182902Skmacy mptable_setup_io 66182902Skmacy}; 67182902Skmacy 68182902Skmacystatic int 69182902Skmacymptable_probe(void) 70182902Skmacy{ 71182902Skmacy 72182902Skmacy return (-100); 73182902Skmacy} 74182902Skmacy 75182902Skmacystatic int 76182902Skmacymptable_probe_cpus(void) 77182902Skmacy{ 78182902Skmacy int i, rc; 79182902Skmacy 80182902Skmacy for (i = 0; i < MAXCPU; i++) { 81182902Skmacy rc = HYPERVISOR_vcpu_op(VCPUOP_is_up, i, NULL); 82182902Skmacy if (rc >= 0) 83182902Skmacy cpu_add(i, (i == 0)); 84182902Skmacy } 85182902Skmacy 86182902Skmacy return (0); 87182902Skmacy} 88182902Skmacy 89182902Skmacy/* 90182902Skmacy * Initialize the local APIC on the BSP. 91182902Skmacy */ 92182902Skmacystatic int 93182902Skmacymptable_setup_local(void) 94182902Skmacy{ 95182902Skmacy 96182902Skmacy return (0); 97182902Skmacy} 98182902Skmacy 99182902Skmacystatic int 100182902Skmacymptable_setup_io(void) 101182902Skmacy{ 102182902Skmacy 103182902Skmacy return (0); 104182902Skmacy} 105182902Skmacy 106182902Skmacystatic void 107182902Skmacymptable_register(void *dummy __unused) 108182902Skmacy{ 109182902Skmacy 110182902Skmacy apic_register_enumerator(&mptable_enumerator); 111182902Skmacy} 112182902SkmacySYSINIT(mptable_register, SI_SUB_CPU - 1, SI_ORDER_FIRST, mptable_register, 113182902Skmacy NULL); 114182902Skmacy 115182902Skmacy 116182902Skmacy 117182902Skmacyint 118182902Skmacymptable_pci_probe_table(int bus) 119182902Skmacy{ 120182902Skmacy 121182902Skmacy return (0); 122182902Skmacy} 123182902Skmacy 124182902Skmacyint 125182902Skmacymptable_pci_route_interrupt(device_t pcib, device_t dev, int pin) 126182902Skmacy{ 127182902Skmacy 128182902Skmacy return (0); 129182902Skmacy} 130182902Skmacy 131