Commit ef96779bc3df7f4fe228fb9a5c7ecb81a04b2644

Authored by edgar_igl
1 parent 35ef81d6

CRIS: Implement set_thread_area for CRIS.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6210 c046a42c-6fe2-441c-8c8c-71466251a162
linux-user/syscall.c
... ... @@ -5912,6 +5912,14 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
5912 5912 ((CPUMIPSState *) cpu_env)->tls_value = arg1;
5913 5913 ret = 0;
5914 5914 break;
  5915 +#elif defined(TARGET_CRIS)
  5916 + if (arg1 & 0xff)
  5917 + ret = -TARGET_EINVAL;
  5918 + else {
  5919 + ((CPUCRISState *) cpu_env)->pregs[PR_PID] = arg1;
  5920 + ret = 0;
  5921 + }
  5922 + break;
5915 5923 #elif defined(TARGET_I386) && defined(TARGET_ABI32)
5916 5924 ret = do_set_thread_area(cpu_env, arg1);
5917 5925 break;
... ...
target-cris/cpu.h
... ... @@ -225,6 +225,11 @@ static inline void cpu_clone_regs(CPUState *env, target_ulong newsp)
225 225 }
226 226 #endif
227 227  
  228 +static inline void cpu_set_tls(CPUCRISState *env, target_ulong newtls)
  229 +{
  230 + env->pregs[PR_PID] = (env->pregs[PR_PID] & 0xff) | newtls;
  231 +}
  232 +
228 233 /* Support function regs. */
229 234 #define SFR_RW_GC_CFG 0][0
230 235 #define SFR_RW_MM_CFG env->pregs[PR_SRS]][0
... ...
tests/cris/Makefile
... ... @@ -117,7 +117,7 @@ TESTCASES += check_mmap3.ctst
117 117 TESTCASES += check_sigalrm.ctst
118 118 TESTCASES += check_time1.ctst
119 119 TESTCASES += check_time2.ctst
120   -
  120 +TESTCASES += check_settls1.ctst
121 121  
122 122 TESTCASES += check_gcctorture_pr28634-1.ctst
123 123 #TESTCASES += check_gcctorture_pr28634.ctst
... ...
tests/cris/check_settls1.c 0 → 100644
  1 +#include <stdio.h>
  2 +#include <stdlib.h>
  3 +#include <errno.h>
  4 +#include <unistd.h>
  5 +
  6 +#include <sys/syscall.h>
  7 +
  8 +#ifndef SYS_set_thread_area
  9 +#define SYS_set_thread_area 243
  10 +#endif
  11 +
  12 +int main (void)
  13 +{
  14 + unsigned long tp;
  15 + int ret;
  16 +
  17 + ret = syscall (SYS_set_thread_area, 0xf0);
  18 + if (ret != -1 || errno != EINVAL) {
  19 + perror ("Invalid thread area accepted:");
  20 + abort();
  21 + }
  22 +
  23 + ret = syscall (SYS_set_thread_area, 0xeddeed00);
  24 + if (ret != 0) {
  25 + perror ("Valid thread area not accepted: ");
  26 + abort ();
  27 + }
  28 +
  29 + asm ("move $pid,%0" : "=r" (tp));
  30 + tp &= ~0xff;
  31 +
  32 + if (tp != 0xeddeed00) {
  33 + perror ("tls2");
  34 + abort ();
  35 + }
  36 +
  37 + printf ("pass\n");
  38 + return EXIT_SUCCESS;
  39 +}
... ...