modify qemu.py to set qemu's cr to 0
authorMichael Nolan <mtnolan2640@gmail.com>
Wed, 10 Jun 2020 19:28:30 +0000 (15:28 -0400)
committerMichael Nolan <mtnolan2640@gmail.com>
Wed, 10 Jun 2020 19:28:30 +0000 (15:28 -0400)
src/soc/simulator/qemu.py

index 3c4733a0be2672281c4f7088098627ba5e16f252..1dbdb20562895cb47290370e42bebb9cf5931891 100644 (file)
@@ -28,6 +28,13 @@ class QemuController:
         cmd = '-break-insert *0x{:x}'.format(addr)
         return self.gdb.write(cmd)
 
+    def delete_breakpoint(self, breakpoint=None):
+        breakstring = ''
+        if breakpoint:
+            breakstring = f' {breakpoint}'
+        return self.gdb.write('-break-delete' + breakstring)
+
+
     def get_registers(self):
         return self.gdb.write('-data-list-register-values x')
 
@@ -49,7 +56,6 @@ class QemuController:
     def get_xer(self): return self._get_register('x 69')
     def get_fpscr(self): return self._get_register('x 70')
     def get_mq(self): return self._get_register('x 71')
-
     def get_register(self, num):
         return self._get_register('x {}'.format(num))
 
@@ -59,6 +65,9 @@ class QemuController:
     def gdb_continue(self):
         return self.gdb.write('-exec-continue')
 
+    def gdb_eval(self, expr):
+        return self.gdb.write(f'-data-evaluate-expression {expr}')
+
     def exit(self):
         self.gdb.exit()
         self.qemu_popen.kill()
@@ -70,6 +79,14 @@ class QemuController:
 def run_program(program):
     q = QemuController(program.binfile.name)
     q.connect()
+    # Run to the start of the program
+    q.break_address(0x20000000)
+    q.gdb_continue()
+    # set the CR to 0, matching the simulator
+    q.gdb_eval('$cr=0')
+    # delete the previous breakpoint so loops don't screw things up
+    q.delete_breakpoint()
+    # run to completion
     q.break_address(0x20000000 + program.size())
     q.gdb_continue()
     return q