Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * include/asm-v850/page.h -- VM ops |
| 3 | * |
Miles Bader | e9c3d6b | 2005-07-27 11:44:52 -0700 | [diff] [blame] | 4 | * Copyright (C) 2001,02,03,05 NEC Electronics Corporation |
| 5 | * Copyright (C) 2001,02,03,05 Miles Bader <miles@gnu.org> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * |
| 7 | * This file is subject to the terms and conditions of the GNU General |
| 8 | * Public License. See the file COPYING in the main directory of this |
| 9 | * archive for more details. |
| 10 | * |
| 11 | * Written by Miles Bader <miles@gnu.org> |
| 12 | */ |
| 13 | |
| 14 | #ifndef __V850_PAGE_H__ |
| 15 | #define __V850_PAGE_H__ |
| 16 | |
| 17 | #include <asm/machdep.h> |
| 18 | |
| 19 | |
| 20 | #define PAGE_SHIFT 12 |
| 21 | #define PAGE_SIZE (1UL << PAGE_SHIFT) |
| 22 | #define PAGE_MASK (~(PAGE_SIZE-1)) |
| 23 | |
| 24 | |
| 25 | /* |
| 26 | * PAGE_OFFSET -- the first address of the first page of memory. For archs with |
| 27 | * no MMU this corresponds to the first free page in physical memory (aligned |
| 28 | * on a page boundary). |
| 29 | */ |
| 30 | #ifndef PAGE_OFFSET |
| 31 | #define PAGE_OFFSET 0x0000000 |
| 32 | #endif |
| 33 | |
| 34 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #ifndef __ASSEMBLY__ |
| 36 | |
| 37 | #define STRICT_MM_TYPECHECKS |
| 38 | |
| 39 | #define clear_page(page) memset ((void *)(page), 0, PAGE_SIZE) |
| 40 | #define copy_page(to, from) memcpy ((void *)(to), (void *)from, PAGE_SIZE) |
| 41 | |
| 42 | #define clear_user_page(addr, vaddr, page) \ |
| 43 | do { clear_page(addr); \ |
| 44 | flush_dcache_page(page); \ |
| 45 | } while (0) |
| 46 | #define copy_user_page(to, from, vaddr, page) \ |
| 47 | do { copy_page(to, from); \ |
| 48 | flush_dcache_page(page); \ |
| 49 | } while (0) |
| 50 | |
| 51 | #ifdef STRICT_MM_TYPECHECKS |
| 52 | /* |
| 53 | * These are used to make use of C type-checking.. |
| 54 | */ |
| 55 | |
| 56 | typedef struct { unsigned long pte; } pte_t; |
| 57 | typedef struct { unsigned long pmd; } pmd_t; |
| 58 | typedef struct { unsigned long pgd; } pgd_t; |
| 59 | typedef struct { unsigned long pgprot; } pgprot_t; |
Martin Schwidefsky | 257ce73 | 2008-02-09 03:13:00 -0800 | [diff] [blame] | 60 | typedef struct page *pgtable_t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | |
| 62 | #define pte_val(x) ((x).pte) |
| 63 | #define pmd_val(x) ((x).pmd) |
| 64 | #define pgd_val(x) ((x).pgd) |
| 65 | #define pgprot_val(x) ((x).pgprot) |
| 66 | |
| 67 | #define __pte(x) ((pte_t) { (x) } ) |
| 68 | #define __pmd(x) ((pmd_t) { (x) } ) |
| 69 | #define __pgd(x) ((pgd_t) { (x) } ) |
| 70 | #define __pgprot(x) ((pgprot_t) { (x) } ) |
| 71 | |
| 72 | #else /* !STRICT_MM_TYPECHECKS */ |
| 73 | /* |
| 74 | * .. while these make it easier on the compiler |
| 75 | */ |
| 76 | |
| 77 | typedef unsigned long pte_t; |
| 78 | typedef unsigned long pmd_t; |
| 79 | typedef unsigned long pgd_t; |
| 80 | typedef unsigned long pgprot_t; |
| 81 | |
| 82 | #define pte_val(x) (x) |
| 83 | #define pmd_val(x) (x) |
| 84 | #define pgd_val(x) (x) |
| 85 | #define pgprot_val(x) (x) |
| 86 | |
| 87 | #define __pte(x) (x) |
| 88 | #define __pmd(x) (x) |
| 89 | #define __pgd(x) (x) |
| 90 | #define __pgprot(x) (x) |
| 91 | |
| 92 | #endif /* STRICT_MM_TYPECHECKS */ |
| 93 | |
| 94 | #endif /* !__ASSEMBLY__ */ |
| 95 | |
| 96 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | /* No current v850 processor has virtual memory. */ |
| 98 | #define __virt_to_phys(addr) (addr) |
| 99 | #define __phys_to_virt(addr) (addr) |
| 100 | |
| 101 | #define virt_to_pfn(kaddr) (__virt_to_phys (kaddr) >> PAGE_SHIFT) |
| 102 | #define pfn_to_virt(pfn) __phys_to_virt ((pfn) << PAGE_SHIFT) |
| 103 | |
| 104 | #define MAP_NR(kaddr) \ |
| 105 | (((unsigned long)(kaddr) - PAGE_OFFSET) >> PAGE_SHIFT) |
| 106 | #define virt_to_page(kaddr) (mem_map + MAP_NR (kaddr)) |
| 107 | #define page_to_virt(page) \ |
| 108 | ((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET) |
| 109 | |
KAMEZAWA Hiroyuki | e6009f1 | 2006-03-27 01:15:52 -0800 | [diff] [blame] | 110 | #define ARCH_PFN_OFFSET (PAGE_OFFSET >> PAGE_SHIFT) |
Miles Bader | e9c3d6b | 2005-07-27 11:44:52 -0700 | [diff] [blame] | 111 | #define pfn_valid(pfn) ((pfn) < max_mapnr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | |
| 113 | #define virt_addr_valid(kaddr) \ |
| 114 | (((void *)(kaddr) >= (void *)PAGE_OFFSET) && MAP_NR (kaddr) < max_mapnr) |
| 115 | |
| 116 | |
| 117 | #define __pa(x) __virt_to_phys ((unsigned long)(x)) |
| 118 | #define __va(x) ((void *)__phys_to_virt ((unsigned long)(x))) |
| 119 | |
| 120 | |
KAMEZAWA Hiroyuki | e6009f1 | 2006-03-27 01:15:52 -0800 | [diff] [blame] | 121 | #include <asm-generic/memory_model.h> |
Stephen Rothwell | fd4fd5a | 2005-09-03 15:54:30 -0700 | [diff] [blame] | 122 | #include <asm-generic/page.h> |
| 123 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | #endif /* __V850_PAGE_H__ */ |