From patchwork Fri Jul 11 08:19:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 4531611 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id ED8C0BEEAA for ; Fri, 11 Jul 2014 08:22:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2A34F201C7 for ; Fri, 11 Jul 2014 08:22:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3FEC1201B9 for ; Fri, 11 Jul 2014 08:22:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752323AbaGKIU1 (ORCPT ); Fri, 11 Jul 2014 04:20:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:15369 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752275AbaGKIUY (ORCPT ); Fri, 11 Jul 2014 04:20:24 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s6B8KMKI013982 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Jul 2014 04:20:22 -0400 Received: from hawk.usersys.redhat.com (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6B8Jmiw010067; Fri, 11 Jul 2014 04:20:20 -0400 From: Andrew Jones To: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Cc: christoffer.dall@linaro.org, pbonzini@redhat.com Subject: [PATCH v6 15/17] arm: Add arch-specific asm/page.h and __va/__pa Date: Fri, 11 Jul 2014 10:19:45 +0200 Message-Id: <1405066787-5793-16-git-send-email-drjones@redhat.com> In-Reply-To: <1405066787-5793-1-git-send-email-drjones@redhat.com> References: <1405066787-5793-1-git-send-email-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP These are pretty much the same as the asm-generic version, but use phys_addr_t. Signed-off-by: Andrew Jones --- lib/arm/asm/io.h | 13 +++++++++++++ lib/arm/asm/page.h | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/lib/arm/asm/io.h b/lib/arm/asm/io.h index 1d0abb7d9f405..bbcbcd0542490 100644 --- a/lib/arm/asm/io.h +++ b/lib/arm/asm/io.h @@ -2,6 +2,7 @@ #define _ASMARM_IO_H_ #include "libcflat.h" #include "asm/barrier.h" +#include "asm/page.h" #define __iomem #define __force @@ -76,6 +77,18 @@ static inline void __raw_writel(u32 val, volatile void __iomem *addr) : "r" (val)); } +#define virt_to_phys virt_to_phys +static inline phys_addr_t virt_to_phys(const volatile void *x) +{ + return __virt_to_phys((unsigned long)(x)); +} + +#define phys_to_virt phys_to_virt +static inline void *phys_to_virt(phys_addr_t x) +{ + return (void *)__phys_to_virt(x); +} + #include "asm-generic/io.h" #endif /* _ASMARM_IO_H_ */ diff --git a/lib/arm/asm/page.h b/lib/arm/asm/page.h index 91a4bc3b7f86e..606d76f5775cf 100644 --- a/lib/arm/asm/page.h +++ b/lib/arm/asm/page.h @@ -1 +1,33 @@ -#include "asm-generic/page.h" +#ifndef _ASMARM_PAGE_H_ +#define _ASMARM_PAGE_H_ +/* + * Copyright (C) 2014, Red Hat Inc, Andrew Jones + * + * This work is licensed under the terms of the GNU LGPL, version 2. + */ + +#define PAGE_SHIFT 12 +#ifndef __ASSEMBLY__ +#define PAGE_SIZE (1UL << PAGE_SHIFT) +#else +#define PAGE_SIZE (1 << PAGE_SHIFT) +#endif +#define PAGE_MASK (~(PAGE_SIZE-1)) +#define PAGE_ALIGN(addr) (((addr) + (PAGE_SIZE-1)) & PAGE_MASK) + +#ifndef __ASSEMBLY__ +#include + +#ifndef __virt_to_phys +#define __phys_to_virt(x) ((unsigned long) (x)) +#define __virt_to_phys(x) (x) +#endif + +#define __va(x) ((void *)__phys_to_virt((phys_addr_t)(x))) +#define __pa(x) __virt_to_phys((unsigned long)(x)) + +#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT) +#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT) +#endif + +#endif