1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
5 #ifndef __ASM_ARC_PAGE_H
6 #define __ASM_ARC_PAGE_H
8 #include <uapi/asm/page.h>
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)
16 struct vm_area_struct
;
19 #define __HAVE_ARCH_COPY_USER_HIGHPAGE
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
);
25 #undef STRICT_MM_TYPECHECKS
27 #ifdef STRICT_MM_TYPECHECKS
29 * These are used to make use of C type-checking..
32 #ifdef CONFIG_ARC_HAS_PAE40
33 unsigned long long pte
;
45 #define pte_val(x) ((x).pte)
46 #define pgd_val(x) ((x).pgd)
47 #define pgprot_val(x) ((x).pgprot)
49 #define __pte(x) ((pte_t) { (x) })
50 #define __pgd(x) ((pgd_t) { (x) })
51 #define __pgprot(x) ((pgprot_t) { (x) })
53 #define pte_pgprot(x) __pgprot(pte_val(x))
55 #else /* !STRICT_MM_TYPECHECKS */
57 #ifdef CONFIG_ARC_HAS_PAE40
58 typedef unsigned long long pte_t
;
60 typedef unsigned long pte_t
;
62 typedef unsigned long pgd_t
;
63 typedef unsigned long pgprot_t
;
65 #define pte_val(x) (x)
66 #define pgd_val(x) (x)
67 #define pgprot_val(x) (x)
70 #define __pgprot(x) (x)
71 #define pte_pgprot(x) (x)
75 typedef pte_t
* pgtable_t
;
78 * Use virt_to_pfn with caution:
79 * If used in pte or paddr related macros, it could cause truncation
81 * As a rule of thumb, only use it in helpers starting with virt_
82 * You have been warned !
84 #define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
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
93 extern unsigned long arch_pfn_offset
;
94 #define ARCH_PFN_OFFSET arch_pfn_offset
96 extern int pfn_valid(unsigned long pfn
);
97 #define pfn_valid pfn_valid
99 #else /* CONFIG_HIGHMEM */
101 #define ARCH_PFN_OFFSET virt_to_pfn(CONFIG_LINUX_RAM_BASE)
102 #define pfn_valid(pfn) (((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
104 #endif /* CONFIG_HIGHMEM */
107 * __pa, __va, virt_to_page (ALERT: deprecated, don't use them)
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
113 #define __pa(vaddr) ((unsigned long)(vaddr))
114 #define __va(paddr) ((void *)((unsigned long)(paddr)))
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))
119 /* Default Permissions for stack/heaps pages (Non Executable) */
120 #define VM_DATA_DEFAULT_FLAGS VM_DATA_FLAGS_NON_EXEC
122 #define WANT_PAGE_VIRTUAL 1
124 #include <asm-generic/memory_model.h> /* page_to_pfn, pfn_to_page */
125 #include <asm-generic/getorder.h>
127 #endif /* !__ASSEMBLY__ */