]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
plat: Move everything `ACPI` to a platform common location
authorSergiu Moga <sergiu.moga@protonmail.com>
Tue, 16 May 2023 12:02:13 +0000 (15:02 +0300)
committerUnikraft <monkey@unikraft.io>
Fri, 11 Aug 2023 15:57:48 +0000 (15:57 +0000)
Since `ACPI` is a platform and architecture agnostic specification,
move it to a place where reality reflects that.

Furthermore, add a corresponding configuration option and dependency
on it for x86 SMP builds.

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

12 files changed:
plat/Config.uk
plat/common/acpi.c [new file with mode: 0644]
plat/common/include/uk/plat/common/acpi.h [new file with mode: 0644]
plat/common/include/uk/plat/common/madt.h [new file with mode: 0644]
plat/common/include/uk/plat/common/sdt.h [new file with mode: 0644]
plat/common/include/x86/acpi/acpi.h [deleted file]
plat/common/include/x86/acpi/madt.h [deleted file]
plat/common/include/x86/acpi/sdt.h [deleted file]
plat/common/x86/acpi.c [deleted file]
plat/common/x86/lcpu.c
plat/kvm/Makefile.uk
plat/kvm/x86/setup.c

index 95b59b6bdfe5474a73b230faa59b0cebe109bbc0..f477e683418dc3fdd264ef8b3f3a8ddae7a24bb2 100644 (file)
@@ -15,10 +15,22 @@ config UKPLAT_MEMREGION_MAX_COUNT
                the amount of statically allocated space in the image made available
                for storing memory region descriptors' metadata.
 
+if ARCH_X86_64 || (KVM_BOOT_EFI_STUB && ARCH_ARM_64)
+
+config UKPLAT_ACPI
+       bool "Enable parsing of ACPI structures"
+       default n
+
+if UKPLAT_ACPI
+
 config UKPLAT_ACPI_CHECKSUM
        bool "Verify ACPI structures' checksum"
        default n
 
+endif
+
+endif
+
 config UKPLAT_LCPU_MAXCOUNT
        int "Maximum number of supported logical CPUs"
        range 1 256
@@ -28,6 +40,7 @@ config HAVE_SMP
        bool
        default y if UKPLAT_LCPU_MAXCOUNT > 1
        default n
+       select UKPLAT_ACPI if ARCH_X86_64
 
 menu "Multiprocessor Configuration"
        depends on HAVE_SMP
