xref: /illumos-gate/usr/src/contrib/bhyve/x86/mptable.h (revision d0b3c59b)
1bf21cd93STycho Nightingale /*-
2bf21cd93STycho Nightingale  * Copyright (c) 1996, by Steve Passe
3bf21cd93STycho Nightingale  * All rights reserved.
4bf21cd93STycho Nightingale  *
5bf21cd93STycho Nightingale  * Redistribution and use in source and binary forms, with or without
6bf21cd93STycho Nightingale  * modification, are permitted provided that the following conditions
7bf21cd93STycho Nightingale  * are met:
8bf21cd93STycho Nightingale  * 1. Redistributions of source code must retain the above copyright
9bf21cd93STycho Nightingale  *    notice, this list of conditions and the following disclaimer.
10bf21cd93STycho Nightingale  * 2. The name of the developer may NOT be used to endorse or promote products
11bf21cd93STycho Nightingale  *    derived from this software without specific prior written permission.
12bf21cd93STycho Nightingale  *
13bf21cd93STycho Nightingale  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14bf21cd93STycho Nightingale  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15bf21cd93STycho Nightingale  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16bf21cd93STycho Nightingale  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17bf21cd93STycho Nightingale  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18bf21cd93STycho Nightingale  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19bf21cd93STycho Nightingale  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20bf21cd93STycho Nightingale  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21bf21cd93STycho Nightingale  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22bf21cd93STycho Nightingale  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23bf21cd93STycho Nightingale  * SUCH DAMAGE.
24bf21cd93STycho Nightingale  *
25bf21cd93STycho Nightingale  * $FreeBSD: head/sys/x86/include/mptable.h 259228 2013-12-11 21:19:04Z jhb $
26bf21cd93STycho Nightingale  */
27bf21cd93STycho Nightingale 
28bf21cd93STycho Nightingale #ifndef __MACHINE_MPTABLE_H__
29bf21cd93STycho Nightingale #define	__MACHINE_MPTABLE_H__
30bf21cd93STycho Nightingale 
31bf21cd93STycho Nightingale enum busTypes {
32bf21cd93STycho Nightingale     NOBUS = 0,
33bf21cd93STycho Nightingale     CBUS = 1,
34bf21cd93STycho Nightingale     CBUSII = 2,
35bf21cd93STycho Nightingale     EISA = 3,
36bf21cd93STycho Nightingale     ISA = 6,
37bf21cd93STycho Nightingale     MCA = 9,
38bf21cd93STycho Nightingale     PCI = 13,
39bf21cd93STycho Nightingale     XPRESS = 18,
40bf21cd93STycho Nightingale     MAX_BUSTYPE = 18,
41bf21cd93STycho Nightingale     UNKNOWN_BUSTYPE = 0xff
42bf21cd93STycho Nightingale };
43bf21cd93STycho Nightingale 
44bf21cd93STycho Nightingale /* MP Floating Pointer Structure */
45bf21cd93STycho Nightingale typedef struct MPFPS {
46bf21cd93STycho Nightingale 	uint8_t	signature[4];
47bf21cd93STycho Nightingale 	uint32_t pap;
48bf21cd93STycho Nightingale 	uint8_t	length;
49bf21cd93STycho Nightingale 	uint8_t	spec_rev;
50bf21cd93STycho Nightingale 	uint8_t	checksum;
51bf21cd93STycho Nightingale 	uint8_t	config_type;
52bf21cd93STycho Nightingale 	uint8_t	mpfb2;
53bf21cd93STycho Nightingale 	uint8_t	mpfb3;
54bf21cd93STycho Nightingale 	uint8_t	mpfb4;
55bf21cd93STycho Nightingale 	uint8_t	mpfb5;
56bf21cd93STycho Nightingale } __packed *mpfps_t;
57bf21cd93STycho Nightingale 
58bf21cd93STycho Nightingale #define	MPFB2_IMCR_PRESENT	0x80
59bf21cd93STycho Nightingale #define	MPFB2_MUL_CLK_SRCS	0x40
60bf21cd93STycho Nightingale 
61bf21cd93STycho Nightingale /* MP Configuration Table Header */
62bf21cd93STycho Nightingale typedef struct MPCTH {
63bf21cd93STycho Nightingale 	uint8_t	signature[4];
64bf21cd93STycho Nightingale 	uint16_t base_table_length;
65bf21cd93STycho Nightingale 	uint8_t	spec_rev;
66bf21cd93STycho Nightingale 	uint8_t	checksum;
67bf21cd93STycho Nightingale 	uint8_t	oem_id[8];
68bf21cd93STycho Nightingale 	uint8_t	product_id[12];
69bf21cd93STycho Nightingale 	uint32_t oem_table_pointer;
70bf21cd93STycho Nightingale 	uint16_t oem_table_size;
71bf21cd93STycho Nightingale 	uint16_t entry_count;
72bf21cd93STycho Nightingale 	uint32_t apic_address;
73bf21cd93STycho Nightingale 	uint16_t extended_table_length;
74bf21cd93STycho Nightingale 	uint8_t	extended_table_checksum;
75bf21cd93STycho Nightingale 	uint8_t	reserved;
76bf21cd93STycho Nightingale } __packed *mpcth_t;
77bf21cd93STycho Nightingale 
78bf21cd93STycho Nightingale /* Base table entries */
79bf21cd93STycho Nightingale 
80bf21cd93STycho Nightingale #define	MPCT_ENTRY_PROCESSOR	0
81bf21cd93STycho Nightingale #define	MPCT_ENTRY_BUS		1
82bf21cd93STycho Nightingale #define	MPCT_ENTRY_IOAPIC	2
83bf21cd93STycho Nightingale #define	MPCT_ENTRY_INT		3
84bf21cd93STycho Nightingale #define	MPCT_ENTRY_LOCAL_INT	4
85bf21cd93STycho Nightingale 
86bf21cd93STycho Nightingale typedef struct PROCENTRY {
87bf21cd93STycho Nightingale 	uint8_t	type;
88bf21cd93STycho Nightingale 	uint8_t	apic_id;
89bf21cd93STycho Nightingale 	uint8_t	apic_version;
90bf21cd93STycho Nightingale 	uint8_t	cpu_flags;
91bf21cd93STycho Nightingale 	uint32_t cpu_signature;
92bf21cd93STycho Nightingale 	uint32_t feature_flags;
93bf21cd93STycho Nightingale 	uint32_t reserved1;
94bf21cd93STycho Nightingale 	uint32_t reserved2;
95bf21cd93STycho Nightingale } __packed *proc_entry_ptr;
96bf21cd93STycho Nightingale 
97bf21cd93STycho Nightingale #define PROCENTRY_FLAG_EN	0x01
98bf21cd93STycho Nightingale #define PROCENTRY_FLAG_BP	0x02
99bf21cd93STycho Nightingale 
100bf21cd93STycho Nightingale typedef struct BUSENTRY {
101bf21cd93STycho Nightingale 	uint8_t	type;
102bf21cd93STycho Nightingale 	uint8_t	bus_id;
103bf21cd93STycho Nightingale 	uint8_t	bus_type[6];
104bf21cd93STycho Nightingale } __packed *bus_entry_ptr;
105bf21cd93STycho Nightingale 
106bf21cd93STycho Nightingale typedef struct IOAPICENTRY {
107bf21cd93STycho Nightingale 	uint8_t	type;
108bf21cd93STycho Nightingale 	uint8_t	apic_id;
109bf21cd93STycho Nightingale 	uint8_t	apic_version;
110bf21cd93STycho Nightingale 	uint8_t	apic_flags;
111bf21cd93STycho Nightingale 	uint32_t apic_address;
112bf21cd93STycho Nightingale } __packed *io_apic_entry_ptr;
113bf21cd93STycho Nightingale 
114bf21cd93STycho Nightingale #define IOAPICENTRY_FLAG_EN	0x01
115bf21cd93STycho Nightingale 
116bf21cd93STycho Nightingale typedef struct INTENTRY {
117bf21cd93STycho Nightingale 	uint8_t	type;
118bf21cd93STycho Nightingale 	uint8_t	int_type;
119bf21cd93STycho Nightingale 	uint16_t int_flags;
120bf21cd93STycho Nightingale 	uint8_t	src_bus_id;
121bf21cd93STycho Nightingale 	uint8_t	src_bus_irq;
122bf21cd93STycho Nightingale 	uint8_t	dst_apic_id;
123bf21cd93STycho Nightingale 	uint8_t	dst_apic_int;
124bf21cd93STycho Nightingale } __packed *int_entry_ptr;
125bf21cd93STycho Nightingale 
126bf21cd93STycho Nightingale #define	INTENTRY_TYPE_INT  	0
127bf21cd93STycho Nightingale #define	INTENTRY_TYPE_NMI	1
128bf21cd93STycho Nightingale #define	INTENTRY_TYPE_SMI	2
129bf21cd93STycho Nightingale #define	INTENTRY_TYPE_EXTINT	3
130bf21cd93STycho Nightingale 
131bf21cd93STycho Nightingale #define	INTENTRY_FLAGS_POLARITY			0x3
132bf21cd93STycho Nightingale #define	INTENTRY_FLAGS_POLARITY_CONFORM		0x0
133bf21cd93STycho Nightingale #define	INTENTRY_FLAGS_POLARITY_ACTIVEHI	0x1
134bf21cd93STycho Nightingale #define	INTENTRY_FLAGS_POLARITY_ACTIVELO	0x3
135bf21cd93STycho Nightingale #define	INTENTRY_FLAGS_TRIGGER			0xc
136bf21cd93STycho Nightingale #define	INTENTRY_FLAGS_TRIGGER_CONFORM		0x0
137bf21cd93STycho Nightingale #define	INTENTRY_FLAGS_TRIGGER_EDGE		0x4
138bf21cd93STycho Nightingale #define	INTENTRY_FLAGS_TRIGGER_LEVEL		0xc
139bf21cd93STycho Nightingale 
140bf21cd93STycho Nightingale /* Extended table entries */
141bf21cd93STycho Nightingale 
142bf21cd93STycho Nightingale typedef	struct EXTENTRY {
143bf21cd93STycho Nightingale 	uint8_t	type;
144bf21cd93STycho Nightingale 	uint8_t	length;
145bf21cd93STycho Nightingale } __packed *ext_entry_ptr;
146bf21cd93STycho Nightingale 
147bf21cd93STycho Nightingale #define	MPCT_EXTENTRY_SAS	0x80
148bf21cd93STycho Nightingale #define	MPCT_EXTENTRY_BHD	0x81
149bf21cd93STycho Nightingale #define	MPCT_EXTENTRY_CBASM	0x82
150bf21cd93STycho Nightingale 
151bf21cd93STycho Nightingale typedef struct SASENTRY {
152bf21cd93STycho Nightingale 	uint8_t	type;
153bf21cd93STycho Nightingale 	uint8_t	length;
154bf21cd93STycho Nightingale 	uint8_t	bus_id;
155bf21cd93STycho Nightingale 	uint8_t	address_type;
156bf21cd93STycho Nightingale 	uint64_t address_base;
157bf21cd93STycho Nightingale 	uint64_t address_length;
158bf21cd93STycho Nightingale } __packed *sas_entry_ptr;
159bf21cd93STycho Nightingale 
160bf21cd93STycho Nightingale #define	SASENTRY_TYPE_IO	0
161bf21cd93STycho Nightingale #define	SASENTRY_TYPE_MEMORY	1
162bf21cd93STycho Nightingale #define	SASENTRY_TYPE_PREFETCH	2
163bf21cd93STycho Nightingale 
164bf21cd93STycho Nightingale typedef struct BHDENTRY {
165bf21cd93STycho Nightingale 	uint8_t	type;
166bf21cd93STycho Nightingale 	uint8_t	length;
167bf21cd93STycho Nightingale 	uint8_t	bus_id;
168bf21cd93STycho Nightingale 	uint8_t	bus_info;
169bf21cd93STycho Nightingale 	uint8_t	parent_bus;
170bf21cd93STycho Nightingale 	uint8_t	reserved[3];
171bf21cd93STycho Nightingale } __packed *bhd_entry_ptr;
172bf21cd93STycho Nightingale 
173bf21cd93STycho Nightingale #define	BHDENTRY_INFO_SUBTRACTIVE_DECODE	0x1
174bf21cd93STycho Nightingale 
175bf21cd93STycho Nightingale typedef struct CBASMENTRY {
176bf21cd93STycho Nightingale 	uint8_t	type;
177bf21cd93STycho Nightingale 	uint8_t	length;
178bf21cd93STycho Nightingale 	uint8_t	bus_id;
179bf21cd93STycho Nightingale 	uint8_t	address_mod;
180bf21cd93STycho Nightingale 	uint32_t predefined_range;
181bf21cd93STycho Nightingale } __packed *cbasm_entry_ptr;
182bf21cd93STycho Nightingale 
183bf21cd93STycho Nightingale #define	CBASMENTRY_ADDRESS_MOD_ADD		0x0
184bf21cd93STycho Nightingale #define	CBASMENTRY_ADDRESS_MOD_SUBTRACT		0x1
185bf21cd93STycho Nightingale 
186bf21cd93STycho Nightingale #define	CBASMENTRY_RANGE_ISA_IO		0
187bf21cd93STycho Nightingale #define	CBASMENTRY_RANGE_VGA_IO		1
188bf21cd93STycho Nightingale 
189bf21cd93STycho Nightingale #ifdef _KERNEL
190bf21cd93STycho Nightingale struct mptable_hostb_softc {
191bf21cd93STycho Nightingale #ifdef NEW_PCIB
192bf21cd93STycho Nightingale 	struct pcib_host_resources sc_host_res;
193bf21cd93STycho Nightingale 	int		sc_decodes_vga_io;
194bf21cd93STycho Nightingale 	int		sc_decodes_isa_io;
195bf21cd93STycho Nightingale #endif
196bf21cd93STycho Nightingale };
197bf21cd93STycho Nightingale 
198bf21cd93STycho Nightingale #ifdef NEW_PCIB
199bf21cd93STycho Nightingale void	mptable_pci_host_res_init(device_t pcib);
200bf21cd93STycho Nightingale #endif
201bf21cd93STycho Nightingale int	mptable_pci_probe_table(int bus);
202bf21cd93STycho Nightingale int	mptable_pci_route_interrupt(device_t pcib, device_t dev, int pin);
203bf21cd93STycho Nightingale #endif
204bf21cd93STycho Nightingale #endif /* !__MACHINE_MPTABLE_H__ */
205