Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* $Id: page.h,v 1.55 2000/10/30 21:01:41 davem Exp $ |
| 2 | * page.h: Various defines and such for MMU operations on the Sparc for |
| 3 | * the Linux kernel. |
| 4 | * |
| 5 | * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) |
| 6 | */ |
| 7 | |
| 8 | #ifndef _SPARC_PAGE_H |
| 9 | #define _SPARC_PAGE_H |
| 10 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #ifdef CONFIG_SUN4 |
| 12 | #define PAGE_SHIFT 13 |
| 13 | #else |
| 14 | #define PAGE_SHIFT 12 |
| 15 | #endif |
| 16 | #ifndef __ASSEMBLY__ |
| 17 | /* I have my suspicions... -DaveM */ |
| 18 | #define PAGE_SIZE (1UL << PAGE_SHIFT) |
| 19 | #else |
| 20 | #define PAGE_SIZE (1 << PAGE_SHIFT) |
| 21 | #endif |
| 22 | #define PAGE_MASK (~(PAGE_SIZE-1)) |
| 23 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | #include <asm/btfixup.h> |
| 25 | |
| 26 | #ifndef __ASSEMBLY__ |
| 27 | |
| 28 | #define clear_page(page) memset((void *)(page), 0, PAGE_SIZE) |
| 29 | #define copy_page(to,from) memcpy((void *)(to), (void *)(from), PAGE_SIZE) |
| 30 | #define clear_user_page(addr, vaddr, page) \ |
| 31 | do { clear_page(addr); \ |
| 32 | sparc_flush_page_to_ram(page); \ |
| 33 | } while (0) |
| 34 | #define copy_user_page(to, from, vaddr, page) \ |
| 35 | do { copy_page(to, from); \ |
| 36 | sparc_flush_page_to_ram(page); \ |
| 37 | } while (0) |
| 38 | |
| 39 | /* The following structure is used to hold the physical |
| 40 | * memory configuration of the machine. This is filled in |
| 41 | * probe_memory() and is later used by mem_init() to set up |
| 42 | * mem_map[]. We statically allocate SPARC_PHYS_BANKS of |
| 43 | * these structs, this is arbitrary. The entry after the |
| 44 | * last valid one has num_bytes==0. |
| 45 | */ |
| 46 | |
| 47 | struct sparc_phys_banks { |
| 48 | unsigned long base_addr; |
| 49 | unsigned long num_bytes; |
| 50 | }; |
| 51 | |
| 52 | #define SPARC_PHYS_BANKS 32 |
| 53 | |
| 54 | extern struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS+1]; |
| 55 | |
| 56 | /* Cache alias structure. Entry is valid if context != -1. */ |
| 57 | struct cache_palias { |
| 58 | unsigned long vaddr; |
| 59 | int context; |
| 60 | }; |
| 61 | |
| 62 | extern struct cache_palias *sparc_aliases; |
| 63 | |
| 64 | /* passing structs on the Sparc slow us down tremendously... */ |
| 65 | |
| 66 | /* #define STRICT_MM_TYPECHECKS */ |
| 67 | |
| 68 | #ifdef STRICT_MM_TYPECHECKS |
| 69 | /* |
| 70 | * These are used to make use of C type-checking.. |
| 71 | */ |
| 72 | typedef struct { unsigned long pte; } pte_t; |
| 73 | typedef struct { unsigned long iopte; } iopte_t; |
| 74 | typedef struct { unsigned long pmdv[16]; } pmd_t; |
| 75 | typedef struct { unsigned long pgd; } pgd_t; |
| 76 | typedef struct { unsigned long ctxd; } ctxd_t; |
| 77 | typedef struct { unsigned long pgprot; } pgprot_t; |
| 78 | typedef struct { unsigned long iopgprot; } iopgprot_t; |
| 79 | |
| 80 | #define pte_val(x) ((x).pte) |
| 81 | #define iopte_val(x) ((x).iopte) |
| 82 | #define pmd_val(x) ((x).pmdv[0]) |
| 83 | #define pgd_val(x) ((x).pgd) |
| 84 | #define ctxd_val(x) ((x).ctxd) |
| 85 | #define pgprot_val(x) ((x).pgprot) |
| 86 | #define iopgprot_val(x) ((x).iopgprot) |
| 87 | |
| 88 | #define __pte(x) ((pte_t) { (x) } ) |
| 89 | #define __iopte(x) ((iopte_t) { (x) } ) |
| 90 | /* #define __pmd(x) ((pmd_t) { (x) } ) */ /* XXX procedure with loop */ |
| 91 | #define __pgd(x) ((pgd_t) { (x) } ) |
| 92 | #define __ctxd(x) ((ctxd_t) { (x) } ) |
| 93 | #define __pgprot(x) ((pgprot_t) { (x) } ) |
| 94 | #define __iopgprot(x) ((iopgprot_t) { (x) } ) |
| 95 | |
| 96 | #else |
| 97 | /* |
| 98 | * .. while these make it easier on the compiler |
| 99 | */ |
| 100 | typedef unsigned long pte_t; |
| 101 | typedef unsigned long iopte_t; |
| 102 | typedef struct { unsigned long pmdv[16]; } pmd_t; |
| 103 | typedef unsigned long pgd_t; |
| 104 | typedef unsigned long ctxd_t; |
| 105 | typedef unsigned long pgprot_t; |
| 106 | typedef unsigned long iopgprot_t; |
| 107 | |
| 108 | #define pte_val(x) (x) |
| 109 | #define iopte_val(x) (x) |
| 110 | #define pmd_val(x) ((x).pmdv[0]) |
| 111 | #define pgd_val(x) (x) |
| 112 | #define ctxd_val(x) (x) |
| 113 | #define pgprot_val(x) (x) |
| 114 | #define iopgprot_val(x) (x) |
| 115 | |
| 116 | #define __pte(x) (x) |
| 117 | #define __iopte(x) (x) |
| 118 | /* #define __pmd(x) (x) */ /* XXX later */ |
| 119 | #define __pgd(x) (x) |
| 120 | #define __ctxd(x) (x) |
| 121 | #define __pgprot(x) (x) |
| 122 | #define __iopgprot(x) (x) |
| 123 | |
| 124 | #endif |
| 125 | |
| 126 | extern unsigned long sparc_unmapped_base; |
| 127 | |
| 128 | BTFIXUPDEF_SETHI(sparc_unmapped_base) |
| 129 | |
| 130 | #define TASK_UNMAPPED_BASE BTFIXUP_SETHI(sparc_unmapped_base) |
| 131 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | #else /* !(__ASSEMBLY__) */ |
| 133 | |
| 134 | #define __pgprot(x) (x) |
| 135 | |
| 136 | #endif /* !(__ASSEMBLY__) */ |
| 137 | |
| 138 | /* to align the pointer to the (next) page boundary */ |
| 139 | #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) |
| 140 | |
| 141 | #define PAGE_OFFSET 0xf0000000 |
| 142 | #ifndef __ASSEMBLY__ |
| 143 | extern unsigned long phys_base; |
| 144 | extern unsigned long pfn_base; |
| 145 | #endif |
| 146 | #define __pa(x) ((unsigned long)(x) - PAGE_OFFSET + phys_base) |
| 147 | #define __va(x) ((void *)((unsigned long) (x) - phys_base + PAGE_OFFSET)) |
| 148 | |
| 149 | #define virt_to_phys __pa |
| 150 | #define phys_to_virt __va |
| 151 | |
KAMEZAWA Hiroyuki | 064b2a0 | 2006-03-27 01:15:48 -0800 | [diff] [blame] | 152 | #define ARCH_PFN_OFFSET (pfn_base) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | #define virt_to_page(kaddr) (mem_map + ((((unsigned long)(kaddr)-PAGE_OFFSET)>>PAGE_SHIFT))) |
| 154 | |
| 155 | #define pfn_valid(pfn) (((pfn) >= (pfn_base)) && (((pfn)-(pfn_base)) < max_mapnr)) |
| 156 | #define virt_addr_valid(kaddr) ((((unsigned long)(kaddr)-PAGE_OFFSET)>>PAGE_SHIFT) < max_mapnr) |
| 157 | |
| 158 | #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ |
| 159 | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) |
| 160 | |
KAMEZAWA Hiroyuki | 064b2a0 | 2006-03-27 01:15:48 -0800 | [diff] [blame] | 161 | #include <asm-generic/memory_model.h> |
Stephen Rothwell | fd4fd5a | 2005-09-03 15:54:30 -0700 | [diff] [blame] | 162 | #include <asm-generic/page.h> |
| 163 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | #endif /* _SPARC_PAGE_H */ |