2 * Copyright (c) 2009 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Sepherosa Ziehau <sepherosa@gmail.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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.
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
35 #include <sys/param.h>
37 #include <sys/kernel.h>
38 #include <sys/systm.h>
40 #include <machine/pmap.h>
41 #include <machine/smp.h>
42 #include <machine/md_var.h>
43 #include <machine/specialreg.h>
44 #include <machine_base/apic/mpapic.h>
47 #include "acpi_sdt_var.h"
49 #define FADT_VPRINTF(fmt, arg...) \
52 kprintf("ACPI FADT: " fmt , ##arg); \
55 /* Fixed ACPI Description Table */
57 struct acpi_sdth fadt_hdr;
58 uint32_t fadt_fw_ctrl;
62 uint16_t fadt_sci_int;
63 uint32_t fadt_smi_cmd;
65 uint8_t fadt_acpi_dis;
71 static int acpi_sci_irq = -1;
76 struct acpi_fadt *fadt;
77 vm_paddr_t fadt_paddr;
79 fadt_paddr = sdt_search(ACPI_FADT_SIG);
80 if (fadt_paddr == 0) {
81 kprintf("fadt_probe: can't locate FADT\n");
85 fadt = sdt_sdth_map(fadt_paddr);
86 KKASSERT(fadt != NULL);
89 * FADT in ACPI specification 1.0 - 4.0
91 if (fadt->fadt_hdr.sdth_rev < 1 || fadt->fadt_hdr.sdth_rev > 4) {
92 kprintf("fadt_probe: unsupported FADT revision %d\n",
93 fadt->fadt_hdr.sdth_rev);
97 if (fadt->fadt_hdr.sdth_len < sizeof(*fadt)) {
98 kprintf("fadt_probe: invalid FADT length %u\n",
99 fadt->fadt_hdr.sdth_len);
103 acpi_sci_irq = fadt->fadt_sci_int;
104 FADT_VPRINTF("ACPI FADT: SCI irq %d\n", acpi_sci_irq);
107 sdt_sdth_unmap(&fadt->fadt_hdr);
109 SYSINIT(fadt_probe, SI_BOOT2_PRESMP, SI_ORDER_SECOND, fadt_probe, 0);