Rev 755 | Rev 757 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 755 | Rev 756 | ||
|---|---|---|---|
| Line 36... | Line 36... | ||
| 36 | #include <typedefs.h> |
36 | #include <typedefs.h> |
| 37 | #include <arch/asm.h> |
37 | #include <arch/asm.h> |
| 38 | #include <synch/spinlock.h> |
38 | #include <synch/spinlock.h> |
| 39 | #include <arch.h> |
39 | #include <arch.h> |
| 40 | #include <debug.h> |
40 | #include <debug.h> |
| - | 41 | #include <memstr.h> |
|
| 41 | 42 | ||
| 42 | /** |
43 | /** |
| 43 | * This lock protects the page hash table. Note that software must |
44 | * This lock protects the page hash table. |
| 44 | * be still careful about ordering of writes to ensure consistent |
- | |
| 45 | * view of the page hash table for hardware helpers such as VHPT |
- | |
| 46 | * walker on ia64. |
- | |
| 47 | */ |
45 | */ |
| 48 | SPINLOCK_INITIALIZE(page_ht_lock); |
46 | SPINLOCK_INITIALIZE(page_ht_lock); |
| 49 | 47 | ||
| 50 | /** |
48 | /** |
| 51 | * Page hash table pointer. |
49 | * Page hash table pointer. |
| 52 | * The page hash table may be accessed only when page_ht_lock is held. |
50 | * The page hash table may be accessed only when page_ht_lock is held. |
| 53 | */ |
51 | */ |
| 54 | pte_t *page_ht = NULL; |
52 | pte_t *page_ht = NULL; |
| 55 | 53 | ||
| 56 | static void ht_mapping_insert(as_t *as, __address page, __address frame, int flags, __address root); |
54 | static void ht_mapping_insert(as_t *as, __address page, __address frame, int flags); |
| 57 | static pte_t *ht_mapping_find(as_t *as, __address page, __address root); |
55 | static pte_t *ht_mapping_find(as_t *as, __address page); |
| 58 | 56 | ||
| 59 | page_operations_t page_ht_operations = { |
57 | page_operations_t page_ht_operations = { |
| 60 | .mapping_insert = ht_mapping_insert, |
58 | .mapping_insert = ht_mapping_insert, |
| 61 | .mapping_find = ht_mapping_find |
59 | .mapping_find = ht_mapping_find, |
| 62 | }; |
60 | }; |
| 63 | 61 | ||
| 64 | /** Map page to frame using page hash table. |
62 | /** Map page to frame using page hash table. |
| 65 | * |
63 | * |
| 66 | * Map virtual address 'page' to physical address 'frame' |
64 | * Map virtual address 'page' to physical address 'frame' |
| 67 | * using 'flags'. In order not to disturb hardware searching, |
- | |
| 68 | * new mappings are appended to the end of the collision |
- | |
| 69 | * chain. |
65 | * using 'flags'. |
| 70 | * |
66 | * |
| - | 67 | * The address space must be locked and interruptsmust be disabled. |
|
| - | 68 | * |
|
| 71 | * @param as Address space to which page belongs. Must be locked prior the call. |
69 | * @param as Address space to which page belongs. |
| 72 | * @param page Virtual address of the page to be mapped. |
70 | * @param page Virtual address of the page to be mapped. |
| 73 | * @param frame Physical address of memory frame to which the mapping is done. |
71 | * @param frame Physical address of memory frame to which the mapping is done. |
| 74 | * @param flags Flags to be used for mapping. |
72 | * @param flags Flags to be used for mapping. |
| 75 | * @param root Ignored. |
- | |
| 76 | */ |
73 | */ |
| 77 | void ht_mapping_insert(as_t *as, __address page, __address frame, int flags, __address root) |
74 | void ht_mapping_insert(as_t *as, __address page, __address frame, int flags) |
| 78 | { |
75 | { |
| 79 | pte_t *t, *u; |
76 | pte_t *t, *u; |
| 80 | ipl_t ipl; |
77 | ipl_t ipl; |
| 81 | 78 | ||
| 82 | ipl = interrupts_disable(); |
79 | ipl = interrupts_disable(); |
| Line 119... | Line 116... | ||
| 119 | 116 | ||
| 120 | /** Find mapping for virtual page in page hash table. |
117 | /** Find mapping for virtual page in page hash table. |
| 121 | * |
118 | * |
| 122 | * Find mapping for virtual page. |
119 | * Find mapping for virtual page. |
| 123 | * |
120 | * |
| 124 | * Interrupts must be disabled. |
121 | * The address space must be locked and interrupts must be disabled. |
| 125 | * |
122 | * |
| 126 | * @param as Address space to wich page belongs. Must be locked prior the call. |
123 | * @param as Address space to wich page belongs. |
| 127 | * @param page Virtual page. |
124 | * @param page Virtual page. |
| 128 | * @param root Ignored. |
- | |
| 129 | * |
125 | * |
| 130 | * @return NULL if there is no such mapping; requested mapping otherwise. |
126 | * @return NULL if there is no such mapping; requested mapping otherwise. |
| 131 | */ |
127 | */ |
| 132 | pte_t *ht_mapping_find(as_t *as, __address page, __address root) |
128 | pte_t *ht_mapping_find(as_t *as, __address page) |
| 133 | { |
129 | { |
| 134 | pte_t *t; |
130 | pte_t *t; |
| 135 | 131 | ||
| 136 | spinlock_lock(&page_ht_lock); |
132 | spinlock_lock(&page_ht_lock); |
| 137 | t = HT_HASH(page, as->asid); |
133 | t = HT_HASH(page, as->asid); |