blob: 0f76a0d586f66e36904ea4568d0fa4f56fe66d12 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef _ASM_PAGE_H
3#define _ASM_PAGE_H
4
Linus Torvalds1da177e2005-04-16 15:20:36 -07005#include <asm/virtconvert.h>
6#include <asm/mem-layout.h>
7#include <asm/sections.h>
8#include <asm/setup.h>
9
10#ifndef __ASSEMBLY__
11
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#define clear_page(pgaddr) memset((pgaddr), 0, PAGE_SIZE)
13#define copy_page(to,from) memcpy((to), (from), PAGE_SIZE)
14
15#define clear_user_page(pgaddr, vaddr, page) memset((pgaddr), 0, PAGE_SIZE)
16#define copy_user_page(vto, vfrom, vaddr, topg) memcpy((vto), (vfrom), PAGE_SIZE)
17
18/*
19 * These are used to make use of C type-checking..
20 */
21typedef struct { unsigned long pte; } pte_t;
22typedef struct { unsigned long ste[64];} pmd_t;
23typedef struct { pmd_t pue[1]; } pud_t;
24typedef struct { pud_t pge[1]; } pgd_t;
25typedef struct { unsigned long pgprot; } pgprot_t;
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080026typedef struct page *pgtable_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
28#define pte_val(x) ((x).pte)
29#define pmd_val(x) ((x).ste[0])
30#define pud_val(x) ((x).pue[0])
31#define pgd_val(x) ((x).pge[0])
32#define pgprot_val(x) ((x).pgprot)
33
34#define __pte(x) ((pte_t) { (x) } )
Dan Williams6d8113c2016-01-15 16:56:35 -080035#define __pmd(x) ((pmd_t) { { (x) } } )
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#define __pud(x) ((pud_t) { (x) } )
37#define __pgd(x) ((pgd_t) { (x) } )
38#define __pgprot(x) ((pgprot_t) { (x) } )
39#define PTE_MASK PAGE_MASK
40
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#define devmem_is_allowed(pfn) 1
42
David Howells8080f232005-11-28 13:43:51 -080043#define __pa(vaddr) virt_to_phys((void *) (unsigned long) (vaddr))
44#define __va(paddr) phys_to_virt((unsigned long) (paddr))
Linus Torvalds1da177e2005-04-16 15:20:36 -070045
46#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
47
48extern unsigned long max_low_pfn;
49extern unsigned long min_low_pfn;
50extern unsigned long max_pfn;
51
52#ifdef CONFIG_MMU
Linus Torvalds1da177e2005-04-16 15:20:36 -070053#define pfn_valid(pfn) ((pfn) < max_mapnr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070054#else
KAMEZAWA Hiroyuki5cdac7c2006-03-27 01:15:40 -080055#define ARCH_PFN_OFFSET (PAGE_OFFSET >> PAGE_SHIFT)
Linus Torvalds1da177e2005-04-16 15:20:36 -070056#define pfn_valid(pfn) ((pfn) >= min_low_pfn && (pfn) < max_low_pfn)
57
58#endif
59
60#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
61#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
62
63
Linus Torvalds1da177e2005-04-16 15:20:36 -070064#define VM_DATA_DEFAULT_FLAGS \
65 (VM_READ | VM_WRITE | \
66 ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
67 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
69#endif /* __ASSEMBLY__ */
70
KAMEZAWA Hiroyuki5cdac7c2006-03-27 01:15:40 -080071#include <asm-generic/memory_model.h>
Arnd Bergmann5b17e1c2009-05-13 22:56:30 +000072#include <asm-generic/getorder.h>
Stephen Rothwellfd4fd5a2005-09-03 15:54:30 -070073
Linus Torvalds1da177e2005-04-16 15:20:36 -070074#endif /* _ASM_PAGE_H */