blob: 6122d3988578ca2cfae14a9a21356cf7bcfc2642 [file] [log] [blame]
Dmitry V. Levind70d1c42015-03-22 22:13:55 +00001if (arm_regs.ARM_ip != 0) {
2 /* It is not a syscall entry */
3 fprintf(stderr, "pid %d stray syscall exit\n", tcp->pid);
4 tcp->flags |= TCB_INSYSCALL;
5 return 0;
6}
7
8/* Note: we support only 32-bit CPUs, not 26-bit */
9
10#if !defined(__ARM_EABI__) || ENABLE_ARM_OABI
11if (arm_regs.ARM_cpsr & 0x20) {
12 /* Thumb mode */
13 goto scno_in_r7;
14}
15/* ARM mode */
16/* Check EABI/OABI by examining SVC insn's low 24 bits */
17errno = 0;
18scno = ptrace(PTRACE_PEEKTEXT, tcp->pid, (void *)(arm_regs.ARM_pc - 4), NULL);
19if (errno)
20 return -1;
21/* EABI syscall convention? */
22if ((unsigned long) scno != 0xef000000) {
23 /* No, it's OABI */
24 if ((scno & 0x0ff00000) != 0x0f900000) {
25 fprintf(stderr, "pid %d unknown syscall trap 0x%08lx\n",
26 tcp->pid, scno);
27 return -1;
28 }
29 /* Fixup the syscall number */
30 scno &= 0x000fffff;
31} else {
32scno_in_r7:
33 scno = arm_regs.ARM_r7;
34}
35#else /* __ARM_EABI__ || !ENABLE_ARM_OABI */
36
37scno = arm_regs.ARM_r7;
38
39#endif
40
41scno = shuffle_scno(scno);