blob: 23e41e890eda7069910742f4f679f9fb47eeaf68 [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Vineet Gupta3be80aa2013-01-18 15:12:17 +05302/*
3 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
Vineet Gupta3be80aa2013-01-18 15:12:17 +05304 */
Vineet Gupta3be80aa2013-01-18 15:12:17 +05305#ifndef __ASM_ARC_PAGE_H
6#define __ASM_ARC_PAGE_H
7
Vineet Gupta8c2f4a82013-02-11 19:55:33 +05308#include <uapi/asm/page.h>
Vineet Gupta3be80aa2013-01-18 15:12:17 +05309
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053010#ifndef __ASSEMBLY__
11
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053012#define clear_page(paddr) memset((paddr), 0, PAGE_SIZE)
13#define copy_page(to, from) memcpy((to), (from), PAGE_SIZE)
14
Vineet Gupta4102b532013-05-09 21:54:51 +053015struct vm_area_struct;
16struct page;
17
18#define __HAVE_ARCH_COPY_USER_HIGHPAGE
19
20void copy_user_highpage(struct page *to, struct page *from,
21 unsigned long u_vaddr, struct vm_area_struct *vma);
22void clear_user_page(void *to, unsigned long u_vaddr, struct page *page);
23
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053024#undef STRICT_MM_TYPECHECKS
25
26#ifdef STRICT_MM_TYPECHECKS
27/*
28 * These are used to make use of C type-checking..
29 */
30typedef struct {
Vineet Gupta5035cd52016-05-03 14:53:40 +053031#ifdef CONFIG_ARC_HAS_PAE40
32 unsigned long long pte;
33#else
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053034 unsigned long pte;
Vineet Gupta5035cd52016-05-03 14:53:40 +053035#endif
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053036} pte_t;
37typedef struct {
38 unsigned long pgd;
39} pgd_t;
40typedef struct {
41 unsigned long pgprot;
42} pgprot_t;
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053043
44#define pte_val(x) ((x).pte)
45#define pgd_val(x) ((x).pgd)
46#define pgprot_val(x) ((x).pgprot)
47
48#define __pte(x) ((pte_t) { (x) })
49#define __pgd(x) ((pgd_t) { (x) })
50#define __pgprot(x) ((pgprot_t) { (x) })
51
Gilad Ben-Yossef43689022013-01-22 16:48:45 +053052#define pte_pgprot(x) __pgprot(pte_val(x))
53
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053054#else /* !STRICT_MM_TYPECHECKS */
55
Vineet Gupta5a364c22015-02-06 18:44:57 +030056#ifdef CONFIG_ARC_HAS_PAE40
57typedef unsigned long long pte_t;
58#else
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053059typedef unsigned long pte_t;
Vineet Gupta5a364c22015-02-06 18:44:57 +030060#endif
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053061typedef unsigned long pgd_t;
62typedef unsigned long pgprot_t;
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053063
64#define pte_val(x) (x)
65#define pgd_val(x) (x)
66#define pgprot_val(x) (x)
67#define __pte(x) (x)
Vineet Guptafe6c1b82014-07-08 18:43:47 +053068#define __pgd(x) (x)
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053069#define __pgprot(x) (x)
Gilad Ben-Yossef43689022013-01-22 16:48:45 +053070#define pte_pgprot(x) (x)
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053071
72#endif
73
Vineet Guptae8a75962015-08-28 08:39:57 +053074typedef pte_t * pgtable_t;
75
Vineet Gupta2519d752016-05-05 14:53:48 +053076/*
77 * Use virt_to_pfn with caution:
78 * If used in pte or paddr related macros, it could cause truncation
79 * in PAE40 builds
80 * As a rule of thumb, only use it in helpers starting with virt_
81 * You have been warned !
82 */
Vineet Guptac2ff5cf22015-12-18 13:57:41 +053083#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053084
Mike Rapoport050b2da2020-12-14 19:10:04 -080085/*
86 * When HIGHMEM is enabled we have holes in the memory map so we need
87 * pfn_valid() that takes into account the actual extents of the physical
88 * memory
89 */
90#ifdef CONFIG_HIGHMEM
Vineet Guptac2ff5cf22015-12-18 13:57:41 +053091
Mike Rapoport050b2da2020-12-14 19:10:04 -080092extern unsigned long arch_pfn_offset;
93#define ARCH_PFN_OFFSET arch_pfn_offset
94
95extern int pfn_valid(unsigned long pfn);
96#define pfn_valid pfn_valid
97
98#else /* CONFIG_HIGHMEM */
99
100#define ARCH_PFN_OFFSET virt_to_pfn(CONFIG_LINUX_RAM_BASE)
Vineet Guptac2ff5cf22015-12-18 13:57:41 +0530101#define pfn_valid(pfn) (((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
Mike Rapoport050b2da2020-12-14 19:10:04 -0800102
103#endif /* CONFIG_HIGHMEM */
Vineet Gupta5dda4dc2013-01-18 15:12:19 +0530104
105/*
106 * __pa, __va, virt_to_page (ALERT: deprecated, don't use them)
107 *
108 * These macros have historically been misnamed
109 * virt here means link-address/program-address as embedded in object code.
Vineet Guptac2ff5cf22015-12-18 13:57:41 +0530110 * And for ARC, link-addr = physical address
Vineet Gupta5dda4dc2013-01-18 15:12:19 +0530111 */
Vineet Gupta2519d752016-05-05 14:53:48 +0530112#define __pa(vaddr) ((unsigned long)(vaddr))
Vineet Gupta5dda4dc2013-01-18 15:12:19 +0530113#define __va(paddr) ((void *)((unsigned long)(paddr)))
114
Vineet Gupta26f9d5f2016-04-18 10:49:56 +0530115#define virt_to_page(kaddr) pfn_to_page(virt_to_pfn(kaddr))
Vineet Guptac2ff5cf22015-12-18 13:57:41 +0530116#define virt_addr_valid(kaddr) pfn_valid(virt_to_pfn(kaddr))
Vineet Gupta5dda4dc2013-01-18 15:12:19 +0530117
Vineet Gupta3abc9442013-06-05 17:49:14 +0530118/* Default Permissions for stack/heaps pages (Non Executable) */
Anshuman Khandualc62da0c2020-04-10 14:33:05 -0700119#define VM_DATA_DEFAULT_FLAGS VM_DATA_FLAGS_NON_EXEC
Vineet Gupta5dda4dc2013-01-18 15:12:19 +0530120
121#define WANT_PAGE_VIRTUAL 1
122
123#include <asm-generic/memory_model.h> /* page_to_pfn, pfn_to_page */
124#include <asm-generic/getorder.h>
125
Vineet Gupta3be80aa2013-01-18 15:12:17 +0530126#endif /* !__ASSEMBLY__ */
127
Vineet Gupta3be80aa2013-01-18 15:12:17 +0530128#endif