Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / score / include / asm / page.h
blob17d9c68b6bd5df0615cf393e7c92b3cbd23b7c87
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_SCORE_PAGE_H
3 #define _ASM_SCORE_PAGE_H
5 #include <linux/pfn.h>
6 #include <linux/const.h>
8 /* PAGE_SHIFT determines the page size */
9 #define PAGE_SHIFT (12)
10 #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
11 #define PAGE_MASK (~(PAGE_SIZE-1))
13 #ifdef __KERNEL__
15 #ifndef __ASSEMBLY__
17 #define PAGE_UP(addr) (((addr)+((PAGE_SIZE)-1))&(~((PAGE_SIZE)-1)))
18 #define PAGE_DOWN(addr) ((addr)&(~((PAGE_SIZE)-1)))
20 /* align addr on a size boundary - adjust address up/down if needed */
21 #define _ALIGN_UP(addr, size) (((addr)+((size)-1))&(~((size)-1)))
22 #define _ALIGN_DOWN(addr, size) ((addr)&(~((size)-1)))
24 /* align addr on a size boundary - adjust address up if needed */
25 #define _ALIGN(addr, size) _ALIGN_UP(addr, size)
28 * PAGE_OFFSET -- the first address of the first page of memory. When not
29 * using MMU this corresponds to the first free page in physical memory (aligned
30 * on a page boundary).
32 #define PAGE_OFFSET (0xA0000000UL)
34 #define clear_page(pgaddr) memset((pgaddr), 0, PAGE_SIZE)
35 #define copy_page(to, from) memcpy((to), (from), PAGE_SIZE)
37 #define clear_user_page(pgaddr, vaddr, page) memset((pgaddr), 0, PAGE_SIZE)
38 #define copy_user_page(vto, vfrom, vaddr, topg) \
39 memcpy((vto), (vfrom), PAGE_SIZE)
42 * These are used to make use of C type-checking..
45 typedef struct { unsigned long pte; } pte_t; /* page table entry */
46 typedef struct { unsigned long pgd; } pgd_t; /* PGD table entry */
47 typedef struct { unsigned long pgprot; } pgprot_t;
48 typedef struct page *pgtable_t;
50 #define pte_val(x) ((x).pte)
51 #define pgd_val(x) ((x).pgd)
52 #define pgprot_val(x) ((x).pgprot)
54 #define __pte(x) ((pte_t) { (x) })
55 #define __pgd(x) ((pgd_t) { (x) })
56 #define __pgprot(x) ((pgprot_t) { (x) })
58 extern unsigned long max_low_pfn;
59 extern unsigned long min_low_pfn;
60 extern unsigned long max_pfn;
62 #define __pa(x) ((unsigned long)(x) - PAGE_OFFSET)
63 #define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
65 #define phys_to_pfn(phys) (PFN_DOWN(phys))
66 #define pfn_to_phys(pfn) (PFN_PHYS(pfn))
68 #define virt_to_pfn(vaddr) (phys_to_pfn((__pa(vaddr))))
69 #define pfn_to_virt(pfn) __va(pfn_to_phys((pfn)))
71 #define virt_to_page(vaddr) (pfn_to_page(virt_to_pfn(vaddr)))
72 #define page_to_virt(page) (pfn_to_virt(page_to_pfn(page)))
74 #define page_to_phys(page) (pfn_to_phys(page_to_pfn(page)))
75 #define page_to_bus(page) (page_to_phys(page))
76 #define phys_to_page(paddr) (pfn_to_page(phys_to_pfn(paddr)))
78 #define pfn_valid(pfn) (((pfn) >= min_low_pfn) && ((pfn) < max_low_pfn))
80 #define ARCH_PFN_OFFSET (PAGE_OFFSET >> PAGE_SHIFT)
82 #endif /* __ASSEMBLY__ */
84 #define virt_addr_valid(vaddr) (pfn_valid(virt_to_pfn(vaddr)))
86 #endif /* __KERNEL__ */
88 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
89 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
91 #include <asm-generic/memory_model.h>
92 #include <asm-generic/getorder.h>
94 #endif /* _ASM_SCORE_PAGE_H */