Changeset 2a003d5b in mainline
- Timestamp:
- 2006-01-26T14:13:50Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c2b95d3
- Parents:
- 4a2f4bb
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/ia64/include/asm.h
r4a2f4bb r2a003d5b 240 240 } 241 241 242 /** Disable protection key checking. */ 243 static inline void pk_disable(void) 244 { 245 __asm__ volatile ("rsm %0\n" : : "i" (PSR_PK_MASK)); 246 } 247 242 248 extern void cpu_halt(void); 243 249 extern void cpu_sleep(void); -
arch/ia64/include/mm/page.h
r4a2f4bb r2a003d5b 43 43 44 44 /** Implementation of page hash table interface. */ 45 #define HT_ENTRIES_ARCH 0 45 46 #define HT_HASH_ARCH(page, asid) 0 46 47 #define HT_COMPARE_ARCH(page, asid, t) 0 47 48 #define HT_SLOT_EMPTY_ARCH(t) 1 49 #define HT_INVALIDATE_SLOT_ARCH(t) 48 50 #define HT_GET_NEXT_ARCH(t) 0 49 51 #define HT_SET_NEXT_ARCH(t, s) -
arch/ia64/include/register.h
r4a2f4bb r2a003d5b 35 35 36 36 #define CR_IVR_MASK 0xf 37 #define PSR_IC_MASK 0x2000 37 38 #define PSR_I_MASK 0x4000 38 #define PSR_ IC_MASK 0x200039 #define PSR_PK_MASK 0x8000 39 40 40 41 /** Application registers. */ -
arch/ia64/src/mm/page.c
r4a2f4bb r2a003d5b 34 34 #include <config.h> 35 35 #include <panic.h> 36 #include <arch/asm.h> 36 37 37 38 __u64 thash(__u64 va); … … 141 142 { 142 143 page_operations = &page_ht_operations; 144 pk_disable(); 143 145 set_VHPT_environment(); 144 146 } -
arch/sparc64/include/mm/page.h
r4a2f4bb r2a003d5b 43 43 44 44 /** Implementation of page hash table interface. */ 45 #define HT_ENTRIES_ARCH 0 45 46 #define HT_HASH_ARCH(page, asid) 0 46 47 #define HT_COMPARE_ARCH(page, asid, t) 0 47 48 #define HT_SLOT_EMPTY_ARCH(t) 1 49 #define HT_INVALIDATE_SLOT_ARCH(t) 48 50 #define HT_GET_NEXT_ARCH(t) 0 49 51 #define HT_SET_NEXT_ARCH(t, s) -
genarch/include/mm/page_ht.h
r4a2f4bb r2a003d5b 37 37 38 38 #include <mm/page.h> 39 #include <typedefs.h> 40 41 /** Number of slots in page hash table. */ 42 #define HT_ENTRIES HT_ENTRIES_ARCH 39 43 40 44 /** Hash function. … … 57 61 #define HT_COMPARE(page, asid, t) HT_COMPARE_ARCH(page, asid, t) 58 62 59 /** Identify empty hash table slots.63 /** Identify empty page hash table slots. 60 64 * 61 65 * @param t Pointer ro hash table typed pte_t *. … … 64 68 */ 65 69 #define HT_SLOT_EMPTY(t) HT_SLOT_EMPTY_ARCH(t) 70 71 /** Invalidate/empty page hash table slot. 72 * 73 * @param t Address of the slot to be invalidated. 74 */ 75 #define HT_INVALIDATE_SLOT(t) HT_INVALIDATE_SLOT_ARCH(t) 66 76 67 77 /** Return next record in collision chain. … … 90 100 #define HT_SET_RECORD(t, page, asid, frame, flags) HT_SET_RECORD_ARCH(t, page, asid, frame, flags) 91 101 102 92 103 extern page_operations_t page_ht_operations; 104 extern spinlock_t page_ht_lock; 105 106 extern pte_t *page_ht; 107 108 extern void ht_invalidate_all(void); 93 109 94 110 #endif -
genarch/src/mm/page_ht.c
r4a2f4bb r2a003d5b 35 35 #include <typedefs.h> 36 36 #include <arch/asm.h> 37 #include <synch/spinlock.h> 38 #include <arch.h> 37 39 #include <debug.h> 40 41 /** 42 * This lock protects the page hash table. Note that software must 43 * be still careful about ordering of writes to ensure consistent 44 * view of the page hash table for hardware helpers such as VHPT 45 * walker on ia64. 46 */ 47 SPINLOCK_INITIALIZE(page_ht_lock); 48 49 /** 50 * Page hash table pointer. 51 * The page hash table may be accessed only when page_ht_lock is held. 52 */ 53 pte_t *page_ht = NULL; 38 54 39 55 static void ht_mapping_insert(__address page, asid_t asid, __address frame, int flags, __address root); … … 48 64 * 49 65 * Map virtual address 'page' to physical address 'frame' 50 * using 'flags'. 66 * using 'flags'. In order not to disturb hardware searching, 67 * new mappings are appended to the end of the collision 68 * chain. 51 69 * 52 70 * @param page Virtual address of the page to be mapped. … … 58 76 void ht_mapping_insert(__address page, asid_t asid, __address frame, int flags, __address root) 59 77 { 60 pte_t *t, *u = NULL; 78 pte_t *t, *u; 79 ipl_t ipl; 80 81 ipl = interrupts_disable(); 82 spinlock_lock(&page_ht_lock); 61 83 62 84 t = HT_HASH(page, asid); 63 85 if (!HT_SLOT_EMPTY(t)) { 64 u = (pte_t *) malloc(sizeof(pte_t)); /* FIXME: use slab allocator for this */ 65 if (!u) 66 panic("could not allocate memory for hash table\n"); 67 *u = *t; 86 87 /* 88 * The slot is occupied. 89 * Walk through the collision chain and append the mapping to its end. 90 */ 91 92 do { 93 u = t; 94 if (HT_COMPARE(page, asid, t)) { 95 /* 96 * Nothing to do, 97 * the record is already there. 98 */ 99 spinlock_unlock(&page_ht_lock); 100 interrupts_restore(ipl); 101 return; 102 } 103 } while ((t = HT_GET_NEXT(t))); 104 105 t = (pte_t *) malloc(sizeof(pte_t)); /* FIXME: use slab allocator for this */ 106 if (!t) 107 panic("could not allocate memory\n"); 108 109 HT_SET_NEXT(u, t); 68 110 } 69 HT_SET_NEXT(t, u);111 70 112 HT_SET_RECORD(t, page, asid, frame, flags); 113 HT_SET_NEXT(t, NULL); 114 115 spinlock_unlock(&page_ht_lock); 116 interrupts_restore(ipl); 71 117 } 72 118 … … 74 120 * 75 121 * Find mapping for virtual page. 122 * 123 * Interrupts must be disabled. 76 124 * 77 125 * @param page Virtual page. … … 85 133 pte_t *t; 86 134 135 spinlock_lock(&page_ht_lock); 87 136 t = HT_HASH(page, asid); 88 while (!HT_COMPARE(page, asid, t) && HT_GET_NEXT(t)) 89 t = HT_GET_NEXT(t); 137 if (!HT_SLOT_EMPTY(t)) { 138 while (!HT_COMPARE(page, asid, t) && HT_GET_NEXT(t)) 139 t = HT_GET_NEXT(t); 140 t = HT_COMPARE(page, asid, t) ? t : NULL; 141 } else { 142 t = NULL; 143 } 144 spinlock_unlock(&page_ht_lock); 145 return t; 146 } 147 148 /** Invalidate page hash table. 149 * 150 * Interrupts must be disabled. 151 */ 152 void ht_invalidate_all(void) 153 { 154 pte_t *t, *u; 155 int i; 90 156 91 return HT_COMPARE(page, asid, t) ? t : NULL; 157 spinlock_lock(&page_ht_lock); 158 for (i = 0; i < HT_ENTRIES; i++) { 159 if (!HT_SLOT_EMPTY(&page_ht[i])) { 160 t = HT_GET_NEXT(&page_ht[i]); 161 while (t) { 162 u = t; 163 t = HT_GET_NEXT(t); 164 free(u); /* FIXME: use slab allocator for this */ 165 } 166 HT_INVALIDATE_SLOT(&page_ht[i]); 167 } 168 } 169 spinlock_unlock(&page_ht_lock); 92 170 }
Note:
See TracChangeset
for help on using the changeset viewer.