Some work on CSR
This commit is contained in:
@ -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 regs[32];
|
||||
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);
|
||||
|
Reference in New Issue
Block a user