aboutsummaryrefslogtreecommitdiff
path: root/triscv/include
diff options
context:
space:
mode:
Diffstat (limited to 'triscv/include')
-rw-r--r--triscv/include/triscv/common.h4
-rw-r--r--triscv/include/triscv/cpu.h3
-rw-r--r--triscv/include/triscv/csr.h6
-rw-r--r--triscv/include/triscv/mmu.h4
4 files changed, 14 insertions, 3 deletions
diff --git a/triscv/include/triscv/common.h b/triscv/include/triscv/common.h
index 865f6e5..4f23edc 100644
--- a/triscv/include/triscv/common.h
+++ b/triscv/include/triscv/common.h
@@ -4,8 +4,8 @@
#include <tri.h>
#include <stdint.h>
-typedef uint64_t vm_t;
-typedef uint64_t pm_t;
+typedef int64_t vm_t;
+typedef int64_t pm_t;
/* forward declarations */
struct cpu;
diff --git a/triscv/include/triscv/cpu.h b/triscv/include/triscv/cpu.h
index 05f8b78..aedd1df 100644
--- a/triscv/include/triscv/cpu.h
+++ b/triscv/include/triscv/cpu.h
@@ -11,4 +11,7 @@ void cpu_destroy(struct cpu *cpu);
* update after each cycle? */
void cpu_run(struct cpu *cpu, vm_t start);
+void set_csr(struct cpu *cpu, long i, tri_t t);
+tri_t get_csr(struct cpu *cpu, long i);
+
#endif
diff --git a/triscv/include/triscv/csr.h b/triscv/include/triscv/csr.h
index a805702..0ca03a3 100644
--- a/triscv/include/triscv/csr.h
+++ b/triscv/include/triscv/csr.h
@@ -2,7 +2,11 @@
#define TRISCV_CSR_H
/* first trit is sleep mode, R/W, second trit shutdown, R/W */
-#define CSR_MPOWER 0
+#define CSR_MPOWER -9841
#define RW_MPOWER 0b1111
+#define CSR_SATPP -3280
+#define CSR_SATPO -3279
+#define CSR_SATPN -3278
+
#endif
diff --git a/triscv/include/triscv/mmu.h b/triscv/include/triscv/mmu.h
index c885814..100d9ac 100644
--- a/triscv/include/triscv/mmu.h
+++ b/triscv/include/triscv/mmu.h
@@ -4,6 +4,8 @@
#include <triscv/common.h>
#include <triscv/cpu.h>
+#define BASE_PAGE_SIZE 19683
+
typedef void (*dev_write1_t)(struct cpu *cpu, void *dev, pm_t addr, tri_t t);
typedef void (*dev_write3_t)(struct cpu *cpu, void *dev, pm_t addr, tri_t t);
typedef tri_t (*dev_read1_t)(struct cpu *cpu, void *dev, pm_t addr);
@@ -37,4 +39,6 @@ tri_t mmu_read3(struct cpu *cpu, struct mmu *mmu, vm_t addr);
void mmu_write1(struct cpu *cpu, struct mmu *mmu, vm_t addr, tri_t t);
void mmu_write3(struct cpu *cpu, struct mmu *mmu, vm_t addr, tri_t t);
+tri_t mmu_read_pc(struct cpu *cpu, struct mmu *mmu, vm_t addr);
+
#endif