Vineet Gupta | 3be80aa | 2013-01-18 15:12:17 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 as |
| 6 | * published by the Free Software Foundation. |
| 7 | */ |
Vineet Gupta | 3be80aa | 2013-01-18 15:12:17 +0530 | [diff] [blame] | 8 | #ifndef __ASM_ARC_PAGE_H |
| 9 | #define __ASM_ARC_PAGE_H |
| 10 | |
Vineet Gupta | 8c2f4a8 | 2013-02-11 19:55:33 +0530 | [diff] [blame^] | 11 | #include <uapi/asm/page.h> |
Vineet Gupta | 3be80aa | 2013-01-18 15:12:17 +0530 | [diff] [blame] | 12 | |
Vineet Gupta | 5dda4dc | 2013-01-18 15:12:19 +0530 | [diff] [blame] | 13 | |
| 14 | #ifndef __ASSEMBLY__ |
| 15 | |
| 16 | #define get_user_page(vaddr) __get_free_page(GFP_KERNEL) |
| 17 | #define free_user_page(page, addr) free_page(addr) |
| 18 | |
| 19 | /* TBD: for now don't worry about VIPT D$ aliasing */ |
| 20 | #define clear_page(paddr) memset((paddr), 0, PAGE_SIZE) |
| 21 | #define copy_page(to, from) memcpy((to), (from), PAGE_SIZE) |
| 22 | |
| 23 | #define clear_user_page(addr, vaddr, pg) clear_page(addr) |
| 24 | #define copy_user_page(vto, vfrom, vaddr, pg) copy_page(vto, vfrom) |
| 25 | |
| 26 | #undef STRICT_MM_TYPECHECKS |
| 27 | |
| 28 | #ifdef STRICT_MM_TYPECHECKS |
| 29 | /* |
| 30 | * These are used to make use of C type-checking.. |
| 31 | */ |
| 32 | typedef struct { |
| 33 | unsigned long pte; |
| 34 | } pte_t; |
| 35 | typedef struct { |
| 36 | unsigned long pgd; |
| 37 | } pgd_t; |
| 38 | typedef struct { |
| 39 | unsigned long pgprot; |
| 40 | } pgprot_t; |
| 41 | typedef unsigned long pgtable_t; |
| 42 | |
| 43 | #define pte_val(x) ((x).pte) |
| 44 | #define pgd_val(x) ((x).pgd) |
| 45 | #define pgprot_val(x) ((x).pgprot) |
| 46 | |
| 47 | #define __pte(x) ((pte_t) { (x) }) |
| 48 | #define __pgd(x) ((pgd_t) { (x) }) |
| 49 | #define __pgprot(x) ((pgprot_t) { (x) }) |
| 50 | |
| 51 | #else /* !STRICT_MM_TYPECHECKS */ |
| 52 | |
| 53 | typedef unsigned long pte_t; |
| 54 | typedef unsigned long pgd_t; |
| 55 | typedef unsigned long pgprot_t; |
| 56 | typedef unsigned long pgtable_t; |
| 57 | |
| 58 | #define pte_val(x) (x) |
| 59 | #define pgd_val(x) (x) |
| 60 | #define pgprot_val(x) (x) |
| 61 | #define __pte(x) (x) |
| 62 | #define __pgprot(x) (x) |
| 63 | |
| 64 | #endif |
| 65 | |
| 66 | #define ARCH_PFN_OFFSET (CONFIG_LINUX_LINK_BASE >> PAGE_SHIFT) |
| 67 | |
| 68 | #define pfn_valid(pfn) (((pfn) - ARCH_PFN_OFFSET) < max_mapnr) |
| 69 | |
| 70 | /* |
| 71 | * __pa, __va, virt_to_page (ALERT: deprecated, don't use them) |
| 72 | * |
| 73 | * These macros have historically been misnamed |
| 74 | * virt here means link-address/program-address as embedded in object code. |
| 75 | * So if kernel img is linked at 0x8000_0000 onwards, 0x8010_0000 will be |
| 76 | * 128th page, and virt_to_page( ) will return the struct page corresp to it. |
| 77 | * mem_map[ ] is an array of struct page for each page frame in the system |
| 78 | * |
| 79 | * Independent of where linux is linked at, link-addr = physical address |
| 80 | * So the old macro __pa = vaddr + PAGE_OFFSET - CONFIG_LINUX_LINK_BASE |
| 81 | * would have been wrong in case kernel is not at 0x8zs |
| 82 | */ |
| 83 | #define __pa(vaddr) ((unsigned long)vaddr) |
| 84 | #define __va(paddr) ((void *)((unsigned long)(paddr))) |
| 85 | |
| 86 | #define virt_to_page(kaddr) \ |
| 87 | (mem_map + ((__pa(kaddr) - CONFIG_LINUX_LINK_BASE) >> PAGE_SHIFT)) |
| 88 | |
| 89 | #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) |
| 90 | |
| 91 | /* Default Permissions for page, used in mmap.c */ |
| 92 | #ifdef CONFIG_ARC_STACK_NONEXEC |
| 93 | #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE) |
| 94 | #else |
| 95 | #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ |
| 96 | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) |
| 97 | #endif |
| 98 | |
| 99 | #define WANT_PAGE_VIRTUAL 1 |
| 100 | |
| 101 | #include <asm-generic/memory_model.h> /* page_to_pfn, pfn_to_page */ |
| 102 | #include <asm-generic/getorder.h> |
| 103 | |
Vineet Gupta | 3be80aa | 2013-01-18 15:12:17 +0530 | [diff] [blame] | 104 | #endif /* !__ASSEMBLY__ */ |
| 105 | |
Vineet Gupta | 3be80aa | 2013-01-18 15:12:17 +0530 | [diff] [blame] | 106 | #endif |