From patchwork Fri Jul 11 08:19:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 4531691 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 B137EBEEAA for ; Fri, 11 Jul 2014 08:22:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EE80F201C7 for ; Fri, 11 Jul 2014 08:22:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1F798201B9 for ; Fri, 11 Jul 2014 08:22:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752637AbaGKIW3 (ORCPT ); Fri, 11 Jul 2014 04:22:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54732 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751983AbaGKIUK (ORCPT ); Fri, 11 Jul 2014 04:20:10 -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 s6B8K8d1013951 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Jul 2014 04:20:08 -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 s6B8Jmip010067; Fri, 11 Jul 2014 04:20:06 -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 08/17] lib: add asm/page.h and virt_to_phys/phys_to_virt Date: Fri, 11 Jul 2014 10:19:38 +0200 Message-Id: <1405066787-5793-9-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 Signed-off-by: Andrew Jones --- lib/asm-generic/io.h | 13 +++++++++++++ lib/asm-generic/page.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 lib/asm-generic/page.h diff --git a/lib/asm-generic/io.h b/lib/asm-generic/io.h index f00f4d3e68fe1..a9939d3a5921f 100644 --- a/lib/asm-generic/io.h +++ b/lib/asm-generic/io.h @@ -10,6 +10,7 @@ * This work is licensed under the terms of the GNU LGPL, version 2. */ #include "libcflat.h" +#include "asm/page.h" #ifndef __raw_readb static inline u8 __raw_readb(const volatile void *addr) @@ -159,4 +160,16 @@ static inline void *ioremap(u64 phys_addr, size_t size __unused) } #endif +#ifndef virt_to_phys +static inline unsigned long virt_to_phys(volatile void *address) +{ + return __pa((unsigned long)address); +} + +static inline void *phys_to_virt(unsigned long address) +{ + return __va(address); +} +#endif + #endif /* _ASM_GENERIC_IO_H_ */ diff --git a/lib/asm-generic/page.h b/lib/asm-generic/page.h new file mode 100644 index 0000000000000..559938fcf0b3f --- /dev/null +++ b/lib/asm-generic/page.h @@ -0,0 +1,28 @@ +#ifndef _ASM_GENERIC_PAGE_H_ +#define _ASM_GENERIC_PAGE_H_ +/* + * asm-generic/page.h + * adapted from the Linux kernel's include/asm-generic/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__ +#define __va(x) ((void *)((unsigned long) (x))) +#define __pa(x) ((unsigned long) (x)) +#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT) +#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT) +#endif + +#endif