Rev 703 | Rev 756 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 703 | Rev 755 | ||
|---|---|---|---|
| Line 31... | Line 31... | ||
| 31 | */ |
31 | */ |
| 32 | 32 | ||
| 33 | #include <mm/page.h> |
33 | #include <mm/page.h> |
| 34 | #include <arch/mm/page.h> |
34 | #include <arch/mm/page.h> |
| 35 | #include <arch/mm/asid.h> |
35 | #include <arch/mm/asid.h> |
| 36 | #include <mm/asid.h> |
36 | #include <mm/as.h> |
| 37 | #include <mm/frame.h> |
37 | #include <mm/frame.h> |
| 38 | #include <arch/types.h> |
38 | #include <arch/types.h> |
| 39 | #include <typedefs.h> |
39 | #include <typedefs.h> |
| 40 | #include <arch/asm.h> |
40 | #include <arch/asm.h> |
| 41 | #include <memstr.h> |
41 | #include <memstr.h> |
| 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(0x0, 0, 0x0, PAGE_NOT_PRESENT, 0); |
51 | page_mapping_insert(AS_KERNEL, 0x0, 0x0, PAGE_NOT_PRESENT, 0); |
| 52 | } |
52 | } |
| 53 | 53 | ||
| 54 | /** Map memory structure |
54 | /** Map memory structure |
| 55 | * |
55 | * |
| 56 | * Identity-map memory structure |
56 | * Identity-map memory structure |
| Line 66... | Line 66... | ||
| 66 | 66 | ||
| 67 | length = size + (s - (s & ~(PAGE_SIZE-1))); |
67 | length = size + (s - (s & ~(PAGE_SIZE-1))); |
| 68 | cnt = length/PAGE_SIZE + (length%PAGE_SIZE>0); |
68 | cnt = length/PAGE_SIZE + (length%PAGE_SIZE>0); |
| 69 | 69 | ||
| 70 | for (i = 0; i < cnt; i++) |
70 | for (i = 0; i < cnt; i++) |
| 71 | page_mapping_insert(s + i*PAGE_SIZE, ASID_KERNEL, s + i*PAGE_SIZE, PAGE_NOT_CACHEABLE, 0); |
71 | page_mapping_insert(AS_KERNEL, s + i*PAGE_SIZE, s + i*PAGE_SIZE, PAGE_NOT_CACHEABLE, 0); |
| 72 | 72 | ||
| 73 | } |
73 | } |
| 74 | 74 | ||
| 75 | /** Map page to frame |
75 | /** Map page to frame |
| 76 | * |
76 | * |
| 77 | * Map virtual address 'page' to physical address 'frame' |
77 | * Map virtual address 'page' to physical address 'frame' |
| 78 | * using 'flags'. Allocate and setup any missing page tables. |
78 | * using 'flags'. Allocate and setup any missing page tables. |
| 79 | * |
79 | * |
| - | 80 | * @param as Address space to wich page belongs. Must be locked prior the call. |
|
| 80 | * @param page Virtual address of the page to be mapped. |
81 | * @param page Virtual address of the page to be mapped. |
| 81 | * @param asid Address space to wich page belongs. |
- | |
| 82 | * @param frame Physical address of memory frame to which the mapping is done. |
82 | * @param frame Physical address of memory frame to which the mapping is done. |
| 83 | * @param flags Flags to be used for mapping. |
83 | * @param flags Flags to be used for mapping. |
| 84 | * @param root Explicit PTL0 address. |
84 | * @param root Explicit PTL0 address. |
| 85 | */ |
85 | */ |
| 86 | void page_mapping_insert(__address page, asid_t asid, __address frame, int flags, __address root) |
86 | void page_mapping_insert(as_t *as, __address page, __address frame, int flags, __address root) |
| 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(page, asid, frame, flags, root); |
91 | page_operations->mapping_insert(as, page, frame, flags, root); |
| 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 | * @param as Address space to wich page belongs must be locked prior the call. |
|
| 98 | * @param page Virtual page. |
99 | * @param page Virtual page. |
| 99 | * @param asid Address space to wich page belongs. |
- | |
| 100 | * @param root PTL0 address if non-zero. |
100 | * @param root PTL0 address if non-zero. |
| 101 | * |
101 | * |
| 102 | * @return NULL if there is no such mapping; requested mapping otherwise. |
102 | * @return NULL if there is no such mapping; requested mapping otherwise. |
| 103 | */ |
103 | */ |
| 104 | pte_t *page_mapping_find(__address page, asid_t asid, __address root) |
104 | pte_t *page_mapping_find(as_t *as, __address page, __address root) |
| 105 | { |
105 | { |
| 106 | ASSERT(page_operations); |
106 | ASSERT(page_operations); |
| 107 | ASSERT(page_operations->mapping_find); |
107 | ASSERT(page_operations->mapping_find); |
| 108 | 108 | ||
| 109 | return page_operations->mapping_find(page, asid, root); |
109 | return page_operations->mapping_find(as, page, root); |
| 110 | } |
110 | } |