Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __ASM_SH64_PAGE_H |
| 2 | #define __ASM_SH64_PAGE_H |
| 3 | |
| 4 | /* |
| 5 | * This file is subject to the terms and conditions of the GNU General Public |
| 6 | * License. See the file "COPYING" in the main directory of this archive |
| 7 | * for more details. |
| 8 | * |
| 9 | * include/asm-sh64/page.h |
| 10 | * |
| 11 | * Copyright (C) 2000, 2001 Paolo Alberelli |
| 12 | * Copyright (C) 2003, 2004 Paul Mundt |
| 13 | * |
| 14 | * benedict.gaster@superh.com 19th, 24th July 2002. |
| 15 | * |
| 16 | * Modified to take account of enabling for D-CACHE support. |
| 17 | * |
| 18 | */ |
| 19 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | |
| 21 | /* PAGE_SHIFT determines the page size */ |
| 22 | #define PAGE_SHIFT 12 |
| 23 | #ifdef __ASSEMBLY__ |
| 24 | #define PAGE_SIZE 4096 |
| 25 | #else |
| 26 | #define PAGE_SIZE (1UL << PAGE_SHIFT) |
| 27 | #endif |
| 28 | #define PAGE_MASK (~(PAGE_SIZE-1)) |
| 29 | #define PTE_MASK PAGE_MASK |
| 30 | |
| 31 | #if defined(CONFIG_HUGETLB_PAGE_SIZE_64K) |
| 32 | #define HPAGE_SHIFT 16 |
| 33 | #elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB) |
| 34 | #define HPAGE_SHIFT 20 |
| 35 | #elif defined(CONFIG_HUGETLB_PAGE_SIZE_512MB) |
| 36 | #define HPAGE_SHIFT 29 |
| 37 | #endif |
| 38 | |
| 39 | #ifdef CONFIG_HUGETLB_PAGE |
| 40 | #define HPAGE_SIZE (1UL << HPAGE_SHIFT) |
| 41 | #define HPAGE_MASK (~(HPAGE_SIZE-1)) |
| 42 | #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT-PAGE_SHIFT) |
David Gibson | 63551ae | 2005-06-21 17:14:44 -0700 | [diff] [blame] | 43 | #define ARCH_HAS_SETCLEAR_HUGE_PTE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #endif |
| 45 | |
| 46 | #ifdef __KERNEL__ |
| 47 | #ifndef __ASSEMBLY__ |
| 48 | |
| 49 | extern struct page *mem_map; |
| 50 | extern void sh64_page_clear(void *page); |
| 51 | extern void sh64_page_copy(void *from, void *to); |
| 52 | |
| 53 | #define clear_page(page) sh64_page_clear(page) |
| 54 | #define copy_page(to,from) sh64_page_copy(from, to) |
| 55 | |
| 56 | #if defined(CONFIG_DCACHE_DISABLED) |
| 57 | |
| 58 | #define clear_user_page(page, vaddr, pg) clear_page(page) |
| 59 | #define copy_user_page(to, from, vaddr, pg) copy_page(to, from) |
| 60 | |
| 61 | #else |
| 62 | |
| 63 | extern void clear_user_page(void *to, unsigned long address, struct page *pg); |
| 64 | extern void copy_user_page(void *to, void *from, unsigned long address, struct page *pg); |
| 65 | |
| 66 | #endif /* defined(CONFIG_DCACHE_DISABLED) */ |
| 67 | |
| 68 | /* |
| 69 | * These are used to make use of C type-checking.. |
| 70 | */ |
| 71 | typedef struct { unsigned long long pte; } pte_t; |
| 72 | typedef struct { unsigned long pmd; } pmd_t; |
| 73 | typedef struct { unsigned long pgd; } pgd_t; |
| 74 | typedef struct { unsigned long pgprot; } pgprot_t; |
| 75 | |
| 76 | #define pte_val(x) ((x).pte) |
| 77 | #define pmd_val(x) ((x).pmd) |
| 78 | #define pgd_val(x) ((x).pgd) |
| 79 | #define pgprot_val(x) ((x).pgprot) |
| 80 | |
| 81 | #define __pte(x) ((pte_t) { (x) } ) |
| 82 | #define __pmd(x) ((pmd_t) { (x) } ) |
| 83 | #define __pgd(x) ((pgd_t) { (x) } ) |
| 84 | #define __pgprot(x) ((pgprot_t) { (x) } ) |
| 85 | |
| 86 | #endif /* !__ASSEMBLY__ */ |
| 87 | |
| 88 | /* to align the pointer to the (next) page boundary */ |
| 89 | #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) |
| 90 | |
| 91 | /* |
| 92 | * Kconfig defined. |
| 93 | */ |
| 94 | #define __MEMORY_START (CONFIG_MEMORY_START) |
| 95 | #define PAGE_OFFSET (CONFIG_CACHED_MEMORY_OFFSET) |
| 96 | |
| 97 | #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET) |
| 98 | #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) |
| 99 | #define MAP_NR(addr) ((__pa(addr)-__MEMORY_START) >> PAGE_SHIFT) |
| 100 | #define VALID_PAGE(page) ((page - mem_map) < max_mapnr) |
| 101 | |
| 102 | #define phys_to_page(phys) (mem_map + (((phys) - __MEMORY_START) >> PAGE_SHIFT)) |
| 103 | #define page_to_phys(page) (((page - mem_map) << PAGE_SHIFT) + __MEMORY_START) |
| 104 | |
| 105 | /* PFN start number, because of __MEMORY_START */ |
| 106 | #define PFN_START (__MEMORY_START >> PAGE_SHIFT) |
KAMEZAWA Hiroyuki | 309d34b | 2006-03-27 01:15:47 -0800 | [diff] [blame] | 107 | #define ARCH_PFN_OFFSET (PFN_START) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) |
| 109 | #define pfn_valid(pfn) (((pfn) - PFN_START) < max_mapnr) |
| 110 | #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) |
| 111 | |
| 112 | #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ |
| 113 | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) |
| 114 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | #endif /* __KERNEL__ */ |
| 116 | |
KAMEZAWA Hiroyuki | 309d34b | 2006-03-27 01:15:47 -0800 | [diff] [blame] | 117 | #include <asm-generic/memory_model.h> |
Stephen Rothwell | fd4fd5a | 2005-09-03 15:54:30 -0700 | [diff] [blame] | 118 | #include <asm-generic/page.h> |
| 119 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | #endif /* __ASM_SH64_PAGE_H */ |