|
|
|
@ -45,6 +45,7 @@ void cpu_init() |
|
|
|
|
pthread_mutex_init(&cpu0_mutex, 0); |
|
|
|
|
pthread_cond_init(&cpu0->sim_condition, 0); |
|
|
|
|
cpu0->regs.zero = 0; |
|
|
|
|
cpu0->privilege_mode = MACHINE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void cpu_decode(raw_instruction_t raw_instruction, instruction_t* output) |
|
|
|
@ -523,8 +524,10 @@ static void cpu_execute(rv32_cpu_t* cpu, instruction_t* instruction) |
|
|
|
|
fprintf(stderr, "SRET: We don't support that.\n"); |
|
|
|
|
break; |
|
|
|
|
case IMM_MRET: |
|
|
|
|
// Act like a normal ret/jalr, with destination address being CSR_MEPC content
|
|
|
|
|
fprintf(stderr, "Warning: MRET: We don't support privilege mode change\n"); |
|
|
|
|
// Ret to destination address : CSR_MEPC content
|
|
|
|
|
// Change privilege mode to SUPERVISOR
|
|
|
|
|
// TODO : Pop lower-privilege interrupt enable and privilege mode stack
|
|
|
|
|
cpu->privilege_mode = SUPERVISOR; |
|
|
|
|
cpu->pc = cpu->csr[CSR_MEPC] - 4; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|