summaryrefslogtreecommitdiff
path: root/emulator/hart.h
diff options
context:
space:
mode:
Diffstat (limited to 'emulator/hart.h')
-rw-r--r--emulator/hart.h25
1 files changed, 22 insertions, 3 deletions
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 <stdint.h>
#include <stdbool.h>
+#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);