redirindex accessed as 32-bit. Make it 32-bits wide.
[dragonfly.git] / sys / platform / pc64 / x86_64 / mp_madt.c
CommitLineData
8e4c6923
MN
1/*
2 * Copyright (c) 2009 The DragonFly Project. All rights reserved.
3 *
4 * This code is derived from software contributed to The DragonFly Project
5 * by Sepherosa Ziehau <sepherosa@gmail.com>
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 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 */
34
35#include <sys/param.h>
91903a05 36#include <sys/kernel.h>
8e4c6923
MN
37#include <sys/systm.h>
38
39#include <machine/pmap.h>
40#include <machine/smp.h>
ee5932ac
MN
41#include <machine/md_var.h>
42#include <machine/specialreg.h>
91903a05 43#include <machine_base/apic/mpapic.h>
8e4c6923
MN
44
45#define ACPI_RSDP_EBDA_MAPSZ 1024
46#define ACPI_RSDP_BIOS_MAPSZ 0x20000
47#define ACPI_RSDP_BIOS_MAPADDR 0xe0000
48
49#define ACPI_RSDP_ALIGN 16
50
51#define ACPI_RSDP_SIGLEN 8
52#define ACPI_RSDP_SIG "RSD PTR "
53
54#define ACPI_SDTH_SIGLEN 4
55#define ACPI_RSDT_SIG "RSDT"
56#define ACPI_XSDT_SIG "XSDT"
57#define ACPI_MADT_SIG "APIC"
58
59/* Root System Description Pointer */
60struct acpi_rsdp {
61 uint8_t rsdp_sig[ACPI_RSDP_SIGLEN];
62 uint8_t rsdp_cksum;
63 uint8_t rsdp_oem_id[6];
64 uint8_t rsdp_rev;
65 uint32_t rsdp_rsdt;
66 uint32_t rsdp_len;
67 uint64_t rsdp_xsdt;
68 uint8_t rsdp_ext_cksum;
69 uint8_t rsdp_rsvd[3];
70} __packed;
71
72/* System Description Table Header */
73struct acpi_sdth {
74 uint8_t sdth_sig[ACPI_SDTH_SIGLEN];
75 uint32_t sdth_len;
76 uint8_t sdth_rev;
77 uint8_t sdth_cksum;
78 uint8_t sdth_oem_id[6];
79 uint8_t sdth_oem_tbid[8];
80 uint32_t sdth_oem_rev;
81 uint32_t sdth_crt_id;
82 uint32_t sdth_crt_rev;
83} __packed;
84
85/* Extended System Description Table */
86struct acpi_xsdt {
87 struct acpi_sdth xsdt_hdr;
88 uint64_t xsdt_ents[1];
89} __packed;
90
91/* Root System Description Table */
92struct acpi_rsdt {
93 struct acpi_sdth rsdt_hdr;
94 uint32_t rsdt_ents[1];
95} __packed;
96
97/* Multiple APIC Description Table */
98struct acpi_madt {
99 struct acpi_sdth madt_hdr;
100 uint32_t madt_lapic_addr;
101 uint32_t madt_flags;
102 uint8_t madt_ents[1];
103} __packed;
104
105/* Common parts of MADT APIC structure */
106struct acpi_madt_ent {
107 uint8_t me_type; /* MADT_ENT_ */
108 uint8_t me_len;
109} __packed;
110
111#define MADT_ENT_LAPIC 0
0492bd82 112#define MADT_ENT_IOAPIC 1
ebbde674 113#define MADT_ENT_LAPIC_ADDR 5
8e4c6923
MN
114
115/* MADT Processor Local APIC */
116struct acpi_madt_lapic {
117 struct acpi_madt_ent ml_hdr;
118 uint8_t ml_cpu_id;
119 uint8_t ml_apic_id;
120 uint32_t ml_flags; /* MADT_LAPIC_ */
121} __packed;
122
123#define MADT_LAPIC_ENABLED 0x1
124
0492bd82
MN
125/* MADT I/O APIC */
126struct acpi_madt_ioapic {
127 struct acpi_madt_ent mio_hdr;
128 uint8_t mio_apic_id;
129 uint8_t mio_reserved;
130 uint32_t mio_addr;
131 uint32_t mio_gsi_base;
132} __packed;
133
ebbde674
MN
134/* MADT Local APIC Address Override */
135struct acpi_madt_lapic_addr {
136 struct acpi_madt_ent mla_hdr;
137 uint16_t mla_reserved;
138 uint64_t mla_lapic_addr;
139} __packed;
140
91903a05
MN
141struct madt_lapic_enumerator {
142 struct lapic_enumerator enumerator;
143 vm_paddr_t madt_paddr;
144};
145
8e4c6923 146typedef vm_paddr_t (*madt_search_t)(vm_paddr_t);
0492bd82
MN
147typedef int (*madt_iter_t)(void *,
148 const struct acpi_madt_ent *);
8e4c6923
MN
149
150static const struct acpi_rsdp *madt_rsdp_search(const uint8_t *, int);
151static void *madt_sdth_map(vm_paddr_t);
152static void madt_sdth_unmap(struct acpi_sdth *);
153static vm_paddr_t madt_search_xsdt(vm_paddr_t);
154static vm_paddr_t madt_search_rsdt(vm_paddr_t);
4ad5917f 155static int madt_check(vm_paddr_t);
0492bd82
MN
156static int madt_iterate_entries(struct acpi_madt *,
157 madt_iter_t, void *);
8e4c6923 158
91903a05
MN
159static vm_paddr_t madt_probe(void);
160static vm_offset_t madt_pass1(vm_paddr_t);
161static int madt_pass2(vm_paddr_t, int);
162
163static void madt_lapic_enumerate(struct lapic_enumerator *);
164static int madt_lapic_probe(struct lapic_enumerator *);
165
8e4c6923
MN
166extern u_long ebda_addr;
167
91903a05 168static vm_paddr_t
8e4c6923
MN
169madt_probe(void)
170{
171 const struct acpi_rsdp *rsdp;
172 madt_search_t search;
173 vm_paddr_t search_paddr, madt_paddr;
174 vm_size_t mapsz;
175 uint8_t *ptr;
176
177 if (ebda_addr != 0) {
178 mapsz = ACPI_RSDP_EBDA_MAPSZ;
179 ptr = pmap_mapdev(ebda_addr, mapsz);
180
181 rsdp = madt_rsdp_search(ptr, mapsz);
182 if (rsdp == NULL) {
183 kprintf("madt: RSDP not in EBDA\n");
184 pmap_unmapdev((vm_offset_t)ptr, mapsz);
185
186 ptr = NULL;
187 mapsz = 0;
188 } else {
189 kprintf("madt: RSDP in EBDA\n");
190 goto found_rsdp;
191 }
192 }
193
194 mapsz = ACPI_RSDP_BIOS_MAPSZ;
195 ptr = pmap_mapdev(ACPI_RSDP_BIOS_MAPADDR, mapsz);
196
197 rsdp = madt_rsdp_search(ptr, mapsz);
198 if (rsdp == NULL) {
199 kprintf("madt_probe: no RSDP\n");
200 pmap_unmapdev((vm_offset_t)ptr, mapsz);
4ad5917f 201 return 0;
8e4c6923
MN
202 } else {
203 kprintf("madt: RSDP in BIOS mem\n");
204 }
205
206found_rsdp:
207 if (rsdp->rsdp_rev != 2) {
208 search_paddr = rsdp->rsdp_rsdt;
209 search = madt_search_rsdt;
210 } else {
211 search_paddr = rsdp->rsdp_xsdt;
212 search = madt_search_xsdt;
213 }
214 pmap_unmapdev((vm_offset_t)ptr, mapsz);
215
216 madt_paddr = search(search_paddr);
217 if (madt_paddr == 0) {
218 kprintf("madt_probe: can't locate MADT\n");
4ad5917f 219 return 0;
8e4c6923 220 }
4ad5917f
MN
221
222 /* Preliminary checks */
223 if (madt_check(madt_paddr))
224 return 0;
225 return madt_paddr;
8e4c6923
MN
226}
227
228static const struct acpi_rsdp *
229madt_rsdp_search(const uint8_t *target, int size)
230{
231 const struct acpi_rsdp *rsdp;
232 int i;
233
234 KKASSERT(size > sizeof(*rsdp));
235
236 for (i = 0; i < size - sizeof(*rsdp); i += ACPI_RSDP_ALIGN) {
237 rsdp = (const struct acpi_rsdp *)&target[i];
238 if (memcmp(rsdp->rsdp_sig, ACPI_RSDP_SIG,
239 ACPI_RSDP_SIGLEN) == 0)
240 return rsdp;
241 }
242 return NULL;
243}
244
245static void *
246madt_sdth_map(vm_paddr_t paddr)
247{
248 struct acpi_sdth *sdth;
249 vm_size_t mapsz;
250
251 sdth = pmap_mapdev(paddr, sizeof(*sdth));
252 mapsz = sdth->sdth_len;
253 pmap_unmapdev((vm_offset_t)sdth, sizeof(*sdth));
254
255 if (mapsz < sizeof(*sdth))
256 return NULL;
257
258 return pmap_mapdev(paddr, mapsz);
259}
260
261static void
262madt_sdth_unmap(struct acpi_sdth *sdth)
263{
264 pmap_unmapdev((vm_offset_t)sdth, sdth->sdth_len);
265}
266
267static vm_paddr_t
268madt_search_xsdt(vm_paddr_t xsdt_paddr)
269{
270 struct acpi_xsdt *xsdt;
271 vm_paddr_t madt_paddr = 0;
272 int i, nent;
273
274 if (xsdt_paddr == 0) {
275 kprintf("madt_search_xsdt: XSDT paddr == 0\n");
276 return 0;
277 }
278
279 xsdt = madt_sdth_map(xsdt_paddr);
280 if (xsdt == NULL) {
281 kprintf("madt_search_xsdt: can't map XSDT\n");
282 return 0;
283 }
284
285 if (memcmp(xsdt->xsdt_hdr.sdth_sig, ACPI_XSDT_SIG,
286 ACPI_SDTH_SIGLEN) != 0) {
287 kprintf("madt_search_xsdt: not XSDT\n");
288 goto back;
289 }
290
291 if (xsdt->xsdt_hdr.sdth_rev != 1) {
292 kprintf("madt_search_xsdt: unsupported XSDT revision %d\n",
293 xsdt->xsdt_hdr.sdth_rev);
294 goto back;
295 }
296
297 nent = (xsdt->xsdt_hdr.sdth_len - sizeof(xsdt->xsdt_hdr)) /
298 sizeof(xsdt->xsdt_ents[0]);
299 for (i = 0; i < nent; ++i) {
300 struct acpi_sdth *sdth;
301
302 if (xsdt->xsdt_ents[i] == 0)
303 continue;
304
305 sdth = madt_sdth_map(xsdt->xsdt_ents[i]);
306 if (sdth != NULL) {
307 int ret;
308
309 ret = memcmp(sdth->sdth_sig, ACPI_MADT_SIG,
310 ACPI_SDTH_SIGLEN);
311 madt_sdth_unmap(sdth);
312
313 if (ret == 0) {
314 kprintf("madt: MADT in XSDT\n");
315 madt_paddr = xsdt->xsdt_ents[i];
316 break;
317 }
318 }
319 }
320back:
321 madt_sdth_unmap(&xsdt->xsdt_hdr);
322 return madt_paddr;
323}
324
325static vm_paddr_t
326madt_search_rsdt(vm_paddr_t rsdt_paddr)
327{
328 struct acpi_rsdt *rsdt;
329 vm_paddr_t madt_paddr = 0;
330 int i, nent;
331
332 if (rsdt_paddr == 0) {
333 kprintf("madt_search_rsdt: RSDT paddr == 0\n");
334 return 0;
335 }
336
337 rsdt = madt_sdth_map(rsdt_paddr);
338 if (rsdt == NULL) {
339 kprintf("madt_search_rsdt: can't map RSDT\n");
340 return 0;
341 }
342
343 if (memcmp(rsdt->rsdt_hdr.sdth_sig, ACPI_RSDT_SIG,
344 ACPI_SDTH_SIGLEN) != 0) {
345 kprintf("madt_search_rsdt: not RSDT\n");
346 goto back;
347 }
348
349 if (rsdt->rsdt_hdr.sdth_rev != 1) {
350 kprintf("madt_search_rsdt: unsupported RSDT revision %d\n",
351 rsdt->rsdt_hdr.sdth_rev);
352 goto back;
353 }
354
355 nent = (rsdt->rsdt_hdr.sdth_len - sizeof(rsdt->rsdt_hdr)) /
356 sizeof(rsdt->rsdt_ents[0]);
357 for (i = 0; i < nent; ++i) {
358 struct acpi_sdth *sdth;
359
360 if (rsdt->rsdt_ents[i] == 0)
361 continue;
362
363 sdth = madt_sdth_map(rsdt->rsdt_ents[i]);
364 if (sdth != NULL) {
365 int ret;
366
367 ret = memcmp(sdth->sdth_sig, ACPI_MADT_SIG,
368 ACPI_SDTH_SIGLEN);
369 madt_sdth_unmap(sdth);
370
371 if (ret == 0) {
372 kprintf("madt: MADT in RSDT\n");
373 madt_paddr = rsdt->rsdt_ents[i];
374 break;
375 }
376 }
377 }
378back:
379 madt_sdth_unmap(&rsdt->rsdt_hdr);
380 return madt_paddr;
381}
382
ebbde674
MN
383static int
384madt_pass1_callback(void *xarg, const struct acpi_madt_ent *ent)
385{
386 const struct acpi_madt_lapic_addr *lapic_addr_ent;
387 uint64_t *addr64 = xarg;
388
389 if (ent->me_type != MADT_ENT_LAPIC_ADDR)
390 return 0;
391 if (ent->me_len < sizeof(*lapic_addr_ent)) {
392 kprintf("madt_pass1: invalid LAPIC address override length\n");
393 return 0;
394 }
395 lapic_addr_ent = (const struct acpi_madt_lapic_addr *)ent;
396
397 *addr64 = lapic_addr_ent->mla_lapic_addr;
398 return 0;
399}
400
91903a05 401static vm_offset_t
4ad5917f 402madt_pass1(vm_paddr_t madt_paddr)
8e4c6923
MN
403{
404 struct acpi_madt *madt;
4ad5917f 405 vm_offset_t lapic_addr;
ebbde674
MN
406 uint64_t lapic_addr64;
407 int error;
8e4c6923
MN
408
409 KKASSERT(madt_paddr != 0);
410
411 madt = madt_sdth_map(madt_paddr);
412 KKASSERT(madt != NULL);
413
8e4c6923
MN
414 kprintf("madt: LAPIC address 0x%08x, flags %#x\n",
415 madt->madt_lapic_addr, madt->madt_flags);
4ad5917f
MN
416 lapic_addr = madt->madt_lapic_addr;
417
ebbde674
MN
418 lapic_addr64 = 0;
419 error = madt_iterate_entries(madt, madt_pass1_callback, &lapic_addr64);
420 if (error)
421 panic("madt_iterate_entries(pass1) failed\n");
422
423 if (lapic_addr64 != 0) {
ca38f7af 424 kprintf("Warning: 64bits lapic address 0x%lx\n", lapic_addr64);
ebbde674
MN
425 /* XXX vm_offset_t is 32bits on i386 */
426 lapic_addr = lapic_addr64;
427 }
428
4ad5917f
MN
429 madt_sdth_unmap(&madt->madt_hdr);
430
431 return lapic_addr;
432}
433
2c394345
MN
434struct madt_pass2_cbarg {
435 int cpu;
436 int bsp_found;
437 int bsp_apic_id;
438};
439
440static int
441madt_pass2_callback(void *xarg, const struct acpi_madt_ent *ent)
442{
443 const struct acpi_madt_lapic *lapic_ent;
444 struct madt_pass2_cbarg *arg = xarg;
445
446 if (ent->me_type != MADT_ENT_LAPIC)
447 return 0;
448
449 lapic_ent = (const struct acpi_madt_lapic *)ent;
450 if (lapic_ent->ml_flags & MADT_LAPIC_ENABLED) {
451 kprintf("madt: cpu_id %d, apic_id %d\n",
452 lapic_ent->ml_cpu_id, lapic_ent->ml_apic_id);
453 if (lapic_ent->ml_apic_id == arg->bsp_apic_id) {
454 mp_set_cpuids(0, lapic_ent->ml_apic_id);
455 arg->bsp_found = 1;
456 } else {
457 mp_set_cpuids(arg->cpu, lapic_ent->ml_apic_id);
458 arg->cpu++;
459 }
460 }
461 return 0;
462}
463
91903a05 464static int
4ad5917f
MN
465madt_pass2(vm_paddr_t madt_paddr, int bsp_apic_id)
466{
467 struct acpi_madt *madt;
2c394345
MN
468 struct madt_pass2_cbarg arg;
469 int error;
4ad5917f
MN
470
471 kprintf("madt: BSP apic id %d\n", bsp_apic_id);
472
473 KKASSERT(madt_paddr != 0);
474
475 madt = madt_sdth_map(madt_paddr);
476 KKASSERT(madt != NULL);
8e4c6923 477
2c394345
MN
478 bzero(&arg, sizeof(arg));
479 arg.cpu = 1;
480 arg.bsp_apic_id = bsp_apic_id;
8e4c6923 481
2c394345
MN
482 error = madt_iterate_entries(madt, madt_pass2_callback, &arg);
483 if (error)
484 panic("madt_iterate_entries(pass2) failed\n");
8e4c6923 485
2c394345
MN
486 KKASSERT(arg.bsp_found);
487 KKASSERT(arg.cpu > 1);
488 mp_naps = arg.cpu - 1; /* exclude BSP */
4ad5917f
MN
489
490 madt_sdth_unmap(&madt->madt_hdr);
2c394345
MN
491
492 return 0;
4ad5917f
MN
493}
494
0492bd82
MN
495struct madt_check_cbarg {
496 int cpu_count;
497};
498
499static int
500madt_check_callback(void *xarg, const struct acpi_madt_ent *ent)
501{
502 struct madt_check_cbarg *arg = xarg;
503 const struct acpi_madt_lapic *lapic_ent;
504
505 if (ent->me_type != MADT_ENT_LAPIC)
506 return 0;
507 lapic_ent = (const struct acpi_madt_lapic *)ent;
508
1c1f402e 509 if (lapic_ent->ml_flags & MADT_LAPIC_ENABLED)
0492bd82
MN
510 arg->cpu_count++;
511 return 0;
512}
513
4ad5917f
MN
514static int
515madt_check(vm_paddr_t madt_paddr)
516{
0492bd82 517 struct madt_check_cbarg arg;
4ad5917f
MN
518 struct acpi_madt *madt;
519 int error = 0;
520
521 KKASSERT(madt_paddr != 0);
522
523 madt = madt_sdth_map(madt_paddr);
524 KKASSERT(madt != NULL);
525
526 if (madt->madt_hdr.sdth_rev != 1 && madt->madt_hdr.sdth_rev != 2) {
527 kprintf("madt_check: unsupported MADT revision %d\n",
528 madt->madt_hdr.sdth_rev);
529 error = EOPNOTSUPP;
530 goto back;
531 }
532
533 if (madt->madt_hdr.sdth_len <
534 sizeof(*madt) - sizeof(madt->madt_ents)) {
535 kprintf("madt_check: invalid MADT length %u\n",
536 madt->madt_hdr.sdth_len);
537 error = EINVAL;
0492bd82
MN
538 goto back;
539 }
540
541 bzero(&arg, sizeof(arg));
ee5932ac 542
0492bd82
MN
543 error = madt_iterate_entries(madt, madt_check_callback, &arg);
544 if (!error) {
ee5932ac
MN
545 if (arg.cpu_count <= 1) {
546 kprintf("madt_check: less than 2 CPUs is found\n");
0492bd82 547 error = EOPNOTSUPP;
ee5932ac 548 }
4ad5917f 549 }
8e4c6923
MN
550back:
551 madt_sdth_unmap(&madt->madt_hdr);
552 return error;
553}
4ad5917f 554
0492bd82
MN
555static int
556madt_iterate_entries(struct acpi_madt *madt, madt_iter_t func, void *arg)
557{
558 int size, cur, error;
559
560 size = madt->madt_hdr.sdth_len -
561 (sizeof(*madt) - sizeof(madt->madt_ents));
562 cur = 0;
563 error = 0;
564
565 while (size - cur > sizeof(struct acpi_madt_ent)) {
566 const struct acpi_madt_ent *ent;
567
568 ent = (const struct acpi_madt_ent *)&madt->madt_ents[cur];
569 if (ent->me_len < sizeof(*ent)) {
570 kprintf("madt_iterate_entries: invalid MADT "
571 "entry len %d\n", ent->me_len);
572 error = EINVAL;
573 break;
574 }
575 if (ent->me_len > (size - cur)) {
576 kprintf("madt_iterate_entries: invalid MADT "
577 "entry len %d, > table length\n", ent->me_len);
578 error = EINVAL;
579 break;
580 }
581
582 cur += ent->me_len;
583
584 /*
585 * Only Local APIC and I/O APIC are defined in
586 * ACPI specification 1.0 - 3.0
587 */
588 switch (ent->me_type) {
589 case MADT_ENT_LAPIC:
590 if (ent->me_len < sizeof(struct acpi_madt_lapic)) {
591 kprintf("madt_iterate_entries: invalid MADT "
592 "lapic entry len %d\n", ent->me_len);
593 error = EINVAL;
594 }
595 break;
596
597 case MADT_ENT_IOAPIC:
598 if (ent->me_len < sizeof(struct acpi_madt_ioapic)) {
599 kprintf("madt_iterate_entries: invalid MADT "
600 "ioapic entry len %d\n", ent->me_len);
601 error = EINVAL;
602 }
603 break;
604 }
605 if (error)
606 break;
607
608 error = func(arg, ent);
609 if (error)
610 break;
611 }
612 return error;
613}
614
91903a05
MN
615static int
616madt_lapic_probe(struct lapic_enumerator *e)
617{
618 vm_paddr_t madt_paddr;
619
620 madt_paddr = madt_probe();
621 if (madt_paddr == 0)
622 return ENXIO;
623
624 ((struct madt_lapic_enumerator *)e)->madt_paddr = madt_paddr;
625 return 0;
626}
627
628static void
629madt_lapic_enumerate(struct lapic_enumerator *e)
630{
631 vm_paddr_t madt_paddr;
632 vm_offset_t lapic_addr;
633 int bsp_apic_id;
634
635 madt_paddr = ((struct madt_lapic_enumerator *)e)->madt_paddr;
636 KKASSERT(madt_paddr != 0);
637
638 lapic_addr = madt_pass1(madt_paddr);
639 if (lapic_addr == 0)
640 panic("madt_lapic_enumerate no local apic\n");
641
1c1f402e
MN
642 lapic_init(lapic_addr);
643
644 bsp_apic_id = APIC_ID(lapic->id);
91903a05
MN
645 if (madt_pass2(madt_paddr, bsp_apic_id))
646 panic("mp_enable: madt_pass2 failed\n");
91903a05
MN
647}
648
649static struct madt_lapic_enumerator madt_lapic_enumerator = {
650 .enumerator = {
651 .lapic_prio = LAPIC_ENUM_PRIO_MADT,
652 .lapic_probe = madt_lapic_probe,
653 .lapic_enumerate = madt_lapic_enumerate
654 }
655};
656
657static void
658madt_apic_register(void)
659{
660 int prio;
661
662 prio = LAPIC_ENUM_PRIO_MADT;
663 kgetenv_int("hw.madt_lapic_prio", &prio);
664 madt_lapic_enumerator.enumerator.lapic_prio = prio;
665
666 lapic_enumerator_register(&madt_lapic_enumerator.enumerator);
667}
668SYSINIT(madt, SI_BOOT2_PRESMP, SI_ORDER_ANY, madt_apic_register, 0);
669
4ad5917f 670