Added SBI functions

This commit is contained in:
vhaudiquet 2023-10-19 16:18:05 +02:00
parent b1a327cccf
commit 5727356559

View File

@ -6,22 +6,41 @@ void sbi_call(rv32_cpu_t* cpu, uint32_t extension_id, uint32_t func_id)
{ {
switch(extension_id) switch(extension_id)
{ {
case SBI_EXTENSION_BASE:
{
switch(func_id)
{
case SBI_FUNCTION_GET_MVENDOR_ID:
cpu->regs.a0 = 0;
break;
case SBI_FUNCTION_GET_MARCH_ID:
cpu->regs.a0 = 0;
break;
case SBI_FUNCTION_GET_MIMPL_ID:
cpu->regs.a0 = 0;
break;
default:
fprintf(stderr, "sbi_call: unknown function id 0x%x for base extension\n", func_id);
break;
}
break;
}
case SBI_EXTENSION_LEGACY_CONSOLE_PUTCHAR: case SBI_EXTENSION_LEGACY_CONSOLE_PUTCHAR:
{ {
printf("%c", cpu->regs.a0); printf("%c", cpu->regs.a0);
cpu->regs.a0 = 0; cpu->regs.a0 = 0;
break; break;
} }
case SBI_EXTENSION_LEGACY_SHUTDOWN: case SBI_EXTENSION_LEGACY_SHUTDOWN:
{ {
printf("sbi_call: shutdown, goodbye !\n"); printf("sbi_call: shutdown, goodbye !\n");
cpu->sim_ticks_left = 1; cpu->sim_ticks_left = 1;
break; break;
} }
default: default:
{ {
fprintf(stderr, "sbi_call: unknown extension id 0x%x\n", extension_id); fprintf(stderr, "sbi_call: unknown extension id 0x%x\n", extension_id);
break; break;
} }
} }
} }