Rev 2278 | Rev 2298 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2278 | Rev 2284 | ||
---|---|---|---|
Line 36... | Line 36... | ||
36 | #include <arch/debug_print/print.h> |
36 | #include <arch/debug_print/print.h> |
37 | #include <arch/mm/page_fault.h> |
37 | #include <arch/mm/page_fault.h> |
38 | #include <mm/as.h> |
38 | #include <mm/as.h> |
39 | #include <genarch/mm/page_pt.h> |
39 | #include <genarch/mm/page_pt.h> |
40 | #include <arch.h> |
40 | #include <arch.h> |
- | 41 | #include <interrupt.h> |
|
41 | 42 | ||
42 | 43 | ||
43 | //TODO: remove in final version |
44 | //TODO: remove in final version |
44 | static void print_istate(istate_t* istate); |
45 | static void print_istate(istate_t* istate); |
45 | static void print_istate(istate_t* istate) { |
46 | static void print_istate(istate_t* istate) { |
Line 135... | Line 136... | ||
135 | instruction_union_t tmp; |
136 | instruction_union_t tmp; |
136 | tmp.ip = instr_addr; |
137 | tmp.ip = instr_addr; |
137 | // get instruction op code |
138 | // get instruction op code |
138 | instruction_t i_code = *(tmp.instr); |
139 | instruction_t i_code = *(tmp.instr); |
139 | 140 | ||
140 | dprintf("get_instruction_memmory_access\n"); |
141 | // dprintf("get_instruction_memmory_access\n"); |
141 | dprintf(" instr_addr:%X\n",instr_addr); |
142 | // dprintf(" instr_addr:%X\n",instr_addr); |
142 | dprintf(" i_code:%X\n",i_code); |
143 | // dprintf(" i_code:%X\n",i_code); |
143 | dprintf(" i_code.condition:%d\n", i_code.condition); |
144 | // dprintf(" i_code.condition:%d\n", i_code.condition); |
144 | dprintf(" i_code.instr_type:%d\n",i_code.instr_type); |
145 | // dprintf(" i_code.instr_type:%d\n",i_code.instr_type); |
145 | dprintf(" i_code.opcode:%d\n",i_code.opcode); |
146 | // dprintf(" i_code.opcode:%d\n",i_code.opcode); |
146 | dprintf(" i_code.acess:%d\n", i_code.access); |
147 | // dprintf(" i_code.acess:%d\n", i_code.access); |
147 | dprintf(" i_code.dummy:%d\n", i_code.dummy); |
148 | // dprintf(" i_code.dummy:%d\n", i_code.dummy); |
148 | dprintf(" i_code.bits567%d\n", i_code.bits567); |
149 | // dprintf(" i_code.bits567%d\n", i_code.bits567); |
149 | dprintf(" i_code.bit4:%d\n", i_code.bit4); |
150 | // dprintf(" i_code.bit4:%d\n", i_code.bit4); |
150 | dprintf(" i_code.dummy1:%d\n", i_code.dummy1); |
151 | // dprintf(" i_code.dummy1:%d\n", i_code.dummy1); |
151 | 152 | ||
152 | 153 | ||
153 | // undefined instructions ... (or special instructions) |
154 | // undefined instructions ... (or special instructions) |
154 | if (i_code.condition == 0xf) { |
155 | if (i_code.condition == 0xf) { |
155 | panic("page_fault - on instruction not acessing to memmory (instr_code:%X, badvaddr:%X)",i_code, badvaddr); |
156 | panic("page_fault - on instruction not acessing to memmory (instr_code:%X, badvaddr:%X)",i_code, badvaddr); |
Line 207... | Line 208... | ||
207 | fault_status_t fsr = read_fault_status_register(); |
208 | fault_status_t fsr = read_fault_status_register(); |
208 | uintptr_t page = read_fault_address_register(); |
209 | uintptr_t page = read_fault_address_register(); |
209 | 210 | ||
210 | pf_access_t access = get_memmory_access_type( istate->lr, page); |
211 | pf_access_t access = get_memmory_access_type( istate->lr, page); |
211 | 212 | ||
212 | print_istate(istate); |
213 | // print_istate(istate); |
213 | dprintf(" page fault : ip:%X, va:%X, status:%x(%x), access:%d\n", istate->lr, page, fsr.status,fsr, access); |
214 | dprintf(" page fault : ip:%X, va:%X, status:%x(%x), access:%d\n", istate->lr, page, fsr.status,fsr, access); |
214 | 215 | ||
215 | /* Alf: Will be commented until stack problem will be solved ... |
216 | /* Alf: Will be commented until stack problem will be solved ... |
216 | as_page_fault make consequent page faults |
217 | as_page_fault make consequent page faults*/ |
217 | 218 | ||
218 | int ret = as_page_fault(page, access, istate); |
219 | int ret = as_page_fault(page, access, istate); |
219 | dprintf(" as_page_fault ret:%d\n", ret); |
220 | dprintf(" as_page_fault ret:%d\n", ret); |
220 | if (ret == AS_PF_FAULT) { |
221 | if (ret == AS_PF_FAULT) { |
221 | fault_if_from_uspace(istate, "Page fault: %#x", page); |
222 | fault_if_from_uspace(istate, "Page fault: %#x", page); |
222 | 223 | ||
223 | panic("page fault\n"); |
224 | panic("page fault\n"); |
224 | } |
225 | } |
225 | */ |
226 | |
226 | // TODO: Remove this ... now for testing purposes ... it's bad to test page faults in kernel, where no page faults should occures |
227 | // TODO: Remove this ... now for testing purposes ... it's bad to test page faults in kernel, where no page faults should occures |
227 | panic("page fault ... solved\n"); |
228 | panic("page fault ... solved\n"); |
228 | 229 | ||
229 | } |
230 | } |
230 | 231 | ||
Line 238... | Line 239... | ||
238 | // Prefetch can be made be bkpt instruction |
239 | // Prefetch can be made be bkpt instruction |
239 | print_istate(istate); |
240 | print_istate(istate); |
240 | dprintf(" prefetch_abourt ... instruction on adress:%x can't be fetched\n", istate->lr); |
241 | dprintf(" prefetch_abourt ... instruction on adress:%x can't be fetched\n", istate->lr); |
241 | 242 | ||
242 | /* Alf: Will be commented until stack problem will be solved ... |
243 | /* Alf: Will be commented until stack problem will be solved ... |
243 | as_page_fault make consequent page faults |
244 | as_page_fault make consequent page faults*/ |
244 | 245 | ||
245 | int ret = as_page_fault(istate->lr, PF_ACCESS_EXEC, istate); |
246 | int ret = as_page_fault(istate->lr, PF_ACCESS_EXEC, istate); |
246 | dprintf(" as_page_fault ret:%d\n", ret); |
247 | dprintf(" as_page_fault ret:%d\n", ret); |
247 | if (ret == AS_PF_FAULT) { |
248 | if (ret == AS_PF_FAULT) { |
248 | panic("page fault - instruction fetch at addr:%X\n", istate->lr); |
249 | panic("page fault - instruction fetch at addr:%X\n", istate->lr); |
249 | } |
250 | } |
250 | */ |
251 | |
251 | 252 | ||
252 | panic("Prefetch abourt ... solved"); |
253 | panic("Prefetch abourt ... solved"); |
253 | } |
254 | } |
254 | 255 | ||
255 | /** @} |
256 | /** @} |