diff options
author | Stuart Menefy <stuart.menefy@st.com> | 2007-11-30 03:52:53 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2008-01-27 23:18:59 -0500 |
commit | d02b08f6e8b184ffef349e395210a5e82ff4f4bc (patch) | |
tree | 1dbec9fe6d2315a95855ce5a91f92a2a1fbf5a22 /include/asm-sh/page.h | |
parent | cbaa118ecfd99fc5ed7adbd9c34a30e1c05e3c93 (diff) |
sh: Clean up places that make 29-bit physical assumptions.
Signed-off-by: Stuart Menefy <stuart.menefy@st.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'include/asm-sh/page.h')
-rw-r--r-- | include/asm-sh/page.h | 50 |
1 files changed, 37 insertions, 13 deletions
diff --git a/include/asm-sh/page.h b/include/asm-sh/page.h index bff635a078c8..002e64a4f049 100644 --- a/include/asm-sh/page.h +++ b/include/asm-sh/page.h | |||
@@ -5,6 +5,8 @@ | |||
5 | * Copyright (C) 1999 Niibe Yutaka | 5 | * Copyright (C) 1999 Niibe Yutaka |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include <linux/const.h> | ||
9 | |||
8 | #ifdef __KERNEL__ | 10 | #ifdef __KERNEL__ |
9 | 11 | ||
10 | /* PAGE_SHIFT determines the page size */ | 12 | /* PAGE_SHIFT determines the page size */ |
@@ -18,15 +20,13 @@ | |||
18 | # error "Bogus kernel page size?" | 20 | # error "Bogus kernel page size?" |
19 | #endif | 21 | #endif |
20 | 22 | ||
21 | #ifdef __ASSEMBLY__ | 23 | #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT) |
22 | #define PAGE_SIZE (1 << PAGE_SHIFT) | ||
23 | #else | ||
24 | #define PAGE_SIZE (1UL << PAGE_SHIFT) | ||
25 | #endif | ||
26 | |||
27 | #define PAGE_MASK (~(PAGE_SIZE-1)) | 24 | #define PAGE_MASK (~(PAGE_SIZE-1)) |
28 | #define PTE_MASK PAGE_MASK | 25 | #define PTE_MASK PAGE_MASK |
29 | 26 | ||
27 | /* to align the pointer to the (next) page boundary */ | ||
28 | #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) | ||
29 | |||
30 | #if defined(CONFIG_HUGETLB_PAGE_SIZE_64K) | 30 | #if defined(CONFIG_HUGETLB_PAGE_SIZE_64K) |
31 | #define HPAGE_SHIFT 16 | 31 | #define HPAGE_SHIFT 16 |
32 | #elif defined(CONFIG_HUGETLB_PAGE_SIZE_256K) | 32 | #elif defined(CONFIG_HUGETLB_PAGE_SIZE_256K) |
@@ -104,20 +104,44 @@ typedef struct { unsigned long pgd; } pgd_t; | |||
104 | 104 | ||
105 | #endif /* !__ASSEMBLY__ */ | 105 | #endif /* !__ASSEMBLY__ */ |
106 | 106 | ||
107 | /* to align the pointer to the (next) page boundary */ | 107 | /* |
108 | #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) | 108 | * __MEMORY_START and SIZE are the physical addresses and size of RAM. |
109 | 109 | */ | |
110 | #define __MEMORY_START CONFIG_MEMORY_START | 110 | #define __MEMORY_START CONFIG_MEMORY_START |
111 | #define __MEMORY_SIZE CONFIG_MEMORY_SIZE | 111 | #define __MEMORY_SIZE CONFIG_MEMORY_SIZE |
112 | 112 | ||
113 | /* | ||
114 | * PAGE_OFFSET is the virtual address of the start of kernel address | ||
115 | * space. | ||
116 | */ | ||
113 | #define PAGE_OFFSET CONFIG_PAGE_OFFSET | 117 | #define PAGE_OFFSET CONFIG_PAGE_OFFSET |
114 | #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET) | ||
115 | #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) | ||
116 | #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) | ||
117 | 118 | ||
119 | /* | ||
120 | * Virtual to physical RAM address translation. | ||
121 | * | ||
122 | * In 29 bit mode, the physical offset of RAM from address 0 is visible in | ||
123 | * the kernel virtual address space, and thus we don't have to take | ||
124 | * this into account when translating. However in 32 bit mode this offset | ||
125 | * is not visible (it is part of the PMB mapping) and so needs to be | ||
126 | * added or subtracted as required. | ||
127 | */ | ||
128 | #ifdef CONFIG_32BIT | ||
129 | #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET+__MEMORY_START) | ||
130 | #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET-__MEMORY_START)) | ||
131 | #else | ||
132 | #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET) | ||
133 | #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) | ||
134 | #endif | ||
135 | |||
136 | #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) | ||
118 | #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) | 137 | #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) |
119 | 138 | ||
120 | /* PFN start number, because of __MEMORY_START */ | 139 | /* |
140 | * PFN = physical frame number (ie PFN 0 == physical address 0) | ||
141 | * PFN_START is the PFN of the first page of RAM. By defining this we | ||
142 | * don't have struct page entries for the portion of address space | ||
143 | * between physical address 0 and the start of RAM. | ||
144 | */ | ||
121 | #define PFN_START (__MEMORY_START >> PAGE_SHIFT) | 145 | #define PFN_START (__MEMORY_START >> PAGE_SHIFT) |
122 | #define ARCH_PFN_OFFSET (PFN_START) | 146 | #define ARCH_PFN_OFFSET (PFN_START) |
123 | #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) | 147 | #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) |