From f95a85de0082010e4af83e26e99299d601bb48d6 Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Mon, 13 May 2024 00:04:44 +0200 Subject: Some work on CSR --- emulator/hart.h | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'emulator/hart.h') diff --git a/emulator/hart.h b/emulator/hart.h index 8e04d19..7135ed7 100644 --- a/emulator/hart.h +++ b/emulator/hart.h @@ -1,19 +1,38 @@ #pragma once +#include "emulator/csr.h" + #include #include +#define PRIV_U 0 +#define PRIV_S 1 +#define PRIV_M 3 + struct Hart { - uint32_t pc; + uint32_t hartid; + uint32_t regs[32]; + + uint32_t pc; + uint8_t priv; + // @Todo Proper memory system char* mem; uint32_t mem_size; - - bool halted; + + // @Todo Deduplicate per machine + Csr csrs[4096]; + + uint64_t instret; + + // @Todo Deduplicate per machine + uint64_t time; }; typedef struct Hart Hart; +void hart_init(Hart* hart, uint32_t id, char* mem, uint32_t mem_size); + void execute(Hart* hart, uint32_t instruction); void execute_from(Hart* hart, uint32_t start_address); -- cgit