Subversion Repositories HelenOS

Rev

Rev 2284 | Rev 2304 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2284 Rev 2298
Line 42... Line 42...
42
 
42
 
43
 
43
 
44
//TODO: remove in final version
44
//TODO: remove in final version
45
static void print_istate(istate_t* istate);
45
static void print_istate(istate_t* istate);
46
static void print_istate(istate_t* istate) {
46
static void print_istate(istate_t* istate) {
47
 dprintf("\nIstate dump:\n");
47
    dprintf("\nIstate dump:\n");
48
 dprintf("    r0:%X    r1:%X    r2:%X    r3:%X\n", istate->r0,  istate->r1, istate->r2,  istate->r3);
48
    dprintf("    r0:%X    r1:%X    r2:%X    r3:%X\n", istate->r0,  istate->r1, istate->r2,  istate->r3);
49
 dprintf("    r4:%X    r5:%X    r6:%X    r7:%X\n", istate->r4,  istate->r5, istate->r6,  istate->r7);
49
    dprintf("    r4:%X    r5:%X    r6:%X    r7:%X\n", istate->r4,  istate->r5, istate->r6,  istate->r7);
50
 dprintf("    r8:%X    r8:%X   r10:%X   r11:%X\n", istate->r8,  istate->r9, istate->r10, istate->r11);
50
    dprintf("    r8:%X    r8:%X   r10:%X   r11:%X\n", istate->r8,  istate->r9, istate->r10, istate->r11);
51
 dprintf("   r12:%X    sp:%X    lr:%X  spsr:%X\n", istate->r12, istate->sp, istate->lr,  istate->spsr);
51
    dprintf("   r12:%X    sp:%X    lr:%X  spsr:%X\n", istate->r12, istate->sp, istate->lr,  istate->spsr);
-
 
52
    dprintf("   pc:%X\n", istate->pc);
-
 
53
 
52
}
54
}
53
 
55
 
54
/**
56
/**
55
 * \return Value stored in fault status register
57
 * \return Value stored in fault status register
56
 */
58
 */
Line 206... Line 208...
206
//TODO: remove debug prints in final tested version
208
//TODO: remove debug prints in final tested version
207
void data_abort(int n, istate_t *istate) {
209
void data_abort(int n, istate_t *istate) {
208
        fault_status_t fsr = read_fault_status_register();
210
        fault_status_t fsr = read_fault_status_register();
209
        uintptr_t  page = read_fault_address_register();
211
        uintptr_t  page = read_fault_address_register();
210
 
212
 
211
    pf_access_t access = get_memmory_access_type( istate->lr, page);
213
    pf_access_t access = get_memmory_access_type( istate->pc, page);
212
 
214
 
213
//  print_istate(istate);
215
//  print_istate(istate);
214
    dprintf(" page fault : ip:%X, va:%X, status:%x(%x), access:%d\n", istate->lr, page, fsr.status,fsr, access);
216
    dprintf(" page fault : ip:%X, va:%X, status:%x(%x), access:%d\n", istate->pc, page, fsr.status,fsr, access);
215
 
217
 
216
/* Alf: Will be commented until stack problem will be solved ...
218
/* Alf: Will be commented until stack problem will be solved ...
217
    as_page_fault make consequent page faults*/
219
    as_page_fault make consequent page faults*/
218
 
220
 
219
        int ret = as_page_fault(page, access, istate);
221
        int ret = as_page_fault(page, access, istate);
220
    dprintf(" as_page_fault ret:%d\n", ret);
222
    dprintf(" as_page_fault ret:%d\n", ret);
221
        if (ret == AS_PF_FAULT) {
223
        if (ret == AS_PF_FAULT) {
222
        fault_if_from_uspace(istate, "Page fault: %#x", page);
224
        fault_if_from_uspace(istate, "Page fault: %#x", page);
223
 
-
 
224
                panic("page fault\n");
225
        panic("page fault\n");
225
        }
226
        }
226
 
227
 
227
    // TODO: Remove this ... now for testing purposes ... it's bad to test page faults in kernel, where no page faults should occures
228
    // TODO: Remove this ... now for testing purposes ... it's bad to test page faults in kernel, where no page faults should occures
228
    panic("page fault ... solved\n");
229
//  panic("page fault ... solved\n");
229
 
230
 
230
}
231
}
231
 
232
 
232
/**
233
/**
233
 * Routine that solves exception prefetch_about
234
 * Routine that solves exception prefetch_about
234
 *  ... you try to execute instruction on invalid address
235
 *  ... you try to execute instruction on invalid address
235
 * \param istate State of CPU when prefetch abourt occured
236
 * \param istate State of CPU when prefetch abourt occured
236
 * \param n number of exception
237
 * \param n number of exception
237
 */
238
 */
238
void prefetch_abort(int n, istate_t *istate) {
239
void prefetch_abort(int n, istate_t *istate) {
239
 // Prefetch can be made be bkpt instruction
-
 
240
    print_istate(istate);
240
    print_istate(istate);
241
    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->pc);
242
 
242
 
243
/* Alf: Will be commented until stack problem will be solved ...
243
/* Alf: Will be commented until stack problem will be solved ...
244
    as_page_fault make consequent page faults*/
244
    as_page_fault make consequent page faults*/
245
 
245
 
246
    int ret = as_page_fault(istate->lr, PF_ACCESS_EXEC, istate);
246
    int ret = as_page_fault(istate->pc, PF_ACCESS_EXEC, istate);
247
    dprintf(" as_page_fault ret:%d\n", ret);
247
    dprintf(" as_page_fault ret:%d\n", ret);
248
        if (ret == AS_PF_FAULT) {
248
        if (ret == AS_PF_FAULT) {
249
                panic("page fault - instruction fetch at addr:%X\n", istate->lr);
249
                panic("page fault - instruction fetch at addr:%X\n", istate->pc);
250
        }
250
        }
251
 
251
 
252
 
252
 
253
    panic("Prefetch abourt ... solved");
253
//  panic("Prefetch abourt ... solved");
254
}
254
}
255
 
255
 
256
/** @}
256
/** @}
257
 */
257
 */
258
 
258