diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/asm-arm/memory.h |
Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'include/asm-arm/memory.h')
-rw-r--r-- | include/asm-arm/memory.h | 200 |
1 files changed, 200 insertions, 0 deletions
diff --git a/include/asm-arm/memory.h b/include/asm-arm/memory.h new file mode 100644 index 000000000000..e47bea7d1723 --- /dev/null +++ b/include/asm-arm/memory.h | |||
@@ -0,0 +1,200 @@ | |||
1 | /* | ||
2 | * linux/include/asm-arm/memory.h | ||
3 | * | ||
4 | * Copyright (C) 2000-2002 Russell King | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | * Note: this file should not be included by non-asm/.h files | ||
11 | */ | ||
12 | #ifndef __ASM_ARM_MEMORY_H | ||
13 | #define __ASM_ARM_MEMORY_H | ||
14 | |||
15 | #include <linux/config.h> | ||
16 | #include <linux/compiler.h> | ||
17 | #include <asm/arch/memory.h> | ||
18 | |||
19 | #ifndef TASK_SIZE | ||
20 | /* | ||
21 | * TASK_SIZE - the maximum size of a user space task. | ||
22 | * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area | ||
23 | */ | ||
24 | #define TASK_SIZE (0xbf000000UL) | ||
25 | #define TASK_UNMAPPED_BASE (0x40000000UL) | ||
26 | #endif | ||
27 | |||
28 | /* | ||
29 | * The maximum size of a 26-bit user space task. | ||
30 | */ | ||
31 | #define TASK_SIZE_26 (0x04000000UL) | ||
32 | |||
33 | /* | ||
34 | * Page offset: 3GB | ||
35 | */ | ||
36 | #ifndef PAGE_OFFSET | ||
37 | #define PAGE_OFFSET (0xc0000000UL) | ||
38 | #endif | ||
39 | |||
40 | /* | ||
41 | * Physical vs virtual RAM address space conversion. These are | ||
42 | * private definitions which should NOT be used outside memory.h | ||
43 | * files. Use virt_to_phys/phys_to_virt/__pa/__va instead. | ||
44 | */ | ||
45 | #ifndef __virt_to_phys | ||
46 | #define __virt_to_phys(x) ((x) - PAGE_OFFSET + PHYS_OFFSET) | ||
47 | #define __phys_to_virt(x) ((x) - PHYS_OFFSET + PAGE_OFFSET) | ||
48 | #endif | ||
49 | |||
50 | /* | ||
51 | * The module space lives between the addresses given by TASK_SIZE | ||
52 | * and PAGE_OFFSET - it must be within 32MB of the kernel text. | ||
53 | */ | ||
54 | #define MODULE_END (PAGE_OFFSET) | ||
55 | #define MODULE_START (MODULE_END - 16*1048576) | ||
56 | |||
57 | #if TASK_SIZE > MODULE_START | ||
58 | #error Top of user space clashes with start of module space | ||
59 | #endif | ||
60 | |||
61 | #ifndef __ASSEMBLY__ | ||
62 | |||
63 | /* | ||
64 | * The DMA mask corresponding to the maximum bus address allocatable | ||
65 | * using GFP_DMA. The default here places no restriction on DMA | ||
66 | * allocations. This must be the smallest DMA mask in the system, | ||
67 | * so a successful GFP_DMA allocation will always satisfy this. | ||
68 | */ | ||
69 | #ifndef ISA_DMA_THRESHOLD | ||
70 | #define ISA_DMA_THRESHOLD (0xffffffffULL) | ||
71 | #endif | ||
72 | |||
73 | #ifndef arch_adjust_zones | ||
74 | #define arch_adjust_zones(node,size,holes) do { } while (0) | ||
75 | #endif | ||
76 | |||
77 | /* | ||
78 | * PFNs are used to describe any physical page; this means | ||
79 | * PFN 0 == physical address 0. | ||
80 | * | ||
81 | * This is the PFN of the first RAM page in the kernel | ||
82 | * direct-mapped view. We assume this is the first page | ||
83 | * of RAM in the mem_map as well. | ||
84 | */ | ||
85 | #define PHYS_PFN_OFFSET (PHYS_OFFSET >> PAGE_SHIFT) | ||
86 | |||
87 | /* | ||
88 | * These are *only* valid on the kernel direct mapped RAM memory. | ||
89 | * Note: Drivers should NOT use these. They are the wrong | ||
90 | * translation for translating DMA addresses. Use the driver | ||
91 | * DMA support - see dma-mapping.h. | ||
92 | */ | ||
93 | static inline unsigned long virt_to_phys(void *x) | ||
94 | { | ||
95 | return __virt_to_phys((unsigned long)(x)); | ||
96 | } | ||
97 | |||
98 | static inline void *phys_to_virt(unsigned long x) | ||
99 | { | ||
100 | return (void *)(__phys_to_virt((unsigned long)(x))); | ||
101 | } | ||
102 | |||
103 | /* | ||
104 | * Drivers should NOT use these either. | ||
105 | */ | ||
106 | #define __pa(x) __virt_to_phys((unsigned long)(x)) | ||
107 | #define __va(x) ((void *)__phys_to_virt((unsigned long)(x))) | ||
108 | |||
109 | /* | ||
110 | * Virtual <-> DMA view memory address translations | ||
111 | * Again, these are *only* valid on the kernel direct mapped RAM | ||
112 | * memory. Use of these is *deprecated* (and that doesn't mean | ||
113 | * use the __ prefixed forms instead.) See dma-mapping.h. | ||
114 | */ | ||
115 | static inline __deprecated unsigned long virt_to_bus(void *x) | ||
116 | { | ||
117 | return __virt_to_bus((unsigned long)x); | ||
118 | } | ||
119 | |||
120 | static inline __deprecated void *bus_to_virt(unsigned long x) | ||
121 | { | ||
122 | return (void *)__bus_to_virt(x); | ||
123 | } | ||
124 | |||
125 | /* | ||
126 | * Conversion between a struct page and a physical address. | ||
127 | * | ||
128 | * Note: when converting an unknown physical address to a | ||
129 | * struct page, the resulting pointer must be validated | ||
130 | * using VALID_PAGE(). It must return an invalid struct page | ||
131 | * for any physical address not corresponding to a system | ||
132 | * RAM address. | ||
133 | * | ||
134 | * page_to_pfn(page) convert a struct page * to a PFN number | ||
135 | * pfn_to_page(pfn) convert a _valid_ PFN number to struct page * | ||
136 | * pfn_valid(pfn) indicates whether a PFN number is valid | ||
137 | * | ||
138 | * virt_to_page(k) convert a _valid_ virtual address to struct page * | ||
139 | * virt_addr_valid(k) indicates whether a virtual address is valid | ||
140 | */ | ||
141 | #ifndef CONFIG_DISCONTIGMEM | ||
142 | |||
143 | #define page_to_pfn(page) (((page) - mem_map) + PHYS_PFN_OFFSET) | ||
144 | #define pfn_to_page(pfn) ((mem_map + (pfn)) - PHYS_PFN_OFFSET) | ||
145 | #define pfn_valid(pfn) ((pfn) >= PHYS_PFN_OFFSET && (pfn) < (PHYS_PFN_OFFSET + max_mapnr)) | ||
146 | |||
147 | #define virt_to_page(kaddr) (pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)) | ||
148 | #define virt_addr_valid(kaddr) ((unsigned long)(kaddr) >= PAGE_OFFSET && (unsigned long)(kaddr) < (unsigned long)high_memory) | ||
149 | |||
150 | #define PHYS_TO_NID(addr) (0) | ||
151 | |||
152 | #else /* CONFIG_DISCONTIGMEM */ | ||
153 | |||
154 | /* | ||
155 | * This is more complex. We have a set of mem_map arrays spread | ||
156 | * around in memory. | ||
157 | */ | ||
158 | #include <linux/numa.h> | ||
159 | |||
160 | #define page_to_pfn(page) \ | ||
161 | (( (page) - page_zone(page)->zone_mem_map) \ | ||
162 | + page_zone(page)->zone_start_pfn) | ||
163 | #define pfn_to_page(pfn) \ | ||
164 | (PFN_TO_MAPBASE(pfn) + LOCAL_MAP_NR((pfn) << PAGE_SHIFT)) | ||
165 | #define pfn_valid(pfn) (PFN_TO_NID(pfn) < MAX_NUMNODES) | ||
166 | |||
167 | #define virt_to_page(kaddr) \ | ||
168 | (ADDR_TO_MAPBASE(kaddr) + LOCAL_MAP_NR(kaddr)) | ||
169 | #define virt_addr_valid(kaddr) (KVADDR_TO_NID(kaddr) < MAX_NUMNODES) | ||
170 | |||
171 | /* | ||
172 | * Common discontigmem stuff. | ||
173 | * PHYS_TO_NID is used by the ARM kernel/setup.c | ||
174 | */ | ||
175 | #define PHYS_TO_NID(addr) PFN_TO_NID((addr) >> PAGE_SHIFT) | ||
176 | |||
177 | #endif /* !CONFIG_DISCONTIGMEM */ | ||
178 | |||
179 | /* | ||
180 | * For BIO. "will die". Kill me when bio_to_phys() and bvec_to_phys() die. | ||
181 | */ | ||
182 | #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) | ||
183 | |||
184 | /* | ||
185 | * Optional device DMA address remapping. Do _not_ use directly! | ||
186 | * We should really eliminate virt_to_bus() here - it's deprecated. | ||
187 | */ | ||
188 | #ifndef __arch_page_to_dma | ||
189 | #define page_to_dma(dev, page) ((dma_addr_t)__virt_to_bus((unsigned long)page_address(page))) | ||
190 | #define dma_to_virt(dev, addr) ((void *)__bus_to_virt(addr)) | ||
191 | #define virt_to_dma(dev, addr) ((dma_addr_t)__virt_to_bus((unsigned long)(addr))) | ||
192 | #else | ||
193 | #define page_to_dma(dev, page) (__arch_page_to_dma(dev, page)) | ||
194 | #define dma_to_virt(dev, addr) (__arch_dma_to_virt(dev, addr)) | ||
195 | #define virt_to_dma(dev, addr) (__arch_virt_to_dma(dev, addr)) | ||
196 | #endif | ||
197 | |||
198 | #endif | ||
199 | |||
200 | #endif | ||