]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
plat/common/x86: Add the `FADT` among the fetched tables
authorSergiu Moga <sergiu.moga@protonmail.com>
Tue, 16 May 2023 11:45:33 +0000 (14:45 +0300)
committerUnikraft <monkey@unikraft.io>
Fri, 11 Aug 2023 15:57:48 +0000 (15:57 +0000)
Add the definition for `FADT` and its related structures. Implement
a getter for it and add its signature in the list of `ACPI` fetched
tables.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Dragos Petre <dragos.petre27@gmail.com>
Reviewed-by: Marco Schlumpp <marco@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #911

plat/common/include/x86/acpi/acpi.h
plat/common/include/x86/acpi/sdt.h
plat/common/x86/acpi.c

index a23fdfbf1240efb936762795a8292cff0bab03e3..b4342296f5b3305df52852341e99612278403c0a 100644 (file)
@@ -60,6 +60,13 @@ struct acpi_rsdp {
  */
 struct acpi_madt *acpi_get_madt(void);
 
+/**
+ * Get the Fixed ACPI Description Table (FADT).
+ *
+ * @return ACPI table pointer on success, NULL otherwise.
+ */
+struct acpi_fadt *acpi_get_fadt(void);
+
 /**
  * Detect ACPI version and fetch ACPI tables.
  *
index bafa8fda46dcd7dff1469f4c9d3a95dab1037c2c..c8298f5056862181318720ec7f86c66c2d717a8b 100644 (file)
@@ -81,4 +81,114 @@ struct acpi_madt {
        __u8 entries[];
 } __packed;
 
+#define ACPI_GAS_ASID_SYS_MEM                          0x00
+#define ACPI_GAS_ASID_SYS_IO                           0x01
+#define ACPI_GAS_ASID_PCI_CFG                          0x02
+#define ACPI_GAS_ASID_EMBED_CTLR                       0x03
+#define ACPI_GAS_ASID_SMBUS                            0x04
+#define ACPI_GAS_ASID_SYS_CMOS                         0x05
+#define ACPI_GAS_ASID_PCI_BAR                          0x06
+#define ACPI_GAS_ASID_IPMI                             0x07
+#define ACPI_GAS_ASID_GPIO                             0x08
+#define ACPI_GAS_ASID_GENERIC_SBUS                     0x09
+#define ACPI_GAS_ASID_PCC                              0x0A
+#define ACPI_GAS_ASID_FFIXED_HW                                0x7F
+struct acpi_gas {
+       __u8 asid;
+       __u8 bit_sz;
+       __u8 bit_off;
+       __u8 access_sz;
+       __u64 addr;
+} __packed;
+
+#define ACPI_FADT_SIG                                  "FACP"
+#define ACPI_FADT_FLAGS_WBINVD                         (1 <<  0)
+#define ACPI_FADT_FLAGS_WBINVD_FLUSH                   (1 <<  1)
+#define ACPI_FADT_FLAGS_PROC_C1                                (1 <<  2)
+#define ACPI_FADT_FLAGS_P_C2_UP                                (1 <<  3)
+#define ACPI_FADT_FLAGS_PWR_BUTTON                     (1 <<  4)
+#define ACPI_FADT_FLAGS_SLP_BUTTON                     (1 <<  5)
+#define ACPI_FADT_FLAGS_FIX_RTC                                (1 <<  6)
+#define ACPI_FADT_FLAGS_RTC_S4                         (1 <<  7)
+#define ACPI_FADT_FLAGS_TMR_VAL_EXT                    (1 <<  8)
+#define ACPI_FADT_FLAGS_DCK_CAP                                (1 <<  9)
+#define ACPI_FADT_FLAGS_RST_REG_SUP                    (1 << 10)
+#define ACPI_FADT_FLAGS_SEALED_CASE                    (1 << 11)
+#define ACPI_FADT_FLAGS_HEADLESS                       (1 << 12)
+#define ACPI_FADT_FLAGS_CPU_SW_SLP                     (1 << 13)
+#define ACPI_FADT_FLAGS_PCIE_WALK                      (1 << 14)
+#define ACPI_FADT_FLAGS_USE_PLAT_CLK                   (1 << 15)
+#define ACPI_FADT_FLAGS_S4_RTC_STS_VALID               (1 << 16)
+#define ACPI_FADT_FLAGS_REMOTE_PWR_ON_CAP              (1 << 17)
+#define ACPI_FADT_FLAGS_FORCE_APIC_CLUSTER_MODEL       (1 << 18)
+#define ACPI_FADT_FLAGS_FORCE_APIC_PHYS_DEST_MODE      (1 << 19)
+#define ACPI_FADT_FLAGS_HW_REDUCED                     (1 << 20)
+#define ACPI_FADT_FLAGS_LOW_PWR_S0_IDLE_CAP            (1 << 21)
+#define ACPI_FADT_X86_BFLAGS_LEGACY_DEVS               (1 <<  1)
+#define ACPI_FADT_X86_BFLAGS_8042                      (1 <<  2)
+#define ACPI_FADT_X86_BFLAGS_NO_VGA                    (1 <<  3)
+#define ACPI_FADT_X86_BFLAGS_NO_MSI                    (1 <<  4)
+#define ACPI_FADT_X86_BFLAGS_NO_PCIE_ASPM              (1 <<  5)
+#define ACPI_FADT_X86_BFLAGS_NO_CMOS_RTC               (1 <<  6)
+#define ACPI_FADT_ARM_BFLAGS_PSCI                      (1 <<  0)
+#define ACPI_FADT_ARM_BFLAGS_PSCI_HVC                  (1 <<  1)
+struct acpi_fadt {
+       struct acpi_sdt_hdr hdr;
+       __u32 facs_paddr;
+       __u32 dsdt_paddr;
+       __u8 reserved0;
+       __u8 pref_pm_prof;
+       __u16 sci_irq;
+       __u32 smi_cmd;
+       __u8 acpi_enable;
+       __u8 acpi_disable;
+       __u8 s4bios_req;
+       __u8 pstate_ctlr;
+       __u32 pm1a_evt_blk;
+       __u32 pm1b_evt_blk;
+       __u32 pm1a_ctlr_blk;
+       __u32 pm1b_ctlr_blk;
+       __u32 pm2_ctlr_blk;
+       __u32 pm_tmr_blk;
+       __u32 gpe0_blk;
+       __u32 gpe1_blk;
+       __u8 pm1_evt_sz;
+       __u8 pm1_ctlr_sz;
+       __u8 pm2_ctlr_sz;
+       __u8 pm_tmr_sz;
+       __u8 gpe0_blk_sz;
+       __u8 gpe1_blk_sz;
+       __u8 gpe1_base;
+       __u8 cst_ctlr;
+       __u16 c2_lat;
+       __u16 c3_lat;
+       __u16 flush_sz;
+       __u16 flush_stride;
+       __u8 duty_offset;
+       __u8 duty_width;
+       __u8 day_alarm;
+       __u8 month_alarm;
+       __u8 century;
+       __u16 x86_bflags;
+       __u8 reserved1;
+       __u32 flags;
+       struct acpi_gas rst_reg;
+       __u8 rst_val;
+       __u16 arm_bflags;
+       __u8 minor_version;
+       __u64 xfacs_paddr;
+       __u64 xdsdt_paddr;
+       struct acpi_gas xpm1a_evt_blk;
+       struct acpi_gas xpm1b_evt_blk;
+       struct acpi_gas xpm1a_ctlr_blk;
+       struct acpi_gas xpm1b_ctlr_blk;
+       struct acpi_gas xpm2_ctlr_blk;
+       struct acpi_gas xpm_tmr_blk;
+       struct acpi_gas xgpe0_blk;
+       struct acpi_gas xgpe1_blk;
+       struct acpi_gas slp_ctlr_blk;
+       struct acpi_gas slp_sts_blk;
+       __u64 hyp_id;
+} __packed;
+
 #endif /* __PLAT_CMN_X86_SDT_H__ */
index 68432b6282a8bc908d90565225e9045944f62a42..ac499784a0ac9617f799be28de9b55cb92bc6e21 100644 (file)
@@ -46,6 +46,7 @@
 #define BIOS_ROM_STEP          16
 
 static struct acpi_madt *acpi_madt;
+static struct acpi_fadt *acpi_fadt;
 static __u8 acpi_rsdt_entries;
 static void *acpi_rsdt;
 static __u8 acpi10;
@@ -54,6 +55,10 @@ static struct {
        struct acpi_sdt_hdr **sdt;
        const char *sig;
 } acpi_sdts[] = {
+       {
+               .sdt = (struct acpi_sdt_hdr **)&acpi_fadt,
+               .sig = ACPI_FADT_SIG,
+       },
        {
                .sdt = (struct acpi_sdt_hdr **)&acpi_madt,
                .sig = ACPI_MADT_SIG,
@@ -260,3 +265,11 @@ struct acpi_madt *acpi_get_madt(void)
 {
        return acpi_madt;
 }
+
+/*
+ * Return the Fixed ACPI Description Table (FADT).
+ */
+struct acpi_fadt *acpi_get_fadt(void)
+{
+       return acpi_fadt;
+}