Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
| 17 | /* PAGE_SHIFT determines the page size */ |
| 18 | #define PAGE_SHIFT 12 |
Paul Mundt | d153ea8 | 2006-09-27 18:20:16 +0900 | [diff] [blame^] | 19 | #define PAGE_SIZE (1 << PAGE_SHIFT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #endif |
| 34 | |
| 35 | #ifdef __KERNEL__ |
| 36 | #ifndef __ASSEMBLY__ |
| 37 | |
| 38 | extern void (*clear_page)(void *to); |
| 39 | extern void (*copy_page)(void *to, void *from); |
| 40 | |
Yoshinori Sato | e96636c | 2006-09-27 17:21:02 +0900 | [diff] [blame] | 41 | #ifdef CONFIG_MMU |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | extern void clear_page_slow(void *to); |
| 43 | extern void copy_page_slow(void *to, void *from); |
Yoshinori Sato | e96636c | 2006-09-27 17:21:02 +0900 | [diff] [blame] | 44 | #else |
| 45 | extern void clear_page_nommu(void *to); |
| 46 | extern void copy_page_nommu(void *to, void *from); |
| 47 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
Paul Mundt | 26ff6c1 | 2006-09-27 15:13:36 +0900 | [diff] [blame] | 49 | #if defined(CONFIG_MMU) && (defined(CONFIG_CPU_SH4) || \ |
| 50 | defined(CONFIG_SH7705_CACHE_32KB)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | struct page; |
| 52 | extern void clear_user_page(void *to, unsigned long address, struct page *pg); |
| 53 | extern void copy_user_page(void *to, void *from, unsigned long address, struct page *pg); |
| 54 | extern void __clear_user_page(void *to, void *orig_to); |
| 55 | extern void __copy_user_page(void *to, void *from, void *orig_to); |
| 56 | #elif defined(CONFIG_CPU_SH2) || defined(CONFIG_CPU_SH3) || !defined(CONFIG_MMU) |
| 57 | #define clear_user_page(page, vaddr, pg) clear_page(page) |
| 58 | #define copy_user_page(to, from, vaddr, pg) copy_page(to, from) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | #endif |
| 60 | |
| 61 | /* |
| 62 | * These are used to make use of C type-checking.. |
| 63 | */ |
| 64 | typedef struct { unsigned long pte; } pte_t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | typedef struct { unsigned long pgd; } pgd_t; |
| 66 | typedef struct { unsigned long pgprot; } pgprot_t; |
| 67 | |
| 68 | #define pte_val(x) ((x).pte) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | #define pgd_val(x) ((x).pgd) |
| 70 | #define pgprot_val(x) ((x).pgprot) |
| 71 | |
| 72 | #define __pte(x) ((pte_t) { (x) } ) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | #define __pgd(x) ((pgd_t) { (x) } ) |
| 74 | #define __pgprot(x) ((pgprot_t) { (x) } ) |
| 75 | |
| 76 | #endif /* !__ASSEMBLY__ */ |
| 77 | |
| 78 | /* to align the pointer to the (next) page boundary */ |
| 79 | #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) |
| 80 | |
| 81 | /* |
| 82 | * IF YOU CHANGE THIS, PLEASE ALSO CHANGE |
| 83 | * |
| 84 | * arch/sh/kernel/vmlinux.lds.S |
| 85 | * |
| 86 | * which has the same constant encoded.. |
| 87 | */ |
| 88 | |
| 89 | #define __MEMORY_START CONFIG_MEMORY_START |
| 90 | #define __MEMORY_SIZE CONFIG_MEMORY_SIZE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | |
Paul Mundt | e7f93a3 | 2006-09-27 17:19:13 +0900 | [diff] [blame] | 92 | #define PAGE_OFFSET CONFIG_PAGE_OFFSET |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET) |
| 94 | #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) |
| 95 | |
| 96 | #define MAP_NR(addr) (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT) |
| 97 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | #define phys_to_page(phys) (mem_map + (((phys)-__MEMORY_START) >> PAGE_SHIFT)) |
| 99 | #define page_to_phys(page) (((page - mem_map) << PAGE_SHIFT) + __MEMORY_START) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | |
| 101 | /* PFN start number, because of __MEMORY_START */ |
| 102 | #define PFN_START (__MEMORY_START >> PAGE_SHIFT) |
Alexey Dobriyan | 67bb2c6 | 2006-09-08 09:47:34 -0700 | [diff] [blame] | 103 | #define ARCH_PFN_OFFSET (PFN_START) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) |
| 105 | #define pfn_valid(pfn) (((pfn) - PFN_START) < max_mapnr) |
| 106 | #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) |
| 107 | |
| 108 | #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ |
| 109 | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) |
| 110 | |
KAMEZAWA Hiroyuki | 104b8de | 2006-03-27 01:15:46 -0800 | [diff] [blame] | 111 | #include <asm-generic/memory_model.h> |
Stephen Rothwell | fd4fd5a | 2005-09-03 15:54:30 -0700 | [diff] [blame] | 112 | #include <asm-generic/page.h> |
| 113 | |
Paul Mundt | b5233d0 | 2006-09-20 03:25:34 +0900 | [diff] [blame] | 114 | #endif /* __KERNEL__ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | #endif /* __ASM_SH_PAGE_H */ |