diff --git a/plat/common/acpi.c b/plat/common/acpi.c
new file mode 100644 (file)
index 0000000..913c1b0
--- /dev/null
@@ -0,0 +1,279 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Cristian Vijelie <cristianvijelie@gmail.com>
+ *          Sergiu Moga <sergiu.moga@protonmail.com>
+ *
+ * Copyright (c) 2023, University POLITEHNICA of Bucharest. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <uk/print.h>
+#include <uk/assert.h>
+#include <uk/plat/common/acpi.h>
+#include <string.h>
+#include <errno.h>
+#include <kvm/efi.h>
+#include <uk/plat/common/bootinfo.h>
+
+#define RSDP10_LEN             20
+#define BIOS_ROM_START         0xE0000UL
+#define BIOS_ROM_END           0xFFFFFUL
+#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;
+
+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,
+       },
+};
+
+static inline __paddr_t get_rsdt_entry(int idx)
+{
+       __u8 *entryp = (__u8 *)acpi_rsdt + sizeof(struct acpi_sdt_hdr);
+
+       if (acpi10)
+               return ((__u32 *)entryp)[idx];
+
+       return ((__u64 *)entryp)[idx];
+}
+
+static __u8 get_acpi_checksum(void __maybe_unused *buf, __sz __maybe_unused len)
+{
+#ifdef CONFIG_UKPLAT_ACPI_CHECKSUM
+       const __u8 *const ptr_end = (__u8 *)buf + len;
+       const __u8 *ptr = (__u8 *)buf;
+       __u8 checksum = 0;
+
+       while (ptr < ptr_end)
+               checksum += *ptr++;
+
+       return checksum;
+#else
+       return 0;
+#endif
+}
+
+static void acpi_init_tables(void)
+{
+       struct acpi_sdt_hdr *h;
+       const char *sig;
+       __sz i, j;
+
+       UK_ASSERT(acpi_rsdt);
+
+       for (i = 0; i < acpi_rsdt_entries; i++)
+               for (j = 0; j < ARRAY_SIZE(acpi_sdts); j++) {
+                       if (*acpi_sdts[j].sdt)
+                               continue;
+
+                       h = (struct acpi_sdt_hdr *)get_rsdt_entry(i);
+                       sig = acpi_sdts[j].sig;
+
+                       if (!memcmp(h->sig, sig, ACPI_SDT_SIG_LEN)) {
+                               if (unlikely(get_acpi_checksum(h,
+                                                              h->tab_len))) {
+                                       uk_pr_warn("ACPI %s corrupted\n", sig);
+
+                                       continue;
+                               }
+
+                               *acpi_sdts[j].sdt = h;
+
+                               continue;
+                       }
+               }
+}
+
+/*
+ * Print the detected ACPI tables to the debug output.
+ */
+#ifdef UK_DEBUG
+static void acpi_list_tables(void)
+{
+       int i;
+
+       UK_ASSERT(acpi_rsdt);
+
+       uk_pr_debug("%d ACPI tables found from %.4s\n", acpi_rsdt_entries,
+                   acpi10 ? ACPI_RSDT_SIG : ACPI_XSDT_SIG);
+       for (i = 0; i < ARRAY_SIZE(acpi_sdts); i++) {
+               if (!acpi_sdts[i].sdt)
+                       continue;
+
+               uk_pr_debug("%p: %.4s\n", acpi_sdts[i].sdt, acpi_sdts[i].sig);
+       }
+}
+#endif /* UK_DEBUG */
+
+static struct acpi_rsdp *acpi_get_efi_st_rsdp(void)
+{
+       struct ukplat_bootinfo *bi = ukplat_bootinfo_get();
+       uk_efi_uintn_t ct_count, i;
+       struct uk_efi_cfg_tbl *ct;
+       struct acpi_rsdp *rsdp;
+
+       UK_ASSERT(bi);
+
+       if (!bi->efi_st)
+               return NULL;
+
+       ct = ((struct uk_efi_sys_tbl *)bi->efi_st)->configuration_table;
+       ct_count = ((struct uk_efi_sys_tbl *)bi->efi_st)->number_of_table_entries;
+
+       UK_ASSERT(ct);
+       UK_ASSERT(ct_count);
+
+       rsdp = NULL;
+       for (i = 0; i < ct_count; i++)
+               if (!memcmp(&ct[i].vendor_guid, UK_EFI_ACPI20_TABLE_GUID,
+                           sizeof(ct[i].vendor_guid))) {
+                       rsdp = ct[i].vendor_table;
+
+                       break;
+               } else if (!memcmp(&ct[i].vendor_guid, UK_EFI_ACPI10_TABLE_GUID,
+                                sizeof(ct[i].vendor_guid))) {
+                       rsdp = ct[i].vendor_table;
+               }
+
+       uk_pr_debug("ACPI RSDP present at %p\n", rsdp);
+
+       return rsdp;
+}
+
+#if defined(__X86_64__)
+static struct acpi_rsdp *acpi_get_bios_rom_rsdp(void)
+{
+       __paddr_t ptr;
+
+       for (ptr = BIOS_ROM_START; ptr < BIOS_ROM_END; ptr += BIOS_ROM_STEP)
+               if (!memcmp((void *)ptr, RSDP_SIG, sizeof(RSDP_SIG) - 1)) {
+                       uk_pr_debug("ACPI RSDP present at %lx\n", ptr);
+
+                       return (struct acpi_rsdp *)ptr;
+               }
+
+       return NULL;
+}
+#endif
+
+static struct acpi_rsdp *acpi_get_rsdp(void)
+{
+       struct acpi_rsdp *rsdp;
+
+       rsdp = acpi_get_efi_st_rsdp();
+       if (rsdp)
+               return rsdp;
+
+#if defined(__X86_64__)
+       return acpi_get_bios_rom_rsdp();
+#else
+       return NULL;
+#endif
+}
+
+/*
+ * Detect ACPI version and discover ACPI tables.
+ */
+int acpi_init(void)
+{
+       struct acpi_rsdp *rsdp;
+       struct acpi_sdt_hdr *h;
+
+       rsdp = acpi_get_rsdp();
+       if (unlikely(!rsdp))
+               return -ENOENT;
+
+       if (unlikely(get_acpi_checksum(rsdp, RSDP10_LEN))) {
+               uk_pr_err("ACPI 1.0 RSDP corrupted\n");
+
+               return -ENOENT;
+       }
+
+       if (rsdp->revision == 0) {
+               h = (struct acpi_sdt_hdr *)((__uptr)rsdp->rsdt_paddr);
+               acpi_rsdt_entries = (h->tab_len - sizeof(*h)) / 4;
+               acpi10 = 1;
+       } else {
+               if (unlikely(get_acpi_checksum(rsdp, sizeof(*rsdp)))) {
+                       uk_pr_err("ACPI 1.0 RSDP corrupted\n");
+
+                       return -ENOENT;
+               }
+
+               h = (struct acpi_sdt_hdr *)rsdp->xsdt_paddr;
+               acpi_rsdt_entries = (h->tab_len - sizeof(*h)) / 8;
+       }
+
+       UK_ASSERT(h);
+
+       if (unlikely(get_acpi_checksum(h, h->tab_len))) {
+               uk_pr_err("ACPI RSDT corrupted\n");
+
+               return -ENOENT;
+       }
+
+       acpi_rsdt = h;
+
+       acpi_init_tables();
+
+#ifdef UK_DEBUG
+       acpi_list_tables();
+#endif
+
+       return 0;
+}
+
+
+/*
+ * Return the Multiple APIC Descriptor Table (MADT).
+ */
+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;
+}
diff --git a/plat/common/include/uk/plat/common/acpi.h b/plat/common/include/uk/plat/common/acpi.h
new file mode 100644 (file)
index 0000000..1b4f8a0
--- /dev/null
@@ -0,0 +1,77 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Cristian Vijelie <cristianvijelie@gmail.com>
+ *          Sergiu Moga <sergiu.moga@protonmail.com>
+ *
+ * Copyright (c) 2023, University POLITEHNICA of Bucharest. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef __PLAT_CMN_ACPI_H__
+#define __PLAT_CMN_ACPI_H__
+
+#include "sdt.h"
+#include "madt.h"
+
+#define RSDP_SIG               "RSD PTR "
+#define RSDP_SIG_LEN           8
+
+struct acpi_rsdp {
+       char sig[RSDP_SIG_LEN];
+       __u8 checksum;
+       char oem_id[ACPI_OEM_ID_LEN];
+       __u8 revision;
+       __u32 rsdt_paddr;
+       __u32 tab_len;
+       __u64 xsdt_paddr;
+       __u8 xchecksum;
+       __u8 reserved[3];
+} __packed;
+
+/**
+ * Get the Multiple APIC Descriptor Table (MADT).
+ *
+ * @return ACPI table pointer on success, NULL otherwise.
+ */
+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.
+ *
+ * @return 0 on success, -errno otherwise.
+ */
+int acpi_init(void);
+
+#endif /* __PLAT_CMN_ACPI_H__ */
diff --git a/plat/common/include/uk/plat/common/madt.h b/plat/common/include/uk/plat/common/madt.h
new file mode 100644 (file)
index 0000000..cabb3d9
--- /dev/null
@@ -0,0 +1,244 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Cristian Vijelie <cristianvijelie@gmail.com>
+ *          Sergiu Moga <sergiu.moga@protonmail.com>
+ *
+ * Copyright (c) 2023, University POLITEHNICA of Bucharest. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef __PLAT_CMN_MADT_H__
+#define __PLAT_CMN_MADT_H__
+
+#include "sdt.h"
+
+#define ACPI_MADT_LAPIC                                                0x00
+#define ACPI_MADT_IO_APIC                                      0x01
+#define ACPI_MADT_IRQ_SRC_OVRD                                 0x02
+#define ACPI_MADT_NMI_SOURCE                                   0x03
+#define ACPI_MADT_LAPIC_NMI                                    0x04
+#define ACPI_MADT_LAPIC_ADDR_OVRD                              0x05
+#define ACPI_MADT_IO_SAPIC                                     0x06
+#define ACPI_MADT_LSAPIC                                       0x07
+#define ACPI_MADT_PLAT_IRQ_SRCS                                        0x08
+#define ACPI_MADT_LX2APIC                                      0x09
+#define ACPI_MADT_LX2APIC_NMI                                  0x0a
+#define ACPI_MADT_GICC                                         0x0b
+#define ACPI_MADT_GICD                                         0x0c
+#define ACPI_MADT_GIC_MSI                                      0x0d
+#define ACPI_MADT_GICR                                         0x0e
+#define ACPI_MADT_GIC_ITS                                      0x0f
+#define ACPI_MADT_MP_WKP                                       0x10
+
+/*
+ * The following structures are declared according to the ACPI
+ * specification version 6.3.
+ *
+ * TODO: This header includes structures that are not related to x86. However,
+ * we move the header when integrating other architectures.
+ */
+
+/* Processor Local APIC Structure */
+#define ACPI_MADT_LAPIC_FLAGS_EN                               0x01
+#define ACPI_MADT_LAPIC_FLAGS_ON_CAP                           0x02
+struct acpi_madt_lapic {
+       struct acpi_subsdt_hdr hdr;
+       __u8 cpu_id;
+       __u8 lapic_id;
+       __u32 flags;
+} __packed;
+
+/* I/O APIC Structure */
+struct acpi_madt_ioapic {
+       struct acpi_subsdt_hdr hdr;
+       __u8 ioapic_id;
+       __u8 reserved;
+       __u32 ioapic_paddr;
+       __u32 gsi_base;
+} __packed;
+
+/* Interrupt Source Override Structure */
+struct acpi_madt_irq_src_ovrd {
+       struct acpi_subsdt_hdr hdr;
+       __u8 bus;
+       __u8 src_irq;
+       __u32 gsi;
+       __u16 flags;
+} __packed;
+
+/* Non-Maskable Interrupt (NMI) Source Structure */
+struct acpi_madt_nmi_src {
+       struct acpi_subsdt_hdr hdr;
+       __u16 flags;
+       __u32 gsi;
+} __packed;
+
+/* Local APIC NMI Structure */
+struct acpi_madt_lapic_nmi {
+       struct acpi_subsdt_hdr hdr;
+       __u8 cpu_id;
+       __u16 flags;
+       __u8 lint;
+} __packed;
+
+/* Local APIC Address Override Structure */
+struct acpi_madt_lapic_addr_ovrd {
+       struct acpi_subsdt_hdr hdr;
+       __u16 reserved;
+       __u64 lapic_paddr;
+} __packed;
+
+/* I/O SAPIC Structure */
+struct acpi_madt_iosapic {
+       struct acpi_subsdt_hdr hdr;
+       __u8 iosapic_id;
+       __u8 reserved;
+       __u32 gsi_base;
+       __u64 iosapic_paddr;
+} __packed;
+
+/* Local SAPIC Structure */
+struct acpi_madt_lsapic {
+       struct acpi_subsdt_hdr hdr;
+       __u8 cpu_id;
+       __u8 lsapic_id;
+       __u8 lsapic_eid;
+       __u8 reserved[3];
+       __u32 flags;
+       __u32 uid;
+       char uid_string[1];
+} __packed;
+
+/* Platform Interrupt Source Structure */
+struct acpi_madt_irq_src {
+       struct acpi_subsdt_hdr hdr;
+       __u16 mps_inti_flags;
+       __u8 irq_type;
+       __u8 cpu_id;
+       __u8 cpu_eid;
+       __u8 io_sapic_vector;
+       __u32 gsi;
+       __u32 flags;
+} __packed;
+
+/* Processor Local x2APIC Structure */
+#define ACPI_MADT_X2APIC_FLAGS_EN                              0x01
+#define ACPI_MADT_X2APIC_FLAGS_ON_CAP                          0x02
+struct acpi_madt_x2apic {
+       struct acpi_subsdt_hdr hdr;
+       __u16 reserved;
+       __u32 lapic_id;
+       __u32 flags;
+       __u32 uid;
+} __packed;
+
+/* Local x2APIC NMI Structure */
+struct acpi_madt_x2apic_nmi {
+       struct acpi_subsdt_hdr hdr;
+       __u16 mps_inti_flags;
+       __u32 uid;
+       __u8 lint;
+       __u8 reserved[3];
+} __packed;
+
+/* GIC CPU Interface (GICC) Structure */
+struct acpi_madt_gicc {
+       struct acpi_subsdt_hdr hdr;
+       __u16 reserved;
+       __u32 cpu_if;
+       __u32 uid;
+       __u32 flags;
+       __u32 parking_version;
+       __u32 perf_mon_gsiv;
+       __u64 parked_paddr;
+       __u64 paddr;
+       __u64 gicv;
+       __u64 gich;
+       __u32 vgic_maintenance_gsiv;
+       __u64 gicr_paddr;
+       __u64 mpidr;
+       __u8 power_efficiency;
+       __u8 reserved2;
+       __u16 spe_gsiv;
+} __packed;
+
+/* GIC Distributor (GICD) Structure */
+struct acpi_madt_gicd {
+       struct acpi_subsdt_hdr hdr;
+       __u16 reserved;
+       __u32 gic_id;
+       __u64 paddr;
+       __u32 gsi_base;
+       __u8 version;
+       __u8 reserved2[3];
+} __packed;
+
+/* GIC MSI Frame Structure */
+struct acpi_madt_gic_msi_frame {
+       struct acpi_subsdt_hdr hdr;
+       __u16 reserved;
+       __u32 msi_frame_id;
+       __u64 paddr;
+       __u32 flags;
+       __u16 spi_count;
+       __u16 spi_base;
+} __packed;
+
+/* GIC Redistributor (GICR) Structure */
+struct acpi_madt_gicr {
+       struct acpi_subsdt_hdr hdr;
+       __u16 reserved;
+       __u64 paddr;
+       __u32 len;
+} __packed;
+
+/* GIC Interrupt Translation Service (ITS) Structure */
+struct acpi_madt_gic_its {
+       struct acpi_subsdt_hdr hdr;
+       __u16 reserved;
+       __u32 id;
+       __u64 paddr;
+       __u32 reserved2;
+} __packed;
+
+/* Multiprocessor Wakeup Structure */
+struct acpi_madt_mp_wkp_src {
+       struct acpi_subsdt_hdr hdr;
+       __u16 mbox_version;
+       __u32 reserved;
+       __u64 mbox_paddr;
+} __packed;
+
+/**
+ * Return the Multiple APIC Descriptor Table (MADT).
+ *
+ * @return Pointer to MADT.
+ */
+struct acpi_madt *acpi_get_madt(void);
+
+#endif /* __PLAT_CMN_MADT_H__ */
diff --git a/plat/common/include/uk/plat/common/sdt.h b/plat/common/include/uk/plat/common/sdt.h
new file mode 100644 (file)
index 0000000..168d389
--- /dev/null
@@ -0,0 +1,194 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Cristian Vijelie <cristianvijelie@gmail.com>
+ *          Sergiu Moga <sergiu.moga@protonmail.com>
+ *
+ * Copyright (c) 2023, University POLITEHNICA of Bucharest. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef __PLAT_CMN_SDT_H__
+#define __PLAT_CMN_SDT_H__
+
+#include <uk/arch/types.h>
+#include <uk/essentials.h>
+
+#define ACPI_OEM_ID_LEN                                        6
+#define ACPI_OEM_TAB_ID_LEN                            8
+#define ACPI_SDT_SIG_LEN                               4
+#define ACPI_SDT_CREATOR_ID_LEN                                4
+
+struct acpi_sdt_hdr {
+       char sig[ACPI_SDT_SIG_LEN];
+       __u32 tab_len;
+       __u8 revision;
+       __u8 checksum;
+       char oem_id[ACPI_OEM_ID_LEN];
+       char oem_table_id[ACPI_OEM_TAB_ID_LEN];
+       __u32 oem_revision;
+       char creator_id[ACPI_SDT_CREATOR_ID_LEN];
+       __u32 creator_revision;
+} __packed;
+
+struct acpi_subsdt_hdr {
+       __u8 type;
+       __u8 len;
+} __packed;
+
+#define ACPI_RSDT_SIG                                  "RSDT"
+struct acpi_rsdt {
+       struct acpi_sdt_hdr hdr;
+       __u32 entry[];
+} __packed;
+
+#define ACPI_XSDT_SIG                                  "XSDT"
+struct acpi_xsdt {
+       struct acpi_sdt_hdr hdr;
+       __u64 entry[];
+} __packed;
+
+#define ACPI_MADT_SIG                                  "APIC"
+#define ACPI_MADT_FLAGS_PCAT_COMPAT                    0x0001
+struct acpi_madt {
+       struct acpi_sdt_hdr hdr;
+       __u32 lapic_paddr;
+       __u32 flags;
+       __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_SDT_H__ */
diff --git a/plat/common/include/x86/acpi/acpi.h b/plat/common/include/x86/acpi/acpi.h
deleted file mode 100644 (file)
index b434229..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause */
-/*
- * Authors: Cristian Vijelie <cristianvijelie@gmail.com>
- *          Sergiu Moga <sergiu.moga@protonmail.com>
- *
- * Copyright (c) 2023, University POLITEHNICA of Bucharest. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the names of its
- *    contributors may be used to endorse or promote products derived from
- *    this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef __PLAT_CMN_X86_ACPI_H__
-#define __PLAT_CMN_X86_ACPI_H__
-
-#include <x86/acpi/sdt.h>
-#include <x86/acpi/madt.h>
-
-#define RSDP_SIG               "RSD PTR "
-#define RSDP_SIG_LEN           8
-
-struct acpi_rsdp {
-       char sig[RSDP_SIG_LEN];
-       __u8 checksum;
-       char oem_id[ACPI_OEM_ID_LEN];
-       __u8 revision;
-       __u32 rsdt_paddr;
-       __u32 tab_len;
-       __u64 xsdt_paddr;
-       __u8 xchecksum;
-       __u8 reserved[3];
-} __packed;
-
-/**
- * Get the Multiple APIC Descriptor Table (MADT).
- *
- * @return ACPI table pointer on success, NULL otherwise.
- */
-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.
- *
- * @return 0 on success, -errno otherwise.
- */
-int acpi_init(void);
-
-#endif /* __PLAT_CMN_X86_ACPI_H__ */
diff --git a/plat/common/include/x86/acpi/madt.h b/plat/common/include/x86/acpi/madt.h
deleted file mode 100644 (file)
index 002a3fb..0000000
+++ /dev/null
@@ -1,245 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause */
-/*
- * Authors: Cristian Vijelie <cristianvijelie@gmail.com>
- *          Sergiu Moga <sergiu.moga@protonmail.com>
- *
- * Copyright (c) 2023, University POLITEHNICA of Bucharest. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the names of its
- *    contributors may be used to endorse or promote products derived from
- *    this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef __PLAT_CMN_X86_MADT_H__
-#define __PLAT_CMN_X86_MADT_H__
-
-#include <x86/acpi/sdt.h>
-
-#define ACPI_MADT_LAPIC                                                0x00
-#define ACPI_MADT_IO_APIC                                      0x01
-#define ACPI_MADT_IRQ_SRC_OVRD                                 0x02
-#define ACPI_MADT_NMI_SOURCE                                   0x03
-#define ACPI_MADT_LAPIC_NMI                                    0x04
-#define ACPI_MADT_LAPIC_ADDR_OVRD                              0x05
-#define ACPI_MADT_IO_SAPIC                                     0x06
-#define ACPI_MADT_LSAPIC                                       0x07
-#define ACPI_MADT_PLAT_IRQ_SRCS                                        0x08
-#define ACPI_MADT_LX2APIC                                      0x09
-#define ACPI_MADT_LX2APIC_NMI                                  0x0a
-#define ACPI_MADT_GICC                                         0x0b
-#define ACPI_MADT_GICD                                         0x0c
-#define ACPI_MADT_GIC_MSI                                      0x0d
-#define ACPI_MADT_GICR                                         0x0e
-#define ACPI_MADT_GIC_ITS                                      0x0f
-#define ACPI_MADT_MP_WKP                                       0x10
-
-/*
- * The following structures are declared according to the ACPI
- * specification version 6.3.
- *
- * TODO: This header includes structures that are not related to x86. However,
- * we move the header when integrating other architectures.
- */
-
-/* Processor Local APIC Structure */
-#define ACPI_MADT_LAPIC_FLAGS_EN                               0x01
-#define ACPI_MADT_LAPIC_FLAGS_ON_CAP                           0x02
-struct acpi_madt_lapic {
-       struct acpi_subsdt_hdr hdr;
-       __u8 cpu_id;
-       __u8 lapic_id;
-       __u32 flags;
-} __packed;
-
-/* I/O APIC Structure */
-struct acpi_madt_ioapic {
-       struct acpi_subsdt_hdr hdr;
-       __u8 ioapic_id;
-       __u8 reserved;
-       __u32 ioapic_paddr;
-       __u32 gsi_base;
-} __packed;
-
-/* Interrupt Source Override Structure */
-struct acpi_madt_irq_src_ovrd {
-       struct acpi_subsdt_hdr hdr;
-       __u8 bus;
-       __u8 src_irq;
-       __u32 gsi;
-       __u16 flags;
-} __packed;
-
-/* Non-Maskable Interrupt (NMI) Source Structure */
-struct acpi_madt_nmi_src {
-       struct acpi_subsdt_hdr hdr;
-       __u16 flags;
-       __u32 gsi;
-} __packed;
-
-/* Local APIC NMI Structure */
-struct acpi_madt_lapic_nmi {
-       struct acpi_subsdt_hdr hdr;
-       __u8 cpu_id;
-       __u16 flags;
-       __u8 lint;
-} __packed;
-
-/* Local APIC Address Override Structure */
-struct acpi_madt_lapic_addr_ovrd {
-       struct acpi_subsdt_hdr hdr;
-       __u16 reserved;
-       __u64 lapic_paddr;
-} __packed;
-
-/* I/O SAPIC Structure */
-struct acpi_madt_iosapic {
-       struct acpi_subsdt_hdr hdr;
-       __u8 iosapic_id;
-       __u8 reserved;
-       __u32 gsi_base;
-       __u64 iosapic_paddr;
-} __packed;
-
-/* Local SAPIC Structure */
-struct acpi_madt_lsapic {
-       struct acpi_subsdt_hdr hdr;
-       __u8 cpu_id;
-       __u8 lsapic_id;
-       __u8 lsapic_eid;
-       __u8 reserved[3];
-       __u32 flags;
-       __u32 uid;
-       char uid_string[1];
-} __packed;
-
-/* Platform Interrupt Source Structure */
-struct acpi_madt_irq_src {
-       struct acpi_subsdt_hdr hdr;
-       __u16 mps_inti_flags;
-       __u8 irq_type;
-       __u8 cpu_id;
-       __u8 cpu_eid;
-       __u8 io_sapic_vector;
-       __u32 gsi;
-       __u32 flags;
-} __packed;
-
-/* Processor Local x2APIC Structure */
-#define ACPI_MADT_X2APIC_FLAGS_EN                              0x01
-#define ACPI_MADT_X2APIC_FLAGS_ON_CAP                          0x02
-struct acpi_madt_x2apic {
-       struct acpi_subsdt_hdr hdr;
-       __u16 reserved;
-       __u32 lapic_id;
-       __u32 flags;
-       __u32 uid;
-} __packed;
-
-/* Local x2APIC NMI Structure */
-struct acpi_madt_x2apic_nmi {
-       struct acpi_subsdt_hdr hdr;
-       __u16 mps_inti_flags;
-       __u32 uid;
-       __u8 lint;
-       __u8 reserved[3];
-} __packed;
-
-/* GIC CPU Interface (GICC) Structure */
-struct acpi_madt_gicc {
-       struct acpi_subsdt_hdr hdr;
-       __u16 reserved;
-       __u32 cpu_if;
-       __u32 uid;
-       __u32 flags;
-       __u32 parking_version;
-       __u32 perf_mon_gsiv;
-       __u64 parked_paddr;
-       __u64 paddr;
-       __u64 gicv;
-       __u64 gich;
-       __u32 vgic_maintenance_gsiv;
-       __u64 gicr_paddr;
-       __u64 mpidr;
-       __u8 power_efficiency;
-       __u8 reserved2;
-       __u16 spe_gsiv;
-} __packed;
-
-/* GIC Distributor (GICD) Structure */
-struct acpi_madt_gicd {
-       struct acpi_subsdt_hdr hdr;
-       __u16 reserved;
-       __u32 gic_id;
-       __u64 paddr;
-       __u32 gsi_base;
-       __u8 version;
-       __u8 reserved2[3];
-} __packed;
-
-/* GIC MSI Frame Structure */
-struct acpi_madt_gic_msi_frame {
-       struct acpi_subsdt_hdr hdr;
-       __u16 reserved;
-       __u32 msi_frame_id;
-       __u64 paddr;
-       __u32 flags;
-       __u16 spi_count;
-       __u16 spi_base;
-} __packed;
-
-/* GIC Redistributor (GICR) Structure */
-struct acpi_madt_gicr {
-       struct acpi_subsdt_hdr hdr;
-       __u16 reserved;
-       __u64 paddr;
-       __u32 len;
-} __packed;
-
-/* GIC Interrupt Translation Service (ITS) Structure */
-struct acpi_madt_gic_its {
-       struct acpi_subsdt_hdr hdr;
-       __u16 reserved;
-       __u32 id;
-       __u64 paddr;
-       __u32 reserved2;
-} __packed;
-
-/* Multiprocessor Wakeup Structure */
-struct acpi_madt_mp_wkp_src {
-       struct acpi_subsdt_hdr hdr;
-       __u16 mbox_version;
-       __u32 reserved;
-       __u64 mbox_paddr;
-} __packed;
-
-/**
- * Return the Multiple APIC Descriptor Table (MADT). ACPI needs to be
- * initialized first.
- *
- * @return Pointer to MADT.
- */
-struct acpi_madt *acpi_get_madt(void);
-
-#endif /* __PLAT_CMN_X86_MADT_H__ */
diff --git a/plat/common/include/x86/acpi/sdt.h b/plat/common/include/x86/acpi/sdt.h
deleted file mode 100644 (file)
index c8298f5..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause */
-/*
- * Authors: Cristian Vijelie <cristianvijelie@gmail.com>
- *          Sergiu Moga <sergiu.moga@protonmail.com>
- *
- * Copyright (c) 2023, University POLITEHNICA of Bucharest. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the names of its
- *    contributors may be used to endorse or promote products derived from
- *    this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef __PLAT_CMN_X86_SDT_H__
-#define __PLAT_CMN_X86_SDT_H__
-
-#include <uk/arch/types.h>
-#include <uk/essentials.h>
-
-#define ACPI_OEM_ID_LEN                                        6
-#define ACPI_OEM_TAB_ID_LEN                            8
-#define ACPI_SDT_SIG_LEN                               4
-#define ACPI_SDT_CREATOR_ID_LEN                                4
-
-struct acpi_sdt_hdr {
-       char sig[ACPI_SDT_SIG_LEN];
-       __u32 tab_len;
-       __u8 revision;
-       __u8 checksum;
-       char oem_id[ACPI_OEM_ID_LEN];
-       char oem_table_id[ACPI_OEM_TAB_ID_LEN];
-       __u32 oem_revision;
-       char creator_id[ACPI_SDT_CREATOR_ID_LEN];
-       __u32 creator_revision;
-} __packed;
-
-struct acpi_subsdt_hdr {
-       __u8 type;
-       __u8 len;
-} __packed;
-
-#define ACPI_RSDT_SIG                                  "RSDT"
-struct acpi_rsdt {
-       struct acpi_sdt_hdr hdr;
-       __u32 entry[];
-} __packed;
-
-#define ACPI_XSDT_SIG                                  "XSDT"
-struct acpi_xsdt {
-       struct acpi_sdt_hdr hdr;
-       __u64 entry[];
-} __packed;
-
-#define ACPI_MADT_SIG                                  "APIC"
-#define ACPI_MADT_FLAGS_PCAT_COMPAT                    0x0001
-struct acpi_madt {
-       struct acpi_sdt_hdr hdr;
-       __u32 lapic_paddr;
-       __u32 flags;
-       __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__ */
diff --git a/plat/common/x86/acpi.c b/plat/common/x86/acpi.c
deleted file mode 100644 (file)
index ac49978..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause */
-/*
- * Authors: Cristian Vijelie <cristianvijelie@gmail.com>
- *          Sergiu Moga <sergiu.moga@protonmail.com>
- *
- * Copyright (c) 2023, University POLITEHNICA of Bucharest. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the names of its
- *    contributors may be used to endorse or promote products derived from
- *    this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include <uk/print.h>
-#include <uk/assert.h>
-#include <x86/acpi/acpi.h>
-#include <string.h>
-#include <errno.h>
-#include <kvm/efi.h>
-#include <uk/plat/common/bootinfo.h>
-
-#define RSDP10_LEN             20
-#define BIOS_ROM_START         0xE0000UL
-#define BIOS_ROM_END           0xFFFFFUL
-#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;
-
-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,
-       },
-};
-
-static inline __paddr_t get_rsdt_entry(int idx)
-{
-       __u8 *entryp = (__u8 *)acpi_rsdt + sizeof(struct acpi_sdt_hdr);
-
-       if (acpi10)
-               return ((__u32 *)entryp)[idx];
-
-       return ((__u64 *)entryp)[idx];
-}
-
-static __u8 get_acpi_checksum(void __maybe_unused *buf, __sz __maybe_unused len)
-{
-#ifdef CONFIG_UKPLAT_ACPI_CHECKSUM
-       const __u8 *const ptr_end = (__u8 *)buf + len;
-       const __u8 *ptr = (__u8 *)buf;
-       __u8 checksum = 0;
-
-       while (ptr < ptr_end)
-               checksum += *ptr++;
-
-       return checksum;
-#else
-       return 0;
-#endif
-}
-
-static void acpi_init_tables(void)
-{
-       struct acpi_sdt_hdr *h;
-       const char *sig;
-       __sz i, j;
-
-       UK_ASSERT(acpi_rsdt);
-
-       for (i = 0; i < acpi_rsdt_entries; i++)
-               for (j = 0; j < ARRAY_SIZE(acpi_sdts); j++) {
-                       if (*acpi_sdts[j].sdt)
-                               continue;
-
-                       h = (struct acpi_sdt_hdr *)get_rsdt_entry(i);
-                       sig = acpi_sdts[j].sig;
-
-                       if (!memcmp(h->sig, sig, ACPI_SDT_SIG_LEN)) {
-                               if (unlikely(get_acpi_checksum(h,
-                                                              h->tab_len))) {
-                                       uk_pr_warn("ACPI %s corrupted\n", sig);
-
-                                       continue;
-                               }
-
-                               *acpi_sdts[j].sdt = h;
-
-                               continue;
-                       }
-               }
-}
-
-/*
- * Print the detected ACPI tables to the debug output.
- */
-#ifdef UK_DEBUG
-static void acpi_list_tables(void)
-{
-       int i;
-
-       UK_ASSERT(acpi_rsdt);
-
-       uk_pr_debug("%d ACPI tables found from %.4s\n", acpi_rsdt_entries,
-                   acpi10 ? ACPI_RSDT_SIG : ACPI_XSDT_SIG);
-       for (i = 0; i < ARRAY_SIZE(acpi_sdts); i++) {
-               if (!acpi_sdts[i].sdt)
-                       continue;
-
-               uk_pr_debug("%p: %.4s\n", acpi_sdts[i].sdt, acpi_sdts[i].sig);
-       }
-}
-#endif /* UK_DEBUG */
-
-static struct acpi_rsdp *acpi_get_efi_st_rsdp(void)
-{
-       struct ukplat_bootinfo *bi = ukplat_bootinfo_get();
-       uk_efi_uintn_t ct_count, i;
-       struct uk_efi_cfg_tbl *ct;
-       struct acpi_rsdp *rsdp;
-
-       UK_ASSERT(bi);
-
-       if (!bi->efi_st)
-               return NULL;
-
-       ct = ((struct uk_efi_sys_tbl *)bi->efi_st)->configuration_table;
-       ct_count = ((struct uk_efi_sys_tbl *)bi->efi_st)->number_of_table_entries;
-
-       UK_ASSERT(ct);
-       UK_ASSERT(ct_count);
-
-       rsdp = NULL;
-       for (i = 0; i < ct_count; i++)
-               if (!memcmp(&ct[i].vendor_guid, UK_EFI_ACPI20_TABLE_GUID,
-                           sizeof(ct[i].vendor_guid))) {
-                       rsdp = ct[i].vendor_table;
-
-                       break;
-               } else if (!memcmp(&ct[i].vendor_guid, UK_EFI_ACPI10_TABLE_GUID,
-                                sizeof(ct[i].vendor_guid))) {
-                       rsdp = ct[i].vendor_table;
-               }
-
-       uk_pr_debug("ACPI RSDP present at %p\n", rsdp);
-
-       return rsdp;
-}
-
-#if defined(__X86_64__)
-static struct acpi_rsdp *acpi_get_bios_rom_rsdp(void)
-{
-       __paddr_t ptr;
-
-       for (ptr = BIOS_ROM_START; ptr < BIOS_ROM_END; ptr += BIOS_ROM_STEP)
-               if (!memcmp((void *)ptr, RSDP_SIG, sizeof(RSDP_SIG) - 1)) {
-                       uk_pr_debug("ACPI RSDP present at %lx\n", ptr);
-
-                       return (struct acpi_rsdp *)ptr;
-               }
-
-       return NULL;
-}
-#endif
-
-static struct acpi_rsdp *acpi_get_rsdp(void)
-{
-       struct acpi_rsdp *rsdp;
-
-       rsdp = acpi_get_efi_st_rsdp();
-       if (rsdp)
-               return rsdp;
-
-       return acpi_get_bios_rom_rsdp();
-}
-
-/*
- * Detect ACPI version and discover ACPI tables.
- */
-int acpi_init(void)
-{
-       struct acpi_rsdp *rsdp;
-       struct acpi_sdt_hdr *h;
-
-       rsdp = acpi_get_rsdp();
-       if (unlikely(!rsdp))
-               return -ENOENT;
-
-       if (unlikely(get_acpi_checksum(rsdp, RSDP10_LEN))) {
-               uk_pr_err("ACPI 1.0 RSDP corrupted\n");
-
-               return -ENOENT;
-       }
-
-       if (rsdp->revision == 0) {
-               h = (struct acpi_sdt_hdr *)((__uptr)rsdp->rsdt_paddr);
-               acpi_rsdt_entries = (h->tab_len - sizeof(*h)) / 4;
-               acpi10 = 1;
-       } else {
-               if (unlikely(get_acpi_checksum(rsdp, sizeof(*rsdp)))) {
-                       uk_pr_err("ACPI 1.0 RSDP corrupted\n");
-
-                       return -ENOENT;
-               }
-
-               h = (struct acpi_sdt_hdr *)rsdp->xsdt_paddr;
-               acpi_rsdt_entries = (h->tab_len - sizeof(*h)) / 8;
-       }
-
-       UK_ASSERT(h);
-
-       if (unlikely(get_acpi_checksum(h, h->tab_len))) {
-               uk_pr_err("ACPI RSDT corrupted\n");
-
-               return -ENOENT;
-       }
-
-       acpi_rsdt = h;
-
-       acpi_init_tables();
-
-#ifdef UK_DEBUG
-       acpi_list_tables();
-#endif
-
-       return 0;
-}
-
-
-/*
- * Return the Multiple APIC Descriptor Table (MADT).
- */
-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;
-}
index 80226f9ad5e8d67460a487912c55a6ea7687c75f..c593f2a7aef751646eb06b931da6c16b0af100bb 100644 (file)
@@ -42,7 +42,7 @@
 #include <x86/cpu.h>
 #include <x86/traps.h>
 #include <x86/delay.h>
