Changeset 1ee9ced in mainline
- Timestamp:
- 2006-03-16T16:33:48Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6eb103c
- Parents:
- dabe6333
- Location:
- arch/amd64
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/amd64/include/interrupt.h
rdabe6333 r1ee9ced 89 89 extern void (* eoi_function)(void); 90 90 91 extern void print_info_errcode(int n, istate_t *istate); 91 92 extern void null_interrupt(int n, istate_t *istate); 92 93 extern void gp_fault(int n, istate_t *istate); -
arch/amd64/src/interrupt.c
rdabe6333 r1ee9ced 43 43 #include <proc/thread.h> 44 44 45 staticvoid print_info_errcode(int n, istate_t *istate)45 void print_info_errcode(int n, istate_t *istate) 46 46 { 47 47 char *symbol; … … 93 93 } 94 94 95 96 95 void nm_fault(int n, istate_t *istate) 97 96 { … … 101 100 panic("fpu fault"); 102 101 #endif 103 }104 105 106 /* Definitions for identic page mapper */107 pte_t helper_ptl1[512] __attribute__((aligned (PAGE_SIZE)));108 pte_t helper_ptl2[512] __attribute__((aligned (PAGE_SIZE)));109 pte_t helper_ptl3[512] __attribute__((aligned (PAGE_SIZE)));110 extern pte_t ptl_0; /* From boot.S */111 112 #define PTL1_PRESENT(ptl0, page) (!(GET_PTL1_FLAGS_ARCH(ptl0, PTL0_INDEX_ARCH(page)) & PAGE_NOT_PRESENT))113 #define PTL2_PRESENT(ptl1, page) (!(GET_PTL2_FLAGS_ARCH(ptl1, PTL1_INDEX_ARCH(page)) & PAGE_NOT_PRESENT))114 #define PTL3_PRESENT(ptl2, page) (!(GET_PTL3_FLAGS_ARCH(ptl2, PTL2_INDEX_ARCH(page)) & PAGE_NOT_PRESENT))115 116 #define PTL1_ADDR(ptl0, page) ((pte_t *)PA2KA(GET_PTL1_ADDRESS_ARCH(ptl0, PTL0_INDEX_ARCH(page))))117 #define PTL2_ADDR(ptl1, page) ((pte_t *)PA2KA(GET_PTL2_ADDRESS_ARCH(ptl1, PTL1_INDEX_ARCH(page))))118 #define PTL3_ADDR(ptl2, page) ((pte_t *)PA2KA(GET_PTL3_ADDRESS_ARCH(ptl2, PTL2_INDEX_ARCH(page))))119 120 #define SETUP_PTL1(ptl0, page, tgt) { \121 SET_PTL1_ADDRESS_ARCH(ptl0, PTL0_INDEX_ARCH(page), (__address)KA2PA(tgt)); \122 SET_PTL1_FLAGS_ARCH(ptl0, PTL0_INDEX_ARCH(page), PAGE_WRITE | PAGE_EXEC); \123 }124 #define SETUP_PTL2(ptl1, page, tgt) { \125 SET_PTL2_ADDRESS_ARCH(ptl1, PTL1_INDEX_ARCH(page), (__address)KA2PA(tgt)); \126 SET_PTL2_FLAGS_ARCH(ptl1, PTL1_INDEX_ARCH(page), PAGE_WRITE | PAGE_EXEC); \127 }128 #define SETUP_PTL3(ptl2, page, tgt) { \129 SET_PTL3_ADDRESS_ARCH(ptl2, PTL2_INDEX_ARCH(page), (__address)KA2PA(tgt)); \130 SET_PTL3_FLAGS_ARCH(ptl2, PTL2_INDEX_ARCH(page), PAGE_WRITE | PAGE_EXEC); \131 }132 #define SETUP_FRAME(ptl3, page, tgt) { \133 SET_FRAME_ADDRESS_ARCH(ptl3, PTL3_INDEX_ARCH(page), (__address)KA2PA(tgt)); \134 SET_FRAME_FLAGS_ARCH(ptl3, PTL3_INDEX_ARCH(page), PAGE_WRITE | PAGE_EXEC); \135 }136 137 /** Identic page mapper138 *139 * We need to map whole physical memory identically before the page subsystem140 * is initializaed. This thing clears page table and fills in the specific141 * items.142 */143 void ident_page_fault(int n, istate_t *istate)144 {145 __address page;146 static __address oldpage = 0;147 pte_t *aptl_1, *aptl_2, *aptl_3;148 149 page = read_cr2();150 if (oldpage) {151 /* Unmap old address */152 aptl_1 = PTL1_ADDR(&ptl_0, oldpage);153 aptl_2 = PTL2_ADDR(aptl_1, oldpage);154 aptl_3 = PTL3_ADDR(aptl_2, oldpage);155 156 SET_FRAME_FLAGS_ARCH(aptl_3, PTL3_INDEX_ARCH(oldpage), PAGE_NOT_PRESENT);157 if (aptl_3 == helper_ptl3)158 SET_PTL3_FLAGS_ARCH(aptl_2, PTL2_INDEX_ARCH(oldpage), PAGE_NOT_PRESENT);159 if (aptl_2 == helper_ptl2)160 SET_PTL2_FLAGS_ARCH(aptl_1, PTL1_INDEX_ARCH(oldpage), PAGE_NOT_PRESENT);161 if (aptl_1 == helper_ptl1)162 SET_PTL1_FLAGS_ARCH(&ptl_0, PTL0_INDEX_ARCH(oldpage), PAGE_NOT_PRESENT);163 }164 if (PTL1_PRESENT(&ptl_0, page))165 aptl_1 = PTL1_ADDR(&ptl_0, page);166 else {167 SETUP_PTL1(&ptl_0, page, helper_ptl1);168 aptl_1 = helper_ptl1;169 }170 171 if (PTL2_PRESENT(aptl_1, page))172 aptl_2 = PTL2_ADDR(aptl_1, page);173 else {174 SETUP_PTL2(aptl_1, page, helper_ptl2);175 aptl_2 = helper_ptl2;176 }177 178 if (PTL3_PRESENT(aptl_2, page))179 aptl_3 = PTL3_ADDR(aptl_2, page);180 else {181 SETUP_PTL3(aptl_2, page, helper_ptl3);182 aptl_3 = helper_ptl3;183 }184 185 SETUP_FRAME(aptl_3, page, page);186 187 oldpage = page;188 }189 190 void page_fault(int n, istate_t *istate)191 {192 __address page;193 194 page = read_cr2();195 if (!as_page_fault(page)) {196 print_info_errcode(n, istate);197 printf("Page fault address: %Q\n", page);198 panic("page fault\n");199 }200 102 } 201 103 -
arch/amd64/src/mm/page.c
rdabe6333 r1ee9ced 38 38 #include <memstr.h> 39 39 #include <interrupt.h> 40 #include <print.h> 41 #include <panic.h> 42 43 /* Definitions for identity page mapper */ 44 pte_t helper_ptl1[512] __attribute__((aligned (PAGE_SIZE))); 45 pte_t helper_ptl2[512] __attribute__((aligned (PAGE_SIZE))); 46 pte_t helper_ptl3[512] __attribute__((aligned (PAGE_SIZE))); 47 extern pte_t ptl_0; /* From boot.S */ 48 49 #define PTL1_PRESENT(ptl0, page) (!(GET_PTL1_FLAGS_ARCH(ptl0, PTL0_INDEX_ARCH(page)) & PAGE_NOT_PRESENT)) 50 #define PTL2_PRESENT(ptl1, page) (!(GET_PTL2_FLAGS_ARCH(ptl1, PTL1_INDEX_ARCH(page)) & PAGE_NOT_PRESENT)) 51 #define PTL3_PRESENT(ptl2, page) (!(GET_PTL3_FLAGS_ARCH(ptl2, PTL2_INDEX_ARCH(page)) & PAGE_NOT_PRESENT)) 52 53 #define PTL1_ADDR(ptl0, page) ((pte_t *)PA2KA(GET_PTL1_ADDRESS_ARCH(ptl0, PTL0_INDEX_ARCH(page)))) 54 #define PTL2_ADDR(ptl1, page) ((pte_t *)PA2KA(GET_PTL2_ADDRESS_ARCH(ptl1, PTL1_INDEX_ARCH(page)))) 55 #define PTL3_ADDR(ptl2, page) ((pte_t *)PA2KA(GET_PTL3_ADDRESS_ARCH(ptl2, PTL2_INDEX_ARCH(page)))) 56 57 #define SETUP_PTL1(ptl0, page, tgt) { \ 58 SET_PTL1_ADDRESS_ARCH(ptl0, PTL0_INDEX_ARCH(page), (__address)KA2PA(tgt)); \ 59 SET_PTL1_FLAGS_ARCH(ptl0, PTL0_INDEX_ARCH(page), PAGE_WRITE | PAGE_EXEC); \ 60 } 61 #define SETUP_PTL2(ptl1, page, tgt) { \ 62 SET_PTL2_ADDRESS_ARCH(ptl1, PTL1_INDEX_ARCH(page), (__address)KA2PA(tgt)); \ 63 SET_PTL2_FLAGS_ARCH(ptl1, PTL1_INDEX_ARCH(page), PAGE_WRITE | PAGE_EXEC); \ 64 } 65 #define SETUP_PTL3(ptl2, page, tgt) { \ 66 SET_PTL3_ADDRESS_ARCH(ptl2, PTL2_INDEX_ARCH(page), (__address)KA2PA(tgt)); \ 67 SET_PTL3_FLAGS_ARCH(ptl2, PTL2_INDEX_ARCH(page), PAGE_WRITE | PAGE_EXEC); \ 68 } 69 #define SETUP_FRAME(ptl3, page, tgt) { \ 70 SET_FRAME_ADDRESS_ARCH(ptl3, PTL3_INDEX_ARCH(page), (__address)KA2PA(tgt)); \ 71 SET_FRAME_FLAGS_ARCH(ptl3, PTL3_INDEX_ARCH(page), PAGE_WRITE | PAGE_EXEC); \ 72 } 40 73 41 74 void page_arch_init(void) … … 63 96 } 64 97 } 98 99 /** Identity page mapper 100 * 101 * We need to map whole physical memory identically before the page subsystem 102 * is initializaed. This thing clears page table and fills in the specific 103 * items. 104 */ 105 void ident_page_fault(int n, istate_t *istate) 106 { 107 __address page; 108 static __address oldpage = 0; 109 pte_t *aptl_1, *aptl_2, *aptl_3; 110 111 page = read_cr2(); 112 if (oldpage) { 113 /* Unmap old address */ 114 aptl_1 = PTL1_ADDR(&ptl_0, oldpage); 115 aptl_2 = PTL2_ADDR(aptl_1, oldpage); 116 aptl_3 = PTL3_ADDR(aptl_2, oldpage); 117 118 SET_FRAME_FLAGS_ARCH(aptl_3, PTL3_INDEX_ARCH(oldpage), PAGE_NOT_PRESENT); 119 if (aptl_3 == helper_ptl3) 120 SET_PTL3_FLAGS_ARCH(aptl_2, PTL2_INDEX_ARCH(oldpage), PAGE_NOT_PRESENT); 121 if (aptl_2 == helper_ptl2) 122 SET_PTL2_FLAGS_ARCH(aptl_1, PTL1_INDEX_ARCH(oldpage), PAGE_NOT_PRESENT); 123 if (aptl_1 == helper_ptl1) 124 SET_PTL1_FLAGS_ARCH(&ptl_0, PTL0_INDEX_ARCH(oldpage), PAGE_NOT_PRESENT); 125 } 126 if (PTL1_PRESENT(&ptl_0, page)) 127 aptl_1 = PTL1_ADDR(&ptl_0, page); 128 else { 129 SETUP_PTL1(&ptl_0, page, helper_ptl1); 130 aptl_1 = helper_ptl1; 131 } 132 133 if (PTL2_PRESENT(aptl_1, page)) 134 aptl_2 = PTL2_ADDR(aptl_1, page); 135 else { 136 SETUP_PTL2(aptl_1, page, helper_ptl2); 137 aptl_2 = helper_ptl2; 138 } 139 140 if (PTL3_PRESENT(aptl_2, page)) 141 aptl_3 = PTL3_ADDR(aptl_2, page); 142 else { 143 SETUP_PTL3(aptl_2, page, helper_ptl3); 144 aptl_3 = helper_ptl3; 145 } 146 147 SETUP_FRAME(aptl_3, page, page); 148 149 oldpage = page; 150 } 151 152 void page_fault(int n, istate_t *istate) 153 { 154 __address page; 155 156 page = read_cr2(); 157 if (!as_page_fault(page)) { 158 print_info_errcode(n, istate); 159 printf("Page fault address: %Q\n", page); 160 panic("page fault\n"); 161 } 162 } -
arch/amd64/src/pm.c
rdabe6333 r1ee9ced 172 172 exc_register(i, "undef", (iroutine)null_interrupt); 173 173 } 174 exc_register(13, "gp_fault", gp_fault); 174 175 175 exc_register( 7, "nm_fault", nm_fault); 176 176 exc_register(12, "ss_fault", ss_fault); 177 exc_register(13, "gp_fault", gp_fault); 177 178 exc_register(14, "ident_mapper", ident_page_fault); 178 179 }
Note:
See TracChangeset
for help on using the changeset viewer.