1 /* 2 * linux/arch/unicore32/include/asm/memory.h 3 * 4 * Code specific to PKUnity SoC and UniCore ISA 5 * 6 * Copyright (C) 2001-2010 GUAN Xue-tao 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License version 2 as 10 * published by the Free Software Foundation. 11 * 12 * Note: this file should not be included by non-asm/.h files 13 */ 14 #ifndef __UNICORE_MEMORY_H__ 15 #define __UNICORE_MEMORY_H__ 16 17 #include <linux/compiler.h> 18 #include <linux/const.h> 19 #include <asm/sizes.h> 20 #include <mach/memory.h> 21 22 /* 23 * Allow for constants defined here to be used from assembly code 24 * by prepending the UL suffix only with actual C code compilation. 25 */ 26 #define UL(x) _AC(x, UL) 27 28 /* 29 * PAGE_OFFSET - the virtual address of the start of the kernel image 30 * TASK_SIZE - the maximum size of a user space task. 31 * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area 32 */ 33 #define PAGE_OFFSET UL(0xC0000000) 34 #define TASK_SIZE (PAGE_OFFSET - UL(0x41000000)) 35 #define TASK_UNMAPPED_BASE (PAGE_OFFSET / 3) 36 37 /* 38 * The module space lives between the addresses given by TASK_SIZE 39 * and PAGE_OFFSET - it must be within 32MB of the kernel text. 40 */ 41 #define MODULES_VADDR (PAGE_OFFSET - 16*1024*1024) 42 #if TASK_SIZE > MODULES_VADDR 43 #error Top of user space clashes with start of module space 44 #endif 45 46 #define MODULES_END (PAGE_OFFSET) 47 48 /* 49 * Allow 16MB-aligned ioremap pages 50 */ 51 #define IOREMAP_MAX_ORDER 24 52 53 /* 54 * Physical vs virtual RAM address space conversion. These are 55 * private definitions which should NOT be used outside memory.h 56 * files. Use virt_to_phys/phys_to_virt/__pa/__va instead. 57 */ 58 #ifndef __virt_to_phys 59 #define __virt_to_phys(x) ((x) - PAGE_OFFSET + PHYS_OFFSET) 60 #define __phys_to_virt(x) ((x) - PHYS_OFFSET + PAGE_OFFSET) 61 #endif 62 63 /* 64 * Convert a physical address to a Page Frame Number and back 65 */ 66 #define __phys_to_pfn(paddr) ((paddr) >> PAGE_SHIFT) 67 #define __pfn_to_phys(pfn) ((pfn) << PAGE_SHIFT) 68 69 /* 70 * Convert a page to/from a physical address 71 */ 72 #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page))) 73 #define phys_to_page(phys) (pfn_to_page(__phys_to_pfn(phys))) 74 75 #ifndef __ASSEMBLY__ 76 77 #ifndef arch_adjust_zones 78 #define arch_adjust_zones(size, holes) do { } while (0) 79 #endif 80 81 /* 82 * PFNs are used to describe any physical page; this means 83 * PFN 0 == physical address 0. 84 * 85 * This is the PFN of the first RAM page in the kernel 86 * direct-mapped view. We assume this is the first page 87 * of RAM in the mem_map as well. 88 */ 89 #define PHYS_PFN_OFFSET (PHYS_OFFSET >> PAGE_SHIFT) 90 91 /* 92 * Drivers should NOT use these either. 93 */ 94 #define __pa(x) __virt_to_phys((unsigned long)(x)) 95 #define __va(x) ((void *)__phys_to_virt((unsigned long)(x))) 96 #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) 97 98 /* 99 * Conversion between a struct page and a physical address. 100 * 101 * Note: when converting an unknown physical address to a 102 * struct page, the resulting pointer must be validated 103 * using VALID_PAGE(). It must return an invalid struct page 104 * for any physical address not corresponding to a system 105 * RAM address. 106 * 107 * page_to_pfn(page) convert a struct page * to a PFN number 108 * pfn_to_page(pfn) convert a _valid_ PFN number to struct page * 109 * 110 * virt_to_page(k) convert a _valid_ virtual address to struct page * 111 * virt_addr_valid(k) indicates whether a virtual address is valid 112 */ 113 #define ARCH_PFN_OFFSET PHYS_PFN_OFFSET 114 115 #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) 116 #define virt_addr_valid(kaddr) ((unsigned long)(kaddr) >= PAGE_OFFSET && \ 117 (unsigned long)(kaddr) < (unsigned long)high_memory) 118 119 #endif 120 121 #include <asm-generic/memory_model.h> 122 123 #endif 124