1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_GENERIC_PAGE_H
3 #define __ASM_GENERIC_PAGE_H
5 * Generic page.h implementation, for NOMMU architectures.
6 * This provides the dummy definitions for the memory management.
10 #error need to provide a real asm/page.h
14 /* PAGE_SHIFT determines the page size */
18 #define PAGE_SIZE (1 << PAGE_SHIFT)
20 #define PAGE_SIZE (1UL << PAGE_SHIFT)
22 #define PAGE_MASK (~(PAGE_SIZE-1))
24 #include <asm/setup.h>
28 #define clear_page(page) memset((page), 0, PAGE_SIZE)
29 #define copy_page(to,from) memcpy((to), (from), PAGE_SIZE)
31 #define clear_user_page(page, vaddr, pg) clear_page(page)
32 #define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
35 * These are used to make use of C type-checking..
41 unsigned long pmd[16];
49 typedef struct page *pgtable_t;
51 #define pte_val(x) ((x).pte)
52 #define pmd_val(x) ((&x)->pmd[0])
53 #define pgd_val(x) ((x).pgd)
54 #define pgprot_val(x) ((x).pgprot)
56 #define __pte(x) ((pte_t) { (x) } )
57 #define __pmd(x) ((pmd_t) { (x) } )
58 #define __pgd(x) ((pgd_t) { (x) } )
59 #define __pgprot(x) ((pgprot_t) { (x) } )
61 extern unsigned long memory_start;
62 extern unsigned long memory_end;
64 #endif /* !__ASSEMBLY__ */
66 #define PAGE_OFFSET (0)
68 #ifndef ARCH_PFN_OFFSET
69 #define ARCH_PFN_OFFSET (PAGE_OFFSET >> PAGE_SHIFT)
74 #define __va(x) ((void *)((unsigned long) (x)))
75 #define __pa(x) ((unsigned long) (x))
77 static inline unsigned long virt_to_pfn(const void *kaddr)
79 return __pa(kaddr) >> PAGE_SHIFT;
81 #define virt_to_pfn virt_to_pfn
82 static inline void *pfn_to_virt(unsigned long pfn)
84 return __va(pfn) << PAGE_SHIFT;
86 #define pfn_to_virt pfn_to_virt
88 #define virt_to_page(addr) pfn_to_page(virt_to_pfn(addr))
89 #define page_to_virt(page) pfn_to_virt(page_to_pfn(page))
92 #define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
95 #define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
96 ((void *)(kaddr) < (void *)memory_end))
98 #endif /* __ASSEMBLY__ */
100 #include <asm-generic/memory_model.h>
101 #include <asm-generic/getorder.h>
103 #endif /* __ASM_GENERIC_PAGE_H */