Rev 823 | Rev 922 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 823 | Rev 826 | ||
---|---|---|---|
Line 45... | Line 45... | ||
45 | static index_t hash(__native key[]); |
45 | static index_t hash(__native key[]); |
46 | static bool compare(__native key[], count_t keys, link_t *item); |
46 | static bool compare(__native key[], count_t keys, link_t *item); |
47 | static void remove_callback(link_t *item); |
47 | static void remove_callback(link_t *item); |
48 | 48 | ||
49 | static void ht_mapping_insert(as_t *as, __address page, __address frame, int flags); |
49 | static void ht_mapping_insert(as_t *as, __address page, __address frame, int flags); |
- | 50 | static void ht_mapping_remove(as_t *as, __address page); |
|
50 | static pte_t *ht_mapping_find(as_t *as, __address page); |
51 | static pte_t *ht_mapping_find(as_t *as, __address page); |
51 | 52 | ||
52 | /** |
53 | /** |
53 | * This lock protects the page hash table. |
54 | * This lock protects the page hash table. |
54 | */ |
55 | */ |
Line 68... | Line 69... | ||
68 | }; |
69 | }; |
69 | 70 | ||
70 | /** Page mapping operations for page hash table architectures. */ |
71 | /** Page mapping operations for page hash table architectures. */ |
71 | page_mapping_operations_t ht_mapping_operations = { |
72 | page_mapping_operations_t ht_mapping_operations = { |
72 | .mapping_insert = ht_mapping_insert, |
73 | .mapping_insert = ht_mapping_insert, |
- | 74 | .mapping_remove = ht_mapping_remove, |
|
73 | .mapping_find = ht_mapping_find |
75 | .mapping_find = ht_mapping_find |
74 | }; |
76 | }; |
75 | 77 | ||
76 | /** Compute page hash table index. |
78 | /** Compute page hash table index. |
77 | * |
79 | * |
Line 160... | Line 162... | ||
160 | * @param flags Flags to be used for mapping. |
162 | * @param flags Flags to be used for mapping. |
161 | */ |
163 | */ |
162 | void ht_mapping_insert(as_t *as, __address page, __address frame, int flags) |
164 | void ht_mapping_insert(as_t *as, __address page, __address frame, int flags) |
163 | { |
165 | { |
164 | pte_t *t; |
166 | pte_t *t; |
165 | ipl_t ipl; |
- | |
166 | __native key[2] = { (__address) as, page }; |
167 | __native key[2] = { (__address) as, page }; |
167 | 168 | ||
168 | ipl = interrupts_disable(); |
- | |
169 | spinlock_lock(&page_ht_lock); |
169 | spinlock_lock(&page_ht_lock); |
170 | 170 | ||
171 | if (!hash_table_find(&page_ht, key)) { |
171 | if (!hash_table_find(&page_ht, key)) { |
172 | t = (pte_t *) malloc(sizeof(pte_t), FRAME_ATOMIC); |
172 | t = (pte_t *) malloc(sizeof(pte_t), FRAME_ATOMIC); |
173 | ASSERT(t != NULL); |
173 | ASSERT(t != NULL); |
174 | 174 | ||
175 | hash_table_insert(&page_ht, key, &t->link); |
175 | hash_table_insert(&page_ht, key, &t->link); |
176 | } |
176 | } |
177 | 177 | ||
178 | spinlock_unlock(&page_ht_lock); |
178 | spinlock_unlock(&page_ht_lock); |
179 | interrupts_restore(ipl); |
- | |
180 | } |
179 | } |
181 | 180 | ||
- | 181 | /** Remove mapping of page from page hash table. |
|
- | 182 | * |
|
- | 183 | * Remove any mapping of 'page' within address space 'as'. |
|
- | 184 | * TLB shootdown should follow in order to make effects of |
|
- | 185 | * this call visible. |
|
- | 186 | * |
|
- | 187 | * The address space must be locked and interrupts must be disabled. |
|
- | 188 | * |
|
- | 189 | * @param as Address space to wich page belongs. |
|
- | 190 | * @param page Virtual address of the page to be demapped. |
|
- | 191 | */ |
|
- | 192 | void ht_mapping_remove(as_t *as, __address page) |
|
- | 193 | { |
|
- | 194 | __native key[2] = { (__address) as, page }; |
|
- | 195 | ||
- | 196 | spinlock_lock(&page_ht_lock); |
|
- | 197 | ||
- | 198 | /* |
|
- | 199 | * Note that removed PTE's will be freed |
|
- | 200 | * by remove_callback(). |
|
- | 201 | */ |
|
- | 202 | hash_table_remove(&page_ht, key, 2); |
|
- | 203 | ||
- | 204 | spinlock_unlock(&page_ht_lock); |
|
- | 205 | } |
|
- | 206 | ||
- | 207 | ||
182 | /** Find mapping for virtual page in page hash table. |
208 | /** Find mapping for virtual page in page hash table. |
183 | * |
209 | * |
184 | * Find mapping for virtual page. |
210 | * Find mapping for virtual page. |
185 | * |
211 | * |
186 | * The address space must be locked and interrupts must be disabled. |
212 | * The address space must be locked and interrupts must be disabled. |