1d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 24baa9922SRussell King /* 34baa9922SRussell King * arch/arm/include/asm/memory.h 44baa9922SRussell King * 54baa9922SRussell King * Copyright (C) 2000-2002 Russell King 64baa9922SRussell King * modification for nommu, Hyok S. Choi, 2004 74baa9922SRussell King * 84baa9922SRussell King * Note: this file should not be included by non-asm/.h files 94baa9922SRussell King */ 104baa9922SRussell King #ifndef __ASM_ARM_MEMORY_H 114baa9922SRussell King #define __ASM_ARM_MEMORY_H 124baa9922SRussell King 138d5796d2SLennert Buytenhek #include <linux/compiler.h> 148d5796d2SLennert Buytenhek #include <linux/const.h> 153a6b1676SWill Deacon #include <linux/types.h> 16158e8bfeSAlessandro Rubini #include <linux/sizes.h> 178d5796d2SLennert Buytenhek 180cdc8b92SNicolas Pitre #ifdef CONFIG_NEED_MACH_MEMORY_H 191b9f95f8SNicolas Pitre #include <mach/memory.h> 201b9f95f8SNicolas Pitre #endif 21c12366baSLinus Walleij #include <asm/kasan_def.h> 221b9f95f8SNicolas Pitre 23b78f63f4SLinus Walleij /* 24b78f63f4SLinus Walleij * PAGE_OFFSET: the virtual address of the start of lowmem, memory above 25b78f63f4SLinus Walleij * the virtual address range for userspace. 26b78f63f4SLinus Walleij * KERNEL_OFFSET: the virtual address of the start of the kernel image. 27b78f63f4SLinus Walleij * we may further offset this with TEXT_OFFSET in practice. 28b78f63f4SLinus Walleij */ 29006fa259SRussell King #define PAGE_OFFSET UL(CONFIG_PAGE_OFFSET) 30b78f63f4SLinus Walleij #define KERNEL_OFFSET (PAGE_OFFSET) 31006fa259SRussell King 324baa9922SRussell King #ifdef CONFIG_MMU 334baa9922SRussell King 344baa9922SRussell King /* 354baa9922SRussell King * TASK_SIZE - the maximum size of a user space task. 364baa9922SRussell King * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area 374baa9922SRussell King */ 38c12366baSLinus Walleij #ifndef CONFIG_KASAN 395d1c20bcSWill Deacon #define TASK_SIZE (UL(CONFIG_PAGE_OFFSET) - UL(SZ_16M)) 40c12366baSLinus Walleij #else 41c12366baSLinus Walleij #define TASK_SIZE (KASAN_SHADOW_START) 42c12366baSLinus Walleij #endif 4379d1f5c9SWill Deacon #define TASK_UNMAPPED_BASE ALIGN(TASK_SIZE / 3, SZ_16M) 444baa9922SRussell King 454baa9922SRussell King /* 464baa9922SRussell King * The maximum size of a 26-bit user space task. 474baa9922SRussell King */ 485d1c20bcSWill Deacon #define TASK_SIZE_26 (UL(1) << 26) 494baa9922SRussell King 504baa9922SRussell King /* 514baa9922SRussell King * The module space lives between the addresses given by TASK_SIZE 524baa9922SRussell King * and PAGE_OFFSET - it must be within 32MB of the kernel text. 534baa9922SRussell King */ 54adca6dc2SCatalin Marinas #ifndef CONFIG_THUMB2_KERNEL 555d1c20bcSWill Deacon #define MODULES_VADDR (PAGE_OFFSET - SZ_16M) 56adca6dc2SCatalin Marinas #else 57adca6dc2SCatalin Marinas /* smaller range for Thumb-2 symbols relocation (2^24)*/ 585d1c20bcSWill Deacon #define MODULES_VADDR (PAGE_OFFSET - SZ_8M) 59adca6dc2SCatalin Marinas #endif 60adca6dc2SCatalin Marinas 61ab4f2ee1SRussell King #if TASK_SIZE > MODULES_VADDR 624baa9922SRussell King #error Top of user space clashes with start of module space 634baa9922SRussell King #endif 644baa9922SRussell King 654baa9922SRussell King /* 66d73cd428SNicolas Pitre * The highmem pkmap virtual space shares the end of the module area. 67d73cd428SNicolas Pitre */ 68d73cd428SNicolas Pitre #ifdef CONFIG_HIGHMEM 69d73cd428SNicolas Pitre #define MODULES_END (PAGE_OFFSET - PMD_SIZE) 70d73cd428SNicolas Pitre #else 71d73cd428SNicolas Pitre #define MODULES_END (PAGE_OFFSET) 72d73cd428SNicolas Pitre #endif 73d73cd428SNicolas Pitre 74d73cd428SNicolas Pitre /* 754baa9922SRussell King * The XIP kernel gets mapped at the bottom of the module vm area. 764baa9922SRussell King * Since we use sections to map it, this macro replaces the physical address 774baa9922SRussell King * with its virtual address while keeping offset from the base section. 784baa9922SRussell King */ 79ab4f2ee1SRussell King #define XIP_VIRT_ADDR(physaddr) (MODULES_VADDR + ((physaddr) & 0x000fffff)) 804baa9922SRussell King 817a1be318SArd Biesheuvel #define FDT_FIXED_BASE UL(0xff800000) 82fc2933c1SArd Biesheuvel #define FDT_FIXED_SIZE (2 * SECTION_SIZE) 83fc2933c1SArd Biesheuvel #define FDT_VIRT_BASE(physbase) ((void *)(FDT_FIXED_BASE | (physbase) % SECTION_SIZE)) 847a1be318SArd Biesheuvel 85803e3dbcSSergey Dyasly #if !defined(CONFIG_SMP) && !defined(CONFIG_ARM_LPAE) 864baa9922SRussell King /* 874baa9922SRussell King * Allow 16MB-aligned ioremap pages 884baa9922SRussell King */ 894baa9922SRussell King #define IOREMAP_MAX_ORDER 24 90803e3dbcSSergey Dyasly #endif 914baa9922SRussell King 9258c16709SAfzal Mohammed #define VECTORS_BASE UL(0xffff0000) 9358c16709SAfzal Mohammed 944baa9922SRussell King #else /* CONFIG_MMU */ 954baa9922SRussell King 9658c16709SAfzal Mohammed #ifndef __ASSEMBLY__ 9762d1c95dSVladimir Murzin extern unsigned long setup_vectors_base(void); 9858c16709SAfzal Mohammed extern unsigned long vectors_base; 9958c16709SAfzal Mohammed #define VECTORS_BASE vectors_base 10058c16709SAfzal Mohammed #endif 10158c16709SAfzal Mohammed 1024baa9922SRussell King /* 1034baa9922SRussell King * The limitation of user task size can grow up to the end of free ram region. 1044baa9922SRussell King * It is difficult to define and perhaps will never meet the original meaning 1054baa9922SRussell King * of this define that was meant to. 1064baa9922SRussell King * Fortunately, there is no reference for this in noMMU mode, for now. 1074baa9922SRussell King */ 10803eca200SUwe Kleine-König #define TASK_SIZE UL(0xffffffff) 1094baa9922SRussell King 1104baa9922SRussell King #ifndef TASK_UNMAPPED_BASE 1114baa9922SRussell King #define TASK_UNMAPPED_BASE UL(0x00000000) 1124baa9922SRussell King #endif 1134baa9922SRussell King 1144baa9922SRussell King #ifndef END_MEM 115c931b4f6SFenkart/Bostandzhyan #define END_MEM (UL(CONFIG_DRAM_BASE) + CONFIG_DRAM_SIZE) 1164baa9922SRussell King #endif 1174baa9922SRussell King 1184baa9922SRussell King /* 1194baa9922SRussell King * The module can be at any place in ram in nommu mode. 1204baa9922SRussell King */ 121ab4f2ee1SRussell King #define MODULES_END (END_MEM) 122b713aa0bSRussell King #define MODULES_VADDR PAGE_OFFSET 1234baa9922SRussell King 12438b4205aSUwe Kleine-König #define XIP_VIRT_ADDR(physaddr) (physaddr) 125fc2933c1SArd Biesheuvel #define FDT_VIRT_BASE(physbase) ((void *)(physbase)) 12638b4205aSUwe Kleine-König 1274baa9922SRussell King #endif /* !CONFIG_MMU */ 1284baa9922SRussell King 129a09975bfSFlorian Fainelli #ifdef CONFIG_XIP_KERNEL 130a09975bfSFlorian Fainelli #define KERNEL_START _sdata 131a09975bfSFlorian Fainelli #else 132a09975bfSFlorian Fainelli #define KERNEL_START _stext 133a09975bfSFlorian Fainelli #endif 134a09975bfSFlorian Fainelli #define KERNEL_END _end 135a09975bfSFlorian Fainelli 1364baa9922SRussell King /* 1371dbd30e9SLinus Walleij * We fix the TCM memories max 32 KiB ITCM resp DTCM at these 1381dbd30e9SLinus Walleij * locations 1391dbd30e9SLinus Walleij */ 1401dbd30e9SLinus Walleij #ifdef CONFIG_HAVE_TCM 1411dbd30e9SLinus Walleij #define ITCM_OFFSET UL(0xfffe0000) 1421dbd30e9SLinus Walleij #define DTCM_OFFSET UL(0xfffe8000) 1431dbd30e9SLinus Walleij #endif 1441dbd30e9SLinus Walleij 1451dbd30e9SLinus Walleij /* 146719301ffSRussell King * Convert a page to/from a physical address 147719301ffSRussell King */ 148719301ffSRussell King #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page))) 149719301ffSRussell King #define phys_to_page(phys) (pfn_to_page(__phys_to_pfn(phys))) 150719301ffSRussell King 1514756dcbfSCyril Chemparathy /* 152b713aa0bSRussell King * PLAT_PHYS_OFFSET is the offset (from zero) of the start of physical 153c6f54a9bSUwe Kleine-König * memory. This is used for XIP and NoMMU kernels, and on platforms that don't 154c6f54a9bSUwe Kleine-König * have CONFIG_ARM_PATCH_PHYS_VIRT. Assembly code must always use 155b713aa0bSRussell King * PLAT_PHYS_OFFSET and not PHYS_OFFSET. 156b713aa0bSRussell King */ 157b713aa0bSRussell King #define PLAT_PHYS_OFFSET UL(CONFIG_PHYS_OFFSET) 158b713aa0bSRussell King 1594baa9922SRussell King #ifndef __ASSEMBLY__ 1604baa9922SRussell King 1614baa9922SRussell King /* 162a91da545SLinus Walleij * Physical start and end address of the kernel sections. These addresses are 163*463dbba4SLinus Walleij * 2MB-aligned to match the section mappings placed over the kernel. We use 164*463dbba4SLinus Walleij * u64 so that LPAE mappings beyond the 32bit limit will work out as well. 165a91da545SLinus Walleij */ 166*463dbba4SLinus Walleij extern u64 kernel_sec_start; 167*463dbba4SLinus Walleij extern u64 kernel_sec_end; 168a91da545SLinus Walleij 169a91da545SLinus Walleij /* 170dc21af99SRussell King * Physical vs virtual RAM address space conversion. These are 171dc21af99SRussell King * private definitions which should NOT be used outside memory.h 172dc21af99SRussell King * files. Use virt_to_phys/phys_to_virt/__pa/__va instead. 173e26a9e00SRussell King * 174e26a9e00SRussell King * PFNs are used to describe any physical page; this means 175e26a9e00SRussell King * PFN 0 == physical address 0. 176dc21af99SRussell King */ 177e26a9e00SRussell King 1787d281b62SNicolas Pitre #if defined(CONFIG_ARM_PATCH_PHYS_VIRT) 179dc21af99SRussell King 180cada3c08SRussell King /* 181cada3c08SRussell King * Constants used to force the right instruction encodings and shifts 182cada3c08SRussell King * so that all we need to do is modify the 8-bit constant field. 183cada3c08SRussell King */ 184cada3c08SRussell King #define __PV_BITS_31_24 0x81000000 1859443076eSArd Biesheuvel #define __PV_BITS_23_16 0x810000 186f52bb722SSricharan R #define __PV_BITS_7_0 0x81 187cada3c08SRussell King 188e26a9e00SRussell King extern unsigned long __pv_phys_pfn_offset; 189f52bb722SSricharan R extern u64 __pv_offset; 190f52bb722SSricharan R extern void fixup_pv_table(const void *, unsigned long); 191f52bb722SSricharan R extern const void *__pv_table_begin, *__pv_table_end; 192f52bb722SSricharan R 193e26a9e00SRussell King #define PHYS_OFFSET ((phys_addr_t)__pv_phys_pfn_offset << PAGE_SHIFT) 194e26a9e00SRussell King #define PHYS_PFN_OFFSET (__pv_phys_pfn_offset) 195e26a9e00SRussell King 196e8e00f5aSArd Biesheuvel #ifndef CONFIG_THUMB2_KERNEL 1970869f3b9SArd Biesheuvel #define __pv_stub(from,to,instr) \ 198dc21af99SRussell King __asm__("@ __pv_stub\n" \ 199dc21af99SRussell King "1: " instr " %0, %1, %2\n" \ 2009443076eSArd Biesheuvel "2: " instr " %0, %0, %3\n" \ 201dc21af99SRussell King " .pushsection .pv_table,\"a\"\n" \ 2029443076eSArd Biesheuvel " .long 1b - ., 2b - .\n" \ 203dc21af99SRussell King " .popsection\n" \ 204dc21af99SRussell King : "=r" (to) \ 2059443076eSArd Biesheuvel : "r" (from), "I" (__PV_BITS_31_24), \ 2069443076eSArd Biesheuvel "I"(__PV_BITS_23_16)) 207f52bb722SSricharan R 208f52bb722SSricharan R #define __pv_add_carry_stub(x, y) \ 209e8e00f5aSArd Biesheuvel __asm__("@ __pv_add_carry_stub\n" \ 210e8e00f5aSArd Biesheuvel "0: movw %R0, #0\n" \ 2119443076eSArd Biesheuvel " adds %Q0, %1, %R0, lsl #20\n" \ 212e8e00f5aSArd Biesheuvel "1: mov %R0, %2\n" \ 213f52bb722SSricharan R " adc %R0, %R0, #0\n" \ 214f52bb722SSricharan R " .pushsection .pv_table,\"a\"\n" \ 215e8e00f5aSArd Biesheuvel " .long 0b - ., 1b - .\n" \ 216f52bb722SSricharan R " .popsection\n" \ 217e8e00f5aSArd Biesheuvel : "=&r" (y) \ 218e8e00f5aSArd Biesheuvel : "r" (x), "I" (__PV_BITS_7_0) \ 219f52bb722SSricharan R : "cc") 220f52bb722SSricharan R 221e8e00f5aSArd Biesheuvel #else 222e8e00f5aSArd Biesheuvel #define __pv_stub(from,to,instr) \ 223e8e00f5aSArd Biesheuvel __asm__("@ __pv_stub\n" \ 224e8e00f5aSArd Biesheuvel "0: movw %0, #0\n" \ 2259443076eSArd Biesheuvel " lsl %0, #21\n" \ 226e8e00f5aSArd Biesheuvel " " instr " %0, %1, %0\n" \ 227e8e00f5aSArd Biesheuvel " .pushsection .pv_table,\"a\"\n" \ 228e8e00f5aSArd Biesheuvel " .long 0b - .\n" \ 229e8e00f5aSArd Biesheuvel " .popsection\n" \ 230e8e00f5aSArd Biesheuvel : "=&r" (to) \ 231e8e00f5aSArd Biesheuvel : "r" (from)) 232e8e00f5aSArd Biesheuvel 233e8e00f5aSArd Biesheuvel #define __pv_add_carry_stub(x, y) \ 234e8e00f5aSArd Biesheuvel __asm__("@ __pv_add_carry_stub\n" \ 235e8e00f5aSArd Biesheuvel "0: movw %R0, #0\n" \ 2369443076eSArd Biesheuvel " lsls %R0, #21\n" \ 237e8e00f5aSArd Biesheuvel " adds %Q0, %1, %R0\n" \ 238e8e00f5aSArd Biesheuvel "1: mvn %R0, #0\n" \ 239e8e00f5aSArd Biesheuvel " adc %R0, %R0, #0\n" \ 240e8e00f5aSArd Biesheuvel " .pushsection .pv_table,\"a\"\n" \ 241e8e00f5aSArd Biesheuvel " .long 0b - ., 1b - .\n" \ 242e8e00f5aSArd Biesheuvel " .popsection\n" \ 243e8e00f5aSArd Biesheuvel : "=&r" (y) \ 244e8e00f5aSArd Biesheuvel : "r" (x) \ 245e8e00f5aSArd Biesheuvel : "cc") 246e8e00f5aSArd Biesheuvel #endif 247e8e00f5aSArd Biesheuvel 248e377cd82SFlorian Fainelli static inline phys_addr_t __virt_to_phys_nodebug(unsigned long x) 249dc21af99SRussell King { 250f52bb722SSricharan R phys_addr_t t; 251f52bb722SSricharan R 252f52bb722SSricharan R if (sizeof(phys_addr_t) == 4) { 2530869f3b9SArd Biesheuvel __pv_stub(x, t, "add"); 254f52bb722SSricharan R } else { 255f52bb722SSricharan R __pv_add_carry_stub(x, t); 256f52bb722SSricharan R } 257dc21af99SRussell King return t; 258dc21af99SRussell King } 259dc21af99SRussell King 260ca5a45c0SSantosh Shilimkar static inline unsigned long __phys_to_virt(phys_addr_t x) 261dc21af99SRussell King { 262dc21af99SRussell King unsigned long t; 263139cc2baSVictor Kamensky 264139cc2baSVictor Kamensky /* 265139cc2baSVictor Kamensky * 'unsigned long' cast discard upper word when 266139cc2baSVictor Kamensky * phys_addr_t is 64 bit, and makes sure that inline 267139cc2baSVictor Kamensky * assembler expression receives 32 bit argument 268139cc2baSVictor Kamensky * in place where 'r' 32 bit operand is expected. 269139cc2baSVictor Kamensky */ 2700869f3b9SArd Biesheuvel __pv_stub((unsigned long) x, t, "sub"); 271dc21af99SRussell King return t; 272dc21af99SRussell King } 273ca5a45c0SSantosh Shilimkar 274dc21af99SRussell King #else 275ca5a45c0SSantosh Shilimkar 276b713aa0bSRussell King #define PHYS_OFFSET PLAT_PHYS_OFFSET 277e26a9e00SRussell King #define PHYS_PFN_OFFSET ((unsigned long)(PHYS_OFFSET >> PAGE_SHIFT)) 278b713aa0bSRussell King 279e377cd82SFlorian Fainelli static inline phys_addr_t __virt_to_phys_nodebug(unsigned long x) 280ca5a45c0SSantosh Shilimkar { 281ca5a45c0SSantosh Shilimkar return (phys_addr_t)x - PAGE_OFFSET + PHYS_OFFSET; 282ca5a45c0SSantosh Shilimkar } 283ca5a45c0SSantosh Shilimkar 284ca5a45c0SSantosh Shilimkar static inline unsigned long __phys_to_virt(phys_addr_t x) 285ca5a45c0SSantosh Shilimkar { 286ca5a45c0SSantosh Shilimkar return x - PHYS_OFFSET + PAGE_OFFSET; 287ca5a45c0SSantosh Shilimkar } 288ca5a45c0SSantosh Shilimkar 2897d281b62SNicolas Pitre #endif 2907d281b62SNicolas Pitre 291e26a9e00SRussell King #define virt_to_pfn(kaddr) \ 292e26a9e00SRussell King ((((unsigned long)(kaddr) - PAGE_OFFSET) >> PAGE_SHIFT) + \ 293e26a9e00SRussell King PHYS_PFN_OFFSET) 294b4ad5155SStephen Boyd 295e377cd82SFlorian Fainelli #define __pa_symbol_nodebug(x) __virt_to_phys_nodebug((x)) 296e377cd82SFlorian Fainelli 297e377cd82SFlorian Fainelli #ifdef CONFIG_DEBUG_VIRTUAL 298e377cd82SFlorian Fainelli extern phys_addr_t __virt_to_phys(unsigned long x); 299e377cd82SFlorian Fainelli extern phys_addr_t __phys_addr_symbol(unsigned long x); 300e377cd82SFlorian Fainelli #else 301e377cd82SFlorian Fainelli #define __virt_to_phys(x) __virt_to_phys_nodebug(x) 302e377cd82SFlorian Fainelli #define __phys_addr_symbol(x) __pa_symbol_nodebug(x) 303e377cd82SFlorian Fainelli #endif 304e377cd82SFlorian Fainelli 3054baa9922SRussell King /* 3064baa9922SRussell King * These are *only* valid on the kernel direct mapped RAM memory. 3074baa9922SRussell King * Note: Drivers should NOT use these. They are the wrong 3084baa9922SRussell King * translation for translating DMA addresses. Use the driver 3094baa9922SRussell King * DMA support - see dma-mapping.h. 3104baa9922SRussell King */ 31184c4d3a6SThierry Reding #define virt_to_phys virt_to_phys 3123a6b1676SWill Deacon static inline phys_addr_t virt_to_phys(const volatile void *x) 3134baa9922SRussell King { 3144baa9922SRussell King return __virt_to_phys((unsigned long)(x)); 3154baa9922SRussell King } 3164baa9922SRussell King 31784c4d3a6SThierry Reding #define phys_to_virt phys_to_virt 3183a6b1676SWill Deacon static inline void *phys_to_virt(phys_addr_t x) 3194baa9922SRussell King { 320ca5a45c0SSantosh Shilimkar return (void *)__phys_to_virt(x); 3214baa9922SRussell King } 3224baa9922SRussell King 3234baa9922SRussell King /* 3244baa9922SRussell King * Drivers should NOT use these either. 3254baa9922SRussell King */ 3264baa9922SRussell King #define __pa(x) __virt_to_phys((unsigned long)(x)) 327e377cd82SFlorian Fainelli #define __pa_symbol(x) __phys_addr_symbol(RELOC_HIDE((unsigned long)(x), 0)) 328ca5a45c0SSantosh Shilimkar #define __va(x) ((void *)__phys_to_virt((phys_addr_t)(x))) 329e4886664SVitaly Andrianov #define pfn_to_kaddr(pfn) __va((phys_addr_t)(pfn) << PAGE_SHIFT) 3304baa9922SRussell King 331981b6714SRussell King extern long long arch_phys_to_idmap_offset; 3325e4432d3SRussell King 3334baa9922SRussell King /* 334981b6714SRussell King * These are for systems that have a hardware interconnect supported alias 335981b6714SRussell King * of physical memory for idmap purposes. Most cases should leave these 33628410293SRussell King * untouched. Note: this can only return addresses less than 4GiB. 3374dc9a817SSantosh Shilimkar */ 33807a7056cSRussell King static inline bool arm_has_idmap_alias(void) 33907a7056cSRussell King { 34007a7056cSRussell King return IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset != 0; 34107a7056cSRussell King } 34207a7056cSRussell King 343981b6714SRussell King #define IDMAP_INVALID_ADDR ((u32)~0) 344981b6714SRussell King 345981b6714SRussell King static inline unsigned long phys_to_idmap(phys_addr_t addr) 346981b6714SRussell King { 347981b6714SRussell King if (IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset) { 348981b6714SRussell King addr += arch_phys_to_idmap_offset; 349981b6714SRussell King if (addr > (u32)~0) 350981b6714SRussell King addr = IDMAP_INVALID_ADDR; 351981b6714SRussell King } 352981b6714SRussell King return addr; 353981b6714SRussell King } 354981b6714SRussell King 355981b6714SRussell King static inline phys_addr_t idmap_to_phys(unsigned long idmap) 356981b6714SRussell King { 357981b6714SRussell King phys_addr_t addr = idmap; 358981b6714SRussell King 359981b6714SRussell King if (IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset) 360981b6714SRussell King addr -= arch_phys_to_idmap_offset; 361981b6714SRussell King 362981b6714SRussell King return addr; 363981b6714SRussell King } 364981b6714SRussell King 36528410293SRussell King static inline unsigned long __virt_to_idmap(unsigned long x) 3664dc9a817SSantosh Shilimkar { 367981b6714SRussell King return phys_to_idmap(__virt_to_phys(x)); 3684dc9a817SSantosh Shilimkar } 3694dc9a817SSantosh Shilimkar 3704dc9a817SSantosh Shilimkar #define virt_to_idmap(x) __virt_to_idmap((unsigned long)(x)) 3714dc9a817SSantosh Shilimkar 3724dc9a817SSantosh Shilimkar /* 3734baa9922SRussell King * Virtual <-> DMA view memory address translations 3744baa9922SRussell King * Again, these are *only* valid on the kernel direct mapped RAM 3754baa9922SRussell King * memory. Use of these is *deprecated* (and that doesn't mean 3764baa9922SRussell King * use the __ prefixed forms instead.) See dma-mapping.h. 3774baa9922SRussell King */ 378b5ee9002SNicolas Pitre #ifndef __virt_to_bus 379b5ee9002SNicolas Pitre #define __virt_to_bus __virt_to_phys 380b5ee9002SNicolas Pitre #define __bus_to_virt __phys_to_virt 3811c4a4f48SRussell King #define __pfn_to_bus(x) __pfn_to_phys(x) 3821c4a4f48SRussell King #define __bus_to_pfn(x) __phys_to_pfn(x) 383b5ee9002SNicolas Pitre #endif 384b5ee9002SNicolas Pitre 3854baa9922SRussell King /* 3864baa9922SRussell King * Conversion between a struct page and a physical address. 3874baa9922SRussell King * 3884baa9922SRussell King * page_to_pfn(page) convert a struct page * to a PFN number 3894baa9922SRussell King * pfn_to_page(pfn) convert a _valid_ PFN number to struct page * 3904baa9922SRussell King * 3914baa9922SRussell King * virt_to_page(k) convert a _valid_ virtual address to struct page * 3924baa9922SRussell King * virt_addr_valid(k) indicates whether a virtual address is valid 3934baa9922SRussell King */ 3944baa9922SRussell King #define ARCH_PFN_OFFSET PHYS_PFN_OFFSET 3954baa9922SRussell King 396e26a9e00SRussell King #define virt_to_page(kaddr) pfn_to_page(virt_to_pfn(kaddr)) 397efea3403SLaura Abbott #define virt_addr_valid(kaddr) (((unsigned long)(kaddr) >= PAGE_OFFSET && (unsigned long)(kaddr) < (unsigned long)high_memory) \ 398e26a9e00SRussell King && pfn_valid(virt_to_pfn(kaddr))) 3994baa9922SRussell King 4004baa9922SRussell King #endif 4014baa9922SRussell King 4024baa9922SRussell King #include <asm-generic/memory_model.h> 4034baa9922SRussell King 4044baa9922SRussell King #endif 405