sort out big/little endian startup on qemu
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 11 Jul 2020 16:38:14 +0000 (17:38 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 11 Jul 2020 16:38:14 +0000 (17:38 +0100)
src/soc/config/endian.py
src/soc/simulator/qemu.py

index eb6e0c3f97be5b76b785d318e469c13e96190e9e..0aaa61c25ea4c59f88cfe0ed7c8bfa9cab4cbee8 100644 (file)
@@ -1,5 +1,5 @@
 global bigendian
-bigendian = 0
+bigendian = 1
 
 def set_endian_mode(mode):
     bigendian = mode
index 89386ea19642da902034f632b34191a4dbe18464..747e4a941b23100afe22aae65b4439c708bec201 100644 (file)
@@ -115,7 +115,7 @@ def run_program(program, initial_mem=None, extra_break_addr=None,
                          bigendian=False):
     q = QemuController(program.binfile.name, bigendian)
     q.connect()
-    q.set_endian(True) # how qemu gets/sets data, NOT sets arch
+    q.set_endian(True) # easier to set variables this way
 
     # Run to the start of the program
     if initial_mem:
@@ -131,6 +131,7 @@ def run_program(program, initial_mem=None, extra_break_addr=None,
     print ("msr", bigendian, hex(msr))
     if bigendian:
         msr &= ~(1<<0)
+        msr = msr & ((1<<64)-1)
     else:
         msr |= (1<<0)
     q.gdb_eval('$msr=%d' % msr)
@@ -147,7 +148,7 @@ def run_program(program, initial_mem=None, extra_break_addr=None,
     if extra_break_addr:
         q.break_address(extra_break_addr)
     q.gdb_continue()
-    q.set_endian(False) # how qemu gets/sets data, NOT sets arch
+    q.set_endian(bigendian)
 
     return q