Rev 902 | Rev 1229 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 902 | Rev 922 | ||
---|---|---|---|
Line 39... | Line 39... | ||
39 | #include <synch/spinlock.h> |
39 | #include <synch/spinlock.h> |
40 | #include <arch.h> |
40 | #include <arch.h> |
41 | #include <debug.h> |
41 | #include <debug.h> |
42 | #include <memstr.h> |
42 | #include <memstr.h> |
43 | #include <adt/hash_table.h> |
43 | #include <adt/hash_table.h> |
- | 44 | #include <align.h> |
|
44 | 45 | ||
45 | static index_t hash(__native key[]); |
46 | static index_t hash(__native key[]); |
46 | static bool compare(__native key[], count_t keys, link_t *item); |
47 | static bool compare(__native key[], count_t keys, link_t *item); |
47 | static void remove_callback(link_t *item); |
48 | static void remove_callback(link_t *item); |
48 | 49 | ||
Line 162... | Line 163... | ||
162 | * @param flags Flags to be used for mapping. |
163 | * @param flags Flags to be used for mapping. |
163 | */ |
164 | */ |
164 | void ht_mapping_insert(as_t *as, __address page, __address frame, int flags) |
165 | void ht_mapping_insert(as_t *as, __address page, __address frame, int flags) |
165 | { |
166 | { |
166 | pte_t *t; |
167 | pte_t *t; |
167 | __native key[2] = { (__address) as, page }; |
168 | __native key[2] = { (__address) as, page = ALIGN_DOWN(page, PAGE_SIZE) }; |
168 | 169 | ||
169 | spinlock_lock(&page_ht_lock); |
170 | spinlock_lock(&page_ht_lock); |
170 | 171 | ||
171 | if (!hash_table_find(&page_ht, key)) { |
172 | if (!hash_table_find(&page_ht, key)) { |
172 | t = (pte_t *) malloc(sizeof(pte_t), FRAME_ATOMIC); |
173 | t = (pte_t *) malloc(sizeof(pte_t), FRAME_ATOMIC); |
Line 200... | Line 201... | ||
200 | * @param as Address space to wich page belongs. |
201 | * @param as Address space to wich page belongs. |
201 | * @param page Virtual address of the page to be demapped. |
202 | * @param page Virtual address of the page to be demapped. |
202 | */ |
203 | */ |
203 | void ht_mapping_remove(as_t *as, __address page) |
204 | void ht_mapping_remove(as_t *as, __address page) |
204 | { |
205 | { |
205 | __native key[2] = { (__address) as, page }; |
206 | __native key[2] = { (__address) as, page = ALIGN_DOWN(page, PAGE_SIZE) }; |
206 | 207 | ||
207 | spinlock_lock(&page_ht_lock); |
208 | spinlock_lock(&page_ht_lock); |
208 | 209 | ||
209 | /* |
210 | /* |
210 | * Note that removed PTE's will be freed |
211 | * Note that removed PTE's will be freed |
Line 229... | Line 230... | ||
229 | */ |
230 | */ |
230 | pte_t *ht_mapping_find(as_t *as, __address page) |
231 | pte_t *ht_mapping_find(as_t *as, __address page) |
231 | { |
232 | { |
232 | link_t *hlp; |
233 | link_t *hlp; |
233 | pte_t *t = NULL; |
234 | pte_t *t = NULL; |
234 | __native key[2] = { (__address) as, page }; |
235 | __native key[2] = { (__address) as, page = ALIGN_DOWN(page, PAGE_SIZE) }; |
235 | 236 | ||
236 | spinlock_lock(&page_ht_lock); |
237 | spinlock_lock(&page_ht_lock); |
237 | 238 | ||
238 | hlp = hash_table_find(&page_ht, key); |
239 | hlp = hash_table_find(&page_ht, key); |
239 | if (hlp) |
240 | if (hlp) |