acpi: Parse FADT to extract SCI IRQ number
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 25 Mar 2011 13:50:53 +0000 (21:50 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 25 Mar 2011 14:59:15 +0000 (22:59 +0800)
sys/platform/pc32/acpica5/acpi_fadt.c [copied from sys/platform/pc32/acpica5/acpi_sdt.h with 52% similarity]
sys/platform/pc32/acpica5/acpi_sdt.h
sys/platform/pc32/conf/files
sys/platform/pc64/acpica5/acpi_fadt.c [copied from sys/platform/pc32/acpica5/acpi_sdt.h with 52% similarity]
sys/platform/pc64/acpica5/acpi_sdt.h
sys/platform/pc64/conf/files

similarity index 52%
copy from sys/platform/pc32/acpica5/acpi_sdt.h
copy to sys/platform/pc32/acpica5/acpi_fadt.c
index 02edcf9..b1d86bd 100644 (file)
  * SUCH DAMAGE.
  */
 
-#ifndef _ACPI_SDT_H_
-#define _ACPI_SDT_H_
-
-#define ACPI_SDTH_SIGLEN       4
-#define ACPI_RSDT_SIG          "RSDT"
-#define ACPI_XSDT_SIG          "XSDT"
-#define ACPI_MADT_SIG          "APIC"
-
-/* System Description Table Header */
-struct acpi_sdth {
-       uint8_t                 sdth_sig[ACPI_SDTH_SIGLEN];
-       uint32_t                sdth_len;
-       uint8_t                 sdth_rev;
-       uint8_t                 sdth_cksum;
-       uint8_t                 sdth_oem_id[6];
-       uint8_t                 sdth_oem_tbid[8];
-       uint32_t                sdth_oem_rev;
-       uint32_t                sdth_crt_id;
-       uint32_t                sdth_crt_rev;
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/kernel.h>
+#include <sys/systm.h>
+
+#include <machine/pmap.h>
+#include <machine/smp.h>
+#include <machine/md_var.h>
+#include <machine/specialreg.h>
+#include <machine_base/apic/mpapic.h>
+
+#include "acpi_sdt.h"
+#include "acpi_sdt_var.h"
+
+#define FADT_VPRINTF(fmt, arg...) \
+do { \
+       if (bootverbose) \
+               kprintf("ACPI FADT: " fmt , ##arg); \
+} while (0)
+
+/* Fixed ACPI Description Table */
+struct acpi_fadt {
+       struct acpi_sdth        fadt_hdr;
+       uint32_t                fadt_fw_ctrl;
+       uint32_t                fadt_dsdt;
+       uint8_t                 fadt_rsvd1;
+       uint8_t                 fadt_pm_prof;
+       uint16_t                fadt_sci_int;
+       uint32_t                fadt_smi_cmd;
+       uint8_t                 fadt_acpi_en;
+       uint8_t                 fadt_acpi_dis;
+       uint8_t                 fadt_s4bios;
+       uint8_t                 fadt_pstate;
+       /* More ... */
 } __packed;
 
-#endif /* !_ACPI_SDT_H_ */
+static int                     acpi_sci_irq = -1;
+
+static void
+fadt_probe(void)
+{
+       struct acpi_fadt *fadt;
+       vm_paddr_t fadt_paddr;
+
+       fadt_paddr = sdt_search(ACPI_FADT_SIG);
+       if (fadt_paddr == 0) {
+               kprintf("fadt_probe: can't locate FADT\n");
+               return;
+       }
+
+       fadt = sdt_sdth_map(fadt_paddr);
+       KKASSERT(fadt != NULL);
+
+       /*
+        * FADT in ACPI specification 1.0 - 4.0
+        */
+       if (fadt->fadt_hdr.sdth_rev < 1 || fadt->fadt_hdr.sdth_rev > 4) {
+               kprintf("fadt_probe: unsupported FADT revision %d\n",
+                       fadt->fadt_hdr.sdth_rev);
+               goto back;
+       }
+
+       if (fadt->fadt_hdr.sdth_len < sizeof(*fadt)) {
+               kprintf("fadt_probe: invalid FADT length %u\n",
+                       fadt->fadt_hdr.sdth_len);
+               goto back;
+       }
+
+       acpi_sci_irq = fadt->fadt_sci_int;
+       kprintf("ACPI FADT: SCI irq %d\n", acpi_sci_irq);
+
+back:
+       sdt_sdth_unmap(&fadt->fadt_hdr);
+}
+SYSINIT(fadt_probe, SI_BOOT2_PRESMP, SI_ORDER_SECOND, fadt_probe, 0);
index 02edcf9..d0b5c6e 100644 (file)
@@ -39,6 +39,7 @@
 #define ACPI_RSDT_SIG          "RSDT"
 #define ACPI_XSDT_SIG          "XSDT"
 #define ACPI_MADT_SIG          "APIC"
+#define ACPI_FADT_SIG          "FACP"
 
 /* System Description Table Header */
 struct acpi_sdth {
index 69263fd..d8aee14 100644 (file)
@@ -219,6 +219,7 @@ platform/pc32/i386/userconfig.c             optional        userconfig
 platform/pc32/i386/vm86.c              standard
 platform/pc32/i386/vm_machdep.c                standard
 platform/pc32/i386/cpufreq_machdep.c   standard
+platform/pc32/acpica5/acpi_fadt.c      optional        smp
 platform/pc32/acpica5/acpi_madt.c      optional        smp
 platform/pc32/acpica5/acpi_sdt.c       optional        smp
 platform/pc32/isa/asc.c                        optional        asc
similarity index 52%
copy from sys/platform/pc32/acpica5/acpi_sdt.h
copy to sys/platform/pc64/acpica5/acpi_fadt.c
index 02edcf9..b1d86bd 100644 (file)
  * SUCH DAMAGE.
  */
 
-#ifndef _ACPI_SDT_H_
-#define _ACPI_SDT_H_
-
-#define ACPI_SDTH_SIGLEN       4
-#define ACPI_RSDT_SIG          "RSDT"
-#define ACPI_XSDT_SIG          "XSDT"
-#define ACPI_MADT_SIG          "APIC"
-
-/* System Description Table Header */
-struct acpi_sdth {
-       uint8_t                 sdth_sig[ACPI_SDTH_SIGLEN];
-       uint32_t                sdth_len;
-       uint8_t                 sdth_rev;
-       uint8_t                 sdth_cksum;
-       uint8_t                 sdth_oem_id[6];
-       uint8_t                 sdth_oem_tbid[8];
-       uint32_t                sdth_oem_rev;
-       uint32_t                sdth_crt_id;
-       uint32_t                sdth_crt_rev;
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/kernel.h>
+#include <sys/systm.h>
+
+#include <machine/pmap.h>
+#include <machine/smp.h>
+#include <machine/md_var.h>
+#include <machine/specialreg.h>
+#include <machine_base/apic/mpapic.h>
+
+#include "acpi_sdt.h"
+#include "acpi_sdt_var.h"
+
+#define FADT_VPRINTF(fmt, arg...) \
+do { \
+       if (bootverbose) \
+               kprintf("ACPI FADT: " fmt , ##arg); \
+} while (0)
+
+/* Fixed ACPI Description Table */
+struct acpi_fadt {
+       struct acpi_sdth        fadt_hdr;
+       uint32_t                fadt_fw_ctrl;
+       uint32_t                fadt_dsdt;
+       uint8_t                 fadt_rsvd1;
+       uint8_t                 fadt_pm_prof;
+       uint16_t                fadt_sci_int;
+       uint32_t                fadt_smi_cmd;
+       uint8_t                 fadt_acpi_en;
+       uint8_t                 fadt_acpi_dis;
+       uint8_t                 fadt_s4bios;
+       uint8_t                 fadt_pstate;
+       /* More ... */
 } __packed;
 
-#endif /* !_ACPI_SDT_H_ */
+static int                     acpi_sci_irq = -1;
+
+static void
+fadt_probe(void)
+{
+       struct acpi_fadt *fadt;
+       vm_paddr_t fadt_paddr;
+
+       fadt_paddr = sdt_search(ACPI_FADT_SIG);
+       if (fadt_paddr == 0) {
+               kprintf("fadt_probe: can't locate FADT\n");
+               return;
+       }
+
+       fadt = sdt_sdth_map(fadt_paddr);
+       KKASSERT(fadt != NULL);
+
+       /*
+        * FADT in ACPI specification 1.0 - 4.0
+        */
+       if (fadt->fadt_hdr.sdth_rev < 1 || fadt->fadt_hdr.sdth_rev > 4) {
+               kprintf("fadt_probe: unsupported FADT revision %d\n",
+                       fadt->fadt_hdr.sdth_rev);
+               goto back;
+       }
+
+       if (fadt->fadt_hdr.sdth_len < sizeof(*fadt)) {
+               kprintf("fadt_probe: invalid FADT length %u\n",
+                       fadt->fadt_hdr.sdth_len);
+               goto back;
+       }
+
+       acpi_sci_irq = fadt->fadt_sci_int;
+       kprintf("ACPI FADT: SCI irq %d\n", acpi_sci_irq);
+
+back:
+       sdt_sdth_unmap(&fadt->fadt_hdr);
+}
+SYSINIT(fadt_probe, SI_BOOT2_PRESMP, SI_ORDER_SECOND, fadt_probe, 0);
index 02edcf9..d0b5c6e 100644 (file)
@@ -39,6 +39,7 @@
 #define ACPI_RSDT_SIG          "RSDT"
 #define ACPI_XSDT_SIG          "XSDT"
 #define ACPI_MADT_SIG          "APIC"
+#define ACPI_FADT_SIG          "FACP"
 
 /* System Description Table Header */
 struct acpi_sdth {
index c18215c..a2e2419 100644 (file)
@@ -201,6 +201,7 @@ kern/syscalls.c                     standard
 platform/pc64/x86_64/mp_machdep.c              optional        smp
 platform/pc64/acpica5/acpi_sdt.c       optional        smp
 platform/pc64/acpica5/acpi_madt.c      optional        smp
+platform/pc64/acpica5/acpi_fadt.c      optional        smp
 dev/misc/atkbd/atkbd_isa.c             optional        atkbd
 dev/misc/atkbdc_layer/atkbdc_isa.c     optional        atkbdc
 dev/misc/ppc/ppc.c                     optional        ppc