1 #ifndef __ASM_SH_PAGE_H
2 #define __ASM_SH_PAGE_H
3 
4 /*
5  * Copyright (C) 1999  Niibe Yutaka
6  */
7 
8 /*
9    [ P0/U0 (virtual) ]		0x00000000     <------ User space
10    [ P1 (fixed)   cached ]	0x80000000     <------ Kernel space
11    [ P2 (fixed)  non-cachable]	0xA0000000     <------ Physical access
12    [ P3 (virtual) cached]	0xC0000000     <------ vmalloced area
13    [ P4 control   ]		0xE0000000
14  */
15 
16 #include <linux/config.h>
17 
18 /* PAGE_SHIFT determines the page size */
19 #define PAGE_SHIFT	12
20 #define PAGE_SIZE	(1UL << PAGE_SHIFT)
21 #define PAGE_MASK	(~(PAGE_SIZE-1))
22 #define PTE_MASK	PAGE_MASK
23 
24 #ifdef __KERNEL__
25 #ifndef __ASSEMBLY__
26 
27 extern void clear_page(void *to);
28 extern void copy_page(void *to, void *from);
29 
30 #if defined(__sh3__)
31 #define clear_user_page(page, vaddr)	clear_page(page)
32 #define copy_user_page(to, from, vaddr)	copy_page(to, from)
33 #elif defined(__SH4__)
34 extern void clear_user_page(void *to, unsigned long address);
35 extern void copy_user_page(void *to, void *from, unsigned long address);
36 extern void __clear_user_page(void *to, void *orig_to);
37 extern void __copy_user_page(void *to, void *from, void *orig_to);
38 #endif
39 
40 /*
41  * These are used to make use of C type-checking..
42  */
43 typedef struct { unsigned long pte; } pte_t;
44 typedef struct { unsigned long pmd; } pmd_t;
45 typedef struct { unsigned long pgd; } pgd_t;
46 typedef struct { unsigned long pgprot; } pgprot_t;
47 
48 #define pte_val(x)	((x).pte)
49 #define pmd_val(x)	((x).pmd)
50 #define pgd_val(x)	((x).pgd)
51 #define pgprot_val(x)	((x).pgprot)
52 
53 #define __pte(x) ((pte_t) { (x) } )
54 #define __pmd(x) ((pmd_t) { (x) } )
55 #define __pgd(x) ((pgd_t) { (x) } )
56 #define __pgprot(x)	((pgprot_t) { (x) } )
57 
58 #endif /* !__ASSEMBLY__ */
59 
60 /* to align the pointer to the (next) page boundary */
61 #define PAGE_ALIGN(addr)	(((addr)+PAGE_SIZE-1)&PAGE_MASK)
62 
63 /*
64  * IF YOU CHANGE THIS, PLEASE ALSO CHANGE
65  *
66  *	arch/sh/vmlinux.lds.S
67  *
68  * which has the same constant encoded..
69  */
70 
71 #define __MEMORY_START		CONFIG_MEMORY_START
72 #define __MEMORY_SIZE		CONFIG_MEMORY_SIZE
73 #ifdef CONFIG_DISCONTIGMEM
74 /* Just for HP690, for now.. */
75 #define __MEMORY_START_2ND	(__MEMORY_START+0x02000000)
76 #define __MEMORY_SIZE_2ND	0x001000000 /* 16MB */
77 #endif
78 
79 #define PAGE_OFFSET		(0x80000000UL)
80 #define __pa(x)			((unsigned long)(x)-PAGE_OFFSET)
81 #define __va(x)			((void *)((unsigned long)(x)+PAGE_OFFSET))
82 
83 #ifndef CONFIG_DISCONTIGMEM
84 #define phys_to_page(phys)	(mem_map + (((phys)-__MEMORY_START) >> PAGE_SHIFT))
85 #define VALID_PAGE(page)	((page - mem_map) < max_mapnr)
86 #define page_to_phys(page)	(((page - mem_map) << PAGE_SHIFT) + __MEMORY_START)
87 #endif
88 
89 #define virt_to_page(kaddr)	phys_to_page(__pa(kaddr))
90 
91 #define VM_DATA_DEFAULT_FLAGS	(VM_READ | VM_WRITE | VM_EXEC | \
92 				 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
93 
94 #ifndef __ASSEMBLY__
95 
96 /*
97  * Tell the user there is some problem.
98  */
99 #define BUG() do { \
100 	printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
101 	asm volatile("nop"); \
102 } while (0)
103 
104 #define PAGE_BUG(page) do { \
105 	BUG(); \
106 } while (0)
107 
108 /* Pure 2^n version of get_order */
get_order(unsigned long size)109 static __inline__ int get_order(unsigned long size)
110 {
111 	int order;
112 
113 	size = (size-1) >> (PAGE_SHIFT-1);
114 	order = -1;
115 	do {
116 		size >>= 1;
117 		order++;
118 	} while (size);
119 	return order;
120 }
121 
122 #endif
123 
124 #endif /* __KERNEL__ */
125 
126 #endif /* __ASM_SH_PAGE_H */
127