@@ -25,6 +25,10 @@ cflatobjs += lib/arm64/processor.o
cflatobjs += lib/arm64/spinlock.o
cflatobjs += lib/arm64/gic-v3-its.o lib/arm64/gic-v3-its-cmd.o
+ifeq ($(CONFIG_EFI),y)
+cflatobjs += lib/acpi.o
+endif
+
OBJDIRS += lib/arm64
# arm64 specific tests
@@ -129,6 +129,11 @@ struct acpi_table_fadt {
u64 hypervisor_id; /* Hypervisor Vendor ID (ACPI 6.0) */
};
+/* Masks for FADT ARM Boot Architecture Flags (arm_boot_flags) ACPI 5.1 */
+
+#define ACPI_FADT_PSCI_COMPLIANT (1) /* 00: [V5+] PSCI 0.2+ is implemented */
+#define ACPI_FADT_PSCI_USE_HVC (1<<1) /* 01: [V5+] HVC must be used instead of SMC as the PSCI conduit */
+
struct acpi_table_facs_rev1 {
u32 signature; /* ACPI Signature */
u32 length; /* Length of structure, in bytes */
@@ -56,7 +56,7 @@ void psci_system_off(void)
printf("CPU%d unable to do system off (error = %d)\n", smp_processor_id(), err);
}
-void psci_set_conduit(void)
+static void psci_set_conduit_fdt(void)
{
const void *fdt = dt_fdt();
const struct fdt_property *method;
@@ -75,3 +75,38 @@ void psci_set_conduit(void)
else
assert_msg(false, "Unknown PSCI conduit: %s", method->data);
}
+
+#ifdef CONFIG_EFI
+
+#include <acpi.h>
+
+static void psci_set_conduit_acpi(void)
+{
+ struct acpi_table_fadt *fadt = find_acpi_table_addr(FACP_SIGNATURE);
+
+ assert_msg(fadt, "Unable to find ACPI FADT");
+ assert_msg(fadt->arm_boot_flags & ACPI_FADT_PSCI_COMPLIANT,
+ "PSCI is not supported in this platform");
+
+ if (fadt->arm_boot_flags & ACPI_FADT_PSCI_USE_HVC)
+ psci_invoke = psci_invoke_hvc;
+ else
+ psci_invoke = psci_invoke_smc;
+}
+
+#else
+
+static void psci_set_conduit_acpi(void)
+{
+ assert_msg(false, "ACPI not available");
+}
+
+#endif
+
+void psci_set_conduit(void)
+{
+ if (dt_available())
+ psci_set_conduit_fdt();
+ else
+ psci_set_conduit_acpi();
+}