Re: [Xen-devel] [PATCH v8 01/17] arm/acpi: Add __acpi_map_table function for ARM

2016-03-02 Thread Stefano Stabellini
On Wed, 2 Mar 2016, Shannon Zhao wrote:
> From: Shannon Zhao 
> 
> Implement __acpi_map_table function for ARM. Move FIX_ACPI_PAGES to
> common place and rename it to NUM_FIXMAP_ACPI_PAGES.
> 
> Cc: Jan Beulich 
> Signed-off-by: Shannon Zhao 

Reviewed-by: Stefano Stabellini 


> v8: fix coding style and file header
> ---
>  xen/arch/arm/Makefile|  1 +
>  xen/arch/arm/acpi/Makefile   |  1 +
>  xen/arch/arm/acpi/lib.c  | 50 
> 
>  xen/include/asm-arm/config.h |  2 ++
>  xen/include/asm-x86/acpi.h   |  3 ---
>  xen/include/asm-x86/fixmap.h |  4 ++--
>  xen/include/xen/acpi.h   |  6 ++
>  7 files changed, 62 insertions(+), 5 deletions(-)
>  create mode 100644 xen/arch/arm/acpi/Makefile
>  create mode 100644 xen/arch/arm/acpi/lib.c
> 
> diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
> index 1783912..0328b50 100644
> --- a/xen/arch/arm/Makefile
> +++ b/xen/arch/arm/Makefile
> @@ -2,6 +2,7 @@ subdir-$(CONFIG_ARM_32) += arm32
>  subdir-$(CONFIG_ARM_64) += arm64
>  subdir-y += platforms
>  subdir-$(CONFIG_ARM_64) += efi
> +subdir-$(CONFIG_ACPI) += acpi
>  
>  obj-$(EARLY_PRINTK) += early_printk.o
>  obj-y += cpu.o
> diff --git a/xen/arch/arm/acpi/Makefile b/xen/arch/arm/acpi/Makefile
> new file mode 100644
> index 000..b5be22d
> --- /dev/null
> +++ b/xen/arch/arm/acpi/Makefile
> @@ -0,0 +1 @@
> +obj-y += lib.o
> diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
> new file mode 100644
> index 000..7996e9a
> --- /dev/null
> +++ b/xen/arch/arm/acpi/lib.c
> @@ -0,0 +1,50 @@
> +/*
> + *  lib.c - Architecture-Specific Low-Level ACPI Support
> + *
> + *  Copyright (C) 2015, Shannon Zhao 
> + *
> + * ~~
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License as published by
> + *  the Free Software Foundation; either version 2 of the License, or
> + *  (at your option) any later version.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; If not, see .
> + *
> + * ~~
> + */
> +
> +#include 
> +#include 
> +#include 
> +
> +char *__acpi_map_table(paddr_t phys, unsigned long size)
> +{
> +unsigned long base, offset, mapped_size;
> +int idx;
> +
> +offset = phys & (PAGE_SIZE - 1);
> +mapped_size = PAGE_SIZE - offset;
> +set_fixmap(FIXMAP_ACPI_BEGIN, phys >> PAGE_SHIFT, PAGE_HYPERVISOR);
> +base = FIXMAP_ADDR(FIXMAP_ACPI_BEGIN);
> +
> +/* Most cases can be covered by the below. */
> +idx = FIXMAP_ACPI_BEGIN;
> +while ( mapped_size < size )
> +{
> +if ( ++idx > FIXMAP_ACPI_END )
> +return NULL;/* cannot handle this */
> +phys += PAGE_SIZE;
> +set_fixmap(idx, phys >> PAGE_SHIFT, PAGE_HYPERVISOR);
> +mapped_size += PAGE_SIZE;
> +}
> +
> +return ((char *) base + offset);
> +}
> diff --git a/xen/include/asm-arm/config.h b/xen/include/asm-arm/config.h
> index b5d155e..7ceb5c5 100644
> --- a/xen/include/asm-arm/config.h
> +++ b/xen/include/asm-arm/config.h
> @@ -173,6 +173,8 @@
>  #define FIXMAP_GICC14  /* Interrupt controller: CPU registers (first 
> page) */
>  #define FIXMAP_GICC25  /* Interrupt controller: CPU registers (second 
> page) */
>  #define FIXMAP_GICH 6  /* Interrupt controller: virtual interface 
> control registers */
> +#define FIXMAP_ACPI_BEGIN  7  /* Start mappings of ACPI tables */
> +#define FIXMAP_ACPI_END(FIXMAP_ACPI_BEGIN + NUM_FIXMAP_ACPI_PAGES - 1)  
> /* End mappings of ACPI tables */
>  
>  #define PAGE_SHIFT  12
>  
> diff --git a/xen/include/asm-x86/acpi.h b/xen/include/asm-x86/acpi.h
> index d532e3d..49f7e1e 100644
> --- a/xen/include/asm-x86/acpi.h
> +++ b/xen/include/asm-x86/acpi.h
> @@ -90,9 +90,6 @@ static inline void disable_acpi(void)
>   acpi_noirq = 1;
>  }
>  
> -/* Fixmap pages to reserve for ACPI boot-time tables (see fixmap.h) */
> -#define FIX_ACPI_PAGES 4
> -
>  static inline void acpi_noirq_set(void) { acpi_noirq = 1; }
>  
>  /* routines for saving/restoring kernel state */
> diff --git a/xen/include/asm-x86/fixmap.h b/xen/include/asm-x86/fixmap.h
> index 1e24b11..dc0856f 100644
> --- a/xen/include/asm-x86/fixmap.h
> +++ b/xen/include/asm-x86/fixmap.h
> @@ -19,11 +19,11 @@
>  
>  #ifndef __ASSEMBLY__
>  
> +#include 
>  #include 
>  #include 
>  #include 
>  

