]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
sim: microblaze: hook up libgloss syscalls
authorMike Frysinger <vapier@gentoo.org>
Tue, 27 Apr 2021 03:14:11 +0000 (23:14 -0400)
committerMike Frysinger <vapier@gentoo.org>
Wed, 5 May 2021 01:47:10 +0000 (21:47 -0400)
When in the virtual environment, have brki 8 trigger libgloss syscalls
like other ports.  This also matches the ABI that Linux uses for its
syscalls (ignoring the syscall table differences).

sim/microblaze/ChangeLog
sim/microblaze/interp.c
sim/testsuite/microblaze/ChangeLog
sim/testsuite/microblaze/fail.s [new file with mode: 0644]
sim/testsuite/microblaze/pass.s
sim/testsuite/microblaze/testutils.inc

index 510cddedf7d470c1ed01c3c0557e33f1e59eb921..8300491731d6100b8a6076333299cd33ecba9a9c 100644 (file)
@@ -1,3 +1,8 @@
+2021-05-04  Mike Frysinger  <vapier@gentoo.org>
+
+       * interp.c: Include sim-syscall.h.
+       (sim_engine_run): Call sim_syscall for brki instructions.
+
 2021-05-04  Mike Frysinger  <vapier@gentoo.org>
 
        * configure: Regenerate.
index 2bd067c6dc51f61d035b27cc492d27d94bd76fe4..129291895d1cc9ed9089f85cd5cd0e152d84dc13 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "sim-main.h"
 #include "sim-options.h"
+#include "sim-syscall.h"
 
 #include "microblaze-dis.h"
 
@@ -284,8 +285,18 @@ sim_engine_run (SIM_DESC sd,
                    IMM_ENABLE = 0;
                }
              else
-               /* no delay slot: increment cycle count */
-               bonus_cycles++;
+               {
+                 if (op == brki && IMM == 8)
+                   {
+                     RETREG = sim_syscall (cpu, CPU.regs[12], CPU.regs[5],
+                                           CPU.regs[6], CPU.regs[7],
+                                           CPU.regs[8]);
+                     PC = RD + INST_SIZE;
+                   }
+
+                 /* no delay slot: increment cycle count */
+                 bonus_cycles++;
+               }
            }
        }
 
index b282fc3a31c97bfbb38fc4d9bd45c74363a08738..205646e8a2e001420f7466db9ffe148d01cfa7ef 100644 (file)
@@ -1,3 +1,11 @@
+2021-05-04  Mike Frysinger  <vapier@gentoo.org>
+
+       * pass.s: Delete output line.
+       * testutils.inc (system_call, write): New macros.
+       (exit): Mark nr required.
+       (pass, fail): Call write
+       * fail.s: New test.
+
 2021-04-08  Mike Frysinger  <vapier@gentoo.org>
 
        * allinsn.exp (arch): Delete.
diff --git a/sim/testsuite/microblaze/fail.s b/sim/testsuite/microblaze/fail.s
new file mode 100644 (file)
index 0000000..f9bbe3c
--- /dev/null
@@ -0,0 +1,9 @@
+# check that the sim doesn't die immediately.
+# mach: microblaze
+# status: 1
+# output: fail\n
+
+.include "testutils.inc"
+
+       start
+       fail
index 93ed92474f8b19e08f2575445702d8f8cdccb3be..36179745c86acd16c33176e9b9ed7614aeca6db8 100644 (file)
@@ -1,6 +1,5 @@
 # check that the sim doesn't die immediately.
 # mach: microblaze
-# output:
 
 .include "testutils.inc"
 
index 158a3c5e7836db5da2a37dd02dbf4090b82f81c7..f222be9dccdc3d95b96778325c40c6b008287227 100644 (file)
@@ -1,5 +1,12 @@
+# MACRO: system_call
+# Make a libgloss/Linux system call
+       .macro system_call nr:req
+       addi r12, r0, \nr;
+       brki r14, 8;
+       .endm
+
 # MACRO: exit
-       .macro exit nr
+       .macro exit nr:req
        addi r3, r0, \nr;
        bri 0;
        .endm
@@ -7,6 +14,7 @@
 # MACRO: pass
 # Write 'pass' to stdout and quit
        .macro pass
+       write 1, 1f, 5
        exit 0
        .data
        1: .asciz "pass\n"
@@ -15,6 +23,7 @@
 # MACRO: fail
 # Write 'fail' to stdout and quit
        .macro fail
+       write 1, 1f, 5
        exit 1
        .data
        1: .asciz "fail\n"
 .global _start
 _start:
        .endm
+
+# MACRO: write
+# Just like the write() C function; uses system calls
+       .macro write fd:req, buf:req, count:req
+       addi r5, r0, \fd;
+       addi r6, r0, \buf;
+       addi r7, r0, \count;
+       system_call 5
+       .endm