[coreboot-gerrit] New patch to review for coreboot: arch/riscv: Make CSR numbers independent of binutils

Jonathan Neuschäfer (j.neuschaefer@gmx.net) gerrit at coreboot.org
Fri Jul 22 17:32:37 CEST 2016


Jonathan Neuschäfer (j.neuschaefer at gmx.net) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15797

-gerrit

commit 17761ca338ba217cce3e22097771bb8b598ded94
Author: Jonathan Neuschäfer <j.neuschaefer at gmx.net>
Date:   Fri Jul 22 16:36:02 2016 +0200

    arch/riscv: Make CSR numbers independent of binutils
    
    Change-Id: I8ca5a044f8be8517cddfb13f194833c1f49a46ab
    Signed-off-by: Jonathan Neuschäfer <j.neuschaefer at gmx.net>
---
 src/arch/riscv/include/arch/encoding.h | 88 ++++++++++++++++++++++++++++++++++
 1 file changed, 88 insertions(+)

diff --git a/src/arch/riscv/include/arch/encoding.h b/src/arch/riscv/include/arch/encoding.h
index 767e8c4..94f20ba 100644
--- a/src/arch/riscv/include/arch/encoding.h
+++ b/src/arch/riscv/include/arch/encoding.h
@@ -983,3 +983,91 @@ DECLARE_CAUSE("stimehw", CAUSE_STIMEHW)
 DECLARE_CAUSE("mtimecmph", CAUSE_MTIMECMPH)
 DECLARE_CAUSE("mtimeh", CAUSE_MTIMEH)
 #endif
+
+/*
+ * These definitions make coreboot more independent of the toolchain version:
+ *
+ * For example, without them, read_csr(mhartid) translates into:
+ *   ({
+ *     unsigned long __tmp;
+ *     asm volatile("csrr %0, mhartid" : "=r"(__tmp));
+ *     __tmp;
+ *   })
+ *
+ * The assembler then translates mhartid into a CSR number.
+ *
+ * With these definitions the "asm" line becomes
+ *   asm volatile("csrr %0, " CSR_MHARTID : "=r"(__tmp));
+ * with the CSR_MHARTID defined above. If a CSR number changes in the
+ * specification, we only have to update this file, and do not have to update
+ * binutils, which can be a lot of work.
+ *
+ * Please remove these definitions once the RISC-V Privileged Architecture
+ * Specification and binutils port are stable.
+ */
+#define fflags CSR_FFLAGS
+#define frm CSR_FRM
+#define fcsr CSR_FCSR
+#define cycle CSR_CYCLE
+#define time CSR_TIME
+#define instret CSR_INSTRET
+#define stats CSR_STATS
+#define uarch0 CSR_UARCH0
+#define uarch1 CSR_UARCH1
+#define uarch2 CSR_UARCH2
+#define uarch3 CSR_UARCH3
+#define uarch4 CSR_UARCH4
+#define uarch5 CSR_UARCH5
+#define uarch6 CSR_UARCH6
+#define uarch7 CSR_UARCH7
+#define uarch8 CSR_UARCH8
+#define uarch9 CSR_UARCH9
+#define uarch10 CSR_UARCH10
+#define uarch11 CSR_UARCH11
+#define uarch12 CSR_UARCH12
+#define uarch13 CSR_UARCH13
+#define uarch14 CSR_UARCH14
+#define uarch15 CSR_UARCH15
+#define sstatus CSR_SSTATUS
+#define stvec CSR_STVEC
+#define sie CSR_SIE
+#define sscratch CSR_SSCRATCH
+#define sepc CSR_SEPC
+#define sip CSR_SIP
+#define sptbr CSR_SPTBR
+#define sasid CSR_SASID
+#define cyclew CSR_CYCLEW
+#define timew CSR_TIMEW
+#define instretw CSR_INSTRETW
+#define stime CSR_STIME
+#define scause CSR_SCAUSE
+#define sbadaddr CSR_SBADADDR
+#define stimew CSR_STIMEW
+#define mstatus CSR_MSTATUS
+#define mtvec CSR_MTVEC
+#define mtdeleg CSR_MTDELEG
+#define mie CSR_MIE
+#define mtimecmp CSR_MTIMECMP
+#define mscratch CSR_MSCRATCH
+#define mepc CSR_MEPC
+#define mcause CSR_MCAUSE
+#define mbadaddr CSR_MBADADDR
+#define mip CSR_MIP
+#define mtime CSR_MTIME
+#define mcpuid CSR_MCPUID
+#define mimpid CSR_MIMPID
+#define mhartid CSR_MHARTID
+#define mtohost CSR_MTOHOST
+#define mfromhost CSR_MFROMHOST
+#define mreset CSR_MRESET
+#define send_ipi CSR_SEND_IPI
+#define cycleh CSR_CYCLEH
+#define timeh CSR_TIMEH
+#define instreth CSR_INSTRETH
+#define cyclehw CSR_CYCLEHW
+#define timehw CSR_TIMEHW
+#define instrethw CSR_INSTRETHW
+#define stimeh CSR_STIMEH
+#define stimehw CSR_STIMEHW
+#define mtimecmph CSR_MTIMECMPH
+#define mtimeh CSR_MTIMEH



More information about the coreboot-gerrit mailing list