[Xen-devel] [PATCH v8 01/17] arm/acpi: Add __acpi_map_table function for ARM

2016-03-01 Thread Shannon Zhao
From: Shannon Zhao 

Implement __acpi_map_table function for ARM. Move FIX_ACPI_PAGES to
common place and rename it to NUM_FIXMAP_ACPI_PAGES.

Cc: Jan Beulich 
Signed-off-by: Shannon Zhao 
---
v8: fix coding style and file header
---
 xen/arch/arm/Makefile|  1 +
 xen/arch/arm/acpi/Makefile   |  1 +
 xen/arch/arm/acpi/lib.c  | 50 
 xen/include/asm-arm/config.h |  2 ++
 xen/include/asm-x86/acpi.h   |  3 ---
 xen/include/asm-x86/fixmap.h |  4 ++--
 xen/include/xen/acpi.h   |  6 ++
 7 files changed, 62 insertions(+), 5 deletions(-)
 create mode 100644 xen/arch/arm/acpi/Makefile
 create mode 100644 xen/arch/arm/acpi/lib.c

diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
index 1783912..0328b50 100644
--- a/xen/arch/arm/Makefile
+++ b/xen/arch/arm/Makefile
@@ -2,6 +2,7 @@ subdir-$(CONFIG_ARM_32) += arm32
 subdir-$(CONFIG_ARM_64) += arm64
 subdir-y += platforms
 subdir-$(CONFIG_ARM_64) += efi
+subdir-$(CONFIG_ACPI) += acpi
 
 obj-$(EARLY_PRINTK) += early_printk.o
 obj-y += cpu.o
diff --git a/xen/arch/arm/acpi/Makefile b/xen/arch/arm/acpi/Makefile
new file mode 100644
index 000..b5be22d
--- /dev/null
+++ b/xen/arch/arm/acpi/Makefile
@@ -0,0 +1 @@
+obj-y += lib.o
diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
new file mode 100644
index 000..7996e9a
--- /dev/null
+++ b/xen/arch/arm/acpi/lib.c
@@ -0,0 +1,50 @@
+/*
+ *  lib.c - Architecture-Specific Low-Level ACPI Support
+ *
+ *  Copyright (C) 2015, Shannon Zhao 
+ *
+ * ~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; If not, see .
+ *
+ * ~~
+ */
+
+#include 
+#include 
+#include 
+
+char *__acpi_map_table(paddr_t phys, unsigned long size)
+{
+unsigned long base, offset, mapped_size;
+int idx;
+
+offset = phys & (PAGE_SIZE - 1);
+mapped_size = PAGE_SIZE - offset;
+set_fixmap(FIXMAP_ACPI_BEGIN, phys >> PAGE_SHIFT, PAGE_HYPERVISOR);
+base = FIXMAP_ADDR(FIXMAP_ACPI_BEGIN);
+
+/* Most cases can be covered by the below. */
+idx = FIXMAP_ACPI_BEGIN;
+while ( mapped_size < size )
+{
+if ( ++idx > FIXMAP_ACPI_END )
+return NULL;/* cannot handle this */
+phys += PAGE_SIZE;
+set_fixmap(idx, phys >> PAGE_SHIFT, PAGE_HYPERVISOR);
+mapped_size += PAGE_SIZE;
+}
+
+return ((char *) base + offset);
+}
diff --git a/xen/include/asm-arm/config.h b/xen/include/asm-arm/config.h
index b5d155e..7ceb5c5 100644
--- a/xen/include/asm-arm/config.h
+++ b/xen/include/asm-arm/config.h
@@ -173,6 +173,8 @@
 #define FIXMAP_GICC14  /* Interrupt controller: CPU registers (first page) 
*/
 #define FIXMAP_GICC25  /* Interrupt controller: CPU registers (second 
page) */
 #define FIXMAP_GICH 6  /* Interrupt controller: virtual interface control 
registers */
+#define FIXMAP_ACPI_BEGIN  7  /* Start mappings of ACPI tables */
+#define FIXMAP_ACPI_END(FIXMAP_ACPI_BEGIN + NUM_FIXMAP_ACPI_PAGES - 1)  /* 
End mappings of ACPI tables */
 
 #define PAGE_SHIFT  12
 
diff --git a/xen/include/asm-x86/acpi.h b/xen/include/asm-x86/acpi.h
index d532e3d..49f7e1e 100644
--- a/xen/include/asm-x86/acpi.h
+++ b/xen/include/asm-x86/acpi.h
@@ -90,9 +90,6 @@ static inline void disable_acpi(void)
acpi_noirq = 1;
 }
 
-/* Fixmap pages to reserve for ACPI boot-time tables (see fixmap.h) */
-#define FIX_ACPI_PAGES 4
-
 static inline void acpi_noirq_set(void) { acpi_noirq = 1; }
 
 /* routines for saving/restoring kernel state */
diff --git a/xen/include/asm-x86/fixmap.h b/xen/include/asm-x86/fixmap.h
index 1e24b11..dc0856f 100644
--- a/xen/include/asm-x86/fixmap.h
+++ b/xen/include/asm-x86/fixmap.h
@@ -19,11 +19,11 @@
 
 #ifndef __ASSEMBLY__
 
+#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -51,7 +51,7 @@ enum fixed_addresses {
 FIX_IO_APIC_BASE_0,
 FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS-1,
 FIX_ACPI_BEGIN,
-FIX_ACPI_END = FIX_ACPI_BEGIN + FIX_ACPI_PAGES - 1,
+FIX_ACPI_END = FIX_ACPI_BEGIN + NUM_FIXMAP_ACPI_PAGES - 1,
 FIX_HPET_BASE,
 FIX_TBOOT_SHARED_BASE,