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>
10 #ifdef CONFIG_ARC_HAS_PAE40
12 #define MAX_POSSIBLE_PHYSMEM_BITS 40
13 #define PAGE_MASK_PHYS (0xff00000000ull | PAGE_MASK)
15 #else /* CONFIG_ARC_HAS_PAE40 */
17 #define MAX_POSSIBLE_PHYSMEM_BITS 32
18 #define PAGE_MASK_PHYS PAGE_MASK
20 #endif /* CONFIG_ARC_HAS_PAE40 */
24 #define clear_page(paddr) memset((paddr), 0, PAGE_SIZE)
25 #define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
26 #define copy_page(to, from) memcpy((to), (from), PAGE_SIZE)
28 struct vm_area_struct;
31 #define __HAVE_ARCH_COPY_USER_HIGHPAGE
33 void copy_user_highpage(struct page *to, struct page *from,
34 unsigned long u_vaddr, struct vm_area_struct *vma);
35 void clear_user_page(void *to, unsigned long u_vaddr, struct page *page);
37 #undef STRICT_MM_TYPECHECKS
39 #ifdef STRICT_MM_TYPECHECKS
41 * These are used to make use of C type-checking..
44 #ifdef CONFIG_ARC_HAS_PAE40
45 unsigned long long pte;
57 #define pte_val(x) ((x).pte)
58 #define pgd_val(x) ((x).pgd)
59 #define pgprot_val(x) ((x).pgprot)
61 #define __pte(x) ((pte_t) { (x) })
62 #define __pgd(x) ((pgd_t) { (x) })
63 #define __pgprot(x) ((pgprot_t) { (x) })
65 #define pte_pgprot(x) __pgprot(pte_val(x))
67 #else /* !STRICT_MM_TYPECHECKS */
69 #ifdef CONFIG_ARC_HAS_PAE40
70 typedef unsigned long long pte_t;
72 typedef unsigned long pte_t;
74 typedef unsigned long pgd_t;
75 typedef unsigned long pgprot_t;
77 #define pte_val(x) (x)
78 #define pgd_val(x) (x)
79 #define pgprot_val(x) (x)
82 #define __pgprot(x) (x)
83 #define pte_pgprot(x) (x)
87 typedef pte_t * pgtable_t;
90 * Use virt_to_pfn with caution:
91 * If used in pte or paddr related macros, it could cause truncation
93 * As a rule of thumb, only use it in helpers starting with virt_
94 * You have been warned !
96 #define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
98 #define ARCH_PFN_OFFSET virt_to_pfn(CONFIG_LINUX_RAM_BASE)
100 #ifdef CONFIG_FLATMEM
101 #define pfn_valid(pfn) (((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
105 * __pa, __va, virt_to_page (ALERT: deprecated, don't use them)
107 * These macros have historically been misnamed
108 * virt here means link-address/program-address as embedded in object code.
109 * And for ARC, link-addr = physical address
111 #define __pa(vaddr) ((unsigned long)(vaddr))
112 #define __va(paddr) ((void *)((unsigned long)(paddr)))
114 #define virt_to_page(kaddr) pfn_to_page(virt_to_pfn(kaddr))
115 #define virt_addr_valid(kaddr) pfn_valid(virt_to_pfn(kaddr))
117 /* Default Permissions for stack/heaps pages (Non Executable) */
118 #define VM_DATA_DEFAULT_FLAGS VM_DATA_FLAGS_NON_EXEC
120 #define WANT_PAGE_VIRTUAL 1
122 #include <asm-generic/memory_model.h> /* page_to_pfn, pfn_to_page */
123 #include <asm-generic/getorder.h>
125 #endif /* !__ASSEMBLY__ */