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