Changes in kernel/arch/amd64/include/mm/page.h [a1f60f3:214ec25c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/include/mm/page.h
ra1f60f3 r214ec25c 35 35 /** Paging on AMD64 36 36 * 37 * The space is divided in positive numbers (uspace) and 38 * negative numbers (kernel). The 'negative' space starting 39 * with 0xffff800000000000 and ending with 0xffffffffffffffff 40 * is identically mapped physical memory. 41 * 37 * The space is divided in positive numbers - userspace and 38 * negative numbers - kernel space. The 'negative' space starting 39 * with 0xffff800000000000 and ending with 0xffffffff80000000 40 * (-2GB) is identically mapped physical memory. The area 41 * (0xffffffff80000000 ... 0xffffffffffffffff is again identically 42 * mapped first 2GB. 43 * 44 * ATTENTION - PA2KA(KA2PA(x)) != x if 'x' is in kernel 42 45 */ 43 46 … … 47 50 #include <arch/mm/frame.h> 48 51 49 #define PAGE_WIDTH 50 #define PAGE_SIZE 52 #define PAGE_WIDTH FRAME_WIDTH 53 #define PAGE_SIZE FRAME_SIZE 51 54 52 55 #ifdef KERNEL 53 56 54 57 #ifndef __ASM__ 55 56 #define KA2PA(x) (((uintptr_t) (x)) - 0xffff800000000000) 57 #define PA2KA(x) (((uintptr_t) (x)) + 0xffff800000000000) 58 59 #else /* __ASM__ */ 60 61 #define KA2PA(x) ((x) - 0xffff800000000000) 62 #define PA2KA(x) ((x) + 0xffff800000000000) 63 64 #endif /* __ASM__ */ 58 # include <mm/mm.h> 59 # include <typedefs.h> 60 # include <arch/interrupt.h> 61 62 static inline uintptr_t ka2pa(uintptr_t x) 63 { 64 if (x > 0xffffffff80000000) 65 return x - 0xffffffff80000000; 66 else 67 return x - 0xffff800000000000; 68 } 69 70 # define KA2PA(x) ka2pa((uintptr_t) x) 71 # define PA2KA_CODE(x) (((uintptr_t) (x)) + 0xffffffff80000000) 72 # define PA2KA(x) (((uintptr_t) (x)) + 0xffff800000000000) 73 #else 74 # define KA2PA(x) ((x) - 0xffffffff80000000) 75 # define PA2KA(x) ((x) + 0xffffffff80000000) 76 #endif 65 77 66 78 /* Number of entries in each level. */ 67 #define PTL0_ENTRIES_ARCH 68 #define PTL1_ENTRIES_ARCH 69 #define PTL2_ENTRIES_ARCH 70 #define PTL3_ENTRIES_ARCH 79 #define PTL0_ENTRIES_ARCH 512 80 #define PTL1_ENTRIES_ARCH 512 81 #define PTL2_ENTRIES_ARCH 512 82 #define PTL3_ENTRIES_ARCH 512 71 83 72 84 /* Page table sizes for each level. */ 73 #define PTL0_SIZE_ARCH 74 #define PTL1_SIZE_ARCH 75 #define PTL2_SIZE_ARCH 76 #define PTL3_SIZE_ARCH 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 77 89 78 90 /* Macros calculating indices into page tables in each level. */ 79 #define PTL0_INDEX_ARCH(vaddr) 80 #define PTL1_INDEX_ARCH(vaddr) 81 #define PTL2_INDEX_ARCH(vaddr) 82 #define PTL3_INDEX_ARCH(vaddr) 91 #define PTL0_INDEX_ARCH(vaddr) (((vaddr) >> 39) & 0x1ff) 92 #define PTL1_INDEX_ARCH(vaddr) (((vaddr) >> 30) & 0x1ff) 93 #define PTL2_INDEX_ARCH(vaddr) (((vaddr) >> 21) & 0x1ff) 94 #define PTL3_INDEX_ARCH(vaddr) (((vaddr) >> 12) & 0x1ff) 83 95 84 96 /* Get PTE address accessors for each level. */ … … 144 156 #ifndef __ASM__ 145 157 146 #include <mm/mm.h>147 #include <arch/interrupt.h>148 #include <typedefs.h>149 150 158 /* Page fault error codes. */ 151 159 … … 153 161 * page. 154 162 */ 155 #define PFERR_CODE_P (1 << 0)163 #define PFERR_CODE_P (1 << 0) 156 164 157 165 /** When bit on this position is 1, the page fault was caused by a write. */ 158 #define PFERR_CODE_RW (1 << 1)166 #define PFERR_CODE_RW (1 << 1) 159 167 160 168 /** When bit on this position is 1, the page fault was caused in user mode. */ 161 #define PFERR_CODE_US (1 << 2)169 #define PFERR_CODE_US (1 << 2) 162 170 163 171 /** When bit on this position is 1, a reserved bit was set in page directory. */ 164 #define PFERR_CODE_RSVD (1 << 3)172 #define PFERR_CODE_RSVD (1 << 3) 165 173 166 174 /** When bit on this position os 1, the page fault was caused during instruction 167 175 * fecth. 168 176 */ 169 #define PFERR_CODE_ID 177 #define PFERR_CODE_ID (1 << 4) 170 178 171 179 /** Page Table Entry. */ 172 180 typedef struct { 173 unsigned intpresent : 1;174 unsigned intwriteable : 1;175 unsigned intuaccessible : 1;176 unsigned intpage_write_through : 1;177 unsigned intpage_cache_disable : 1;178 unsigned intaccessed : 1;179 unsigned intdirty : 1;180 unsigned intunused: 1;181 unsigned intglobal : 1;182 unsigned int soft_valid : 1;/**< Valid content even if present bit is cleared. */183 unsigned intavl : 2;184 unsigned intaddr_12_31 : 30;185 unsigned intaddr_32_51 : 21;186 unsigned intno_execute : 1;181 unsigned present : 1; 182 unsigned writeable : 1; 183 unsigned uaccessible : 1; 184 unsigned page_write_through : 1; 185 unsigned page_cache_disable : 1; 186 unsigned accessed : 1; 187 unsigned dirty : 1; 188 unsigned unused: 1; 189 unsigned global : 1; 190 unsigned soft_valid : 1; /**< Valid content even if present bit is cleared. */ 191 unsigned avl : 2; 192 unsigned addr_12_31 : 30; 193 unsigned addr_32_51 : 21; 194 unsigned no_execute : 1; 187 195 } __attribute__ ((packed)) pte_t; 188 196 … … 203 211 { 204 212 pte_t *p = &pt[i]; 205 213 206 214 p->addr_12_31 = (a >> 12) & 0xfffff; 207 215 p->addr_32_51 = a >> 32;
Note:
See TracChangeset
for help on using the changeset viewer.