mptable.c revision 256073
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 256073 2013-10-05 23:11:01Z gibbs $"); 29182902Skmacy 30182902Skmacy#include <sys/param.h> 31182902Skmacy#include <sys/bus.h> 32182902Skmacy#include <sys/kernel.h> 33182902Skmacy 34182902Skmacy#include <vm/vm.h> 35182902Skmacy#include <vm/vm_param.h> 36182902Skmacy#include <vm/pmap.h> 37182902Skmacy 38182902Skmacy#include <machine/frame.h> 39182902Skmacy#include <machine/intr_machdep.h> 40182902Skmacy#include <machine/apicvar.h> 41182902Skmacy 42186557Skmacy#include <xen/hypervisor.h> 43255040Sgibbs#include <xen/xen-os.h> 44182902Skmacy#include <machine/smp.h> 45182902Skmacy#include <xen/interface/vcpu.h> 46182902Skmacy 47182902Skmacy 48182902Skmacystatic int mptable_probe(void); 49182902Skmacystatic int mptable_probe_cpus(void); 50182902Skmacystatic void mptable_register(void *dummy); 51182902Skmacystatic int mptable_setup_local(void); 52182902Skmacystatic int mptable_setup_io(void); 53182902Skmacy 54182902Skmacystatic struct apic_enumerator mptable_enumerator = { 55182902Skmacy "MPTable", 56182902Skmacy mptable_probe, 57182902Skmacy mptable_probe_cpus, 58182902Skmacy mptable_setup_local, 59182902Skmacy mptable_setup_io 60182902Skmacy}; 61182902Skmacy 62182902Skmacystatic int 63182902Skmacymptable_probe(void) 64182902Skmacy{ 65182902Skmacy 66182902Skmacy return (-100); 67182902Skmacy} 68182902Skmacy 69182902Skmacystatic int 70182902Skmacymptable_probe_cpus(void) 71182902Skmacy{ 72182902Skmacy int i, rc; 73182902Skmacy 74182902Skmacy for (i = 0; i < MAXCPU; i++) { 75182902Skmacy rc = HYPERVISOR_vcpu_op(VCPUOP_is_up, i, NULL); 76182902Skmacy if (rc >= 0) 77182902Skmacy cpu_add(i, (i == 0)); 78182902Skmacy } 79182902Skmacy 80182902Skmacy return (0); 81182902Skmacy} 82182902Skmacy 83182902Skmacy/* 84182902Skmacy * Initialize the local APIC on the BSP. 85182902Skmacy */ 86182902Skmacystatic int 87182902Skmacymptable_setup_local(void) 88182902Skmacy{ 89182902Skmacy 90255725Sgibbs PCPU_SET(apic_id, 0); 91256073Sgibbs PCPU_SET(vcpu_id, 0); 92182902Skmacy return (0); 93182902Skmacy} 94182902Skmacy 95182902Skmacystatic int 96182902Skmacymptable_setup_io(void) 97182902Skmacy{ 98182902Skmacy 99182902Skmacy return (0); 100182902Skmacy} 101182902Skmacy 102182902Skmacystatic void 103182902Skmacymptable_register(void *dummy __unused) 104182902Skmacy{ 105182902Skmacy 106182902Skmacy apic_register_enumerator(&mptable_enumerator); 107182902Skmacy} 108215009SjhbSYSINIT(mptable_register, SI_SUB_TUNABLES - 1, SI_ORDER_FIRST, mptable_register, 109182902Skmacy NULL); 110