blob: 7135ed7eb9dfad03d15e6259b7e6987de7cf225d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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 hartid;
uint32_t regs[32];
uint32_t pc;
uint8_t priv;
// @Todo Proper memory system
char* mem;
uint32_t mem_size;
// @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);
|