Rev 755 | Rev 793 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 755 | Rev 756 | ||
|---|---|---|---|
| Line 46... | Line 46... | ||
| 46 | page_operations_t *page_operations = NULL; |
46 | page_operations_t *page_operations = NULL; |
| 47 | 47 | ||
| 48 | void page_init(void) |
48 | void page_init(void) |
| 49 | { |
49 | { |
| 50 | page_arch_init(); |
50 | page_arch_init(); |
| 51 | page_mapping_insert(AS_KERNEL, 0x0, 0x0, PAGE_NOT_PRESENT, 0); |
- | |
| 52 | } |
51 | } |
| 53 | 52 | ||
| 54 | /** Map memory structure |
53 | /** Map memory structure |
| 55 | * |
54 | * |
| 56 | * Identity-map memory structure |
55 | * Identity-map memory structure |
| Line 66... | Line 65... | ||
| 66 | 65 | ||
| 67 | length = size + (s - (s & ~(PAGE_SIZE-1))); |
66 | length = size + (s - (s & ~(PAGE_SIZE-1))); |
| 68 | cnt = length/PAGE_SIZE + (length%PAGE_SIZE>0); |
67 | cnt = length/PAGE_SIZE + (length%PAGE_SIZE>0); |
| 69 | 68 | ||
| 70 | for (i = 0; i < cnt; i++) |
69 | for (i = 0; i < cnt; i++) |
| 71 | page_mapping_insert(AS_KERNEL, s + i*PAGE_SIZE, s + i*PAGE_SIZE, PAGE_NOT_CACHEABLE, 0); |
70 | page_mapping_insert(AS_KERNEL, s + i*PAGE_SIZE, s + i*PAGE_SIZE, PAGE_NOT_CACHEABLE); |
| 72 | 71 | ||
| 73 | } |
72 | } |
| 74 | 73 | ||
| 75 | /** Map page to frame |
74 | /** Map page to frame |
| 76 | * |
75 | * |
| 77 | * Map virtual address 'page' to physical address 'frame' |
76 | * Map virtual address 'page' to physical address 'frame' |
| 78 | * using 'flags'. Allocate and setup any missing page tables. |
77 | * using 'flags'. Allocate and setup any missing page tables. |
| 79 | * |
78 | * |
| - | 79 | * The address space must be locked and interrupts must be disabled. |
|
| - | 80 | * |
|
| 80 | * @param as Address space to wich page belongs. Must be locked prior the call. |
81 | * @param as Address space to wich page belongs.. |
| 81 | * @param page Virtual address of the page to be mapped. |
82 | * @param page Virtual address of the page to be mapped. |
| 82 | * @param frame Physical address of memory frame to which the mapping is done. |
83 | * @param frame Physical address of memory frame to which the mapping is done. |
| 83 | * @param flags Flags to be used for mapping. |
84 | * @param flags Flags to be used for mapping. |
| 84 | * @param root Explicit PTL0 address. |
- | |
| 85 | */ |
85 | */ |
| 86 | void page_mapping_insert(as_t *as, __address page, __address frame, int flags, __address root) |
86 | void page_mapping_insert(as_t *as, __address page, __address frame, int flags) |
| 87 | { |
87 | { |
| 88 | ASSERT(page_operations); |
88 | ASSERT(page_operations); |
| 89 | ASSERT(page_operations->mapping_insert); |
89 | ASSERT(page_operations->mapping_insert); |
| 90 | 90 | ||
| 91 | page_operations->mapping_insert(as, page, frame, flags, root); |
91 | page_operations->mapping_insert(as, page, frame, flags); |
| 92 | } |
92 | } |
| 93 | 93 | ||
| 94 | /** Find mapping for virtual page |
94 | /** Find mapping for virtual page |
| 95 | * |
95 | * |
| 96 | * Find mapping for virtual page. |
96 | * Find mapping for virtual page. |
| 97 | * |
97 | * |
| - | 98 | * The address space must be locked and interrupts must be disabled. |
|
| - | 99 | * |
|
| 98 | * @param as Address space to wich page belongs must be locked prior the call. |
100 | * @param as Address space to wich page belongs. |
| 99 | * @param page Virtual page. |
101 | * @param page Virtual page. |
| 100 | * @param root PTL0 address if non-zero. |
- | |
| 101 | * |
102 | * |
| 102 | * @return NULL if there is no such mapping; requested mapping otherwise. |
103 | * @return NULL if there is no such mapping; requested mapping otherwise. |
| 103 | */ |
104 | */ |
| 104 | pte_t *page_mapping_find(as_t *as, __address page, __address root) |
105 | pte_t *page_mapping_find(as_t *as, __address page) |
| 105 | { |
106 | { |
| 106 | ASSERT(page_operations); |
107 | ASSERT(page_operations); |
| 107 | ASSERT(page_operations->mapping_find); |
108 | ASSERT(page_operations->mapping_find); |
| 108 | 109 | ||
| 109 | return page_operations->mapping_find(as, page, root); |
110 | return page_operations->mapping_find(as, page); |
| 110 | } |
111 | } |