Rev 2149 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2149 | Rev 2182 | ||
---|---|---|---|
Line 34... | Line 34... | ||
34 | 34 | ||
35 | #ifndef KERN_arm32_PAGE_H_ |
35 | #ifndef KERN_arm32_PAGE_H_ |
36 | #define KERN_arm32_PAGE_H_ |
36 | #define KERN_arm32_PAGE_H_ |
37 | 37 | ||
38 | #include <arch/mm/frame.h> |
38 | #include <arch/mm/frame.h> |
- | 39 | #include <mm/mm.h> |
|
- | 40 | #include <arch/exception.h> |
|
- | 41 | ||
39 | 42 | ||
40 | #define PAGE_WIDTH FRAME_WIDTH |
43 | #define PAGE_WIDTH FRAME_WIDTH |
41 | #define PAGE_SIZE FRAME_SIZE |
44 | #define PAGE_SIZE FRAME_SIZE |
42 | 45 | ||
43 | #define PAGE_COLOR_BITS 0 /* dummy */ |
46 | #define PAGE_COLOR_BITS 0 /* dummy */ |
Line 66... | Line 69... | ||
66 | #define GET_PTL1_ADDRESS_ARCH(ptl0, i) ((pte_t *)( (((pte_level0_t*)(ptl0))[(i)]).coarse_table_addr << 10 )) |
69 | #define GET_PTL1_ADDRESS_ARCH(ptl0, i) ((pte_t *)( (((pte_level0_t*)(ptl0))[(i)]).coarse_table_addr << 10 )) |
67 | #define GET_PTL2_ADDRESS_ARCH(ptl1, i) (ptl1) |
70 | #define GET_PTL2_ADDRESS_ARCH(ptl1, i) (ptl1) |
68 | #define GET_PTL3_ADDRESS_ARCH(ptl2, i) (ptl2) |
71 | #define GET_PTL3_ADDRESS_ARCH(ptl2, i) (ptl2) |
69 | #define GET_FRAME_ADDRESS_ARCH(ptl3, i) ( (uintptr_t)(((pte_level1_t*)(ptl3))[(i)]).frame_base_addr << 12 )) |
72 | #define GET_FRAME_ADDRESS_ARCH(ptl3, i) ( (uintptr_t)(((pte_level1_t*)(ptl3))[(i)]).frame_base_addr << 12 )) |
70 | 73 | ||
71 | #define SET_PTL0_ADDRESS_ARCH(ptl0) // TODO |
74 | #define SET_PTL0_ADDRESS_ARCH(ptl0) ( set_ptl0_addr((pte_level0_t *)(ptl0)) ) |
72 | #define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) (((pte_level0_t *)(ptl0))[(i)].coarse_table_addr = (a)>>10) |
75 | #define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) (((pte_level0_t *)(ptl0))[(i)].coarse_table_addr = (a)>>10) |
73 | #define SET_PTL2_ADDRESS_ARCH(ptl1, i, a) |
76 | #define SET_PTL2_ADDRESS_ARCH(ptl1, i, a) |
74 | #define SET_PTL3_ADDRESS_ARCH(ptl2, i, a) |
77 | #define SET_PTL3_ADDRESS_ARCH(ptl2, i, a) |
75 | #define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) (((pte_level1_t *)(ptl3))[(i)].frame_base_addr = (a)>>12) |
78 | #define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) (((pte_level1_t *)(ptl3))[(i)].frame_base_addr = (a)>>12) |
76 | 79 | ||
77 | #define GET_PTL1_FLAGS_ARCH(ptl0, i) get_pt_level0_flags((pte_level0_t *)(ptl0), (index_t)(i)) |
80 | #define GET_PTL1_FLAGS_ARCH(ptl0, i) get_pt_level0_flags((pte_level0_t *)(ptl0), (index_t)(i)) |
78 | #define GET_PTL2_FLAGS_ARCH(ptl1, i) PAGE_PRESENT |
81 | #define GET_PTL2_FLAGS_ARCH(ptl1, i) PAGE_PRESENT |
79 | #define GET_PTL3_FLAGS_ARCH(ptl2, i) PAGE_PRESENT |
82 | #define GET_PTL3_FLAGS_ARCH(ptl2, i) PAGE_PRESENT |
80 | #define GET_FRAME_FLAGS_ARCH(ptl3, i) get_pt_level1_flags((pte_level1_t *)(ptl3), (index_t)(i)) |
83 | #define GET_FRAME_FLAGS_ARCH(ptl3, i) get_pt_level1_flags((pte_level1_t *)(ptl3), (index_t)(i)) |
Line 82... | Line 85... | ||
82 | #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) set_pt_level0_flags((pte_level0_t *)(ptl0), (index_t)(i), (x)) |
85 | #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) set_pt_level0_flags((pte_level0_t *)(ptl0), (index_t)(i), (x)) |
83 | #define SET_PTL2_FLAGS_ARCH(ptl1, i, x) |
86 | #define SET_PTL2_FLAGS_ARCH(ptl1, i, x) |
84 | #define SET_PTL3_FLAGS_ARCH(ptl2, i, x) |
87 | #define SET_PTL3_FLAGS_ARCH(ptl2, i, x) |
85 | #define SET_FRAME_FLAGS_ARCH(ptl3, i, x) set_pt_level1_flags((pte_level1_t *)(ptl3), (index_t)(i), (x)) |
88 | #define SET_FRAME_FLAGS_ARCH(ptl3, i, x) set_pt_level1_flags((pte_level1_t *)(ptl3), (index_t)(i), (x)) |
86 | 89 | ||
87 | #define PTE_VALID_ARCH(pte) (*((uint32_t *) (pte)) != 0) |
90 | #define PTE_VALID_ARCH(pte) (*((uint32_t *) (pte)) != 0) |
88 | #define PTE_PRESENT_ARCH(pte) ( ((pte_level0_t *)(pte))->descriptor_type ) |
91 | #define PTE_PRESENT_ARCH(pte) ( ((pte_level0_t *)(pte))->descriptor_type ) |
89 | #define PTE_GET_FRAME_ARCH(pte) ( ((pte_level1_t *)(pte))->frame_base_addr << FRAME_WIDTH) // pte should point into ptl3 |
92 | #define PTE_GET_FRAME_ARCH(pte) ( ((pte_level1_t *)(pte))->frame_base_addr << FRAME_WIDTH) // pte should point into ptl3 |
90 | #define PTE_WRITABLE_ARCH(pte) ( ((pte_level1_t *)(pte))->access_permission_0 == pte_ap_user_rw_kernel_rw ) // pte should point into ptl3 |
93 | #define PTE_WRITABLE_ARCH(pte) ( ((pte_level1_t *)(pte))->access_permission_0 == pte_ap_user_rw_kernel_rw ) // pte should point into ptl3 |
91 | #define PTE_EXECUTABLE_ARCH(pte) 1 |
94 | #define PTE_EXECUTABLE_ARCH(pte) 1 |
92 | 95 | ||
93 | #ifndef __ASM__ |
96 | #ifndef __ASM__ |
94 | 97 | ||
95 | #include <mm/mm.h> |
98 | /** Set adress of paging level 0 table |
96 | #include <arch/exception.h> |
99 | * \param pt pointer to page table to set |
- | 100 | */ |
|
- | 101 | static inline void set_ptl0_addr( pte_level0_t* pt){ |
|
- | 102 | asm volatile ( "mrc p15, 0, %0, c2, c0, 0 \n" |
|
- | 103 | : |
|
- | 104 | : "r"(pt) |
|
- | 105 | ); |
|
- | 106 | ||
- | 107 | } |
|
97 | 108 | ||
98 | //TODO Comment: Page table structure as in other architectures |
109 | //TODO Comment: Page table structure as in other architectures |
99 | 110 | ||
100 | static inline int get_pt_level0_flags(pte_level0_t *pt, index_t i) |
111 | static inline int get_pt_level0_flags(pte_level0_t *pt, index_t i) |
101 | { |
112 | { |
Line 104... | Line 115... | ||
104 | return ( |
115 | return ( |
105 | ( p->descriptor_type != pte_descriptor_not_preset ) << PAGE_PRESENT_SHIFT | |
116 | ( p->descriptor_type != pte_descriptor_not_preset ) << PAGE_PRESENT_SHIFT | |
106 | ( 1 << PAGE_READ_SHIFT ) | |
117 | ( 1 << PAGE_READ_SHIFT ) | |
107 | ( 1 << PAGE_EXEC_SHIFT ) | |
118 | ( 1 << PAGE_EXEC_SHIFT ) | |
108 | ( 1 << PAGE_CACHEABLE ) |
119 | ( 1 << PAGE_CACHEABLE ) |
109 | // Alf Note: MayBe return WriteAble because level0 should use only kernel which can write |
- | |
110 | // Alf Note: MayBe return global flag if index i > 2048 (horni 2GB because kernel is mapped globaly) |
- | |
111 | ); |
120 | ); |
112 | 121 | ||
113 | } |
122 | } |
114 | static inline int get_pt_level1_flags(pte_level1_t *pt, index_t i) |
123 | static inline int get_pt_level1_flags(pte_level1_t *pt, index_t i) |
115 | { |
124 | { |
Line 118... | Line 127... | ||
118 | return ( |
127 | return ( |
119 | ( p->descriptor_type != pte_descriptor_not_preset ) << PAGE_PRESENT_SHIFT | |
128 | ( p->descriptor_type != pte_descriptor_not_preset ) << PAGE_PRESENT_SHIFT | |
120 | ( (p->access_permission_0 == pte_ap_user_ro_kernel_rw) << PAGE_READ_SHIFT ) | |
129 | ( (p->access_permission_0 == pte_ap_user_ro_kernel_rw) << PAGE_READ_SHIFT ) | |
121 | ( (p->access_permission_0 == pte_ap_user_rw_kernel_rw) << PAGE_READ_SHIFT ) | |
130 | ( (p->access_permission_0 == pte_ap_user_rw_kernel_rw) << PAGE_READ_SHIFT ) | |
122 | ( (p->access_permission_0 == pte_ap_user_rw_kernel_rw) << PAGE_WRITE_SHIFT ) | |
131 | ( (p->access_permission_0 == pte_ap_user_rw_kernel_rw) << PAGE_WRITE_SHIFT ) | |
123 | ( (p->access_permission_0 != pte_ap_user_no_kernel_rw) << PAGE_USER_SHIFT ) | |
132 | ( (p->access_permission_0 != pte_ap_user_no_kernel_rw) << PAGE_USER_SHIFT ) | |
124 | ( 1 << PAGE_EXEC_SHIFT ) | |
133 | ( 1 << PAGE_EXEC_SHIFT ) | |
125 | ( p->bufferable << PAGE_CACHEABLE ) |
134 | ( p->bufferable << PAGE_CACHEABLE ) |
126 | // Alf Note: MayBe return global flag if index i > 2048 (horni 2GB because kernel is mapped globaly) |
- | |
127 | 135 | ||
128 | 136 | ||
129 | ); |
137 | ); |
130 | 138 | ||
131 | } |
139 | } |
Line 153... | Line 161... | ||
153 | { |
161 | { |
154 | pte_level1_t *p = &pt[i]; |
162 | pte_level1_t *p = &pt[i]; |
155 | 163 | ||
156 | if ( flags & PAGE_NOT_PRESENT ) { |
164 | if ( flags & PAGE_NOT_PRESENT ) { |
157 | p->descriptor_type = pte_descriptor_not_preset; |
165 | p->descriptor_type = pte_descriptor_not_preset; |
158 | p->access_permission_3 = 1; // Ensure not all bits set to zero ... correct acess rights are stored in other 0-2 access permission entries |
166 | p->access_permission_3 = 1; |
159 | } else |
167 | } else |
160 | { |
168 | { |
161 | p->descriptor_type = pte_descriptor_coarse_table; |
169 | p->descriptor_type = pte_descriptor_coarse_table; |
162 | p->access_permission_3 = p->access_permission_0; |
170 | p->access_permission_3 = p->access_permission_0; |
163 | } |
171 | } |