cpu/mor1kx: fix .data initialization (follow-up to PR #567)
authorGabriel Somlo <gsomlo@gmail.com>
Wed, 17 Jun 2020 00:19:46 +0000 (20:19 -0400)
committerGabriel Somlo <gsomlo@gmail.com>
Wed, 17 Jun 2020 00:28:57 +0000 (20:28 -0400)
litex/soc/cores/cpu/mor1kx/crt0.S

index ff77910dc2671f08f57cd18a7c67dcfa29acc1e0..b8eeec07129ab6774dff827d6bb32f640157caa3 100644 (file)
@@ -153,6 +153,25 @@ _crt0:
     l.movhi    r1, hi(_fstack)
     l.ori     r1, r1, lo(_fstack)
 
+    /* Init DATA */
+    l.movhi   r14,hi(_fdata_rom)
+    l.ori     r14,r14,lo(_fdata_rom)
+    l.movhi   r18,hi(_fdata)
+    l.ori     r18,r18,lo(_fdata)
+    l.movhi   r20,hi(_edata)
+    l.ori     r20,r20,lo(_edata)
+.copyDATA:
+    l.sfeq    r18,r20
+    l.bf      .doneDATA
+     l.nop
+    l.lwz     r3,0(r14)
+    l.sw      0(r18),r3
+    l.addi    r14,r14,4
+    l.addi    r18,r18,4
+    l.j       .copyDATA
+     l.nop
+.doneDATA:
+
     /* Clear BSS */
     l.movhi    r21, hi(_fbss)
     l.ori     r21, r21, lo(_fbss)