Changeset 2299914 in mainline for genarch/src
- Timestamp:
- 2006-03-16T12:57:31Z (20 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e898a8d7
- Parents:
- b7dcabb
- Location:
- genarch/src/mm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
genarch/src/mm/as_ht.c
rb7dcabb r2299914 35 35 #include <memstr.h> 36 36 #include <adt/hash_table.h> 37 #include <synch/spinlock.h> 37 38 38 39 static pte_t *ht_create(int flags); 39 40 41 static void ht_lock(as_t *as, bool lock); 42 static void ht_unlock(as_t *as, bool unlock); 43 40 44 as_operations_t as_ht_operations = { 41 .page_table_create = ht_create 45 .page_table_create = ht_create, 46 .page_table_lock = ht_lock, 47 .page_table_unlock = ht_unlock, 42 48 }; 43 49 … … 59 65 return NULL; 60 66 } 67 68 /** Lock page table. 69 * 70 * Lock address space and page hash table. 71 * Interrupts must be disabled. 72 * 73 * @param as Address space. 74 * @param lock If false, do not attempt to lock the address space. 75 */ 76 void ht_lock(as_t *as, bool lock) 77 { 78 if (lock) 79 spinlock_lock(&as->lock); 80 spinlock_lock(&page_ht_lock); 81 } 82 83 /** Unlock page table. 84 * 85 * Unlock address space and page hash table. 86 * Interrupts must be disabled. 87 * 88 * @param as Address space. 89 * @param unlock If false, do not attempt to lock the address space. 90 */ 91 void ht_unlock(as_t *as, bool unlock) 92 { 93 spinlock_unlock(&page_ht_lock); 94 if (unlock) 95 spinlock_unlock(&as->lock); 96 } -
genarch/src/mm/as_pt.c
rb7dcabb r2299914 40 40 static pte_t *ptl0_create(int flags); 41 41 42 static void pt_lock(as_t *as, bool lock); 43 static void pt_unlock(as_t *as, bool unlock); 44 42 45 as_operations_t as_pt_operations = { 43 .page_table_create = ptl0_create 46 .page_table_create = ptl0_create, 47 .page_table_lock = pt_lock, 48 .page_table_unlock = pt_unlock 44 49 }; 45 50 … … 77 82 return (pte_t *) KA2PA((__address) dst_ptl0); 78 83 } 84 85 /** Lock page tables. 86 * 87 * Lock only the address space. 88 * Interrupts must be disabled. 89 * 90 * @param as Address space. 91 * @param lock If false, do not attempt to lock the address space. 92 */ 93 void pt_lock(as_t *as, bool lock) 94 { 95 if (lock) 96 spinlock_lock(&as->lock); 97 } 98 99 /** Unlock page tables. 100 * 101 * Unlock the address space. 102 * Interrupts must be disabled. 103 * 104 * @param as Address space. 105 * @param unlock If false, do not attempt to unlock the address space. 106 */ 107 void pt_unlock(as_t *as, bool unlock) 108 { 109 if (unlock) 110 spinlock_unlock(&as->lock); 111 } -
genarch/src/mm/page_ht.c
rb7dcabb r2299914 53 53 54 54 /** 55 * This lock protects the page hash table. 55 * This lock protects the page hash table. It must be acquired 56 * after address space lock and after any address space area 57 * locks. 56 58 */ 57 59 SPINLOCK_INITIALIZE(page_ht_lock); … … 156 158 * using 'flags'. 157 159 * 158 * The address space must be locked and interruptsmust be disabled.160 * The page table must be locked and interrupts must be disabled. 159 161 * 160 162 * @param as Address space to which page belongs. … … 168 170 __native key[2] = { (__address) as, page = ALIGN_DOWN(page, PAGE_SIZE) }; 169 171 170 spinlock_lock(&page_ht_lock);171 172 172 if (!hash_table_find(&page_ht, key)) { 173 173 t = (pte_t *) malloc(sizeof(pte_t), FRAME_ATOMIC); … … 187 187 hash_table_insert(&page_ht, key, &t->link); 188 188 } 189 190 spinlock_unlock(&page_ht_lock);191 189 } 192 190 … … 197 195 * this call visible. 198 196 * 199 * The address space must be locked and interrupts must be disabled.197 * The page table must be locked and interrupts must be disabled. 200 198 * 201 199 * @param as Address space to wich page belongs. … … 206 204 __native key[2] = { (__address) as, page = ALIGN_DOWN(page, PAGE_SIZE) }; 207 205 208 spinlock_lock(&page_ht_lock);209 210 206 /* 211 207 * Note that removed PTE's will be freed … … 213 209 */ 214 210 hash_table_remove(&page_ht, key, 2); 215 216 spinlock_unlock(&page_ht_lock);217 211 } 218 212 … … 222 216 * Find mapping for virtual page. 223 217 * 224 * The address space must be locked and interrupts must be disabled.218 * The page table must be locked and interrupts must be disabled. 225 219 * 226 220 * @param as Address space to wich page belongs. … … 235 229 __native key[2] = { (__address) as, page = ALIGN_DOWN(page, PAGE_SIZE) }; 236 230 237 spinlock_lock(&page_ht_lock);238 239 231 hlp = hash_table_find(&page_ht, key); 240 232 if (hlp) 241 233 t = hash_table_get_instance(hlp, pte_t, link); 242 234 243 spinlock_unlock(&page_ht_lock);244 235 return t; 245 236 } -
genarch/src/mm/page_pt.c
rb7dcabb r2299914 53 53 * using 'flags'. 54 54 * 55 * The address space must be locked and interrupts must be disabled.55 * The page table must be locked and interrupts must be disabled. 56 56 * 57 57 * @param as Address space to wich page belongs. … … 106 106 * Empty page tables except PTL0 are freed. 107 107 * 108 * The address space must be locked and interrupts must be disabled.108 * The page table must be locked and interrupts must be disabled. 109 109 * 110 110 * @param as Address space to wich page belongs. … … 226 226 * Find mapping for virtual page. 227 227 * 228 * The address space must be locked and interrupts must be disabled.228 * The page table must be locked and interrupts must be disabled. 229 229 * 230 230 * @param as Address space to which page belongs.
Note:
See TracChangeset
for help on using the changeset viewer.