xref: /linux/arch/csky/include/asm/page.h (revision fcb3ad4366b9c810cbb9da34c076a9a52d8aa1e0)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 #ifndef __ASM_CSKY_PAGE_H
4 #define __ASM_CSKY_PAGE_H
5 
6 #include <asm/setup.h>
7 #include <asm/cache.h>
8 #include <linux/const.h>
9 
10 #include <vdso/page.h>
11 
12 #define THREAD_SIZE	(PAGE_SIZE * 2)
13 #define THREAD_MASK	(~(THREAD_SIZE - 1))
14 #define THREAD_SHIFT	(PAGE_SHIFT + 1)
15 
16 
17 /*
18  * For C-SKY "User-space:Kernel-space" is "2GB:2GB" fixed by hardware and there
19  * are two segment registers (MSA0 + MSA1) to mapping 512MB + 512MB physical
20  * address region. We use them mapping kernel 1GB direct-map address area and
21  * for more than 1GB of memory we use highmem.
22  */
23 #define PAGE_OFFSET	CONFIG_PAGE_OFFSET
24 #define SSEG_SIZE	0x20000000
25 #define LOWMEM_LIMIT	(SSEG_SIZE * 2)
26 
27 #define PHYS_OFFSET_OFFSET (CONFIG_DRAM_BASE & (SSEG_SIZE - 1))
28 
29 #ifndef __ASSEMBLY__
30 
31 #include <linux/pfn.h>
32 
33 #define virt_addr_valid(kaddr)  ((void *)(kaddr) >= (void *)PAGE_OFFSET && \
34 			(void *)(kaddr) < high_memory)
35 
36 extern void *memset(void *dest, int c, size_t l);
37 extern void *memcpy(void *to, const void *from, size_t l);
38 
39 #define clear_page(page)	memset((page), 0, PAGE_SIZE)
40 #define copy_page(to, from)	memcpy((to), (from), PAGE_SIZE)
41 
42 #define page_to_phys(page)	(page_to_pfn(page) << PAGE_SHIFT)
43 #define phys_to_page(paddr)	(pfn_to_page(PFN_DOWN(paddr)))
44 
45 struct page;
46 
47 #include <abi/page.h>
48 
49 struct vm_area_struct;
50 
51 typedef struct { unsigned long pte_low; } pte_t;
52 #define pte_val(x)	((x).pte_low)
53 
54 typedef struct { unsigned long pgd; } pgd_t;
55 typedef struct { unsigned long pgprot; } pgprot_t;
56 typedef struct page *pgtable_t;
57 
58 #define pgd_val(x)	((x).pgd)
59 #define pgprot_val(x)	((x).pgprot)
60 
61 #define ptep_buddy(x)	((pte_t *)((unsigned long)(x) ^ sizeof(pte_t)))
62 
63 #define __pte(x)	((pte_t) { (x) })
64 #define __pgd(x)	((pgd_t) { (x) })
65 #define __pgprot(x)	((pgprot_t) { (x) })
66 
67 extern unsigned long va_pa_offset;
68 
69 #define ARCH_PFN_OFFSET	PFN_DOWN(va_pa_offset + PHYS_OFFSET_OFFSET)
70 
71 #define __pa(x)		 ((unsigned long)(x) - PAGE_OFFSET + va_pa_offset)
72 #define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET - va_pa_offset))
73 
74 #define __pa_symbol(x)	__pa(RELOC_HIDE((unsigned long)(x), 0))
75 
76 static inline unsigned long virt_to_pfn(const void *kaddr)
77 {
78 	return __pa(kaddr) >> PAGE_SHIFT;
79 }
80 
81 #define MAP_NR(x)	PFN_DOWN((unsigned long)(x) - PAGE_OFFSET - \
82 				 PHYS_OFFSET_OFFSET)
83 #define virt_to_page(x)	(mem_map + MAP_NR(x))
84 
85 #define pfn_to_kaddr(x)	__va(PFN_PHYS(x))
86 
87 #include <asm-generic/memory_model.h>
88 #include <asm-generic/getorder.h>
89 
90 #endif /* !__ASSEMBLY__ */
91 #endif /* __ASM_CSKY_PAGE_H */
92