Added MMU
This commit is contained in:
25
src/cpu/exception.c
Normal file
25
src/cpu/exception.c
Normal file
@@ -0,0 +1,25 @@
|
||||
#include "exception.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void exception_trigger(rv32_cpu_t* cpu, uint32_t scause)
|
||||
{
|
||||
// An exception can only be triggered by the CPU itself,
|
||||
// so we know we already own the mutex
|
||||
// We are in the CPU thread itself, but we need
|
||||
// the return of this function to be the beginning of
|
||||
// the cpu loop
|
||||
// To achieve that, we can just call cpu_loop (noreturn)
|
||||
// at the end of this function
|
||||
|
||||
// Save execution context, so that 'mret/sret/..' can restore it
|
||||
// TODO
|
||||
|
||||
// Set PC to STVEC, and set SCAUSE
|
||||
// TODO: If PC cannot be mmu_resolved, throw a 'double fault' ?
|
||||
cpu->pc = cpu->csr[CSR_STVEC];
|
||||
cpu->csr[CSR_SCAUSE] = scause;
|
||||
|
||||
pthread_mutex_unlock(&cpu0_mutex);
|
||||
cpu_loop(cpu);
|
||||
}
|
Reference in New Issue
Block a user