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