public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
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	[thread overview]
Message-ID: <1405066787-5793-9-git-send-email-drjones@redhat.com> (raw)
In-Reply-To: <1405066787-5793-1-git-send-email-drjones@redhat.com>

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 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 <drjones@redhat.com>
+ *
+ * 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
-- 
1.9.3


  parent reply	other threads:[~2014-07-11  8:20 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-11  8:19 [PATCH v6 00/17] kvm-unit-tests/arm: initial drop Andrew Jones
2014-07-11  8:19 ` [PATCH v6 02/17] libfdt: get libfdt to build Andrew Jones
2014-07-11  8:19 ` [PATCH v6 03/17] add support for Linux device trees Andrew Jones
2014-07-11  8:19 ` [PATCH v6 04/17] libcflat: add abort() and assert() Andrew Jones
2014-07-11  8:19 ` [PATCH v6 05/17] Introduce asm-generic/*.h files Andrew Jones
2014-07-11  8:19 ` [PATCH v6 06/17] Introduce alloc_ops Andrew Jones
2014-07-11  8:40   ` Paolo Bonzini
2014-07-11  8:55     ` Andrew Jones
2014-07-11  9:41       ` Paolo Bonzini
2014-07-11 10:07         ` Andrew Jones
2014-07-11 10:12           ` Paolo Bonzini
2014-07-15 17:16           ` Andrew Jones
2014-07-11  8:19 ` [PATCH v6 07/17] add minimal virtio support for devtree virtio-mmio Andrew Jones
2014-07-11  8:32   ` Paolo Bonzini
2014-07-11  9:08     ` Andrew Jones
2014-07-11  9:27       ` Paolo Bonzini
2014-07-11  9:36         ` Andrew Jones
2014-07-15 17:22       ` Andrew Jones
2014-07-11  8:19 ` Andrew Jones [this message]
2014-07-11  8:19 ` [PATCH v6 09/17] virtio: add minimal support for virtqueues Andrew Jones
2014-07-11  9:23   ` Paolo Bonzini
2014-07-11  9:32     ` Paolo Bonzini
2014-07-11  9:52       ` Andrew Jones
2014-07-11  8:19 ` [PATCH v6 10/17] Introduce chr-testdev Andrew Jones
2014-07-11  8:19 ` [PATCH v6 11/17] libcflat: clean up libcflat.h Andrew Jones
2014-07-11  8:19 ` [PATCH v6 12/17] arm: initial drop Andrew Jones
2014-07-11  8:19 ` [PATCH v6 13/17] arm: Add spinlock implementation Andrew Jones
2014-07-11  8:19 ` [PATCH v6 14/17] arm: Add IO accessors to avoid register-writeback Andrew Jones
2014-07-11  8:19 ` [PATCH v6 15/17] arm: Add arch-specific asm/page.h and __va/__pa Andrew Jones
2014-07-11  8:19 ` [PATCH v6 16/17] arm: add useful headers from the Linux kernel Andrew Jones
2014-07-11  8:19 ` [PATCH v6 17/17] arm: vectors support Andrew Jones
2014-07-11  8:47 ` [PATCH v6 00/17] kvm-unit-tests/arm: initial drop Paolo Bonzini
2014-07-15 17:24   ` Andrew Jones
2014-07-15 20:19     ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1405066787-5793-9-git-send-email-drjones@redhat.com \
    --to=drjones@redhat.com \
    --cc=christoffer.dall@linaro.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=pbonzini@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox