chore: code clean up

This commit is contained in:
William Wang 2022-05-05 17:51:47 +08:00
parent f201776cae
commit 88d75d286c
4 changed files with 4 additions and 16 deletions

View File

@ -157,18 +157,6 @@ void custom_handler_reg(uintptr_t code, _Context*(*handler)(_Event, _Context*))
}
}
void register_handler(uintptr_t code, _Context*(*handler)(_Event*, _Context*)) {
if (INTR_BIT & code) { // is interrupt
int cause = code % INTERRUPT_CAUSE_SIZE;
printf("Register handler for %d interrupt\n", cause);
interrupt_handler[cause] = handler;
} else { // is exception
int cause = code % EXCEPTION_CAUSE_SIZE;
printf("Register handler for %d exception\n", cause);
exception_handler[cause] = handler;
}
}
/*
* Generic interrupt/exception handler register function
* code: scause code

View File

@ -66,7 +66,7 @@ void stip_handler_reg(_Context*(*handler)(_Event, _Context*));
void seip_handler_reg(_Context*(*handler)(_Event, _Context*));
void secall_handler_reg(_Context*(*handler)(_Event, _Context*));
void custom_handler_reg(uintptr_t code, _Context*(*handler)(_Event, _Context*));
void register_handler(uintptr_t code, _Context*(*handler)(_Event*, _Context*));
void irq_handler_reg(uintptr_t code, _Context*(*handler)(_Event*, _Context*));
#ifdef __cplusplus
}

View File

@ -24,7 +24,7 @@ _Context* store_access_fault_handler(_Event* ev, _Context *c) {
}
void pmp_test() {
register_handler(EXCEPTION_STORE_ACCESS_FAULT, &store_access_fault_handler);
irq_handler_reg(EXCEPTION_STORE_ACCESS_FAULT, &store_access_fault_handler);
printf("start pmp test\n");
#if defined(__ARCH_RISCV64_NOOP) || defined(__ARCH_RISCV32_NOOP) || defined(__ARCH_RISCV64_XS)
#ifdef PMP_1

View File

@ -84,8 +84,8 @@ void sv39_test() {
// invalid arch
_halt(1);
#endif
register_handler(EXCEPTION_STORE_PAGE_FAULT, &store_page_fault_handler);
register_handler(EXCEPTION_LOAD_PAGE_FAULT, &load_page_fault_handler);
irq_handler_reg(EXCEPTION_STORE_PAGE_FAULT, &store_page_fault_handler);
irq_handler_reg(EXCEPTION_LOAD_PAGE_FAULT, &load_page_fault_handler);
printf("test sv39 data write\n");
*w_ptr = 'a';