aboutsummaryrefslogtreecommitdiff
path: root/riscv/pcr.h
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@cs.berkeley.edu>2013-07-26 20:25:18 -0700
committerAndrew Waterman <waterman@cs.berkeley.edu>2013-07-26 20:25:18 -0700
commit7a16302b4d8049d80bb56a0cd00cc226170c1ca7 (patch)
tree687db59f4bf0adf02d16875bc29c46d15db6f8ea /riscv/pcr.h
parentb357c97b249cdb13cc08f0893d73994662b5be8d (diff)
downloadriscv-isa-sim-7a16302b4d8049d80bb56a0cd00cc226170c1ca7.zip
riscv-isa-sim-7a16302b4d8049d80bb56a0cd00cc226170c1ca7.tar.gz
riscv-isa-sim-7a16302b4d8049d80bb56a0cd00cc226170c1ca7.tar.bz2
New supervisor mode
Diffstat (limited to 'riscv/pcr.h')
-rw-r--r--riscv/pcr.h68
1 files changed, 48 insertions, 20 deletions
diff --git a/riscv/pcr.h b/riscv/pcr.h
index 11bfc65..77cee01 100644
--- a/riscv/pcr.h
+++ b/riscv/pcr.h
@@ -3,18 +3,18 @@
#ifndef _RISCV_PCR_H
#define _RISCV_PCR_H
-#define SR_ET 0x00000001
-#define SR_EF 0x00000002
-#define SR_EV 0x00000004
-#define SR_EC 0x00000008
-#define SR_PS 0x00000010
-#define SR_S 0x00000020
-#define SR_U64 0x00000040
-#define SR_S64 0x00000080
-#define SR_VM 0x00000100
+#define SR_S 0x00000001
+#define SR_PS 0x00000002
+#define SR_EI 0x00000004
+#define SR_PEI 0x00000008
+#define SR_EF 0x00000010
+#define SR_U64 0x00000020
+#define SR_S64 0x00000040
+#define SR_VM 0x00000080
+#define SR_EV 0x00000100
#define SR_IM 0x00FF0000
#define SR_IP 0xFF000000
-#define SR_ZERO ~(SR_ET|SR_EF|SR_EV|SR_EC|SR_PS|SR_S|SR_U64|SR_S64|SR_VM|SR_IM|SR_IP)
+#define SR_ZERO ~(SR_S|SR_PS|SR_EI|SR_PEI|SR_EF|SR_U64|SR_S64|SR_VM|SR_EV|SR_IM|SR_IP)
#define SR_IM_SHIFT 16
#define SR_IP_SHIFT 24
@@ -22,16 +22,18 @@
#define PCR_EPC 1
#define PCR_BADVADDR 2
#define PCR_EVEC 3
-#define PCR_COUNT 4
-#define PCR_COMPARE 5
-#define PCR_CAUSE 6
-#define PCR_PTBR 7
-#define PCR_SEND_IPI 8
-#define PCR_CLR_IPI 9
-#define PCR_COREID 10
-#define PCR_IMPL 11
-#define PCR_K0 12
-#define PCR_K1 13
+#define PCR_CAUSE 4
+#define PCR_PTBR 5
+#define PCR_ASID 6
+#define PCR_FATC 7
+#define PCR_COUNT 8
+#define PCR_COMPARE 9
+#define PCR_SEND_IPI 10
+#define PCR_CLR_IPI 11
+#define PCR_HARTID 12
+#define PCR_IMPL 13
+#define PCR_K0 14
+#define PCR_K1 15
#define PCR_VECBANK 18
#define PCR_VECCFG 19
#define PCR_RESET 29
@@ -65,8 +67,30 @@
#define CAUSE_VECTOR_FAULT_LOAD 30
#define CAUSE_VECTOR_FAULT_STORE 31
+// page table entry (PTE) fields
+#define PTE_V 0x001 // Entry is a page Table descriptor
+#define PTE_T 0x002 // Entry is a page Table, not a terminal node
+#define PTE_G 0x004 // Global
+#define PTE_UR 0x008 // User Write permission
+#define PTE_UW 0x010 // User Read permission
+#define PTE_UX 0x020 // User eXecute permission
+#define PTE_SR 0x040 // Supervisor Read permission
+#define PTE_SW 0x080 // Supervisor Write permission
+#define PTE_SX 0x100 // Supervisor eXecute permission
+#define PTE_PERM (PTE_SR | PTE_SW | PTE_SX | PTE_UR | PTE_UW | PTE_UX)
+
#ifdef __riscv
+#ifdef __riscv64
+# define RISCV_PGLEVELS 3
+# define RISCV_PGSHIFT 13
+#else
+# define RISCV_PGLEVELS 2
+# define RISCV_PGSHIFT 12
+#endif
+#define RISCV_PGLEVEL_BITS 10
+#define RISCV_PGSIZE (1 << RISCV_PGSHIFT)
+
#define ASM_CR(r) _ASM_CR(r)
#define _ASM_CR(r) cr##r
@@ -88,6 +112,10 @@
asm volatile ("clearpcr %0,cr%2,%1" : "=r"(__tmp) : "i"(val), "i"(reg)); \
__tmp; })
+#define rdcycle() ({ unsigned long __tmp; \
+ asm volatile ("rdcycle %0" : "=r"(__tmp)); \
+ __tmp; })
+
#endif
#endif