public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] sim: microblaze: hook up libgloss syscalls
@ 2021-05-05  1:48 Michael Frysinger
  0 siblings, 0 replies; only message in thread
From: Michael Frysinger @ 2021-05-05  1:48 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cd09ab7c7463d05fe27e3dab4f97bb8aa6570413

commit cd09ab7c7463d05fe27e3dab4f97bb8aa6570413
Author: Mike Frysinger <vapier@gentoo.org>
Date:   Mon Apr 26 23:14:11 2021 -0400

    sim: microblaze: hook up libgloss syscalls
    
    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).

Diff:
---
 sim/microblaze/ChangeLog               |  5 +++++
 sim/microblaze/interp.c                | 15 +++++++++++++--
 sim/testsuite/microblaze/ChangeLog     |  8 ++++++++
 sim/testsuite/microblaze/fail.s        |  9 +++++++++
 sim/testsuite/microblaze/pass.s        |  1 -
 sim/testsuite/microblaze/testutils.inc | 20 +++++++++++++++++++-
 6 files changed, 54 insertions(+), 4 deletions(-)

diff --git a/sim/microblaze/ChangeLog b/sim/microblaze/ChangeLog
index 510cddedf7d..8300491731d 100644
--- a/sim/microblaze/ChangeLog
+++ b/sim/microblaze/ChangeLog
@@ -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.
diff --git a/sim/microblaze/interp.c b/sim/microblaze/interp.c
index 2bd067c6dc5..129291895d1 100644
--- a/sim/microblaze/interp.c
+++ b/sim/microblaze/interp.c
@@ -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++;
+		}
 	    }
 	}
 
diff --git a/sim/testsuite/microblaze/ChangeLog b/sim/testsuite/microblaze/ChangeLog
index b282fc3a31c..205646e8a2e 100644
--- a/sim/testsuite/microblaze/ChangeLog
+++ b/sim/testsuite/microblaze/ChangeLog
@@ -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
index 00000000000..f9bbe3c311c
--- /dev/null
+++ b/sim/testsuite/microblaze/fail.s
@@ -0,0 +1,9 @@
+# check that the sim doesn't die immediately.
+# mach: microblaze
+# status: 1
+# output: fail\n
+
+.include "testutils.inc"
+
+	start
+	fail
diff --git a/sim/testsuite/microblaze/pass.s b/sim/testsuite/microblaze/pass.s
index 93ed92474f8..36179745c86 100644
--- a/sim/testsuite/microblaze/pass.s
+++ b/sim/testsuite/microblaze/pass.s
@@ -1,6 +1,5 @@
 # check that the sim doesn't die immediately.
 # mach: microblaze
-# output:
 
 .include "testutils.inc"
 
diff --git a/sim/testsuite/microblaze/testutils.inc b/sim/testsuite/microblaze/testutils.inc
index 158a3c5e783..f222be9dccd 100644
--- a/sim/testsuite/microblaze/testutils.inc
+++ b/sim/testsuite/microblaze/testutils.inc
@@ -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"
@@ -27,3 +36,12 @@
 .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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-05  1:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-05  1:48 [binutils-gdb] sim: microblaze: hook up libgloss syscalls Michael Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).