-#include <x86/acpi/acpi.h>
+#include <uk/plat/common/acpi.h>
 
 #include <uk/plat/lcpu.h>
 #include <uk/plat/common/lcpu.h>
index a33fc9a0e5c46e99c0cc25f1df7827e5be5ac7d7..55a00779e5bafd55c2d4a9d9dcec3a577c482bbb 100644 (file)
@@ -55,9 +55,6 @@ LIBKVMPLAT_SRCS-$(CONFIG_ARCH_X86_64) += $(UK_PLAT_COMMON_BASE)/tls.c|common
 ifeq ($(CONFIG_HAVE_SYSCALL),y)
 LIBKVMPLAT_SRCS-$(CONFIG_ARCH_X86_64) += $(UK_PLAT_COMMON_BASE)/x86/syscall.S|common
 endif
-ifeq ($(CONFIG_HAVE_SMP),y)
-LIBKVMPLAT_SRCS-$(CONFIG_ARCH_X86_64) += $(UK_PLAT_COMMON_BASE)/x86/acpi.c|common
-endif
 ifeq ($(CONFIG_KVM_BOOT_PROTO_MULTIBOOT),y)
 LIBKVMPLAT_SRCS-$(CONFIG_ARCH_X86_64) += $(LIBKVMPLAT_BASE)/x86/multiboot.S|x86
 LIBKVMPLAT_SRCS-$(CONFIG_ARCH_X86_64) += $(LIBKVMPLAT_BASE)/x86/multiboot.c
