Changeset c03ee1c in mainline
- Timestamp:
- 2007-06-13T17:49:57Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- de7663f
- Parents:
- 6b781c0
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/genarch/include/softint
r6b781c0 rc03ee1c 1 ../../../kernel/genarch/include/softint /1 ../../../kernel/genarch/include/softint -
boot/generic/genarch
r6b781c0 rc03ee1c 1 ../genarch/include /1 ../genarch/include -
kernel/arch/amd64/include/mm/page.h
r6b781c0 rc03ee1c 70 70 } 71 71 72 # define KA2PA(x) ka2pa((uintptr_t)x)73 # define PA2KA_CODE(x) 74 # define PA2KA(x) 72 # define KA2PA(x) ka2pa((uintptr_t) x) 73 # define PA2KA_CODE(x) (((uintptr_t) (x)) + 0xffffffff80000000) 74 # define PA2KA(x) (((uintptr_t) (x)) + 0xffff800000000000) 75 75 #else 76 # define KA2PA(x) 77 # define PA2KA(x) 76 # define KA2PA(x) ((x) - 0xffffffff80000000) 77 # define PA2KA(x) ((x) + 0xffffffff80000000) 78 78 #endif 79 79 80 /* Number of entries in each level. */ 80 81 #define PTL0_ENTRIES_ARCH 512 81 82 #define PTL1_ENTRIES_ARCH 512 … … 83 84 #define PTL3_ENTRIES_ARCH 512 84 85 85 #define PTL0_SIZE_ARCH ONE_FRAME 86 #define PTL1_SIZE_ARCH ONE_FRAME 87 #define PTL2_SIZE_ARCH ONE_FRAME 88 #define PTL3_SIZE_ARCH ONE_FRAME 89 90 #define PTL0_INDEX_ARCH(vaddr) (((vaddr)>>39)&0x1ff) 91 #define PTL1_INDEX_ARCH(vaddr) (((vaddr)>>30)&0x1ff) 92 #define PTL2_INDEX_ARCH(vaddr) (((vaddr)>>21)&0x1ff) 93 #define PTL3_INDEX_ARCH(vaddr) (((vaddr)>>12)&0x1ff) 94 95 #define GET_PTL1_ADDRESS_ARCH(ptl0, i) ((pte_t *) ((((uint64_t) ((pte_t *)(ptl0))[(i)].addr_12_31)<<12) | (((uint64_t) ((pte_t *)(ptl0))[(i)].addr_32_51)<<32 ))) 96 #define GET_PTL2_ADDRESS_ARCH(ptl1, i) ((pte_t *) ((((uint64_t) ((pte_t *)(ptl1))[(i)].addr_12_31)<<12) | (((uint64_t) ((pte_t *)(ptl1))[(i)].addr_32_51)<<32 ))) 97 #define GET_PTL3_ADDRESS_ARCH(ptl2, i) ((pte_t *) ((((uint64_t) ((pte_t *)(ptl2))[(i)].addr_12_31)<<12) | (((uint64_t) ((pte_t *)(ptl2))[(i)].addr_32_51)<<32 ))) 98 #define GET_FRAME_ADDRESS_ARCH(ptl3, i) ((uintptr_t *) ((((uint64_t) ((pte_t *)(ptl3))[(i)].addr_12_31)<<12) | (((uint64_t) ((pte_t *)(ptl3))[(i)].addr_32_51)<<32 ))) 99 100 #define SET_PTL0_ADDRESS_ARCH(ptl0) (write_cr3((uintptr_t) (ptl0))) 101 #define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) set_pt_addr((pte_t *)(ptl0), (index_t)(i), a) 102 #define SET_PTL2_ADDRESS_ARCH(ptl1, i, a) set_pt_addr((pte_t *)(ptl1), (index_t)(i), a) 103 #define SET_PTL3_ADDRESS_ARCH(ptl2, i, a) set_pt_addr((pte_t *)(ptl2), (index_t)(i), a) 104 #define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) set_pt_addr((pte_t *)(ptl3), (index_t)(i), a) 105 106 #define GET_PTL1_FLAGS_ARCH(ptl0, i) get_pt_flags((pte_t *)(ptl0), (index_t)(i)) 107 #define GET_PTL2_FLAGS_ARCH(ptl1, i) get_pt_flags((pte_t *)(ptl1), (index_t)(i)) 108 #define GET_PTL3_FLAGS_ARCH(ptl2, i) get_pt_flags((pte_t *)(ptl2), (index_t)(i)) 109 #define GET_FRAME_FLAGS_ARCH(ptl3, i) get_pt_flags((pte_t *)(ptl3), (index_t)(i)) 110 111 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) set_pt_flags((pte_t *)(ptl0), (index_t)(i), (x)) 112 #define SET_PTL2_FLAGS_ARCH(ptl1, i, x) set_pt_flags((pte_t *)(ptl1), (index_t)(i), (x)) 113 #define SET_PTL3_FLAGS_ARCH(ptl2, i, x) set_pt_flags((pte_t *)(ptl2), (index_t)(i), (x)) 114 #define SET_FRAME_FLAGS_ARCH(ptl3, i, x) set_pt_flags((pte_t *)(ptl3), (index_t)(i), (x)) 115 116 #define PTE_VALID_ARCH(p) (*((uint64_t *) (p)) != 0) 117 #define PTE_PRESENT_ARCH(p) ((p)->present != 0) 118 #define PTE_GET_FRAME_ARCH(p) ((((uintptr_t)(p)->addr_12_31)<<12) | ((uintptr_t)(p)->addr_32_51<<32)) 119 #define PTE_WRITABLE_ARCH(p) ((p)->writeable != 0) 120 #define PTE_EXECUTABLE_ARCH(p) ((p)->no_execute == 0) 86 /* Page table sizes for each level. */ 87 #define PTL0_SIZE_ARCH ONE_FRAME 88 #define PTL1_SIZE_ARCH ONE_FRAME 89 #define PTL2_SIZE_ARCH ONE_FRAME 90 #define PTL3_SIZE_ARCH ONE_FRAME 91 92 /* Macros calculating indices into page tables in each level. */ 93 #define PTL0_INDEX_ARCH(vaddr) (((vaddr) >> 39) & 0x1ff) 94 #define PTL1_INDEX_ARCH(vaddr) (((vaddr) >> 30) & 0x1ff) 95 #define PTL2_INDEX_ARCH(vaddr) (((vaddr) >> 21) & 0x1ff) 96 #define PTL3_INDEX_ARCH(vaddr) (((vaddr) >> 12) & 0x1ff) 97 98 /* Get PTE address accessors for each level. */ 99 #define GET_PTL1_ADDRESS_ARCH(ptl0, i) \ 100 ((pte_t *) ((((uint64_t) ((pte_t *) (ptl0))[(i)].addr_12_31) << 12) | \ 101 (((uint64_t) ((pte_t *) (ptl0))[(i)].addr_32_51) << 32))) 102 #define GET_PTL2_ADDRESS_ARCH(ptl1, i) \ 103 ((pte_t *) ((((uint64_t) ((pte_t *) (ptl1))[(i)].addr_12_31) << 12) | \ 104 (((uint64_t) ((pte_t *) (ptl1))[(i)].addr_32_51) << 32))) 105 #define GET_PTL3_ADDRESS_ARCH(ptl2, i) \ 106 ((pte_t *) ((((uint64_t) ((pte_t *) (ptl2))[(i)].addr_12_31) << 12) | \ 107 (((uint64_t) ((pte_t *) (ptl2))[(i)].addr_32_51) << 32))) 108 #define GET_FRAME_ADDRESS_ARCH(ptl3, i) \ 109 ((uintptr_t *) \ 110 ((((uint64_t) ((pte_t *) (ptl3))[(i)].addr_12_31) << 12) | \ 111 (((uint64_t) ((pte_t *) (ptl3))[(i)].addr_32_51) << 32))) 112 113 /* Set PTE address accessors for each level. */ 114 #define SET_PTL0_ADDRESS_ARCH(ptl0) \ 115 (write_cr3((uintptr_t) (ptl0))) 116 #define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) \ 117 set_pt_addr((pte_t *) (ptl0), (index_t) (i), a) 118 #define SET_PTL2_ADDRESS_ARCH(ptl1, i, a) \ 119 set_pt_addr((pte_t *) (ptl1), (index_t) (i), a) 120 #define SET_PTL3_ADDRESS_ARCH(ptl2, i, a) \ 121 set_pt_addr((pte_t *) (ptl2), (index_t) (i), a) 122 #define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) \ 123 set_pt_addr((pte_t *) (ptl3), (index_t) (i), a) 124 125 /* Get PTE flags accessors for each level. */ 126 #define GET_PTL1_FLAGS_ARCH(ptl0, i) \ 127 get_pt_flags((pte_t *) (ptl0), (index_t) (i)) 128 #define GET_PTL2_FLAGS_ARCH(ptl1, i) \ 129 get_pt_flags((pte_t *) (ptl1), (index_t) (i)) 130 #define GET_PTL3_FLAGS_ARCH(ptl2, i) \ 131 get_pt_flags((pte_t *) (ptl2), (index_t) (i)) 132 #define GET_FRAME_FLAGS_ARCH(ptl3, i) \ 133 get_pt_flags((pte_t *) (ptl3), (index_t) (i)) 134 135 /* Set PTE flags accessors for each level. */ 136 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) \ 137 set_pt_flags((pte_t *) (ptl0), (index_t) (i), (x)) 138 #define SET_PTL2_FLAGS_ARCH(ptl1, i, x) \ 139 set_pt_flags((pte_t *) (ptl1), (index_t) (i), (x)) 140 #define SET_PTL3_FLAGS_ARCH(ptl2, i, x) \ 141 set_pt_flags((pte_t *) (ptl2), (index_t) (i), (x)) 142 #define SET_FRAME_FLAGS_ARCH(ptl3, i, x) \ 143 set_pt_flags((pte_t *) (ptl3), (index_t) (i), (x)) 144 145 /* Macros for querying the last-level PTE entries. */ 146 #define PTE_VALID_ARCH(p) \ 147 (*((uint64_t *) (p)) != 0) 148 #define PTE_PRESENT_ARCH(p) \ 149 ((p)->present != 0) 150 #define PTE_GET_FRAME_ARCH(p) \ 151 ((((uintptr_t) (p)->addr_12_31) << 12) | \ 152 ((uintptr_t) (p)->addr_32_51 << 32)) 153 #define PTE_WRITABLE_ARCH(p) \ 154 ((p)->writeable != 0) 155 #define PTE_EXECUTABLE_ARCH(p) \ 156 ((p)->no_execute == 0) 121 157 122 158 #ifndef __ASM__ … … 124 160 /* Page fault error codes. */ 125 161 126 /** When bit on this position is 0, the page fault was caused by a not-present page. */ 127 #define PFERR_CODE_P (1<<0) 162 /** When bit on this position is 0, the page fault was caused by a not-present 163 * page. 164 */ 165 #define PFERR_CODE_P (1 << 0) 128 166 129 167 /** When bit on this position is 1, the page fault was caused by a write. */ 130 #define PFERR_CODE_RW (1 <<1)168 #define PFERR_CODE_RW (1 << 1) 131 169 132 170 /** When bit on this position is 1, the page fault was caused in user mode. */ 133 #define PFERR_CODE_US (1 <<2)171 #define PFERR_CODE_US (1 << 2) 134 172 135 173 /** When bit on this position is 1, a reserved bit was set in page directory. */ 136 #define PFERR_CODE_RSVD (1<<3) 137 138 /** When bit on this position os 1, the page fault was caused during instruction fecth. */ 139 #define PFERR_CODE_ID (1<<4) 174 #define PFERR_CODE_RSVD (1 << 3) 175 176 /** When bit on this position os 1, the page fault was caused during instruction 177 * fecth. 178 */ 179 #define PFERR_CODE_ID (1 << 4) 140 180 141 181 static inline int get_pt_flags(pte_t *pt, index_t i) … … 143 183 pte_t *p = &pt[i]; 144 184 145 return ( 146 (!p->page_cache_disable)<<PAGE_CACHEABLE_SHIFT | 147 (!p->present)<<PAGE_PRESENT_SHIFT | 148 p->uaccessible<<PAGE_USER_SHIFT | 149 1<<PAGE_READ_SHIFT | 150 p->writeable<<PAGE_WRITE_SHIFT | 151 (!p->no_execute)<<PAGE_EXEC_SHIFT | 152 p->global<<PAGE_GLOBAL_SHIFT 153 ); 185 return ((!p->page_cache_disable) << PAGE_CACHEABLE_SHIFT | 186 (!p->present) << PAGE_PRESENT_SHIFT | 187 p->uaccessible << PAGE_USER_SHIFT | 188 1 << PAGE_READ_SHIFT | 189 p->writeable << PAGE_WRITE_SHIFT | 190 (!p->no_execute) << PAGE_EXEC_SHIFT | 191 p->global << PAGE_GLOBAL_SHIFT); 154 192 } 155 193 -
kernel/arch/arm32/include/mm/page.h
r6b781c0 rc03ee1c 56 56 #ifdef KERNEL 57 57 58 /* Number of entries in each level. */ 58 59 #define PTL0_ENTRIES_ARCH (2 << 12) /* 4096 */ 59 60 #define PTL1_ENTRIES_ARCH 0 60 61 #define PTL2_ENTRIES_ARCH 0 61 62 62 /* coarse page tables used (256 * 4 = 1KB per page) */ 63 63 #define PTL3_ENTRIES_ARCH (2 << 8) /* 256 */ 64 64 65 /* Page table sizes for each level. */ 65 66 #define PTL0_SIZE_ARCH FOUR_FRAMES 66 67 #define PTL1_SIZE_ARCH 0 … … 68 69 #define PTL3_SIZE_ARCH ONE_FRAME 69 70 71 /* Macros calculating indices into page tables for each level. */ 70 72 #define PTL0_INDEX_ARCH(vaddr) (((vaddr) >> 20) & 0xfff) 71 73 #define PTL1_INDEX_ARCH(vaddr) 0 … … 73 75 #define PTL3_INDEX_ARCH(vaddr) (((vaddr) >> 12) & 0x0ff) 74 76 77 /* Get PTE address accessors for each level. */ 75 78 #define GET_PTL1_ADDRESS_ARCH(ptl0, i) \ 76 79 ((pte_t *) ((((pte_level0_t *)(ptl0))[(i)]).coarse_table_addr << 10)) … … 82 85 ((uintptr_t) ((((pte_level1_t *)(ptl3))[(i)]).frame_base_addr << 12)) 83 86 87 /* Set PTE address accessors for each level. */ 84 88 #define SET_PTL0_ADDRESS_ARCH(ptl0) \ 85 89 (set_ptl0_addr((pte_level0_t *) (ptl0))) … … 91 95 (((pte_level1_t *) (ptl3))[(i)].frame_base_addr = (a) >> 12) 92 96 97 /* Get PTE flags accessors for each level. */ 93 98 #define GET_PTL1_FLAGS_ARCH(ptl0, i) \ 94 99 get_pt_level0_flags((pte_level0_t *) (ptl0), (index_t) (i)) … … 100 105 get_pt_level1_flags((pte_level1_t *) (ptl3), (index_t) (i)) 101 106 107 /* Set PTE flags accessors for each level. */ 102 108 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) \ 103 109 set_pt_level0_flags((pte_level0_t *) (ptl0), (index_t) (i), (x)) … … 107 113 set_pt_level1_flags((pte_level1_t *) (ptl3), (index_t) (i), (x)) 108 114 115 /* Macros for querying the last-level PTE entries. */ 109 116 #define PTE_VALID_ARCH(pte) \ 110 117 (*((uint32_t *) (pte)) != 0) 111 118 #define PTE_PRESENT_ARCH(pte) \ 112 119 (((pte_level0_t *) (pte))->descriptor_type != 0) 113 114 /* pte should point into ptl3 */115 120 #define PTE_GET_FRAME_ARCH(pte) \ 116 121 (((pte_level1_t *) (pte))->frame_base_addr << FRAME_WIDTH) 117 118 /* pte should point into ptl3 */119 122 #define PTE_WRITABLE_ARCH(pte) \ 120 123 (((pte_level1_t *) (pte))->access_permission_0 == \ 121 124 PTE_AP_USER_RW_KERNEL_RW) 122 123 125 #define PTE_EXECUTABLE_ARCH(pte) \ 124 126 1 … … 129 131 typedef struct { 130 132 /* 0b01 for coarse tables, see below for details */ 131 unsigned descriptor_type 132 unsigned impl_specific 133 unsigned domain 134 unsigned should_be_zero 133 unsigned descriptor_type : 2; 134 unsigned impl_specific : 3; 135 unsigned domain : 4; 136 unsigned should_be_zero : 1; 135 137 136 138 /* Pointer to the coarse 2nd level page table (holding entries for small … … 139 141 * per table in comparison with 1KB per the coarse table) 140 142 */ 141 unsigned coarse_table_addr 143 unsigned coarse_table_addr : 22; 142 144 } ATTRIBUTE_PACKED pte_level0_t; 143 145 … … 146 148 147 149 /* 0b10 for small pages */ 148 unsigned descriptor_type 149 unsigned bufferable 150 unsigned cacheable 150 unsigned descriptor_type : 2; 151 unsigned bufferable : 1; 152 unsigned cacheable : 1; 151 153 152 154 /* access permissions for each of 4 subparts of a page … … 156 158 unsigned access_permission_2 : 2; 157 159 unsigned access_permission_3 : 2; 158 unsigned frame_base_addr 160 unsigned frame_base_addr : 20; 159 161 } ATTRIBUTE_PACKED pte_level1_t; 160 162 … … 191 193 * @param pt Pointer to the page table to set. 192 194 */ 193 static inline void set_ptl0_addr( 195 static inline void set_ptl0_addr(pte_level0_t *pt) 194 196 { 195 197 asm volatile ( -
kernel/arch/arm32/include/mm/page_fault.h
r6b781c0 rc03ee1c 42 42 /** Decribes CP15 "fault status register" (FSR). */ 43 43 typedef struct { 44 unsigned status 45 unsigned domain 46 unsigned zero 47 unsigned should_be_zero 44 unsigned status : 3; 45 unsigned domain : 4; 46 unsigned zero : 1; 47 unsigned should_be_zero : 24; 48 48 } ATTRIBUTE_PACKED fault_status_t; 49 49 … … 62 62 */ 63 63 typedef struct { 64 unsigned dummy1 65 unsigned bit4 66 unsigned bits567 67 unsigned dummy 68 unsigned access 69 unsigned opcode 70 unsigned type 71 unsigned condition 64 unsigned dummy1 : 4; 65 unsigned bit4 : 1; 66 unsigned bits567 : 3; 67 unsigned dummy : 12; 68 unsigned access : 1; 69 unsigned opcode : 4; 70 unsigned type : 3; 71 unsigned condition : 4; 72 72 } ATTRIBUTE_PACKED instruction_t; 73 73 -
kernel/arch/ia32/include/mm/page.h
r6b781c0 rc03ee1c 57 57 * IA-32 has 2-level page tables, so PTL1 and PTL2 are left out. 58 58 */ 59 60 /* Number of entries in each level. */ 59 61 #define PTL0_ENTRIES_ARCH 1024 60 62 #define PTL1_ENTRIES_ARCH 0 … … 62 64 #define PTL3_ENTRIES_ARCH 1024 63 65 64 #define PTL0_SIZE_ARCH ONE_FRAME 65 #define PTL1_SIZE_ARCH 0 66 #define PTL2_SIZE_ARCH 0 67 #define PTL3_SIZE_ARCH ONE_FRAME 66 /* Page table sizes for each level. */ 67 #define PTL0_SIZE_ARCH ONE_FRAME 68 #define PTL1_SIZE_ARCH 0 69 #define PTL2_SIZE_ARCH 0 70 #define PTL3_SIZE_ARCH ONE_FRAME 68 71 72 /* Macros calculating indices for each level. */ 69 73 #define PTL0_INDEX_ARCH(vaddr) (((vaddr) >> 22) & 0x3ff) 70 74 #define PTL1_INDEX_ARCH(vaddr) 0 … … 72 76 #define PTL3_INDEX_ARCH(vaddr) (((vaddr) >> 12) & 0x3ff) 73 77 74 #define GET_PTL1_ADDRESS_ARCH(ptl0, i) ((pte_t *)((((pte_t *)(ptl0))[(i)].frame_address) << 12)) 75 #define GET_PTL2_ADDRESS_ARCH(ptl1, i) (ptl1) 76 #define GET_PTL3_ADDRESS_ARCH(ptl2, i) (ptl2) 77 #define GET_FRAME_ADDRESS_ARCH(ptl3, i) ((uintptr_t)((((pte_t *)(ptl3))[(i)].frame_address) << 12)) 78 /* Get PTE address accessors for each level. */ 79 #define GET_PTL1_ADDRESS_ARCH(ptl0, i) \ 80 ((pte_t *) ((((pte_t *) (ptl0))[(i)].frame_address) << 12)) 81 #define GET_PTL2_ADDRESS_ARCH(ptl1, i) \ 82 (ptl1) 83 #define GET_PTL3_ADDRESS_ARCH(ptl2, i) \ 84 (ptl2) 85 #define GET_FRAME_ADDRESS_ARCH(ptl3, i) \ 86 ((uintptr_t) ((((pte_t *) (ptl3))[(i)].frame_address) << 12)) 78 87 79 #define SET_PTL0_ADDRESS_ARCH(ptl0) (write_cr3((uintptr_t) (ptl0))) 80 #define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) (((pte_t *)(ptl0))[(i)].frame_address = (a)>>12) 88 /* Set PTE address accessors for each level. */ 89 #define SET_PTL0_ADDRESS_ARCH(ptl0) \ 90 (write_cr3((uintptr_t) (ptl0))) 91 #define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) \ 92 (((pte_t *) (ptl0))[(i)].frame_address = (a) >> 12) 81 93 #define SET_PTL2_ADDRESS_ARCH(ptl1, i, a) 82 94 #define SET_PTL3_ADDRESS_ARCH(ptl2, i, a) 83 #define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) (((pte_t *)(ptl3))[(i)].frame_address = (a)>>12) 95 #define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) \ 96 (((pte_t *) (ptl3))[(i)].frame_address = (a) >> 12) 84 97 85 #define GET_PTL1_FLAGS_ARCH(ptl0, i) get_pt_flags((pte_t *)(ptl0), (index_t)(i)) 86 #define GET_PTL2_FLAGS_ARCH(ptl1, i) PAGE_PRESENT 87 #define GET_PTL3_FLAGS_ARCH(ptl2, i) PAGE_PRESENT 88 #define GET_FRAME_FLAGS_ARCH(ptl3, i) get_pt_flags((pte_t *)(ptl3), (index_t)(i)) 98 /* Get PTE flags accessors for each level. */ 99 #define GET_PTL1_FLAGS_ARCH(ptl0, i) \ 100 get_pt_flags((pte_t *) (ptl0), (index_t) (i)) 101 #define GET_PTL2_FLAGS_ARCH(ptl1, i) \ 102 PAGE_PRESENT 103 #define GET_PTL3_FLAGS_ARCH(ptl2, i) \ 104 PAGE_PRESENT 105 #define GET_FRAME_FLAGS_ARCH(ptl3, i) \ 106 get_pt_flags((pte_t *) (ptl3), (index_t) (i)) 89 107 90 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) set_pt_flags((pte_t *)(ptl0), (index_t)(i), (x)) 108 /* Set PTE flags accessors for each level. */ 109 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) \ 110 set_pt_flags((pte_t *) (ptl0), (index_t) (i), (x)) 91 111 #define SET_PTL2_FLAGS_ARCH(ptl1, i, x) 92 112 #define SET_PTL3_FLAGS_ARCH(ptl2, i, x) 93 #define SET_FRAME_FLAGS_ARCH(ptl3, i, x) set_pt_flags((pte_t *)(ptl3), (index_t)(i), (x)) 113 #define SET_FRAME_FLAGS_ARCH(ptl3, i, x) \ 114 set_pt_flags((pte_t *) (ptl3), (index_t) (i), (x)) 94 115 95 #define PTE_VALID_ARCH(p) (*((uint32_t *) (p)) != 0) 96 #define PTE_PRESENT_ARCH(p) ((p)->present != 0) 97 #define PTE_GET_FRAME_ARCH(p) ((p)->frame_address << FRAME_WIDTH) 98 #define PTE_WRITABLE_ARCH(p) ((p)->writeable != 0) 116 /* Macros for querying the last level entries. */ 117 #define PTE_VALID_ARCH(p) \ 118 (*((uint32_t *) (p)) != 0) 119 #define PTE_PRESENT_ARCH(p) \ 120 ((p)->present != 0) 121 #define PTE_GET_FRAME_ARCH(p) \ 122 ((p)->frame_address << FRAME_WIDTH) 123 #define PTE_WRITABLE_ARCH(p) \ 124 ((p)->writeable != 0) 99 125 #define PTE_EXECUTABLE_ARCH(p) 1 100 126 … … 106 132 /* Page fault error codes. */ 107 133 108 /** When bit on this position is 0, the page fault was caused by a not-present page. */ 134 /** When bit on this position is 0, the page fault was caused by a not-present 135 * page. 136 */ 109 137 #define PFERR_CODE_P (1 << 0) 110 138 … … 122 150 pte_t *p = &pt[i]; 123 151 124 return ( 125 (!p->page_cache_disable) << PAGE_CACHEABLE_SHIFT | 126 (!p->present) << PAGE_PRESENT_SHIFT | 127 p->uaccessible << PAGE_USER_SHIFT | 128 1<<PAGE_READ_SHIFT | 129 p->writeable << PAGE_WRITE_SHIFT | 130 1<<PAGE_EXEC_SHIFT | 131 p->global << PAGE_GLOBAL_SHIFT 132 ); 152 return ((!p->page_cache_disable) << PAGE_CACHEABLE_SHIFT | 153 (!p->present) << PAGE_PRESENT_SHIFT | 154 p->uaccessible << PAGE_USER_SHIFT | 155 1 << PAGE_READ_SHIFT | 156 p->writeable << PAGE_WRITE_SHIFT | 157 1 << PAGE_EXEC_SHIFT | 158 p->global << PAGE_GLOBAL_SHIFT); 133 159 } 134 160 … … 144 170 145 171 /* 146 * Ensure that there is at least one bit set even if the present bit is cleared. 172 * Ensure that there is at least one bit set even if the present bit is 173 * cleared. 147 174 */ 148 175 p->soft_valid = true; -
kernel/arch/ia32xen/include/mm/page.h
r6b781c0 rc03ee1c 57 57 * IA-32 has 2-level page tables, so PTL1 and PTL2 are left out. 58 58 */ 59 60 /* Number of entries in each level. */ 59 61 #define PTL0_ENTRIES_ARCH 1024 60 62 #define PTL1_ENTRIES_ARCH 0 … … 62 64 #define PTL3_ENTRIES_ARCH 1024 63 65 64 #define PTL0_SIZE_ARCH ONE_FRAME 65 #define PTL1_SIZE_ARCH 0 66 #define PTL2_SIZE_ARCH 0 67 #define PTL3_SIZE_ARCH ONE_FRAME 68 66 /* Page table size for each level. */ 67 #define PTL0_SIZE_ARCH ONE_FRAME 68 #define PTL1_SIZE_ARCH 0 69 #define PTL2_SIZE_ARCH 0 70 #define PTL3_SIZE_ARCH ONE_FRAME 71 72 /* Macros calculating indices into page tables in each level. */ 69 73 #define PTL0_INDEX_ARCH(vaddr) (((vaddr) >> 22) & 0x3ff) 70 74 #define PTL1_INDEX_ARCH(vaddr) 0 … … 72 76 #define PTL3_INDEX_ARCH(vaddr) (((vaddr) >> 12) & 0x3ff) 73 77 74 #define GET_PTL1_ADDRESS_ARCH(ptl0, i) ((pte_t *) MA2PA((((pte_t *) (ptl0))[(i)].frame_address) << 12)) 75 #define GET_PTL2_ADDRESS_ARCH(ptl1, i) (ptl1) 76 #define GET_PTL3_ADDRESS_ARCH(ptl2, i) (ptl2) 77 #define GET_FRAME_ADDRESS_ARCH(ptl3, i) ((uintptr_t) MA2PA((((pte_t *) (ptl3))[(i)].frame_address) << 12)) 78 79 #define SET_PTL0_ADDRESS_ARCH(ptl0) { \ 78 /* Get PTE address accessors for each level. */ 79 #define GET_PTL1_ADDRESS_ARCH(ptl0, i) \ 80 ((pte_t *) MA2PA((((pte_t *) (ptl0))[(i)].frame_address) << 12)) 81 #define GET_PTL2_ADDRESS_ARCH(ptl1, i) \ 82 (ptl1) 83 #define GET_PTL3_ADDRESS_ARCH(ptl2, i) \ 84 (ptl2) 85 #define GET_FRAME_ADDRESS_ARCH(ptl3, i) \ 86 ((uintptr_t) MA2PA((((pte_t *) (ptl3))[(i)].frame_address) << 12)) 87 88 /* Set PTE address accessors for each level. */ 89 #define SET_PTL0_ADDRESS_ARCH(ptl0) \ 90 { \ 80 91 mmuext_op_t mmu_ext; \ 81 92 \ … … 85 96 } 86 97 87 #define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) { \ 98 #define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) \ 99 { \ 88 100 mmuext_op_t mmu_ext; \ 89 101 \ … … 101 113 #define SET_PTL2_ADDRESS_ARCH(ptl1, i, a) 102 114 #define SET_PTL3_ADDRESS_ARCH(ptl2, i, a) 103 #define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) { \ 115 #define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) \ 116 { \ 104 117 mmu_update_t update; \ 105 118 \ … … 109 122 } 110 123 111 #define GET_PTL1_FLAGS_ARCH(ptl0, i) get_pt_flags((pte_t *) (ptl0), (index_t)(i)) 112 #define GET_PTL2_FLAGS_ARCH(ptl1, i) PAGE_PRESENT 113 #define GET_PTL3_FLAGS_ARCH(ptl2, i) PAGE_PRESENT 114 #define GET_FRAME_FLAGS_ARCH(ptl3, i) get_pt_flags((pte_t *) (ptl3), (index_t)(i)) 115 116 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) set_pt_flags((pte_t *) (ptl0), (index_t)(i), (x)) 124 /* Get PTE flags accessors for each level. */ 125 #define GET_PTL1_FLAGS_ARCH(ptl0, i) \ 126 get_pt_flags((pte_t *) (ptl0), (index_t) (i)) 127 #define GET_PTL2_FLAGS_ARCH(ptl1, i) \ 128 PAGE_PRESENT 129 #define GET_PTL3_FLAGS_ARCH(ptl2, i) \ 130 PAGE_PRESENT 131 #define GET_FRAME_FLAGS_ARCH(ptl3, i) \ 132 get_pt_flags((pte_t *) (ptl3), (index_t) (i)) 133 134 /* Set PTE flags accessors for each level. */ 135 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) \ 136 set_pt_flags((pte_t *) (ptl0), (index_t) (i), (x)) 117 137 #define SET_PTL2_FLAGS_ARCH(ptl1, i, x) 118 138 #define SET_PTL3_FLAGS_ARCH(ptl2, i, x) 119 #define SET_FRAME_FLAGS_ARCH(ptl3, i, x) set_pt_flags((pte_t *) (ptl3), (index_t)(i), (x)) 120 121 #define PTE_VALID_ARCH(p) (*((uint32_t *) (p)) != 0) 122 #define PTE_PRESENT_ARCH(p) ((p)->present != 0) 123 #define PTE_GET_FRAME_ARCH(p) ((p)->frame_address << FRAME_WIDTH) 124 #define PTE_WRITABLE_ARCH(p) ((p)->writeable != 0) 125 #define PTE_EXECUTABLE_ARCH(p) 1 139 #define SET_FRAME_FLAGS_ARCH(ptl3, i, x) \ 140 set_pt_flags((pte_t *) (ptl3), (index_t) (i), (x)) 141 142 /* Query macros for the last level. */ 143 #define PTE_VALID_ARCH(p) \ 144 (*((uint32_t *) (p)) != 0) 145 #define PTE_PRESENT_ARCH(p) \ 146 ((p)->present != 0) 147 #define PTE_GET_FRAME_ARCH(p) \ 148 ((p)->frame_address << FRAME_WIDTH) 149 #define PTE_WRITABLE_ARCH(p) \ 150 ((p)->writeable != 0) 151 #define PTE_EXECUTABLE_ARCH(p) \ 152 1 126 153 127 154 #ifndef __ASM__ … … 133 160 /* Page fault error codes. */ 134 161 135 /** When bit on this position is 0, the page fault was caused by a not-present page. */ 162 /** When bit on this position is 0, the page fault was caused by a not-present 163 * page. 164 */ 136 165 #define PFERR_CODE_P (1 << 0) 137 166 … … 165 194 } mmuext_op_t; 166 195 167 static inline int xen_update_va_mapping(const void *va, const pte_t pte, const unsigned int flags) 196 static inline int xen_update_va_mapping(const void *va, const pte_t pte, 197 const unsigned int flags) 168 198 { 169 199 return hypercall4(XEN_UPDATE_VA_MAPPING, va, pte, 0, flags); 170 200 } 171 201 172 static inline int xen_mmu_update(const mmu_update_t *req, const unsigned int count, unsigned int *success_count, domid_t domid) 202 static inline int xen_mmu_update(const mmu_update_t *req, 203 const unsigned int count, unsigned int *success_count, domid_t domid) 173 204 { 174 205 return hypercall4(XEN_MMU_UPDATE, req, count, success_count, domid); 175 206 } 176 207 177 static inline int xen_mmuext_op(const mmuext_op_t *op, const unsigned int count, unsigned int *success_count, domid_t domid) 208 static inline int xen_mmuext_op(const mmuext_op_t *op, const unsigned int count, 209 unsigned int *success_count, domid_t domid) 178 210 { 179 211 return hypercall4(XEN_MMUEXT_OP, op, count, success_count, domid); … … 184 216 pte_t *p = &pt[i]; 185 217 186 return ( 187 (!p->page_cache_disable)<<PAGE_CACHEABLE_SHIFT | 188 (!p->present)<<PAGE_PRESENT_SHIFT | 189 p->uaccessible<<PAGE_USER_SHIFT | 190 1<<PAGE_READ_SHIFT | 191 p->writeable<<PAGE_WRITE_SHIFT | 192 1<<PAGE_EXEC_SHIFT | 193 p->global<<PAGE_GLOBAL_SHIFT 194 ); 218 return ((!p->page_cache_disable) << PAGE_CACHEABLE_SHIFT | 219 (!p->present) << PAGE_PRESENT_SHIFT | 220 p->uaccessible << PAGE_USER_SHIFT | 221 1 << PAGE_READ_SHIFT | 222 p->writeable << PAGE_WRITE_SHIFT | 223 1 << PAGE_EXEC_SHIFT | 224 p->global << PAGE_GLOBAL_SHIFT); 195 225 } 196 226 -
kernel/arch/mips32/include/mm/page.h
r6b781c0 rc03ee1c 59 59 * - 32-bit virtual addresses 60 60 * - Offset is 14 bits => pages are 16K long 61 * - PTE's use similar format as CP0 EntryLo[01] registers => PTE is therefore 4 bytes long 61 * - PTE's use similar format as CP0 EntryLo[01] registers => PTE is therefore 62 * 4 bytes long 62 63 * - PTE's replace EntryLo v (valid) bit with p (present) bit 63 * - PTE's use only one bit to distinguish between cacheable and uncacheable mappings 64 * - PTE's define soft_valid field to ensure there is at least one 1 bit even if the p bit is cleared 65 * - PTE's make use of CP0 EntryLo's two-bit reserved field for bit W (writable) and bit A (accessed) 64 * - PTE's use only one bit to distinguish between cacheable and uncacheable 65 * mappings 66 * - PTE's define soft_valid field to ensure there is at least one 1 bit even if 67 * the p bit is cleared 68 * - PTE's make use of CP0 EntryLo's two-bit reserved field for bit W (writable) 69 * and bit A (accessed) 66 70 * - PTL0 has 64 entries (6 bits) 67 71 * - PTL1 is not used … … 70 74 */ 71 75 76 /* Macros describing number of entries in each level. */ 72 77 #define PTL0_ENTRIES_ARCH 64 73 78 #define PTL1_ENTRIES_ARCH 0 … … 75 80 #define PTL3_ENTRIES_ARCH 4096 76 81 77 #define PTL0_SIZE_ARCH ONE_FRAME 78 #define PTL1_SIZE_ARCH 0 79 #define PTL2_SIZE_ARCH 0 80 #define PTL3_SIZE_ARCH ONE_FRAME 82 /* Macros describing size of page tables in each level. */ 83 #define PTL0_SIZE_ARCH ONE_FRAME 84 #define PTL1_SIZE_ARCH 0 85 #define PTL2_SIZE_ARCH 0 86 #define PTL3_SIZE_ARCH ONE_FRAME 81 87 82 #define PTL0_INDEX_ARCH(vaddr) ((vaddr)>>26) 83 #define PTL1_INDEX_ARCH(vaddr) 0 84 #define PTL2_INDEX_ARCH(vaddr) 0 85 #define PTL3_INDEX_ARCH(vaddr) (((vaddr)>>14) & 0xfff) 88 /* Macros calculating entry indices for each level. */ 89 #define PTL0_INDEX_ARCH(vaddr) ((vaddr) >> 26) 90 #define PTL1_INDEX_ARCH(vaddr) 0 91 #define PTL2_INDEX_ARCH(vaddr) 0 92 #define PTL3_INDEX_ARCH(vaddr) (((vaddr) >> 14) & 0xfff) 86 93 94 /* Set accessor for PTL0 address. */ 87 95 #define SET_PTL0_ADDRESS_ARCH(ptl0) 88 96 89 #define GET_PTL1_ADDRESS_ARCH(ptl0, i) (((pte_t *)(ptl0))[(i)].pfn<<12) 90 #define GET_PTL2_ADDRESS_ARCH(ptl1, i) (ptl1) 91 #define GET_PTL3_ADDRESS_ARCH(ptl2, i) (ptl2) 92 #define GET_FRAME_ADDRESS_ARCH(ptl3, i) (((pte_t *)(ptl3))[(i)].pfn<<12) 97 /* Get PTE address accessors for each level. */ 98 #define GET_PTL1_ADDRESS_ARCH(ptl0, i) \ 99 (((pte_t *) (ptl0))[(i)].pfn << 12) 100 #define GET_PTL2_ADDRESS_ARCH(ptl1, i) \ 101 (ptl1) 102 #define GET_PTL3_ADDRESS_ARCH(ptl2, i) \ 103 (ptl2) 104 #define GET_FRAME_ADDRESS_ARCH(ptl3, i) \ 105 (((pte_t *) (ptl3))[(i)].pfn << 12) 93 106 94 #define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) (((pte_t *)(ptl0))[(i)].pfn = (a)>>12) 107 /* Set PTE address accessors for each level. */ 108 #define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) \ 109 (((pte_t *) (ptl0))[(i)].pfn = (a) >> 12) 95 110 #define SET_PTL2_ADDRESS_ARCH(ptl1, i, a) 96 111 #define SET_PTL3_ADDRESS_ARCH(ptl2, i, a) 97 #define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) (((pte_t *)(ptl3))[(i)].pfn = (a)>>12) 112 #define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) \ 113 (((pte_t *) (ptl3))[(i)].pfn = (a) >> 12) 98 114 99 #define GET_PTL1_FLAGS_ARCH(ptl0, i) get_pt_flags((pte_t *)(ptl0), (index_t)(i)) 100 #define GET_PTL2_FLAGS_ARCH(ptl1, i) PAGE_PRESENT 101 #define GET_PTL3_FLAGS_ARCH(ptl2, i) PAGE_PRESENT 102 #define GET_FRAME_FLAGS_ARCH(ptl3, i) get_pt_flags((pte_t *)(ptl3), (index_t)(i)) 115 /* Get PTE flags accessors for each level. */ 116 #define GET_PTL1_FLAGS_ARCH(ptl0, i) \ 117 get_pt_flags((pte_t *) (ptl0), (index_t) (i)) 118 #define GET_PTL2_FLAGS_ARCH(ptl1, i) \ 119 PAGE_PRESENT 120 #define GET_PTL3_FLAGS_ARCH(ptl2, i) \ 121 PAGE_PRESENT 122 #define GET_FRAME_FLAGS_ARCH(ptl3, i) \ 123 get_pt_flags((pte_t *) (ptl3), (index_t) (i)) 103 124 104 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) set_pt_flags((pte_t *)(ptl0), (index_t)(i), (x)) 125 /* Set PTE flags accessors for each level. */ 126 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) \ 127 set_pt_flags((pte_t *) (ptl0), (index_t) (i), (x)) 105 128 #define SET_PTL2_FLAGS_ARCH(ptl1, i, x) 106 129 #define SET_PTL3_FLAGS_ARCH(ptl2, i, x) 107 #define SET_FRAME_FLAGS_ARCH(ptl3, i, x) set_pt_flags((pte_t *)(ptl3), (index_t)(i), (x)) 130 #define SET_FRAME_FLAGS_ARCH(ptl3, i, x) \ 131 set_pt_flags((pte_t *) (ptl3), (index_t) (i), (x)) 108 132 133 /* Last-level info macros. */ 109 134 #define PTE_VALID_ARCH(pte) (*((uint32_t *) (pte)) != 0) 110 135 #define PTE_PRESENT_ARCH(pte) ((pte)->p != 0) 111 #define PTE_GET_FRAME_ARCH(pte) ((pte)->pfn <<12)136 #define PTE_GET_FRAME_ARCH(pte) ((pte)->pfn << 12) 112 137 #define PTE_WRITABLE_ARCH(pte) ((pte)->w != 0) 113 138 #define PTE_EXECUTABLE_ARCH(pte) 1 … … 122 147 pte_t *p = &pt[i]; 123 148 124 return ( 125 (p->cacheable<<PAGE_CACHEABLE_SHIFT) | 126 ((!p->p)<<PAGE_PRESENT_SHIFT) | 127 (1<<PAGE_USER_SHIFT) | 128 (1<<PAGE_READ_SHIFT) | 129 ((p->w)<<PAGE_WRITE_SHIFT) | 130 (1<<PAGE_EXEC_SHIFT) | 131 (p->g<<PAGE_GLOBAL_SHIFT) 132 ); 133 149 return ((p->cacheable << PAGE_CACHEABLE_SHIFT) | 150 ((!p->p) << PAGE_PRESENT_SHIFT) | 151 (1 << PAGE_USER_SHIFT) | 152 (1 << PAGE_READ_SHIFT) | 153 ((p->w) << PAGE_WRITE_SHIFT) | 154 (1 << PAGE_EXEC_SHIFT) | 155 (p->g << PAGE_GLOBAL_SHIFT)); 134 156 } 135 157 -
kernel/arch/ppc32/include/mm/page.h
r6b781c0 rc03ee1c 33 33 */ 34 34 35 #ifndef __ppc32_PAGE_H__36 #define __ppc32_PAGE_H__35 #ifndef KERN_ppc32_PAGE_H_ 36 #define KERN_ppc32_PAGE_H_ 37 37 38 38 #include <arch/mm/frame.h> … … 66 66 */ 67 67 68 /* Number of entries in each level. */ 68 69 #define PTL0_ENTRIES_ARCH 1024 69 70 #define PTL1_ENTRIES_ARCH 0 … … 71 72 #define PTL3_ENTRIES_ARCH 1024 72 73 73 #define PTL0_SIZE_ARCH ONE_FRAME 74 #define PTL1_SIZE_ARCH 0 75 #define PTL2_SIZE_ARCH 0 76 #define PTL3_SIZE_ARCH ONE_FRAME 74 /* Page table sizes for each level. */ 75 #define PTL0_SIZE_ARCH ONE_FRAME 76 #define PTL1_SIZE_ARCH 0 77 #define PTL2_SIZE_ARCH 0 78 #define PTL3_SIZE_ARCH ONE_FRAME 77 79 80 /* Macros calculating indices into page tables on each level. */ 78 81 #define PTL0_INDEX_ARCH(vaddr) (((vaddr) >> 22) & 0x3ff) 79 82 #define PTL1_INDEX_ARCH(vaddr) 0 … … 81 84 #define PTL3_INDEX_ARCH(vaddr) (((vaddr) >> 12) & 0x3ff) 82 85 83 #define GET_PTL1_ADDRESS_ARCH(ptl0, i) (((pte_t *) (ptl0))[(i)].pfn << 12) 84 #define GET_PTL2_ADDRESS_ARCH(ptl1, i) (ptl1) 85 #define GET_PTL3_ADDRESS_ARCH(ptl2, i) (ptl2) 86 #define GET_FRAME_ADDRESS_ARCH(ptl3, i) (((pte_t *) (ptl3))[(i)].pfn << 12) 86 /* Get PTE address accessors for each level. */ 87 #define GET_PTL1_ADDRESS_ARCH(ptl0, i) \ 88 (((pte_t *) (ptl0))[(i)].pfn << 12) 89 #define GET_PTL2_ADDRESS_ARCH(ptl1, i) \ 90 (ptl1) 91 #define GET_PTL3_ADDRESS_ARCH(ptl2, i) \ 92 (ptl2) 93 #define GET_FRAME_ADDRESS_ARCH(ptl3, i) \ 94 (((pte_t *) (ptl3))[(i)].pfn << 12) 87 95 96 /* Set PTE address accessors for each level. */ 88 97 #define SET_PTL0_ADDRESS_ARCH(ptl0) 89 #define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) (((pte_t *) (ptl0))[(i)].pfn = (a) >> 12) 98 #define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) \ 99 (((pte_t *) (ptl0))[(i)].pfn = (a) >> 12) 90 100 #define SET_PTL2_ADDRESS_ARCH(ptl1, i, a) 91 101 #define SET_PTL3_ADDRESS_ARCH(ptl2, i, a) 92 #define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) (((pte_t *) (ptl3))[(i)].pfn = (a) >> 12) 102 #define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) \ 103 (((pte_t *) (ptl3))[(i)].pfn = (a) >> 12) 93 104 94 #define GET_PTL1_FLAGS_ARCH(ptl0, i) get_pt_flags((pte_t *) (ptl0), (index_t) (i)) 95 #define GET_PTL2_FLAGS_ARCH(ptl1, i) PAGE_PRESENT 96 #define GET_PTL3_FLAGS_ARCH(ptl2, i) PAGE_PRESENT 97 #define GET_FRAME_FLAGS_ARCH(ptl3, i) get_pt_flags((pte_t *) (ptl3), (index_t) (i)) 105 /* Get PTE flags accessors for each level. */ 106 #define GET_PTL1_FLAGS_ARCH(ptl0, i) \ 107 get_pt_flags((pte_t *) (ptl0), (index_t) (i)) 108 #define GET_PTL2_FLAGS_ARCH(ptl1, i) \ 109 PAGE_PRESENT 110 #define GET_PTL3_FLAGS_ARCH(ptl2, i) \ 111 PAGE_PRESENT 112 #define GET_FRAME_FLAGS_ARCH(ptl3, i) \ 113 get_pt_flags((pte_t *) (ptl3), (index_t) (i)) 98 114 99 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) set_pt_flags((pte_t *) (ptl0), (index_t) (i), (x)) 115 /* Set PTE flags accessors for each level. */ 116 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) \ 117 set_pt_flags((pte_t *) (ptl0), (index_t) (i), (x)) 100 118 #define SET_PTL2_FLAGS_ARCH(ptl1, i, x) 101 119 #define SET_PTL3_FLAGS_ARCH(ptl2, i, x) 102 #define SET_FRAME_FLAGS_ARCH(ptl3, i, x) set_pt_flags((pte_t *) (ptl3), (index_t) (i), (x)) 120 #define SET_FRAME_FLAGS_ARCH(ptl3, i, x) \ 121 set_pt_flags((pte_t *) (ptl3), (index_t) (i), (x)) 103 122 123 /* Macros for querying the last-level PTEs. */ 104 124 #define PTE_VALID_ARCH(pte) (*((uint32_t *) (pte)) != 0) 105 125 #define PTE_PRESENT_ARCH(pte) ((pte)->p != 0) … … 117 137 pte_t *p = &pt[i]; 118 138 119 return ( 120 (1 << PAGE_CACHEABLE_SHIFT) | 121 ((!p->p) << PAGE_PRESENT_SHIFT) | 122 (1 << PAGE_USER_SHIFT) | 123 (1 << PAGE_READ_SHIFT) | 124 (1 << PAGE_WRITE_SHIFT) | 125 (1 << PAGE_EXEC_SHIFT) | 126 (p->g << PAGE_GLOBAL_SHIFT) 127 ); 139 return ((1 << PAGE_CACHEABLE_SHIFT) | 140 ((!p->p) << PAGE_PRESENT_SHIFT) | 141 (1 << PAGE_USER_SHIFT) | 142 (1 << PAGE_READ_SHIFT) | 143 (1 << PAGE_WRITE_SHIFT) | 144 (1 << PAGE_EXEC_SHIFT) | 145 (p->g << PAGE_GLOBAL_SHIFT)); 128 146 } 129 147 -
kernel/arch/ppc64/include/mm/page.h
r6b781c0 rc03ee1c 66 66 */ 67 67 68 /* Number of entries in each level. */ 68 69 #define PTL0_ENTRIES_ARCH 1024 69 70 #define PTL1_ENTRIES_ARCH 0 … … 71 72 #define PTL3_ENTRIES_ARCH 1024 72 73 74 /* Sizes of page tables in each level. */ 73 75 #define PTL0_SIZE_ARCH ONE_FRAME 74 76 #define PTL1_SIZE_ARCH 0 … … 76 78 #define PTL3_SIZE_ARCH ONE_FRAME 77 79 80 /* Macros calculating indices into page tables in each level. */ 78 81 #define PTL0_INDEX_ARCH(vaddr) (((vaddr) >> 22) & 0x3ff) 79 82 #define PTL1_INDEX_ARCH(vaddr) 0 … … 81 84 #define PTL3_INDEX_ARCH(vaddr) (((vaddr) >> 12) & 0x3ff) 82 85 83 #define GET_PTL1_ADDRESS_ARCH(ptl0, i) (((pte_t *) (ptl0))[(i)].pfn << 12) 84 #define GET_PTL2_ADDRESS_ARCH(ptl1, i) (ptl1) 85 #define GET_PTL3_ADDRESS_ARCH(ptl2, i) (ptl2) 86 #define GET_FRAME_ADDRESS_ARCH(ptl3, i) (((pte_t *) (ptl3))[(i)].pfn << 12) 86 /* Get PTE address accessors for each level. */ 87 #define GET_PTL1_ADDRESS_ARCH(ptl0, i) \ 88 (((pte_t *) (ptl0))[(i)].pfn << 12) 89 #define GET_PTL2_ADDRESS_ARCH(ptl1, i) \ 90 (ptl1) 91 #define GET_PTL3_ADDRESS_ARCH(ptl2, i) \ 92 (ptl2) 93 #define GET_FRAME_ADDRESS_ARCH(ptl3, i) \ 94 (((pte_t *) (ptl3))[(i)].pfn << 12) 87 95 96 /* Set PTE address accessors for each level. */ 88 97 #define SET_PTL0_ADDRESS_ARCH(ptl0) 89 #define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) (((pte_t *) (ptl0))[(i)].pfn = (a) >> 12) 98 #define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) \ 99 (((pte_t *) (ptl0))[(i)].pfn = (a) >> 12) 90 100 #define SET_PTL2_ADDRESS_ARCH(ptl1, i, a) 91 101 #define SET_PTL3_ADDRESS_ARCH(ptl2, i, a) 92 #define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) (((pte_t *) (ptl3))[(i)].pfn = (a) >> 12) 102 #define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) \ 103 (((pte_t *) (ptl3))[(i)].pfn = (a) >> 12) 93 104 94 #define GET_PTL1_FLAGS_ARCH(ptl0, i) get_pt_flags((pte_t *) (ptl0), (index_t) (i)) 95 #define GET_PTL2_FLAGS_ARCH(ptl1, i) PAGE_PRESENT 96 #define GET_PTL3_FLAGS_ARCH(ptl2, i) PAGE_PRESENT 97 #define GET_FRAME_FLAGS_ARCH(ptl3, i) get_pt_flags((pte_t *) (ptl3), (index_t) (i)) 105 /* Get PTE flags accessors for each level. */ 106 #define GET_PTL1_FLAGS_ARCH(ptl0, i) \ 107 get_pt_flags((pte_t *) (ptl0), (index_t) (i)) 108 #define GET_PTL2_FLAGS_ARCH(ptl1, i) \ 109 PAGE_PRESENT 110 #define GET_PTL3_FLAGS_ARCH(ptl2, i) \ 111 PAGE_PRESENT 112 #define GET_FRAME_FLAGS_ARCH(ptl3, i) \ 113 get_pt_flags((pte_t *) (ptl3), (index_t) (i)) 98 114 99 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) set_pt_flags((pte_t *) (ptl0), (index_t) (i), (x)) 115 /* Set PTE flags accessors for each level. */ 116 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) \ 117 set_pt_flags((pte_t *) (ptl0), (index_t) (i), (x)) 100 118 #define SET_PTL2_FLAGS_ARCH(ptl1, i, x) 101 119 #define SET_PTL3_FLAGS_ARCH(ptl2, i, x) 102 #define SET_FRAME_FLAGS_ARCH(ptl3, i, x) set_pt_flags((pte_t *) (ptl3), (index_t) (i), (x)) 120 #define SET_FRAME_FLAGS_ARCH(ptl3, i, x) \ 121 set_pt_flags((pte_t *) (ptl3), (index_t) (i), (x)) 103 122 123 /* Macros for querying the last-level PTEs. */ 104 124 #define PTE_VALID_ARCH(pte) (*((uint32_t *) (pte)) != 0) 105 125 #define PTE_PRESENT_ARCH(pte) ((pte)->p != 0) … … 117 137 pte_t *p = &pt[i]; 118 138 119 return ( 120 (1 << PAGE_CACHEABLE_SHIFT) | 121 ((!p->p) << PAGE_PRESENT_SHIFT) | 122 (1 << PAGE_USER_SHIFT) | 123 (1 << PAGE_READ_SHIFT) | 124 (1 << PAGE_WRITE_SHIFT) | 125 (1 << PAGE_EXEC_SHIFT) | 126 (p->g << PAGE_GLOBAL_SHIFT) 127 ); 139 return ((1 << PAGE_CACHEABLE_SHIFT) | 140 ((!p->p) << PAGE_PRESENT_SHIFT) | 141 (1 << PAGE_USER_SHIFT) | 142 (1 << PAGE_READ_SHIFT) | 143 (1 << PAGE_WRITE_SHIFT) | 144 (1 << PAGE_EXEC_SHIFT) | 145 (p->g << PAGE_GLOBAL_SHIFT)); 128 146 } 129 147 -
kernel/genarch/include/mm/page_ht.h
r6b781c0 rc03ee1c 51 51 52 52 #define PAGE_HT_ENTRIES_BITS 13 53 #define PAGE_HT_ENTRIES (1 <<PAGE_HT_ENTRIES_BITS)53 #define PAGE_HT_ENTRIES (1 << PAGE_HT_ENTRIES_BITS) 54 54 55 /* Macros for querying page hash table PTEs. */ 55 56 #define PTE_VALID(pte) ((pte) != NULL) 56 57 #define PTE_PRESENT(pte) ((pte)->p != 0) -
kernel/genarch/include/mm/page_pt.h
r6b781c0 rc03ee1c 83 83 84 84 /* 85 * These macros are provided to change shape of the 4-level86 * t ree of page tables on respective level.85 * These macros are provided to change the shape of the 4-level tree of page 86 * tables on respective level. 87 87 */ 88 88 #define SET_PTL1_ADDRESS(ptl0, i, a) SET_PTL1_ADDRESS_ARCH(ptl0, i, a) … … 107 107 #define SET_FRAME_FLAGS(ptl3, i, x) SET_FRAME_FLAGS_ARCH(ptl3, i, x) 108 108 109 /* 110 * Macros for querying the last-level PTEs. 111 */ 109 112 #define PTE_VALID(p) PTE_VALID_ARCH((p)) 110 113 #define PTE_PRESENT(p) PTE_PRESENT_ARCH((p)) … … 119 122 extern page_mapping_operations_t pt_mapping_operations; 120 123 121 extern void page_mapping_insert_pt(as_t *as, uintptr_t page, uintptr_t frame, int flags); 124 extern void page_mapping_insert_pt(as_t *as, uintptr_t page, uintptr_t frame, 125 int flags); 122 126 extern pte_t *page_mapping_find_pt(as_t *as, uintptr_t page); 123 127 -
kernel/generic/src/mm/backend_elf.c
r6b781c0 rc03ee1c 327 327 btree_insert(&area->sh_info->pagemap, 328 328 (base + j * PAGE_SIZE) - area->base, 329 329 (void *) PTE_GET_FRAME(pte), NULL); 330 330 page_table_unlock(area->as, false); 331 331 -
kernel/generic/src/syscall/syscall.c
r6b781c0 rc03ee1c 93 93 94 94 /** Dispatch system call */ 95 unative_t syscall_handler(unative_t a1, unative_t a2, unative_t a3, 96 unative_t a4,unative_t id)95 unative_t syscall_handler(unative_t a1, unative_t a2, unative_t a3, unative_t a4, 96 unative_t id) 97 97 { 98 98 unative_t rc; … … 101 101 rc = syscall_table[id](a1, a2, a3, a4); 102 102 else { 103 klog_printf("TASK %llu: Unknown syscall id %d",TASK->taskid,id); 103 klog_printf("TASK %llu: Unknown syscall id %d", TASK->taskid, 104 id); 104 105 task_kill(TASK->taskid); 105 106 thread_exit();
Note:
See TracChangeset
for help on using the changeset viewer.