From patchwork Wed Mar 2 07:34:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 63372 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2242357lbc; Tue, 1 Mar 2016 23:37:49 -0800 (PST) X-Received: by 10.31.183.209 with SMTP id h200mr19148836vkf.141.1456904256670; Tue, 01 Mar 2016 23:37:36 -0800 (PST) Return-Path: Received: from lists.xen.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id f68si21603718vka.42.2016.03.01.23.37.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Mar 2016 23:37:36 -0800 (PST) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1ab1Km-0005Aq-KB; Wed, 02 Mar 2016 07:36:36 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1ab1Kl-00058k-28 for xen-devel@lists.xen.org; Wed, 02 Mar 2016 07:36:35 +0000 Received: from [85.158.139.211] by server-17.bemta-5.messagelabs.com id 97/05-03800-20896D65; Wed, 02 Mar 2016 07:36:34 +0000 X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-13.tower-206.messagelabs.com!1456904191!25928788!1 X-Originating-IP: [119.145.14.65] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTE5LjE0NS4xNC42NSA9PiA3NzQ2Mw==\n X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 10879 invoked from network); 2 Mar 2016 07:36:33 -0000 Received: from szxga02-in.huawei.com (HELO szxga02-in.huawei.com) (119.145.14.65) by server-13.tower-206.messagelabs.com with SMTP; 2 Mar 2016 07:36:33 -0000 Received: from 172.24.1.49 (EHLO SZXEML424-HUB.china.huawei.com) ([172.24.1.49]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DCK03044; Wed, 02 Mar 2016 15:35:37 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by SZXEML424-HUB.china.huawei.com (10.82.67.153) with Microsoft SMTP Server id 14.3.235.1; Wed, 2 Mar 2016 15:35:11 +0800 From: Shannon Zhao To: Date: Wed, 2 Mar 2016 15:34:27 +0800 Message-ID: <1456904083-13168-2-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1456904083-13168-1-git-send-email-zhaoshenglong@huawei.com> References: <1456904083-13168-1-git-send-email-zhaoshenglong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.56D697CB.00A4, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 2b5659705e5acb127cec7564c4dc8964 Cc: zhaoshenglong@huawei.com, stefano.stabellini@citrix.com, ian.campbell@citrix.com, Jan Beulich , shannon.zhao@linaro.org Subject: [Xen-devel] [PATCH v8 01/17] arm/acpi: Add __acpi_map_table function for ARM X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" 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 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..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_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 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, FIX_MSIX_IO_RESERV_BASE, diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h index 65e53a6..6633414 100644 --- a/xen/include/xen/acpi.h +++ b/xen/include/xen/acpi.h @@ -39,6 +39,12 @@ #define ACPI_MADT_GET_POLARITY(inti) ACPI_MADT_GET_(POLARITY, inti) #define ACPI_MADT_GET_TRIGGER(inti) ACPI_MADT_GET_(TRIGGER, inti) +/* + * Fixmap pages to reserve for ACPI boot-time tables (see asm-x86/fixmap.h or + * asm-arm/config.h) + */ +#define NUM_FIXMAP_ACPI_PAGES 4 + #ifdef CONFIG_ACPI_BOOT enum acpi_interrupt_id {