Deleted Added
full compact
madt.c (85399) madt.c (85656)
1/*-
2 * Copyright (c) 2001 Doug Rabson
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 unchanged lines hidden (view full) ---

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 *
1/*-
2 * Copyright (c) 2001 Doug Rabson
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 unchanged lines hidden (view full) ---

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 * $FreeBSD: head/sys/ia64/acpica/madt.c 85399 2001-10-24 04:48:05Z marcel $
26 * $FreeBSD: head/sys/ia64/acpica/madt.c 85656 2001-10-29 02:16:02Z marcel $
27 */
28
29#include "acpi.h"
30
27 */
28
29#include "acpi.h"
30
31void cpu_mp_add(uint, uint, uint);
32struct sapic *sapic_create(int, int, u_int64_t);
33
31#pragma pack(1)
32
34#pragma pack(1)
35
33#define APIC_INTERRUPT_SOURCE_OVERRIDE 2
34#define APIC_NMI 3
35#define APIC_LOCAL_APIC_NMI 4
36#define APIC_LOCAL_APIC_OVERRIDE 5
37#define APIC_IO_SAPIC 6
38#define APIC_LOCAL_SAPIC 7
39#define APIC_PLATFORM_INTERRUPT 8
36#define APIC_INTERRUPT_SOURCE_OVERRIDE 2
37#define APIC_NMI 3
38#define APIC_LOCAL_APIC_NMI 4
39#define APIC_LOCAL_APIC_OVERRIDE 5
40#define APIC_IO_SAPIC 6
41#define APIC_LOCAL_SAPIC 7
42#define APIC_PLATFORM_INTERRUPT 8
40
43
41
42typedef struct /* Interrupt Source Override */
44typedef struct /* Interrupt Source Override */
43{
45{
44 APIC_HEADER header;
45 UINT8 Bus;
46 UINT8 Source;
47 UINT32 GlobalSystemInterrupt;
48 UINT16 Flags;
46 APIC_HEADER header;
47 UINT8 Bus;
48 UINT8 Source;
49 UINT32 GlobalSystemInterrupt;
50 UINT16 Flags;
49} INTERRUPT_SOURCE_OVERRIDE;
50
51} INTERRUPT_SOURCE_OVERRIDE;
52
51typedef struct /* IO SAPIC */
53typedef struct /* IO SAPIC */
52{
54{
53 APIC_HEADER header;
54 UINT8 IoSapicId; /* I/O SAPIC ID */
55 UINT8 Reserved; /* reserved - must be zero */
56 UINT32 Vector; /* interrupt vector index where INTI
57 * lines start */
58 UINT64 IoSapicAddress; /* SAPIC's physical address */
59
55 APIC_HEADER header;
56 UINT8 IoSapicId; /* I/O SAPIC ID */
57 UINT8 Reserved; /* reserved - must be zero */
58 UINT32 Vector; /* interrupt base */
59 UINT64 IoSapicAddress; /* SAPIC's physical address */
60} IO_SAPIC;
61
60} IO_SAPIC;
61
62
63typedef struct /* LOCAL SAPIC */
64{
62typedef struct /* LOCAL SAPIC */
63{
65 APIC_HEADER header;
66 UINT16 ProcessorId; /* ACPI processor id */
67 UINT16 ProcessorEnabled: 1; /* Processor is usable if set */
68 UINT16 Reserved1 : 15;
69 UINT8 LocalSapicId; /* processor's local SAPIC id */
70 UINT8 LocalSapicEid; /* processor's local SAPIC eid */
71
64 APIC_HEADER header;
65 UINT8 ProcessorId; /* ACPI processor id */
66 UINT8 LocalSapicId; /* Processor local SAPIC id */
67 UINT8 LocalSapicEid; /* Processor local SAPIC eid */
68 UINT8 Reserved;
69 UINT32 Reserved1: 16;
70 UINT32 ProcessorEnabled: 1;
71 UINT32 Reserved2: 15;
72} LOCAL_SAPIC;
73
72} LOCAL_SAPIC;
73
74
75typedef struct /* PLATFORM INTERRUPT SOURCE */
76{
74typedef struct /* PLATFORM INTERRUPT SOURCE */
75{
77 APIC_HEADER header;
78 UINT16 Polarity : 2; /* Polarity of input signal */
79 UINT16 TriggerMode: 2; /* Trigger mode of input signal */
80 UINT16 Reserved1 : 12;
81 UINT8 InterruptType; /* 1-PMI, 2-INIT, 3-Error */
82 UINT8 ProcessorId; /* Processor ID of destination */
83 UINT8 ProcessorEid; /* Processor EID of destination */
84 UINT8 IoSapicVector; /* Value for redirection table */
85 UINT32 GlobalSystemInterrupt; /* Global System Interrupt */
86 UINT32 Reserved2;
87
76 APIC_HEADER header;
77 UINT16 Polarity : 2; /* Polarity of input signal */
78 UINT16 TriggerMode: 2; /* Trigger mode of input signal */
79 UINT16 Reserved1 : 12;
80 UINT8 InterruptType; /* 1-PMI, 2-INIT, 3-Error */
81 UINT8 ProcessorId; /* Processor ID of destination */
82 UINT8 ProcessorEid; /* Processor EID of destination */
83 UINT8 IoSapicVector; /* Value for redirection table */
84 UINT32 GlobalSystemInterrupt; /* Global System Interrupt */
85 UINT32 Reserved2;
88} PLATFORM_INTERRUPT_SOURCE;
86} PLATFORM_INTERRUPT_SOURCE;
89
90
91#pragma pack()
92
93static void
87
88#pragma pack()
89
90static void
94parse_local_apic(PROCESSOR_APIC *apic)
95{
96 if (bootverbose) {
97 printf("\t\tProcessorId=0x%x, APIC Id=0x%x",
98 apic->ProcessorApicId, apic->LocalApicId);
99 if (!apic->ProcessorEnabled)
100 printf(" (disabled)");
101 printf("\n");
102 }
103}
104
105static void
106parse_io_apic(IO_APIC *apic)
107{
108 if (bootverbose)
109 printf("\t\tId=0x%x, Vector=0x%x, Address=0x%lx\n",
110 apic->IoApicId, apic->Vector, apic->IoApicAddress);
111}
112
113static void
114parse_interrupt_override(INTERRUPT_SOURCE_OVERRIDE *override)
115{
116 if (bootverbose)
91parse_interrupt_override(INTERRUPT_SOURCE_OVERRIDE *override)
92{
93 if (bootverbose)
117 printf("\t\tBus=%d, Source=%d, Irq=0x%x\n",
118 override->Bus,
119 override->Source,
120 override->GlobalSystemInterrupt);
94 printf("\t\tBus=%d, Source=%d, Irq=0x%x\n", override->Bus,
95 override->Source, override->GlobalSystemInterrupt);
121}
122
123static void
124parse_io_sapic(IO_SAPIC *sapic)
125{
126 if (bootverbose)
127 printf("\t\tId=0x%x, Vector=0x%x, Address=0x%lx\n",
96}
97
98static void
99parse_io_sapic(IO_SAPIC *sapic)
100{
101 if (bootverbose)
102 printf("\t\tId=0x%x, Vector=0x%x, Address=0x%lx\n",
128 sapic->IoSapicId,
129 sapic->Vector,
130 sapic->IoSapicAddress);
103 sapic->IoSapicId, sapic->Vector, sapic->IoSapicAddress);
131 sapic_create(sapic->IoSapicId, sapic->Vector, sapic->IoSapicAddress);
132}
133
134static void
135parse_local_sapic(LOCAL_SAPIC *sapic)
136{
137 if (bootverbose) {
138 printf("\t\tProcessorId=0x%x, Id=0x%x, Eid=0x%x",
139 sapic->ProcessorId, sapic->LocalSapicId,
140 sapic->LocalSapicEid);
141 if (!sapic->ProcessorEnabled)
142 printf(" (disabled)");
143 printf("\n");
144 }
104 sapic_create(sapic->IoSapicId, sapic->Vector, sapic->IoSapicAddress);
105}
106
107static void
108parse_local_sapic(LOCAL_SAPIC *sapic)
109{
110 if (bootverbose) {
111 printf("\t\tProcessorId=0x%x, Id=0x%x, Eid=0x%x",
112 sapic->ProcessorId, sapic->LocalSapicId,
113 sapic->LocalSapicEid);
114 if (!sapic->ProcessorEnabled)
115 printf(" (disabled)");
116 printf("\n");
117 }
118#ifdef SMP
119 if (sapic->ProcessorEnabled)
120 cpu_mp_add(sapic->ProcessorId, sapic->LocalSapicId,
121 sapic->LocalSapicEid);
122#endif
145}
146
147static void
148parse_platform_interrupt(PLATFORM_INTERRUPT_SOURCE *source)
149{
150 if (bootverbose)
151 printf("\t\tPolarity=%d, TriggerMode=%d, Id=0x%x, "
123}
124
125static void
126parse_platform_interrupt(PLATFORM_INTERRUPT_SOURCE *source)
127{
128 if (bootverbose)
129 printf("\t\tPolarity=%d, TriggerMode=%d, Id=0x%x, "
152 "Eid=0x%x, Vector=0x%x, Irq=%d\n",
153 source->Polarity,
154 source->TriggerMode,
155 source->ProcessorId,
156 source->ProcessorEid,
157 source->IoSapicVector,
158 source->GlobalSystemInterrupt);
130 "Eid=0x%x, Vector=0x%x, Irq=%d\n", source->Polarity,
131 source->TriggerMode, source->ProcessorId,
132 source->ProcessorEid, source->IoSapicVector,
133 source->GlobalSystemInterrupt);
159}
160
161static void
162parse_madt(APIC_TABLE *madt)
163{
164 char *p, *end;
165
166 /*

--- 5 unchanged lines hidden (view full) ---

172 APIC_HEADER *head = (APIC_HEADER *) p;
173
174 if (bootverbose)
175 printf("\t");
176 switch (head->Type) {
177 case APIC_PROC:
178 if (bootverbose)
179 printf("Local APIC entry\n");
134}
135
136static void
137parse_madt(APIC_TABLE *madt)
138{
139 char *p, *end;
140
141 /*

--- 5 unchanged lines hidden (view full) ---

147 APIC_HEADER *head = (APIC_HEADER *) p;
148
149 if (bootverbose)
150 printf("\t");
151 switch (head->Type) {
152 case APIC_PROC:
153 if (bootverbose)
154 printf("Local APIC entry\n");
180 parse_local_apic((PROCESSOR_APIC *) head);
181 break;
182
183 case APIC_IO:
184 if (bootverbose)
185 printf("I/O APIC entry\n");
155 break;
156
157 case APIC_IO:
158 if (bootverbose)
159 printf("I/O APIC entry\n");
186 parse_io_apic((IO_APIC *) head);
187 break;
188
189 case APIC_INTERRUPT_SOURCE_OVERRIDE:
190 if (bootverbose)
191 printf("Interrupt source override entry\n");
192 parse_interrupt_override
193 ((INTERRUPT_SOURCE_OVERRIDE *) head);
194 break;
195
196 case APIC_NMI:
197 if (bootverbose)
198 printf("NMI entry\n");
199 break;
200
201 case APIC_LOCAL_APIC_NMI:
202 if (bootverbose)
203 printf("Local APIC NMI entry\n");
204 break;
205
160 break;
161
162 case APIC_INTERRUPT_SOURCE_OVERRIDE:
163 if (bootverbose)
164 printf("Interrupt source override entry\n");
165 parse_interrupt_override
166 ((INTERRUPT_SOURCE_OVERRIDE *) head);
167 break;
168
169 case APIC_NMI:
170 if (bootverbose)
171 printf("NMI entry\n");
172 break;
173
174 case APIC_LOCAL_APIC_NMI:
175 if (bootverbose)
176 printf("Local APIC NMI entry\n");
177 break;
178
179
206 case APIC_LOCAL_APIC_OVERRIDE:
207 if (bootverbose)
208 printf("Local APIC override entry\n");
209 break;
210
211 case APIC_IO_SAPIC:
212 if (bootverbose)
213 printf("I/O SAPIC entry\n");

--- 19 unchanged lines hidden (view full) ---

233 break;
234 }
235
236 p = p + head->Length;
237 }
238}
239
240void
180 case APIC_LOCAL_APIC_OVERRIDE:
181 if (bootverbose)
182 printf("Local APIC override entry\n");
183 break;
184
185 case APIC_IO_SAPIC:
186 if (bootverbose)
187 printf("I/O SAPIC entry\n");

--- 19 unchanged lines hidden (view full) ---

207 break;
208 }
209
210 p = p + head->Length;
211 }
212}
213
214void
241ia64_parse_xsdt(XSDT_DESCRIPTOR *xsdt)
215ia64_probe_sapics(void)
242{
216{
243 int i, count;
217 ACPI_PHYSICAL_ADDRESS rsdp_phys;
218 RSDP_DESCRIPTOR *rsdp;
219 XSDT_DESCRIPTOR *xsdt;
244 ACPI_TABLE_HEADER *table;
220 ACPI_TABLE_HEADER *table;
221 int i, count;
245
222
246 /*
247 * First find the MADT.
248 */
249 count = (UINT64 *) ((char *) xsdt + xsdt->Header.Length)
250 - &xsdt->TableOffsetEntry[0];
223 if (AcpiOsGetRootPointer(0, &rsdp_phys) != AE_OK)
224 return;
225
226 rsdp = (RSDP_DESCRIPTOR *)IA64_PHYS_TO_RR7(rsdp_phys);
227 xsdt = (XSDT_DESCRIPTOR *)IA64_PHYS_TO_RR7(rsdp->XsdtPhysicalAddress);
228
229 count = (UINT64 *)((char *)xsdt + xsdt->Header.Length)
230 - xsdt->TableOffsetEntry;
251 for (i = 0; i < count; i++) {
252 table = (ACPI_TABLE_HEADER *)
253 IA64_PHYS_TO_RR7(xsdt->TableOffsetEntry[i]);
231 for (i = 0; i < count; i++) {
232 table = (ACPI_TABLE_HEADER *)
233 IA64_PHYS_TO_RR7(xsdt->TableOffsetEntry[i]);
234
254 if (bootverbose)
235 if (bootverbose)
255 printf("Table '%c%c%c%c' at %p\n",
256 table->Signature[0],
257 table->Signature[1],
258 table->Signature[2],
259 table->Signature[3],
260 table);
261 if (!strncmp(table->Signature, APIC_SIG, 4)) {
236 printf("Table '%c%c%c%c' at %p\n", table->Signature[0],
237 table->Signature[1], table->Signature[2],
238 table->Signature[3], table);
239
240 if (!strncmp(table->Signature, APIC_SIG, 4))
262 parse_madt((APIC_TABLE *) table);
241 parse_madt((APIC_TABLE *) table);
263 }
264 }
265}
242 }
243}