blob: 51d7281a546adc6d42835e61e08cd9d3e6e68656 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#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
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
17/* PAGE_SHIFT determines the page size */
18#define PAGE_SHIFT 12
19#define PAGE_SIZE (1UL << PAGE_SHIFT)
20#define PAGE_MASK (~(PAGE_SIZE-1))
21#define PTE_MASK PAGE_MASK
22
23#if defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
24#define HPAGE_SHIFT 16
25#elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB)
26#define HPAGE_SHIFT 20
27#endif
28
29#ifdef CONFIG_HUGETLB_PAGE
30#define HPAGE_SIZE (1UL << HPAGE_SHIFT)
31#define HPAGE_MASK (~(HPAGE_SIZE-1))
32#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT-PAGE_SHIFT)
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#endif
34
35#ifdef __KERNEL__
36#ifndef __ASSEMBLY__
37
38extern void (*clear_page)(void *to);
39extern void (*copy_page)(void *to, void *from);
40
41extern void clear_page_slow(void *to);
42extern void copy_page_slow(void *to, void *from);
43
Paul Mundt26ff6c12006-09-27 15:13:36 +090044#if defined(CONFIG_MMU) && (defined(CONFIG_CPU_SH4) || \
45 defined(CONFIG_SH7705_CACHE_32KB))
Linus Torvalds1da177e2005-04-16 15:20:36 -070046struct page;
47extern void clear_user_page(void *to, unsigned long address, struct page *pg);
48extern void copy_user_page(void *to, void *from, unsigned long address, struct page *pg);
49extern void __clear_user_page(void *to, void *orig_to);
50extern void __copy_user_page(void *to, void *from, void *orig_to);
51#elif defined(CONFIG_CPU_SH2) || defined(CONFIG_CPU_SH3) || !defined(CONFIG_MMU)
52#define clear_user_page(page, vaddr, pg) clear_page(page)
53#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
Linus Torvalds1da177e2005-04-16 15:20:36 -070054#endif
55
56/*
57 * These are used to make use of C type-checking..
58 */
59typedef struct { unsigned long pte; } pte_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060typedef struct { unsigned long pgd; } pgd_t;
61typedef struct { unsigned long pgprot; } pgprot_t;
62
63#define pte_val(x) ((x).pte)
Linus Torvalds1da177e2005-04-16 15:20:36 -070064#define pgd_val(x) ((x).pgd)
65#define pgprot_val(x) ((x).pgprot)
66
67#define __pte(x) ((pte_t) { (x) } )
Linus Torvalds1da177e2005-04-16 15:20:36 -070068#define __pgd(x) ((pgd_t) { (x) } )
69#define __pgprot(x) ((pgprot_t) { (x) } )
70
71#endif /* !__ASSEMBLY__ */
72
73/* to align the pointer to the (next) page boundary */
74#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
75
76/*
77 * IF YOU CHANGE THIS, PLEASE ALSO CHANGE
78 *
79 * arch/sh/kernel/vmlinux.lds.S
80 *
81 * which has the same constant encoded..
82 */
83
84#define __MEMORY_START CONFIG_MEMORY_START
85#define __MEMORY_SIZE CONFIG_MEMORY_SIZE
Linus Torvalds1da177e2005-04-16 15:20:36 -070086
87#define PAGE_OFFSET (0x80000000UL)
88#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
89#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
90
91#define MAP_NR(addr) (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)
92
Linus Torvalds1da177e2005-04-16 15:20:36 -070093#define phys_to_page(phys) (mem_map + (((phys)-__MEMORY_START) >> PAGE_SHIFT))
94#define page_to_phys(page) (((page - mem_map) << PAGE_SHIFT) + __MEMORY_START)
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
96/* PFN start number, because of __MEMORY_START */
97#define PFN_START (__MEMORY_START >> PAGE_SHIFT)
Alexey Dobriyan67bb2c62006-09-08 09:47:34 -070098#define ARCH_PFN_OFFSET (PFN_START)
Linus Torvalds1da177e2005-04-16 15:20:36 -070099#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
100#define pfn_valid(pfn) (((pfn) - PFN_START) < max_mapnr)
101#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
102
103#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
104 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
105
KAMEZAWA Hiroyuki104b8de2006-03-27 01:15:46 -0800106#include <asm-generic/memory_model.h>
Stephen Rothwellfd4fd5a2005-09-03 15:54:30 -0700107#include <asm-generic/page.h>
108
Paul Mundtb5233d02006-09-20 03:25:34 +0900109#endif /* __KERNEL__ */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110#endif /* __ASM_SH_PAGE_H */