@@ -133,6 +130,7 @@ LIBKVMPLAT_SRCS-y                          += $(LIBKVMPLAT_BASE)/io.c
 LIBKVMPLAT_SRCS-y                          += $(UK_PLAT_COMMON_BASE)/lcpu.c|common
 LIBKVMPLAT_SRCS-y                          += $(UK_PLAT_COMMON_BASE)/memory.c|common
 LIBKVMPLAT_SRCS-y                          += $(UK_PLAT_KVM_DEF_LDS)
+LIBKVMPLAT_SRCS-$(CONFIG_UKPLAT_ACPI)      += $(UK_PLAT_COMMON_BASE)/acpi.c|common
 ifeq ($(CONFIG_KVM_BOOT_EFI_STUB),y)
 LIBKVMPLAT_SRCS-y                          += $(LIBKVMPLAT_BASE)/efi.c|common
 endif
index 86d2af303a110cf7043fd0074fc0c31ce6c50a78..729221cb17cc766973c710e9b3b7a60aaff8fcc8 100644 (file)
@@ -7,7 +7,7 @@
 #include <string.h>
 #include <x86/cpu.h>
 #include <x86/traps.h>
-#include <x86/acpi/acpi.h>
+#include <uk/plat/common/acpi.h>
 #include <uk/arch/limits.h>
 #include <uk/arch/types.h>
 #include <uk/arch/paging.h>
@@ -111,7 +111,7 @@ void _ukplat_entry(struct lcpu *lcpu, struct ukplat_bootinfo *bi)
        /* Print boot information */
        ukplat_bootinfo_print();
 
-#ifdef CONFIG_HAVE_SMP
+#if defined(CONFIG_HAVE_SMP) && defined(CONFIG_UKPLAT_ACPI)
        rc = acpi_init();
        if (likely(rc == 0)) {
                rc = lcpu_mp_init(CONFIG_UKPLAT_LCPU_RUN_IRQ,
@@ -122,7 +122,7 @@ void _ukplat_entry(struct lcpu *lcpu, struct ukplat_bootinfo *bi)
        } else {
                uk_pr_err("ACPI init failed: %d\n", rc);
        }
-#endif /* CONFIG_HAVE_SMP */
+#endif /* CONFIG_HAVE_SMP && CONFIG_UKPLAT_ACPI */
 
 #ifdef CONFIG_HAVE_SYSCALL
        _init_syscall();