diff options
author | Mark Salter <msalter@redhat.com> | 2011-10-04 09:24:15 -0400 |
---|---|---|
committer | Mark Salter <msalter@redhat.com> | 2011-10-06 19:47:16 -0400 |
commit | b7a0556e0f2d6946a57f993c6d1043cf065ccfa8 (patch) | |
tree | 3aaef3ec59cff7cfb58ef6f9905792c2a5644603 /include/asm-generic | |
parent | 830f5800acae17b972d264ab65fe54a7f10c1d82 (diff) |
fixed generic page.h for non-zero PAGE_OFFSET
asm-generic/page.h had several problems when used with a non-zero PAGE_OFFSET.
This patch adds a default ARCH_PFN_OFFSET and fixes the __va, __pa, and
pfn_valid macros to work with non-zero PAGE_OFFSETs.
Signed-off-by: Mark Salter <msalter@redhat.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'include/asm-generic')
-rw-r--r-- | include/asm-generic/page.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/include/asm-generic/page.h b/include/asm-generic/page.h index 75fec18cdc59..f376db24c4a6 100644 --- a/include/asm-generic/page.h +++ b/include/asm-generic/page.h | |||
@@ -71,10 +71,14 @@ extern unsigned long memory_end; | |||
71 | #define PAGE_OFFSET (0) | 71 | #define PAGE_OFFSET (0) |
72 | #endif | 72 | #endif |
73 | 73 | ||
74 | #ifndef ARCH_PFN_OFFSET | ||
75 | #define ARCH_PFN_OFFSET (PAGE_OFFSET >> PAGE_SHIFT) | ||
76 | #endif | ||
77 | |||
74 | #ifndef __ASSEMBLY__ | 78 | #ifndef __ASSEMBLY__ |
75 | 79 | ||
76 | #define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET)) | 80 | #define __va(x) ((void *)((unsigned long) (x))) |
77 | #define __pa(x) ((unsigned long) (x) - PAGE_OFFSET) | 81 | #define __pa(x) ((unsigned long) (x)) |
78 | 82 | ||
79 | #define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT) | 83 | #define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT) |
80 | #define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT) | 84 | #define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT) |
@@ -86,7 +90,7 @@ extern unsigned long memory_end; | |||
86 | #define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT) | 90 | #define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT) |
87 | #endif | 91 | #endif |
88 | 92 | ||
89 | #define pfn_valid(pfn) ((pfn) < max_mapnr) | 93 | #define pfn_valid(pfn) ((pfn) >= ARCH_PFN_OFFSET && ((pfn) - ARCH_PFN_OFFSET) < max_mapnr) |
90 | 94 | ||
91 | #define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \ | 95 | #define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \ |
92 | ((void *)(kaddr) < (void *)memory_end)) | 96 | ((void *)(kaddr) < (void *)memory_end)) |