1 #ifndef __ASM_SH_PAGE_H
2 #define __ASM_SH_PAGE_H
5 * Copyright (C) 1999 Niibe Yutaka
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
17 /* PAGE_SHIFT determines the page size */
21 #define PAGE_SIZE (1 << PAGE_SHIFT)
23 #define PAGE_SIZE (1UL << PAGE_SHIFT)
26 #define PAGE_MASK (~(PAGE_SIZE-1))
27 #define PTE_MASK PAGE_MASK
29 #if defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
30 #define HPAGE_SHIFT 16
31 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB)
32 #define HPAGE_SHIFT 20
35 #ifdef CONFIG_HUGETLB_PAGE
36 #define HPAGE_SIZE (1UL << HPAGE_SHIFT)
37 #define HPAGE_MASK (~(HPAGE_SIZE-1))
38 #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT-PAGE_SHIFT)
44 extern void (*clear_page)(void *to);
45 extern void (*copy_page)(void *to, void *from);
47 extern unsigned long shm_align_mask;
50 extern void clear_page_slow(void *to);
51 extern void copy_page_slow(void *to, void *from);
53 extern void clear_page_nommu(void *to);
54 extern void copy_page_nommu(void *to, void *from);
57 #if defined(CONFIG_MMU) && (defined(CONFIG_CPU_SH4) || \
58 defined(CONFIG_SH7705_CACHE_32KB))
60 extern void clear_user_page(void *to, unsigned long address, struct page *pg);
61 extern void copy_user_page(void *to, void *from, unsigned long address, struct page *pg);
62 extern void __clear_user_page(void *to, void *orig_to);
63 extern void __copy_user_page(void *to, void *from, void *orig_to);
64 #elif defined(CONFIG_CPU_SH2) || defined(CONFIG_CPU_SH3) || !defined(CONFIG_MMU)
65 #define clear_user_page(page, vaddr, pg) clear_page(page)
66 #define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
70 * These are used to make use of C type-checking..
72 typedef struct { unsigned long pte; } pte_t;
73 typedef struct { unsigned long pgd; } pgd_t;
74 typedef struct { unsigned long pgprot; } pgprot_t;
76 #define pte_val(x) ((x).pte)
77 #define pgd_val(x) ((x).pgd)
78 #define pgprot_val(x) ((x).pgprot)
80 #define __pte(x) ((pte_t) { (x) } )
81 #define __pgd(x) ((pgd_t) { (x) } )
82 #define __pgprot(x) ((pgprot_t) { (x) } )
84 #endif /* !__ASSEMBLY__ */
86 /* to align the pointer to the (next) page boundary */
87 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
90 * IF YOU CHANGE THIS, PLEASE ALSO CHANGE
92 * arch/sh/kernel/vmlinux.lds.S
94 * which has the same constant encoded..
97 #define __MEMORY_START CONFIG_MEMORY_START
98 #define __MEMORY_SIZE CONFIG_MEMORY_SIZE
100 #define PAGE_OFFSET CONFIG_PAGE_OFFSET
101 #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
102 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
104 #define MAP_NR(addr) (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)
106 #define phys_to_page(phys) (mem_map + (((phys)-__MEMORY_START) >> PAGE_SHIFT))
107 #define page_to_phys(page) (((page - mem_map) << PAGE_SHIFT) + __MEMORY_START)
109 /* PFN start number, because of __MEMORY_START */
110 #define PFN_START (__MEMORY_START >> PAGE_SHIFT)
111 #define ARCH_PFN_OFFSET (PFN_START)
112 #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
113 #define pfn_valid(pfn) (((pfn) - PFN_START) < max_mapnr)
114 #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
116 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
117 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
119 #include <asm-generic/memory_model.h>
120 #include <asm-generic/page.h>
123 #ifdef CONFIG_VSYSCALL
124 #define __HAVE_ARCH_GATE_AREA
127 #endif /* __KERNEL__ */
128 #endif /* __ASM_SH_PAGE_H */