This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Committed: set_thread_area syscall for sim/cris


The semantics aren't weird like for x86, but rather
straight-forward like for MIPS: just set the applicable register
to the darn parameter.  Syscall implementation for CRIS appears
in 2.6.27 +- ..1 depending on subtarget-to-your-distribution
propagation latency.  Committed.

sim:
	* cris/sim-main.h (struct _sim_cpu): New member
	set_target_thread_data.
	* cris/crisv32f.c (CRIS_TLS_REGISTER): Define.
	* cris/crisv10f.c: Ditto.
	* cris/cris-tmpl.c (MY (set_target_thread_data)): New function.
	(MY (f_specific_init)): Set new _sim_cpu member to new function.
	* cris/traps.c (TARGET_SYS_set_thread_area): Define.
	(cris_break_13_handler) <case TARGET_SYS_set_thread_area>: New
	case.

sim/testsuite:
	* sim/cris/c/settls1.c: New test.

Index: cris/cris-tmpl.c
===================================================================
RCS file: /cvs/src/src/sim/cris/cris-tmpl.c,v
retrieving revision 1.8
diff -p -u -r1.8 cris-tmpl.c
--- cris/cris-tmpl.c	1 Jan 2008 22:53:23 -0000	1.8
+++ cris/cris-tmpl.c	3 Jan 2009 20:35:05 -0000
@@ -233,6 +233,14 @@ MY (f_model_mark_set_h_gr) (SIM_CPU *cur
 }
 #endif
 
+/* Set the thread register contents.  */
+
+void
+MY (set_target_thread_data) (SIM_CPU *current_cpu, USI val)
+{
+  (CPU (XCONCAT2 (h_sr_v, BASENUM) [CRIS_TLS_REGISTER])) = val;
+}
+
 /* Create the context for a thread.  */
 
 void *
@@ -256,6 +264,7 @@ MY (f_specific_init) (SIM_CPU *current_c
 {
   current_cpu->make_thread_cpu_data = MY (make_thread_cpu_data);
   current_cpu->thread_cpu_data_size = sizeof (current_cpu->cpu_data);
+  current_cpu->set_target_thread_data = MY (set_target_thread_data);
 #if WITH_HW
   current_cpu->deliver_interrupt = MY (deliver_interrupt);
 #endif
Index: cris/crisv10f.c
===================================================================
RCS file: /cvs/src/src/sim/cris/crisv10f.c,v
retrieving revision 1.5
diff -p -u -r1.5 crisv10f.c
--- cris/crisv10f.c	1 Jan 2008 22:53:23 -0000	1.5
+++ cris/crisv10f.c	3 Jan 2009 20:35:05 -0000
@@ -22,6 +22,7 @@ along with this program.  If not, see <h
 #define WANT_CPU_CRISV10F
 
 #define BASENUM 10
+#define CRIS_TLS_REGISTER 14
 #include "cris-tmpl.c"
 
 #if WITH_PROFILE_MODEL_P
Index: cris/crisv32f.c
===================================================================
RCS file: /cvs/src/src/sim/cris/crisv32f.c,v
retrieving revision 1.6
diff -p -u -r1.6 crisv32f.c
--- cris/crisv32f.c	1 Jan 2008 22:53:23 -0000	1.6
+++ cris/crisv32f.c	3 Jan 2009 20:35:05 -0000
@@ -28,6 +28,7 @@ along with this program.  If not, see <h
 #define SPECIFIC_U_MEM_FN
 #define SPECIFIC_U_MOVEM_FN
 #define BASENUM 32
+#define CRIS_TLS_REGISTER 2
 #include "cris-tmpl.c"
 
 #if WITH_PROFILE_MODEL_P
Index: cris/sim-main.h
===================================================================
RCS file: /cvs/src/src/sim/cris/sim-main.h,v
retrieving revision 1.7
diff -p -u -r1.7 sim-main.h
--- cris/sim-main.h	1 Jan 2008 22:53:24 -0000	1.7
+++ cris/sim-main.h	3 Jan 2009 20:35:06 -0000
@@ -191,6 +191,9 @@ struct _sim_cpu {
   void* (*make_thread_cpu_data) (SIM_CPU *, void *);
   size_t thread_cpu_data_size;
 
+  /* The register differs, so we dispatch to a CPU-specific function.  */
+  void (*set_target_thread_data) (SIM_CPU *, USI);
+
   /* CPU-model specific parts go here.
      Note that in files that don't need to access these pieces WANT_CPU_FOO
      won't be defined and thus these parts won't appear.  This is ok in the
Index: cris/traps.c
===================================================================
RCS file: /cvs/src/src/sim/cris/traps.c,v
retrieving revision 1.19
diff -p -u -r1.19 traps.c
--- cris/traps.c	3 Jan 2009 20:25:48 -0000	1.19
+++ cris/traps.c	3 Jan 2009 20:35:06 -0000
@@ -113,6 +113,7 @@ along with this program.  If not, see <h
 #define TARGET_SYS_getegid32 202
 #define TARGET_SYS_getgid32 200
 #define TARGET_SYS_fcntl64 221
+#define TARGET_SYS_set_thread_area 243
 #define TARGET_SYS_exit_group 252
 
 #define TARGET_PROT_READ	0x1
@@ -3154,6 +3155,17 @@ cris_break_13_handler (SIM_CPU *current_
 	  retval = -cb_host_to_target_errno (cb, ENOSYS);
 	  break;
 
+	case TARGET_SYS_set_thread_area:
+	  /* Do the same error check as Linux.  */
+	  if (arg1 & 255)
+	    {
+	      retval = -cb_host_to_target_errno (cb, EINVAL);
+	      break;
+	    }
+	  (*current_cpu->set_target_thread_data) (current_cpu, arg1);
+	  retval = 0;
+	  break;
+
 	unimplemented_syscall:
 	default:
 	  retval
Index: sim/cris/c/settls1.c
===================================================================
RCS file: sim/cris/c/settls1.c
diff -N sim/cris/c/settls1.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sim/cris/c/settls1.c	3 Jan 2009 20:43:01 -0000
@@ -0,0 +1,49 @@
+/* Check that the syscall set_thread_area is supported and does the right thing.
+#notarget: cris*-*-elf
+*/
+
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#ifndef SYS_set_thread_area
+#define SYS_set_thread_area 243
+#endif
+
+int main (void)
+{
+  int ret;
+
+  /* Check the error check that the low 8 bits must be 0.  */
+  ret = syscall (SYS_set_thread_area, 0xfeeb1ff0);
+  if (ret != -1 || errno != EINVAL)
+    {
+      perror ("tls1");
+      abort ();
+    }
+
+  ret = syscall (SYS_set_thread_area, 0xcafebe00);
+  if (ret != 0)
+    {
+      perror ("tls2");
+      abort ();
+    }
+
+  /* Check that we got the right result.  */
+#ifdef __arch_v32
+  asm ("move $pid,%0\n\tclear.b %0" : "=rm" (ret));
+#else
+  asm ("move $brp,%0" : "=rm" (ret));
+#endif
+
+  if (ret != 0xcafebe00)
+    {
+      perror ("tls2");
+      abort ();
+    }
+
+  printf ("pass\n");
+  exit (0);
+}

brgds, H-P


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]