Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * CRIS MMU constants and PTE layout |
| 3 | */ |
| 4 | |
| 5 | #ifndef _CRIS_ARCH_MMU_H |
| 6 | #define _CRIS_ARCH_MMU_H |
| 7 | |
| 8 | /* type used in struct mm to couple an MMU context to an active mm */ |
| 9 | |
Mikael Starvik | 4f18cfb | 2005-07-27 11:44:39 -0700 | [diff] [blame] | 10 | typedef struct |
| 11 | { |
| 12 | unsigned int page_id; |
| 13 | } mm_context_t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | |
| 15 | /* kernel memory segments */ |
| 16 | |
| 17 | #define KSEG_F 0xf0000000UL |
| 18 | #define KSEG_E 0xe0000000UL |
| 19 | #define KSEG_D 0xd0000000UL |
| 20 | #define KSEG_C 0xc0000000UL |
| 21 | #define KSEG_B 0xb0000000UL |
| 22 | #define KSEG_A 0xa0000000UL |
| 23 | #define KSEG_9 0x90000000UL |
| 24 | #define KSEG_8 0x80000000UL |
| 25 | #define KSEG_7 0x70000000UL |
| 26 | #define KSEG_6 0x60000000UL |
| 27 | #define KSEG_5 0x50000000UL |
| 28 | #define KSEG_4 0x40000000UL |
| 29 | #define KSEG_3 0x30000000UL |
| 30 | #define KSEG_2 0x20000000UL |
| 31 | #define KSEG_1 0x10000000UL |
| 32 | #define KSEG_0 0x00000000UL |
| 33 | |
| 34 | /* CRIS PTE bits (see R_TLB_LO in the register description) |
| 35 | * |
| 36 | * Bit: 31-13 12-------4 3 2 1 0 |
| 37 | * ________________________________________________ |
| 38 | * | pfn | reserved | global | valid | kernel | we | |
| 39 | * |_____|__________|________|_______|________|_____| |
| 40 | * |
| 41 | * (pfn = physical frame number) |
| 42 | */ |
| 43 | |
| 44 | /* Real HW-based PTE bits. We use some synonym names so that |
| 45 | * things become less confusing in combination with the SW-based |
| 46 | * bits further below. |
| 47 | * |
| 48 | */ |
| 49 | |
| 50 | #define _PAGE_WE (1<<0) /* page is write-enabled */ |
| 51 | #define _PAGE_SILENT_WRITE (1<<0) /* synonym */ |
| 52 | #define _PAGE_KERNEL (1<<1) /* page is kernel only */ |
| 53 | #define _PAGE_VALID (1<<2) /* page is valid */ |
| 54 | #define _PAGE_SILENT_READ (1<<2) /* synonym */ |
| 55 | #define _PAGE_GLOBAL (1<<3) /* global page - context is ignored */ |
| 56 | |
| 57 | /* Bits the HW doesn't care about but the kernel uses them in SW */ |
| 58 | |
| 59 | #define _PAGE_PRESENT (1<<4) /* page present in memory */ |
| 60 | #define _PAGE_FILE (1<<5) /* set: pagecache, unset: swap (when !PRESENT) */ |
| 61 | #define _PAGE_ACCESSED (1<<5) /* simulated in software using valid bit */ |
| 62 | #define _PAGE_MODIFIED (1<<6) /* simulated in software using we bit */ |
| 63 | #define _PAGE_READ (1<<7) /* read-enabled */ |
| 64 | #define _PAGE_WRITE (1<<8) /* write-enabled */ |
| 65 | |
| 66 | /* Define some higher level generic page attributes. */ |
| 67 | |
| 68 | #define __READABLE (_PAGE_READ | _PAGE_SILENT_READ | _PAGE_ACCESSED) |
| 69 | #define __WRITEABLE (_PAGE_WRITE | _PAGE_SILENT_WRITE | _PAGE_MODIFIED) |
| 70 | |
| 71 | #define _PAGE_TABLE (_PAGE_PRESENT | __READABLE | __WRITEABLE) |
| 72 | #define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_MODIFIED) |
| 73 | |
| 74 | #define PAGE_NONE __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED) |
| 75 | #define PAGE_SHARED __pgprot(_PAGE_PRESENT | __READABLE | _PAGE_WRITE | \ |
| 76 | _PAGE_ACCESSED) |
| 77 | #define PAGE_COPY __pgprot(_PAGE_PRESENT | __READABLE) // | _PAGE_COW |
| 78 | #define PAGE_READONLY __pgprot(_PAGE_PRESENT | __READABLE) |
| 79 | #define PAGE_KERNEL __pgprot(_PAGE_GLOBAL | _PAGE_KERNEL | \ |
| 80 | _PAGE_PRESENT | __READABLE | __WRITEABLE) |
| 81 | #define _KERNPG_TABLE (_PAGE_TABLE | _PAGE_KERNEL) |
| 82 | |
| 83 | /* |
| 84 | * CRIS can't do page protection for execute, and considers read the same. |
| 85 | * Also, write permissions imply read permissions. This is the closest we can |
| 86 | * get.. |
| 87 | */ |
| 88 | |
| 89 | #define __P000 PAGE_NONE |
| 90 | #define __P001 PAGE_READONLY |
| 91 | #define __P010 PAGE_COPY |
| 92 | #define __P011 PAGE_COPY |
| 93 | #define __P100 PAGE_READONLY |
| 94 | #define __P101 PAGE_READONLY |
| 95 | #define __P110 PAGE_COPY |
| 96 | #define __P111 PAGE_COPY |
| 97 | |
| 98 | #define __S000 PAGE_NONE |
| 99 | #define __S001 PAGE_READONLY |
| 100 | #define __S010 PAGE_SHARED |
| 101 | #define __S011 PAGE_SHARED |
| 102 | #define __S100 PAGE_READONLY |
| 103 | #define __S101 PAGE_READONLY |
| 104 | #define __S110 PAGE_SHARED |
| 105 | #define __S111 PAGE_SHARED |
| 106 | |
| 107 | #define PTE_FILE_MAX_BITS 26 |
| 108 | |
| 109 | #endif |