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 | #ifndef __ASSEMBLY__ |
| 14 | |
Vineet Gupta | 5dda4dc | 2013-01-18 15:12:19 +0530 | [diff] [blame] | 15 | #define clear_page(paddr) memset((paddr), 0, PAGE_SIZE) |
| 16 | #define copy_page(to, from) memcpy((to), (from), PAGE_SIZE) |
| 17 | |
Vineet Gupta | 4102b53 | 2013-05-09 21:54:51 +0530 | [diff] [blame] | 18 | struct vm_area_struct; |
| 19 | struct page; |
| 20 | |
| 21 | #define __HAVE_ARCH_COPY_USER_HIGHPAGE |
| 22 | |
| 23 | void copy_user_highpage(struct page *to, struct page *from, |
| 24 | unsigned long u_vaddr, struct vm_area_struct *vma); |
| 25 | void clear_user_page(void *to, unsigned long u_vaddr, struct page *page); |
| 26 | |
Vineet Gupta | 5dda4dc | 2013-01-18 15:12:19 +0530 | [diff] [blame] | 27 | #undef STRICT_MM_TYPECHECKS |
| 28 | |
| 29 | #ifdef STRICT_MM_TYPECHECKS |
| 30 | /* |
| 31 | * These are used to make use of C type-checking.. |
| 32 | */ |
| 33 | typedef struct { |
| 34 | unsigned long pte; |
| 35 | } pte_t; |
| 36 | typedef struct { |
| 37 | unsigned long pgd; |
| 38 | } pgd_t; |
| 39 | typedef struct { |
| 40 | unsigned long pgprot; |
| 41 | } pgprot_t; |
Vineet Gupta | 5dda4dc | 2013-01-18 15:12:19 +0530 | [diff] [blame] | 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 | |
Gilad Ben-Yossef | 4368902 | 2013-01-22 16:48:45 +0530 | [diff] [blame] | 51 | #define pte_pgprot(x) __pgprot(pte_val(x)) |
| 52 | |
Vineet Gupta | 5dda4dc | 2013-01-18 15:12:19 +0530 | [diff] [blame] | 53 | #else /* !STRICT_MM_TYPECHECKS */ |
| 54 | |
Vineet Gupta | 5a364c2 | 2015-02-06 18:44:57 +0300 | [diff] [blame] | 55 | #ifdef CONFIG_ARC_HAS_PAE40 |
| 56 | typedef unsigned long long pte_t; |
| 57 | #else |
Vineet Gupta | 5dda4dc | 2013-01-18 15:12:19 +0530 | [diff] [blame] | 58 | typedef unsigned long pte_t; |
Vineet Gupta | 5a364c2 | 2015-02-06 18:44:57 +0300 | [diff] [blame] | 59 | #endif |
Vineet Gupta | 5dda4dc | 2013-01-18 15:12:19 +0530 | [diff] [blame] | 60 | typedef unsigned long pgd_t; |
| 61 | typedef unsigned long pgprot_t; |
Vineet Gupta | 5dda4dc | 2013-01-18 15:12:19 +0530 | [diff] [blame] | 62 | |
| 63 | #define pte_val(x) (x) |
| 64 | #define pgd_val(x) (x) |
| 65 | #define pgprot_val(x) (x) |
| 66 | #define __pte(x) (x) |
Vineet Gupta | fe6c1b8 | 2014-07-08 18:43:47 +0530 | [diff] [blame] | 67 | #define __pgd(x) (x) |
Vineet Gupta | 5dda4dc | 2013-01-18 15:12:19 +0530 | [diff] [blame] | 68 | #define __pgprot(x) (x) |
Gilad Ben-Yossef | 4368902 | 2013-01-22 16:48:45 +0530 | [diff] [blame] | 69 | #define pte_pgprot(x) (x) |
Vineet Gupta | 5dda4dc | 2013-01-18 15:12:19 +0530 | [diff] [blame] | 70 | |
| 71 | #endif |
| 72 | |
Vineet Gupta | e8a7596 | 2015-08-28 08:39:57 +0530 | [diff] [blame] | 73 | typedef pte_t * pgtable_t; |
| 74 | |
Vineet Gupta | c2ff5cf2 | 2015-12-18 13:57:41 +0530 | [diff] [blame] | 75 | #define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT) |
Vineet Gupta | 5dda4dc | 2013-01-18 15:12:19 +0530 | [diff] [blame] | 76 | |
Vineet Gupta | c2ff5cf2 | 2015-12-18 13:57:41 +0530 | [diff] [blame] | 77 | #define ARCH_PFN_OFFSET virt_to_pfn(CONFIG_LINUX_LINK_BASE) |
| 78 | |
| 79 | #define pfn_valid(pfn) (((pfn) - ARCH_PFN_OFFSET) < max_mapnr) |
Vineet Gupta | 5dda4dc | 2013-01-18 15:12:19 +0530 | [diff] [blame] | 80 | |
| 81 | /* |
| 82 | * __pa, __va, virt_to_page (ALERT: deprecated, don't use them) |
| 83 | * |
| 84 | * These macros have historically been misnamed |
| 85 | * virt here means link-address/program-address as embedded in object code. |
Vineet Gupta | c2ff5cf2 | 2015-12-18 13:57:41 +0530 | [diff] [blame] | 86 | * And for ARC, link-addr = physical address |
Vineet Gupta | 5dda4dc | 2013-01-18 15:12:19 +0530 | [diff] [blame] | 87 | */ |
| 88 | #define __pa(vaddr) ((unsigned long)vaddr) |
| 89 | #define __va(paddr) ((void *)((unsigned long)(paddr))) |
| 90 | |
| 91 | #define virt_to_page(kaddr) \ |
Vineet Gupta | c2ff5cf2 | 2015-12-18 13:57:41 +0530 | [diff] [blame] | 92 | (mem_map + virt_to_pfn((kaddr) - CONFIG_LINUX_LINK_BASE)) |
Vineet Gupta | 5dda4dc | 2013-01-18 15:12:19 +0530 | [diff] [blame] | 93 | |
Vineet Gupta | c2ff5cf2 | 2015-12-18 13:57:41 +0530 | [diff] [blame] | 94 | #define virt_addr_valid(kaddr) pfn_valid(virt_to_pfn(kaddr)) |
Vineet Gupta | 5dda4dc | 2013-01-18 15:12:19 +0530 | [diff] [blame] | 95 | |
Vineet Gupta | 3abc944 | 2013-06-05 17:49:14 +0530 | [diff] [blame] | 96 | /* Default Permissions for stack/heaps pages (Non Executable) */ |
Vineet Gupta | 5dda4dc | 2013-01-18 15:12:19 +0530 | [diff] [blame] | 97 | #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE) |
Vineet Gupta | 5dda4dc | 2013-01-18 15:12:19 +0530 | [diff] [blame] | 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 |