aboutsummaryrefslogtreecommitdiff
path: root/pk
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@cs.berkeley.edu>2016-02-28 20:42:24 -0800
committerAndrew Waterman <waterman@cs.berkeley.edu>2016-02-28 20:42:24 -0800
commit75471727f834ba6e227804a2b7330658a65f700a (patch)
tree8720ea479543d1795724ef54b0fa03f160f466a1 /pk
parent4991166b0c9a676ead9eb92980db646c680c097b (diff)
downloadpk-75471727f834ba6e227804a2b7330658a65f700a.zip
pk-75471727f834ba6e227804a2b7330658a65f700a.tar.gz
pk-75471727f834ba6e227804a2b7330658a65f700a.tar.bz2
New definitions of misa/marchid/mvendorid
Diffstat (limited to 'pk')
-rw-r--r--pk/devicetree.c2
-rw-r--r--pk/encoding.h37
-rw-r--r--pk/mtrap.h8
3 files changed, 25 insertions, 22 deletions
diff --git a/pk/devicetree.c b/pk/devicetree.c
index a60645a..2c236a5 100644
--- a/pk/devicetree.c
+++ b/pk/devicetree.c
@@ -85,7 +85,7 @@ out:
void parse_device_tree()
{
- struct fdt_header* hdr = (struct fdt_header*)read_csr(miobase);
+ struct fdt_header* hdr = (struct fdt_header*)read_csr(mcfgaddr);
debug_printk("reading device tree at %p\n", hdr);
kassert(ntohl(hdr->magic) == FDT_MAGIC);
char* strings = (char*)hdr + ntohl(hdr->off_dt_strings);
diff --git a/pk/encoding.h b/pk/encoding.h
index a88205f..411a7af 100644
--- a/pk/encoding.h
+++ b/pk/encoding.h
@@ -17,7 +17,8 @@
#define MSTATUS_FS 0x00006000
#define MSTATUS_XS 0x00018000
#define MSTATUS_MPRV 0x00020000
-#define MSTATUS_VM 0x007C0000
+#define MSTATUS_PUM 0x00040000
+#define MSTATUS_VM 0x1F000000
#define MSTATUS32_SD 0x80000000
#define MSTATUS64_SD 0x8000000000000000
@@ -28,7 +29,7 @@
#define SSTATUS_SPP 0x00000100
#define SSTATUS_FS 0x00006000
#define SSTATUS_XS 0x00018000
-#define SSTATUS_VM 0x007C0000
+#define SSTATUS_PUM 0x00040000
#define SSTATUS32_SD 0x80000000
#define SSTATUS64_SD 0x8000000000000000
@@ -63,8 +64,6 @@
#define IRQ_COP 8
#define IRQ_HOST 9
-#define IMPL_ROCKET 1
-
#define DEFAULT_RSTVEC 0x0
#define DEFAULT_NMIVEC 0x4
#define DEFAULT_MTVEC 0x8
@@ -639,8 +638,8 @@
#define CSR_UARCH14 0xcce
#define CSR_UARCH15 0xccf
#define CSR_SSTATUS 0x100
-#define CSR_STVEC 0x101
#define CSR_SIE 0x104
+#define CSR_STVEC 0x105
#define CSR_SSCRATCH 0x140
#define CSR_SEPC 0x141
#define CSR_SCAUSE 0x142
@@ -654,10 +653,10 @@
#define CSR_STIME 0xd01
#define CSR_STIMEW 0xa01
#define CSR_MSTATUS 0x300
-#define CSR_MTVEC 0x301
#define CSR_MEDELEG 0x302
#define CSR_MIDELEG 0x303
#define CSR_MIE 0x304
+#define CSR_MTVEC 0x305
#define CSR_MTIMECMP 0x321
#define CSR_MSCRATCH 0x340
#define CSR_MEPC 0x341
@@ -666,13 +665,15 @@
#define CSR_MIP 0x344
#define CSR_MIPI 0x345
#define CSR_MTIME 0x701
-#define CSR_MCPUID 0xf00
-#define CSR_MIMPID 0xf01
+#define CSR_MISA 0xf00
+#define CSR_MVENDORID 0xf01
+#define CSR_MARCHID 0xf02
+#define CSR_MIMPID 0xf03
+#define CSR_MCFGADDR 0xf04
#define CSR_MHARTID 0xf10
-#define CSR_MTOHOST 0x780
-#define CSR_MFROMHOST 0x781
-#define CSR_MRESET 0x782
-#define CSR_MIOBASE 0x784
+#define CSR_MTOHOST 0x7c0
+#define CSR_MFROMHOST 0x7c1
+#define CSR_MRESET 0x7c2
#define CSR_CYCLEH 0xc80
#define CSR_TIMEH 0xc81
#define CSR_INSTRETH 0xc82
@@ -682,7 +683,7 @@
#define CSR_STIMEH 0xd81
#define CSR_STIMEHW 0xa81
#define CSR_MTIMECMPH 0x361
-#define CSR_MTIMEH 0x741
+#define CSR_MTIMEH 0x781
#define CAUSE_MISALIGNED_FETCH 0x0
#define CAUSE_FAULT_FETCH 0x1
#define CAUSE_ILLEGAL_INSTRUCTION 0x2
@@ -948,8 +949,8 @@ DECLARE_CSR(uarch13, CSR_UARCH13)
DECLARE_CSR(uarch14, CSR_UARCH14)
DECLARE_CSR(uarch15, CSR_UARCH15)
DECLARE_CSR(sstatus, CSR_SSTATUS)
-DECLARE_CSR(stvec, CSR_STVEC)
DECLARE_CSR(sie, CSR_SIE)
+DECLARE_CSR(stvec, CSR_STVEC)
DECLARE_CSR(sscratch, CSR_SSCRATCH)
DECLARE_CSR(sepc, CSR_SEPC)
DECLARE_CSR(scause, CSR_SCAUSE)
@@ -963,10 +964,10 @@ DECLARE_CSR(instretw, CSR_INSTRETW)
DECLARE_CSR(stime, CSR_STIME)
DECLARE_CSR(stimew, CSR_STIMEW)
DECLARE_CSR(mstatus, CSR_MSTATUS)
-DECLARE_CSR(mtvec, CSR_MTVEC)
DECLARE_CSR(medeleg, CSR_MEDELEG)
DECLARE_CSR(mideleg, CSR_MIDELEG)
DECLARE_CSR(mie, CSR_MIE)
+DECLARE_CSR(mtvec, CSR_MTVEC)
DECLARE_CSR(mtimecmp, CSR_MTIMECMP)
DECLARE_CSR(mscratch, CSR_MSCRATCH)
DECLARE_CSR(mepc, CSR_MEPC)
@@ -975,13 +976,15 @@ DECLARE_CSR(mbadaddr, CSR_MBADADDR)
DECLARE_CSR(mip, CSR_MIP)
DECLARE_CSR(mipi, CSR_MIPI)
DECLARE_CSR(mtime, CSR_MTIME)
-DECLARE_CSR(mcpuid, CSR_MCPUID)
+DECLARE_CSR(misa, CSR_MISA)
+DECLARE_CSR(mvendorid, CSR_MVENDORID)
+DECLARE_CSR(marchid, CSR_MARCHID)
DECLARE_CSR(mimpid, CSR_MIMPID)
+DECLARE_CSR(mcfgaddr, CSR_MCFGADDR)
DECLARE_CSR(mhartid, CSR_MHARTID)
DECLARE_CSR(mtohost, CSR_MTOHOST)
DECLARE_CSR(mfromhost, CSR_MFROMHOST)
DECLARE_CSR(mreset, CSR_MRESET)
-DECLARE_CSR(miobase, CSR_MIOBASE)
DECLARE_CSR(cycleh, CSR_CYCLEH)
DECLARE_CSR(timeh, CSR_TIMEH)
DECLARE_CSR(instreth, CSR_INSTRETH)
diff --git a/pk/mtrap.h b/pk/mtrap.h
index 99308a2..b0369ca 100644
--- a/pk/mtrap.h
+++ b/pk/mtrap.h
@@ -145,21 +145,21 @@ static insn_t __attribute__((always_inline)) get_insn(uintptr_t mepc, uintptr_t*
return insn;
}
-static inline long __attribute__((pure)) cpuid()
+static inline long __attribute__((pure)) isa()
{
long res;
- asm ("csrr %0, mcpuid" : "=r"(res)); // not volatile, so don't use read_csr()
+ asm ("csrr %0, misa" : "=r"(res)); // not volatile, so don't use read_csr()
return res;
}
static inline int supports_extension(char ext)
{
- return cpuid() & (1 << (ext - 'A'));
+ return isa() & (1 << (ext - 'A'));
}
static inline int xlen()
{
- return cpuid() < 0 ? 64 : 32;
+ return isa() < 0 ? 64 : 32;
}
typedef struct {