Permalink
Browse files

Use GAS macros to assemble wcsr/rcsr opcodes for non-standard registers.

Now compiles with normal non-patched binutils.
  • Loading branch information...
1 parent 8f9b733 commit 4da6d2b4141751f40b2cd92ef3efd94cdb6a2703 @dvdkhlng dvdkhlng committed Feb 12, 2012
Showing with 60 additions and 5 deletions.
  1. +8 −5 software/mmu-bios/crt0.S
  2. +52 −0 software/mmu-bios/csr-opcodes.h
View
@@ -22,10 +22,13 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-
+
+
/* Exception handlers - Must be 32 bytes long. */
.section .text, "ax", @progbits
.global _start
+.include "./csr-opcodes.h"
+
_start:
_reset_handler:
xor r0, r0, r0
@@ -133,19 +136,19 @@ loop:
/* TLBVADDR = 0x00000000 */
xor r1, r1, r1
ori r1, r1, 0x0001
- wcsr TLBVADDR, r1
+ WCSR_EXT CSR_TLBVADDR, 1
/* TLBPADDR = 0x00001000 */
xor r1, r1, r1
ori r1, r1, 0x1001
- wcsr TLBPADDR, r1
+ WCSR_EXT CSR_TLBPADDR, 1
/* TLBCTRL = 0x80000010 which is cmd DTLB_UPDATE */
xor r1, r1, r1
ori r1, r1, 5
- wcsr TLBCTRL, r1
+ WCSR_EXT CSR_TLBCTRL, 1
/* TLBCTRL = 0x00000011 which is cmd DTLB_SWITCH_TO_USER_MODE */
xor r1, r1, r1
ori r1, r1, 0x0011
- wcsr TLBCTRL, r1
+ WCSR_EXT CSR_TLBCTRL, 1
/* Now DTLB should be active
* All accesses to virtual page 0 should be remapped to physical page 1
*/
@@ -0,0 +1,52 @@
+/* -*- asm -*-
+ *
+ * Macros to assemble LM32 CSR read/write instructions for *any* CSR, even the
+ * ones not supported by GNU binutils.
+ *
+ * Author: David Kühling <dvdkhlng TA gmx TOD de>
+ * Created: Feb 2012
+ *
+ * License: (at your opinion) GPLv2 or later or LM32 open-source license.
+ */
+
+ .set CSR_IE, 0
+ .set CSR_IM, 1
+ .set CSR_IP, 2
+ .set CSR_ICC, 3
+ .set CSR_DCC, 4
+ .set CSR_CC, 5
+ .set CSR_CFG, 6
+ .set CSR_EBA, 7
+ .set CSR_DC, 8
+ .set CSR_DEBA, 9
+ .set CSR_JTX, 14
+ .set CSR_JRX, 15
+ .set CSR_BP0, 16
+ .set CSR_BP1, 17
+ .set CSR_BP2, 18
+ .set CSR_BP3, 19
+ .set CSR_WP0, 24
+ .set CSR_WP1, 25
+ .set CSR_WP2, 26
+ .set CSR_WP3, 27
+ .set CSR_TLBCTRL, 28
+ .set CSR_TLBVADDR, 29
+ .set CSR_TLBPADDR, 30
+
+ /* usage: WCSR_EXT CSR_NR, REG_NR
+ *
+ * example: WCSR_EXT CSR_IM, 7
+ */
+ .macro WCSR_EXT dst_csr, src_reg
+ .word 0xD0000000+(\dst_csr<<21)+(\src_reg<<16)
+ .endm
+
+ /* usage: RCSR_EXT REG_NR, CSR_NR
+ *
+ * example: RCSR_EXT 5, CSR_IM
+ */
+ .macro RCSR_EXT dst_reg, src_csr
+ .word 0x90000000+(\src_csr<<21)+(\dst_reg<<11)
+ .endm
+
+

0 comments on commit 4da6d2b

Please sign in to comment.