Changeset 32e8cd1 in mainline for kernel/arch/sparc32/include/arch/mm/page.h
- Timestamp:
- 2013-12-28T17:16:44Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c1023bcb
- Parents:
- f6f22cdb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/sparc32/include/arch/mm/page.h
rf6f22cdb r32e8cd1 48 48 #define PA2KA(x) (((uintptr_t) (x)) + UINT32_C(0x40000000)) 49 49 50 #define PTE_ET_INVALID051 #define PTE_ET_DESCRIPTOR152 #define PTE_ET_ENTRY253 54 #define PTE_ACC_USER_RO_KERNEL_RO055 #define PTE_ACC_USER_RW_KERNEL_RW156 #define PTE_ACC_USER_RX_KERNEL_RX257 #define PTE_ACC_USER_RWX_KERNEL_RWX358 #define PTE_ACC_USER_XO_KERNEL_XO459 #define PTE_ACC_USER_RO_KERNEL_RW560 #define PTE_ACC_USER_NO_KERNEL_RX661 #define PTE_ACC_USER_NO_KERNEL_RWX750 #define PTE_ET_INVALID 0 51 #define PTE_ET_DESCRIPTOR 1 52 #define PTE_ET_ENTRY 2 53 54 #define PTE_ACC_USER_RO_KERNEL_RO 0 55 #define PTE_ACC_USER_RW_KERNEL_RW 1 56 #define PTE_ACC_USER_RX_KERNEL_RX 2 57 #define PTE_ACC_USER_RWX_KERNEL_RWX 3 58 #define PTE_ACC_USER_XO_KERNEL_XO 4 59 #define PTE_ACC_USER_RO_KERNEL_RW 5 60 #define PTE_ACC_USER_NO_KERNEL_RX 6 61 #define PTE_ACC_USER_NO_KERNEL_RWX 7 62 62 63 63 /* Number of entries in each level. */ … … 143 143 /** Page Table Descriptor. */ 144 144 typedef struct { 145 unsigned int table_pointer : 30;146 unsigned int et : 2;145 unsigned int table_pointer : 30; 146 unsigned int et : 2; 147 147 } __attribute__((packed)) ptd_t; 148 148 149 149 /** Page Table Entry. */ 150 150 typedef struct { 151 unsigned int frame_address : 24;152 unsigned int cacheable : 1;153 unsigned int modified : 1;154 unsigned int referenced : 1;155 unsigned int acc : 3;156 unsigned int et : 2;151 unsigned int frame_address : 24; 152 unsigned int cacheable : 1; 153 unsigned int modified : 1; 154 unsigned int referenced : 1; 155 unsigned int acc : 3; 156 unsigned int et : 2; 157 157 } __attribute__((packed)) pte_t; 158 158 … … 163 163 NO_TRACE static inline bool pte_is_writeable(pte_t *pt) 164 164 { 165 return ( 166 pt->acc == PTE_ACC_USER_RW_KERNEL_RW || 167 pt->acc == PTE_ACC_USER_RWX_KERNEL_RWX || 168 pt->acc == PTE_ACC_USER_RO_KERNEL_RW || 169 pt->acc == PTE_ACC_USER_NO_KERNEL_RWX 170 ); 165 return ((pt->acc == PTE_ACC_USER_RW_KERNEL_RW) || 166 (pt->acc == PTE_ACC_USER_RWX_KERNEL_RWX) || 167 (pt->acc == PTE_ACC_USER_RO_KERNEL_RW) || 168 (pt->acc == PTE_ACC_USER_NO_KERNEL_RWX)); 171 169 } 172 170 173 171 NO_TRACE static inline bool pte_is_executable(pte_t *pt) 174 172 { 175 return ( 176 pt->acc != PTE_ACC_USER_RO_KERNEL_RO && 177 pt->acc != PTE_ACC_USER_RW_KERNEL_RW && 178 pt->acc != PTE_ACC_USER_RO_KERNEL_RW 179 ); 173 return ((pt->acc != PTE_ACC_USER_RO_KERNEL_RO) && 174 (pt->acc != PTE_ACC_USER_RW_KERNEL_RW) && 175 (pt->acc != PTE_ACC_USER_RO_KERNEL_RW)); 180 176 } 181 177 … … 184 180 { 185 181 pte_t *p = &pt[i]; 186 187 bool notpresent = p->et == 0; 188 189 return ( 190 (p->cacheable << PAGE_CACHEABLE_SHIFT) | 191 (notpresent << PAGE_PRESENT_SHIFT) | 192 ((p->acc != PTE_ACC_USER_NO_KERNEL_RX && p->acc != PTE_ACC_USER_NO_KERNEL_RWX) << PAGE_USER_SHIFT) | 193 (1 << PAGE_READ_SHIFT) | 194 (( 195 p->acc == PTE_ACC_USER_RW_KERNEL_RW || 196 p->acc == PTE_ACC_USER_RWX_KERNEL_RWX || 197 p->acc == PTE_ACC_USER_RO_KERNEL_RW || 198 p->acc == PTE_ACC_USER_NO_KERNEL_RWX 199 ) << PAGE_WRITE_SHIFT) | 200 (( 201 p->acc != PTE_ACC_USER_RO_KERNEL_RO && 202 p->acc != PTE_ACC_USER_RW_KERNEL_RW && 203 p->acc != PTE_ACC_USER_RO_KERNEL_RW 204 ) << PAGE_EXEC_SHIFT) | 205 (1 << PAGE_GLOBAL_SHIFT) 206 ); 182 183 bool notpresent = (p->et == 0); 184 185 return ((p->cacheable << PAGE_CACHEABLE_SHIFT) | 186 (notpresent << PAGE_PRESENT_SHIFT) | 187 (((p->acc != PTE_ACC_USER_NO_KERNEL_RX) && 188 (p->acc != PTE_ACC_USER_NO_KERNEL_RWX)) << PAGE_USER_SHIFT) | 189 (1 << PAGE_READ_SHIFT) | 190 (((p->acc == PTE_ACC_USER_RW_KERNEL_RW) || 191 (p->acc == PTE_ACC_USER_RWX_KERNEL_RWX) || 192 (p->acc == PTE_ACC_USER_RO_KERNEL_RW) || 193 (p->acc == PTE_ACC_USER_NO_KERNEL_RWX)) << PAGE_WRITE_SHIFT) | 194 (((p->acc != PTE_ACC_USER_RO_KERNEL_RO) && 195 (p->acc != PTE_ACC_USER_RW_KERNEL_RW) && 196 (p->acc != PTE_ACC_USER_RO_KERNEL_RW)) << PAGE_EXEC_SHIFT) | 197 (1 << PAGE_GLOBAL_SHIFT)); 207 198 } 208 199 … … 213 204 pte_t *p = &pt[i]; 214 205 215 p->et = (flags & PAGE_NOT_PRESENT) 216 ? PTE_ET_INVALID 217 : PTE_ET_DESCRIPTOR; 206 p->et = (flags & PAGE_NOT_PRESENT) ? 207 PTE_ET_INVALID : PTE_ET_DESCRIPTOR; 218 208 } 219 209 … … 223 213 { 224 214 pte_t *p = &pt[i]; 225 215 226 216 p->et = PTE_ET_ENTRY; 227 217 p->acc = PTE_ACC_USER_NO_KERNEL_RWX; … … 240 230 } 241 231 } 242 232 243 233 if (flags & PAGE_NOT_PRESENT) 244 234 p->et = PTE_ET_INVALID; 245 235 246 236 p->cacheable = (flags & PAGE_CACHEABLE) != 0; 247 237 } … … 252 242 { 253 243 pte_t *p = &pt[i]; 254 244 255 245 p->et = PTE_ET_DESCRIPTOR; 256 246 } … … 261 251 { 262 252 pte_t *p = &pt[i]; 263 253 264 254 p->et = PTE_ET_ENTRY; 265 255 }
Note:
See TracChangeset
for help on using the changeset viewer.