arm/acpi: Add a helper function to get the acpi table offset
authorShannon Zhao <shannon.zhao@linaro.org>
Wed, 30 Mar 2016 10:16:00 +0000 (12:16 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 30 Mar 2016 14:58:01 +0000 (16:58 +0200)
These tables are aligned with 64bit.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
xen/arch/arm/acpi/lib.c
xen/include/asm-arm/acpi.h

index db5c4d84fe5cc2402b15ac2607bde02544c895c0..79f7edd181f2c9ef9cba61577d90e55bccb05084 100644 (file)
@@ -60,3 +60,18 @@ bool_t __init acpi_psci_hvc_present(void)
 {
     return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC;
 }
+
+paddr_t __init acpi_get_table_offset(struct membank tbl_add[],
+                                     EFI_MEM_RES index)
+{
+    int i;
+    paddr_t offset = 0;
+
+    for ( i = 0; i < index; i++ )
+    {
+        /* Aligned with 64bit (8 bytes) */
+        offset += ROUNDUP(tbl_add[i].size, 8);
+    }
+
+    return offset;
+}
index 7f5976193eb71e9d9e0e3ee42570bbc4dcc17f4b..9f954d39e160dc7f18ce0cdd9083c212c2fca638 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <xen/init.h>
 #include <asm/page.h>
+#include <asm/setup.h>
 
 #define COMPILER_DEPENDENT_INT64   long long
 #define COMPILER_DEPENDENT_UINT64  unsigned long long
@@ -46,6 +47,15 @@ bool_t __init acpi_psci_present(void);
 bool_t __init acpi_psci_hvc_present(void);
 void __init acpi_smp_init_cpus(void);
 
+/*
+ * This function returns the offset of a given ACPI/EFI table in the allocated
+ * memory region. Currently, the tables should be created in the same order as
+ * their associated 'index' in the enum EFI_MEM_RES. This means the function
+ * won't return the correct offset until all the tables before a given 'index'
+ * are created.
+ */
+paddr_t acpi_get_table_offset(struct membank tbl_add[], EFI_MEM_RES index);
+
 #ifdef CONFIG_ACPI
 extern bool_t acpi_disabled;
 /* Basic configuration for ACPI */