WIP FPC-III support
[linux/fpc-iii.git] / arch / arc / include / asm / page.h
blobad9b7fe4dba363a4713a16275a99f5968802eca9
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
8 #include <uapi/asm/page.h>
10 #ifndef __ASSEMBLY__
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;
17 struct page;
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..
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;
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;
59 #else
60 typedef unsigned long pte_t;
61 #endif
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)
68 #define __pte(x) (x)
69 #define __pgd(x) (x)
70 #define __pgprot(x) (x)
71 #define pte_pgprot(x) (x)
73 #endif
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
80 * in PAE40 builds
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
89 * memory
91 #ifdef CONFIG_HIGHMEM
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__ */
129 #endif