1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) 4 */ 5 #ifndef __ASM_ARC_PAGE_H 6 #define __ASM_ARC_PAGE_H 7 8 #include <uapi/asm/page.h> 9 10 #ifndef __ASSEMBLY__ 11 12 #define clear_page(paddr) memset((paddr), 0, PAGE_SIZE) 13 #define copy_user_page(to, from, vaddr, pg) copy_page(to, from) 14 #define copy_page(to, from) memcpy((to), (from), PAGE_SIZE) 15 16 struct vm_area_struct; 17 struct page; 18 19 #define __HAVE_ARCH_COPY_USER_HIGHPAGE 20 21 void copy_user_highpage(struct page *to, struct page *from, 22 unsigned long u_vaddr, struct vm_area_struct *vma); 23 void clear_user_page(void *to, unsigned long u_vaddr, struct page *page); 24 25 #undef STRICT_MM_TYPECHECKS 26 27 #ifdef STRICT_MM_TYPECHECKS 28 /* 29 * These are used to make use of C type-checking.. 30 */ 31 typedef struct { 32 #ifdef CONFIG_ARC_HAS_PAE40 33 unsigned long long pte; 34 #else 35 unsigned long pte; 36 #endif 37 } pte_t; 38 typedef struct { 39 unsigned long pgd; 40 } pgd_t; 41 typedef struct { 42 unsigned long pgprot; 43 } pgprot_t; 44 45 #define pte_val(x) ((x).pte) 46 #define pgd_val(x) ((x).pgd) 47 #define pgprot_val(x) ((x).pgprot) 48 49 #define __pte(x) ((pte_t) { (x) }) 50 #define __pgd(x) ((pgd_t) { (x) }) 51 #define __pgprot(x) ((pgprot_t) { (x) }) 52 53 #define pte_pgprot(x) __pgprot(pte_val(x)) 54 55 #else /* !STRICT_MM_TYPECHECKS */ 56 57 #ifdef CONFIG_ARC_HAS_PAE40 58 typedef unsigned long long pte_t; 59 #else 60 typedef unsigned long pte_t; 61 #endif 62 typedef unsigned long pgd_t; 63 typedef unsigned long pgprot_t; 64 65 #define pte_val(x) (x) 66 #define pgd_val(x) (x) 67 #define pgprot_val(x) (x) 68 #define __pte(x) (x) 69 #define __pgd(x) (x) 70 #define __pgprot(x) (x) 71 #define pte_pgprot(x) (x) 72 73 #endif 74 75 typedef pte_t * pgtable_t; 76 77 /* 78 * Use virt_to_pfn with caution: 79 * If used in pte or paddr related macros, it could cause truncation 80 * in PAE40 builds 81 * As a rule of thumb, only use it in helpers starting with virt_ 82 * You have been warned ! 83 */ 84 #define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT) 85 86 /* 87 * When HIGHMEM is enabled we have holes in the memory map so we need 88 * pfn_valid() that takes into account the actual extents of the physical 89 * memory 90 */ 91 #ifdef CONFIG_HIGHMEM 92 93 extern unsigned long arch_pfn_offset; 94 #define ARCH_PFN_OFFSET arch_pfn_offset 95 96 extern int pfn_valid(unsigned long pfn); 97 #define pfn_valid pfn_valid 98 99 #else /* CONFIG_HIGHMEM */ 100 101 #define ARCH_PFN_OFFSET virt_to_pfn(CONFIG_LINUX_RAM_BASE) 102 #define pfn_valid(pfn) (((pfn) - ARCH_PFN_OFFSET) < max_mapnr) 103 104 #endif /* CONFIG_HIGHMEM */ 105 106 /* 107 * __pa, __va, virt_to_page (ALERT: deprecated, don't use them) 108 * 109 * These macros have historically been misnamed 110 * virt here means link-address/program-address as embedded in object code. 111 * And for ARC, link-addr = physical address 112 */ 113 #define __pa(vaddr) ((unsigned long)(vaddr)) 114 #define __va(paddr) ((void *)((unsigned long)(paddr))) 115 116 #define virt_to_page(kaddr) pfn_to_page(virt_to_pfn(kaddr)) 117 #define virt_addr_valid(kaddr) pfn_valid(virt_to_pfn(kaddr)) 118 119 /* Default Permissions for stack/heaps pages (Non Executable) */ 120 #define VM_DATA_DEFAULT_FLAGS VM_DATA_FLAGS_NON_EXEC 121 122 #define WANT_PAGE_VIRTUAL 1 123 124 #include <asm-generic/memory_model.h> /* page_to_pfn, pfn_to_page */ 125 #include <asm-generic/getorder.h> 126 127 #endif /* !__ASSEMBLY__ */ 128 129 #endif 130