diff mbox

[v5,03/22] arm/acpi: Add __acpi_map_table function for ARM

Message ID 1456467780-8476-4-git-send-email-zhaoshenglong@huawei.com (mailing list archive)
State New, archived
Headers show

Commit Message

Shannon Zhao Feb. 26, 2016, 6:22 a.m. UTC
From: Shannon Zhao <shannon.zhao@linaro.org>

Implement __acpi_map_table function for ARM.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
V4: add __acpi_map_table function
---
 xen/arch/arm/Makefile        |  1 +
 xen/arch/arm/acpi/Makefile   |  1 +
 xen/arch/arm/acpi/lib.c      | 52 ++++++++++++++++++++++++++++++++++++++++++++
 xen/include/asm-arm/config.h |  2 ++
 4 files changed, 56 insertions(+)
 create mode 100644 xen/arch/arm/acpi/Makefile
 create mode 100644 xen/arch/arm/acpi/lib.c

Comments

Stefano Stabellini Feb. 26, 2016, 2:12 p.m. UTC | #1
On Fri, 26 Feb 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Implement __acpi_map_table function for ARM.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> V4: add __acpi_map_table function
> ---
>  xen/arch/arm/Makefile        |  1 +
>  xen/arch/arm/acpi/Makefile   |  1 +
>  xen/arch/arm/acpi/lib.c      | 52 ++++++++++++++++++++++++++++++++++++++++++++
>  xen/include/asm-arm/config.h |  2 ++
>  4 files changed, 56 insertions(+)
>  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..6d51094 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_HAS_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 0000000..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 0000000..f817fe6
> --- /dev/null
> +++ b/xen/arch/arm/acpi/lib.c
> @@ -0,0 +1,52 @@
> +/*
> + *  lib.c - Architecture-Specific Low-Level ACPI Support
> + *
> + *  Copyright (C) 2015, Shannon Zhao <shannon.zhao@linaro.org>
> + *
> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> + *
> + *  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, write to the Free Software
> + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> + *
> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> + */
> +
> +#include <xen/acpi.h>
> +#include <xen/mm.h>
> +#include <asm/config.h>
> +
> +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(FIX_ACPI_BEGIN, phys >> PAGE_SHIFT, PAGE_HYPERVISOR);
> +	base = FIXMAP_ADDR(FIX_ACPI_BEGIN);
> +
> +	/*
> +	 * Most cases can be covered by the below.
> +	 */
> +	idx = FIX_ACPI_BEGIN;
> +	while (mapped_size < size) {
> +		if (++idx > FIX_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 a1b968d..41dd860 100644
> --- a/xen/include/asm-arm/config.h
> +++ b/xen/include/asm-arm/config.h
> @@ -180,6 +180,8 @@
>  #define FIXMAP_GICC1    4  /* Interrupt controller: CPU registers (first page) */
>  #define FIXMAP_GICC2    5  /* Interrupt controller: CPU registers (second page) */
>  #define FIXMAP_GICH     6  /* Interrupt controller: virtual interface control registers */
> +#define FIX_ACPI_BEGIN  7  /* Start mappings of ACPI tables */
> +#define FIX_ACPI_END    10 /* End mappings of ACPI tables */
>  
>  #define PAGE_SHIFT              12

Please rename FIX_ACPI_BEGIN and FIX_ACPI_END to FIXMAP_ACPI_BEGIN and
FIXMAP_ACPI_END.

Also please move the declaration of FIX_ACPI_PAGES from asm-x86/acpi.h
to a common header, and maybe rename it to NUM_ACPI_PAGES. Then you can
define FIXMAP_ACPI_END as (FIXMAP_ACPI_BEGIN + NUM_ACPI_PAGES - 1).
Jan Beulich Feb. 26, 2016, 4:29 p.m. UTC | #2
>>> On 26.02.16 at 15:12, <stefano.stabellini@eu.citrix.com> wrote:
> On Fri, 26 Feb 2016, Shannon Zhao wrote:
>> --- a/xen/include/asm-arm/config.h
>> +++ b/xen/include/asm-arm/config.h
>> @@ -180,6 +180,8 @@
>>  #define FIXMAP_GICC1    4  /* Interrupt controller: CPU registers (first page) */
>>  #define FIXMAP_GICC2    5  /* Interrupt controller: CPU registers (second page) */
>>  #define FIXMAP_GICH     6  /* Interrupt controller: virtual interface control registers */
>> +#define FIX_ACPI_BEGIN  7  /* Start mappings of ACPI tables */
>> +#define FIX_ACPI_END    10 /* End mappings of ACPI tables */
>>  
>>  #define PAGE_SHIFT              12
> 
> Please rename FIX_ACPI_BEGIN and FIX_ACPI_END to FIXMAP_ACPI_BEGIN and
> FIXMAP_ACPI_END.
> 
> Also please move the declaration of FIX_ACPI_PAGES from asm-x86/acpi.h
> to a common header, and maybe rename it to NUM_ACPI_PAGES. Then you can
> define FIXMAP_ACPI_END as (FIXMAP_ACPI_BEGIN + NUM_ACPI_PAGES - 1).

That's a bad name, as it eliminates the connection to the fixmap.
If you really can't live with its current name, then please
NUM_FIXMAP_ACPI_PAGES or some such.

Jan
Stefano Stabellini Feb. 26, 2016, 4:30 p.m. UTC | #3
On Fri, 26 Feb 2016, Jan Beulich wrote:
> >>> On 26.02.16 at 15:12, <stefano.stabellini@eu.citrix.com> wrote:
> > On Fri, 26 Feb 2016, Shannon Zhao wrote:
> >> --- a/xen/include/asm-arm/config.h
> >> +++ b/xen/include/asm-arm/config.h
> >> @@ -180,6 +180,8 @@
> >>  #define FIXMAP_GICC1    4  /* Interrupt controller: CPU registers (first page) */
> >>  #define FIXMAP_GICC2    5  /* Interrupt controller: CPU registers (second page) */
> >>  #define FIXMAP_GICH     6  /* Interrupt controller: virtual interface control registers */
> >> +#define FIX_ACPI_BEGIN  7  /* Start mappings of ACPI tables */
> >> +#define FIX_ACPI_END    10 /* End mappings of ACPI tables */
> >>  
> >>  #define PAGE_SHIFT              12
> > 
> > Please rename FIX_ACPI_BEGIN and FIX_ACPI_END to FIXMAP_ACPI_BEGIN and
> > FIXMAP_ACPI_END.
> > 
> > Also please move the declaration of FIX_ACPI_PAGES from asm-x86/acpi.h
> > to a common header, and maybe rename it to NUM_ACPI_PAGES. Then you can
> > define FIXMAP_ACPI_END as (FIXMAP_ACPI_BEGIN + NUM_ACPI_PAGES - 1).
> 
> That's a bad name, as it eliminates the connection to the fixmap.
> If you really can't live with its current name, then please
> NUM_FIXMAP_ACPI_PAGES or some such.

NUM_FIXMAP_ACPI_PAGES is fine for me
diff mbox

Patch

diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
index 1783912..6d51094 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_HAS_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 0000000..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 0000000..f817fe6
--- /dev/null
+++ b/xen/arch/arm/acpi/lib.c
@@ -0,0 +1,52 @@ 
+/*
+ *  lib.c - Architecture-Specific Low-Level ACPI Support
+ *
+ *  Copyright (C) 2015, Shannon Zhao <shannon.zhao@linaro.org>
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  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, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#include <xen/acpi.h>
+#include <xen/mm.h>
+#include <asm/config.h>
+
+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(FIX_ACPI_BEGIN, phys >> PAGE_SHIFT, PAGE_HYPERVISOR);
+	base = FIXMAP_ADDR(FIX_ACPI_BEGIN);
+
+	/*
+	 * Most cases can be covered by the below.
+	 */
+	idx = FIX_ACPI_BEGIN;
+	while (mapped_size < size) {
+		if (++idx > FIX_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 a1b968d..41dd860 100644
--- a/xen/include/asm-arm/config.h
+++ b/xen/include/asm-arm/config.h
@@ -180,6 +180,8 @@ 
 #define FIXMAP_GICC1    4  /* Interrupt controller: CPU registers (first page) */
 #define FIXMAP_GICC2    5  /* Interrupt controller: CPU registers (second page) */
 #define FIXMAP_GICH     6  /* Interrupt controller: virtual interface control registers */
+#define FIX_ACPI_BEGIN  7  /* Start mappings of ACPI tables */
+#define FIX_ACPI_END    10 /* End mappings of ACPI tables */
 
 #define PAGE_SHIFT              12