mptable.c revision 224097
1/*-
2 * Copyright (c) 2003 John Baldwin <jhb@FreeBSD.org>
3 * Copyright (c) 1996, by Steve Passe
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 * 2. The name of the developer may NOT be used to endorse or promote products
12 *    derived from this software without specific prior written permission.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/i386/xen/mptable.c 224097 2011-07-16 14:06:02Z jhb $");
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/bus.h>
33#include <sys/kernel.h>
34#include <sys/malloc.h>
35#ifdef NEW_PCIB
36#include <sys/rman.h>
37#endif
38
39#include <vm/vm.h>
40#include <vm/vm_param.h>
41#include <vm/pmap.h>
42
43#ifdef NEW_PCIB
44#include <dev/pci/pcivar.h>
45#include <dev/pci/pcib_private.h>
46#endif
47#include <x86/apicreg.h>
48#include <x86/mptable.h>
49#include <machine/frame.h>
50#include <machine/intr_machdep.h>
51#include <machine/apicvar.h>
52#include <machine/md_var.h>
53#include <machine/specialreg.h>
54
55#include <xen/hypervisor.h>
56#include <machine/xen/xen-os.h>
57#include <machine/smp.h>
58#include <xen/interface/vcpu.h>
59
60
61static int	mptable_probe(void);
62static int	mptable_probe_cpus(void);
63static void	mptable_register(void *dummy);
64static int	mptable_setup_local(void);
65static int	mptable_setup_io(void);
66
67static struct apic_enumerator mptable_enumerator = {
68	"MPTable",
69	mptable_probe,
70	mptable_probe_cpus,
71	mptable_setup_local,
72	mptable_setup_io
73};
74
75static int
76mptable_probe(void)
77{
78
79	return (-100);
80}
81
82static int
83mptable_probe_cpus(void)
84{
85	int i, rc;
86
87	for (i = 0; i < MAXCPU; i++) {
88		rc = HYPERVISOR_vcpu_op(VCPUOP_is_up, i, NULL);
89		if (rc >= 0)
90			cpu_add(i, (i == 0));
91	}
92
93	return (0);
94}
95
96/*
97 * Initialize the local APIC on the BSP.
98 */
99static int
100mptable_setup_local(void)
101{
102
103	return (0);
104}
105
106static int
107mptable_setup_io(void)
108{
109
110	return (0);
111}
112
113static void
114mptable_register(void *dummy __unused)
115{
116
117	apic_register_enumerator(&mptable_enumerator);
118}
119SYSINIT(mptable_register, SI_SUB_TUNABLES - 1, SI_ORDER_FIRST, mptable_register,
120    NULL);
121
122
123
124int
125mptable_pci_probe_table(int bus)
126{
127
128	return (0);
129}
130
131int
132mptable_pci_route_interrupt(device_t pcib, device_t dev, int pin)
133{
134
135	return (0);
136}
137
138