xref: /linux/arch/csky/include/asm/page.h (revision cdd30ebb1b9f36159d66f088b61aee264e649d7a)
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 struct page;
43 
44 #include <abi/page.h>
45 
46 struct vm_area_struct;
47 
48 typedef struct { unsigned long pte_low; } pte_t;
49 #define pte_val(x)	((x).pte_low)
50 
51 typedef struct { unsigned long pgd; } pgd_t;
52 typedef struct { unsigned long pgprot; } pgprot_t;
53 typedef struct page *pgtable_t;
54 
55 #define pgd_val(x)	((x).pgd)
56 #define pgprot_val(x)	((x).pgprot)
57 
58 #define ptep_buddy(x)	((pte_t *)((unsigned long)(x) ^ sizeof(pte_t)))
59 
60 #define __pte(x)	((pte_t) { (x) })
61 #define __pgd(x)	((pgd_t) { (x) })
62 #define __pgprot(x)	((pgprot_t) { (x) })
63 
64 extern unsigned long va_pa_offset;
65 
66 #define ARCH_PFN_OFFSET	PFN_DOWN(va_pa_offset + PHYS_OFFSET_OFFSET)
67 
68 #define __pa(x)		 ((unsigned long)(x) - PAGE_OFFSET + va_pa_offset)
69 #define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET - va_pa_offset))
70 
71 #define __pa_symbol(x)	__pa(RELOC_HIDE((unsigned long)(x), 0))
72 
73 static inline unsigned long virt_to_pfn(const void *kaddr)
74 {
75 	return __pa(kaddr) >> PAGE_SHIFT;
76 }
77 
78 #define MAP_NR(x)	PFN_DOWN((unsigned long)(x) - PAGE_OFFSET - \
79 				 PHYS_OFFSET_OFFSET)
80 #define virt_to_page(x)	(mem_map + MAP_NR(x))
81 
82 #define pfn_to_kaddr(x)	__va(PFN_PHYS(x))
83 
84 #include <asm-generic/memory_model.h>
85 #include <asm-generic/getorder.h>
86 
87 #endif /* !__ASSEMBLY__ */
88 #endif /* __ASM_CSKY_PAGE_H */
89