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