1 /* m32r exception, interrupt, and trap (EIT) support
2 Copyright (C) 1998-2021 Free Software Foundation, Inc.
3 Contributed by Renesas.
5 This file is part of GDB, the GNU debugger.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 /* This must come before any other includes. */
23 #include "portability.h"
25 #include "sim-signal.h"
26 #include "sim-syscall.h"
28 #include "targ-vals.h"
37 #include <sys/resource.h>
38 #include <sys/sysinfo.h>
41 #include <sys/timeb.h>
42 #include <sys/timex.h>
43 #include <sys/types.h>
45 #include <sys/utsname.h>
47 #include <linux/sysctl.h>
48 #include <linux/types.h>
49 #include <linux/unistd.h>
51 #define TRAP_ELF_SYSCALL 0
52 #define TRAP_LINUX_SYSCALL 2
53 #define TRAP_FLUSH_CACHE 12
55 /* The semantic code invokes this for invalid (unrecognized) instructions. */
58 sim_engine_invalid_insn (SIM_CPU
*current_cpu
, IADDR cia
, SEM_PC vpc
)
60 SIM_DESC sd
= CPU_STATE (current_cpu
);
63 if (STATE_ENVIRONMENT (sd
) == OPERATING_ENVIRONMENT
)
65 h_bsm_set (current_cpu
, h_sm_get (current_cpu
));
66 h_bie_set (current_cpu
, h_ie_get (current_cpu
));
67 h_bcond_set (current_cpu
, h_cond_get (current_cpu
));
69 h_ie_set (current_cpu
, 0);
70 h_cond_set (current_cpu
, 0);
72 h_bpc_set (current_cpu
, cia
);
74 sim_engine_restart (CPU_STATE (current_cpu
), current_cpu
, NULL
,
79 sim_engine_halt (sd
, current_cpu
, NULL
, cia
, sim_stopped
, SIM_SIGILL
);
83 /* Process an address exception. */
86 m32r_core_signal (SIM_DESC sd
, SIM_CPU
*current_cpu
, sim_cia cia
,
87 unsigned int map
, int nr_bytes
, address_word addr
,
88 transfer_type transfer
, sim_core_signals sig
)
90 if (STATE_ENVIRONMENT (sd
) == OPERATING_ENVIRONMENT
)
92 m32rbf_h_cr_set (current_cpu
, H_CR_BBPC
,
93 m32rbf_h_cr_get (current_cpu
, H_CR_BPC
));
94 if (MACH_NUM (CPU_MACH (current_cpu
)) == MACH_M32R
)
96 m32rbf_h_bpsw_set (current_cpu
, m32rbf_h_psw_get (current_cpu
));
98 m32rbf_h_psw_set (current_cpu
, m32rbf_h_psw_get (current_cpu
) & 0x80);
100 else if (MACH_NUM (CPU_MACH (current_cpu
)) == MACH_M32RX
)
102 m32rxf_h_bpsw_set (current_cpu
, m32rxf_h_psw_get (current_cpu
));
104 m32rxf_h_psw_set (current_cpu
, m32rxf_h_psw_get (current_cpu
) & 0x80);
108 m32r2f_h_bpsw_set (current_cpu
, m32r2f_h_psw_get (current_cpu
));
110 m32r2f_h_psw_set (current_cpu
, m32r2f_h_psw_get (current_cpu
) & 0x80);
112 m32rbf_h_cr_set (current_cpu
, H_CR_BPC
, cia
);
114 sim_engine_restart (CPU_STATE (current_cpu
), current_cpu
, NULL
,
118 sim_core_signal (sd
, current_cpu
, cia
, map
, nr_bytes
, addr
,
122 /* Translate target's address to host's address. */
125 t2h_addr (host_callback
*cb
, struct cb_syscall
*sc
,
129 SIM_DESC sd
= (SIM_DESC
) sc
->p1
;
130 SIM_CPU
*cpu
= (SIM_CPU
*) sc
->p2
;
135 return sim_core_trans_addr (sd
, cpu
, read_map
, taddr
);
139 conv_endian (unsigned int tvalue
)
142 unsigned int t1
, t2
, t3
, t4
;
144 if (HOST_BYTE_ORDER
== BFD_ENDIAN_LITTLE
)
146 t1
= tvalue
& 0xff000000;
147 t2
= tvalue
& 0x00ff0000;
148 t3
= tvalue
& 0x0000ff00;
149 t4
= tvalue
& 0x000000ff;
162 static unsigned short
163 conv_endian16 (unsigned short tvalue
)
165 unsigned short hvalue
;
166 unsigned short t1
, t2
;
168 if (HOST_BYTE_ORDER
== BFD_ENDIAN_LITTLE
)
170 t1
= tvalue
& 0xff00;
171 t2
= tvalue
& 0x00ff;
183 translate_endian(void *addr
, size_t size
)
185 unsigned int *p
= (unsigned int *) addr
;
188 for (i
= 0; i
<= size
- 4; i
+= 4,p
++)
189 *p
= conv_endian(*p
);
192 *((unsigned short *) p
) = conv_endian16(*((unsigned short *) p
));
196 The result is the pc address to continue at.
197 Preprocessing like saving the various registers has already been done. */
200 m32r_trap (SIM_CPU
*current_cpu
, PCADDR pc
, int num
)
202 SIM_DESC sd
= CPU_STATE (current_cpu
);
203 host_callback
*cb
= STATE_CALLBACK (sd
);
207 case TRAP_ELF_SYSCALL
:
209 long result
, result2
;
212 sim_syscall_multi (current_cpu
,
213 m32rbf_h_gr_get (current_cpu
, 0),
214 m32rbf_h_gr_get (current_cpu
, 1),
215 m32rbf_h_gr_get (current_cpu
, 2),
216 m32rbf_h_gr_get (current_cpu
, 3),
217 m32rbf_h_gr_get (current_cpu
, 4),
218 &result
, &result2
, &errcode
);
220 m32rbf_h_gr_set (current_cpu
, 2, errcode
);
221 m32rbf_h_gr_set (current_cpu
, 0, result
);
222 m32rbf_h_gr_set (current_cpu
, 1, result2
);
226 case TRAP_LINUX_SYSCALL
:
229 unsigned int func
, arg1
, arg2
, arg3
, arg4
, arg5
, arg6
, arg7
;
230 int result
, result2
, errcode
;
232 if (STATE_ENVIRONMENT (sd
) == OPERATING_ENVIRONMENT
)
234 /* The new pc is the trap vector entry.
235 We assume there's a branch there to some handler.
236 Use cr5 as EVB (EIT Vector Base) register. */
237 USI new_pc
= m32rbf_h_cr_get (current_cpu
, 5) + 0x40 + num
* 4;
241 func
= m32rbf_h_gr_get (current_cpu
, 7);
242 arg1
= m32rbf_h_gr_get (current_cpu
, 0);
243 arg2
= m32rbf_h_gr_get (current_cpu
, 1);
244 arg3
= m32rbf_h_gr_get (current_cpu
, 2);
245 arg4
= m32rbf_h_gr_get (current_cpu
, 3);
246 arg5
= m32rbf_h_gr_get (current_cpu
, 4);
247 arg6
= m32rbf_h_gr_get (current_cpu
, 5);
248 arg7
= m32rbf_h_gr_get (current_cpu
, 6);
250 CB_SYSCALL_INIT (&s
);
261 s
.p2
= (PTR
) current_cpu
;
262 s
.read_mem
= sim_syscall_read_mem
;
263 s
.write_mem
= sim_syscall_write_mem
;
272 sim_engine_halt (sd
, current_cpu
, NULL
, pc
, sim_exited
, arg1
);
276 result
= read(arg1
, t2h_addr(cb
, &s
, arg2
), arg3
);
281 result
= write(arg1
, t2h_addr(cb
, &s
, arg2
), arg3
);
286 result
= open((char *) t2h_addr(cb
, &s
, arg1
), arg2
, arg3
);
291 result
= close(arg1
);
296 result
= creat((char *) t2h_addr(cb
, &s
, arg1
), arg2
);
301 result
= link((char *) t2h_addr(cb
, &s
, arg1
),
302 (char *) t2h_addr(cb
, &s
, arg2
));
307 result
= unlink((char *) t2h_addr(cb
, &s
, arg1
));
312 result
= chdir((char *) t2h_addr(cb
, &s
, arg1
));
322 result
= (int) time(NULL
);
327 result
= (int) time(&t
);
333 translate_endian((void *) &t
, sizeof(t
));
334 if ((s
.write_mem
) (cb
, &s
, arg1
, (char *) &t
, sizeof(t
)) != sizeof(t
))
344 result
= mknod((char *) t2h_addr(cb
, &s
, arg1
),
345 (mode_t
) arg2
, (dev_t
) arg3
);
350 result
= chmod((char *) t2h_addr(cb
, &s
, arg1
), (mode_t
) arg2
);
356 result
= lchown((char *) t2h_addr(cb
, &s
, arg1
),
357 (uid_t
) arg2
, (gid_t
) arg3
);
362 result
= (int) lseek(arg1
, (off_t
) arg2
, arg3
);
383 result
= utime((char *) t2h_addr(cb
, &s
, arg1
), NULL
);
388 buf
= *((struct utimbuf
*) t2h_addr(cb
, &s
, arg2
));
389 translate_endian((void *) &buf
, sizeof(buf
));
390 result
= utime((char *) t2h_addr(cb
, &s
, arg1
), &buf
);
397 result
= access((char *) t2h_addr(cb
, &s
, arg1
), arg2
);
411 t
.time
= conv_endian(t
.time
);
412 t
.millitm
= conv_endian16(t
.millitm
);
413 t
.timezone
= conv_endian16(t
.timezone
);
414 t
.dstflag
= conv_endian16(t
.dstflag
);
415 if ((s
.write_mem
) (cb
, &s
, arg1
, (char *) &t
, sizeof(t
))
429 result
= rename((char *) t2h_addr(cb
, &s
, arg1
),
430 (char *) t2h_addr(cb
, &s
, arg2
));
435 result
= mkdir((char *) t2h_addr(cb
, &s
, arg1
), arg2
);
440 result
= rmdir((char *) t2h_addr(cb
, &s
, arg1
));
450 result
= brk((void *) arg1
);
474 result
= ioctl(arg1
, arg2
, arg3
);
479 result
= fcntl(arg1
, arg2
, arg3
);
484 result
= dup2(arg1
, arg2
);
502 result
= getrlimit(arg1
, &rlim
);
508 translate_endian((void *) &rlim
, sizeof(rlim
));
509 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &rlim
, sizeof(rlim
))
522 result
= getrusage(arg1
, &usage
);
528 translate_endian((void *) &usage
, sizeof(usage
));
529 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &usage
, sizeof(usage
))
538 case __NR_gettimeofday
:
543 result
= gettimeofday(&tv
, &tz
);
549 translate_endian((void *) &tv
, sizeof(tv
));
550 if ((s
.write_mem
) (cb
, &s
, arg1
, (char *) &tv
, sizeof(tv
))
557 translate_endian((void *) &tz
, sizeof(tz
));
558 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &tz
, sizeof(tz
))
567 case __NR_getgroups32
:
573 list
= (gid_t
*) malloc(arg1
* sizeof(gid_t
));
575 result
= getgroups(arg1
, list
);
581 translate_endian((void *) list
, arg1
* sizeof(gid_t
));
583 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) list
, arg1
* sizeof(gid_t
))
584 != arg1
* sizeof(gid_t
))
604 struct timeval
*ttimeoutp
;
605 struct timeval timeout
;
609 treadfdsp
= (fd_set
*) arg2
;
610 if (treadfdsp
!= NULL
)
612 readfds
= *((fd_set
*) t2h_addr(cb
, &s
, (unsigned int) treadfdsp
));
613 translate_endian((void *) &readfds
, sizeof(readfds
));
614 hreadfdsp
= &readfds
;
619 twritefdsp
= (fd_set
*) arg3
;
620 if (twritefdsp
!= NULL
)
622 writefds
= *((fd_set
*) t2h_addr(cb
, &s
, (unsigned int) twritefdsp
));
623 translate_endian((void *) &writefds
, sizeof(writefds
));
624 hwritefdsp
= &writefds
;
629 texceptfdsp
= (fd_set
*) arg4
;
630 if (texceptfdsp
!= NULL
)
632 exceptfds
= *((fd_set
*) t2h_addr(cb
, &s
, (unsigned int) texceptfdsp
));
633 translate_endian((void *) &exceptfds
, sizeof(exceptfds
));
634 hexceptfdsp
= &exceptfds
;
639 ttimeoutp
= (struct timeval
*) arg5
;
640 timeout
= *((struct timeval
*) t2h_addr(cb
, &s
, (unsigned int) ttimeoutp
));
641 translate_endian((void *) &timeout
, sizeof(timeout
));
643 result
= select(n
, hreadfdsp
, hwritefdsp
, hexceptfdsp
, &timeout
);
649 if (treadfdsp
!= NULL
)
651 translate_endian((void *) &readfds
, sizeof(readfds
));
652 if ((s
.write_mem
) (cb
, &s
, (unsigned long) treadfdsp
,
653 (char *) &readfds
, sizeof(readfds
)) != sizeof(readfds
))
660 if (twritefdsp
!= NULL
)
662 translate_endian((void *) &writefds
, sizeof(writefds
));
663 if ((s
.write_mem
) (cb
, &s
, (unsigned long) twritefdsp
,
664 (char *) &writefds
, sizeof(writefds
)) != sizeof(writefds
))
671 if (texceptfdsp
!= NULL
)
673 translate_endian((void *) &exceptfds
, sizeof(exceptfds
));
674 if ((s
.write_mem
) (cb
, &s
, (unsigned long) texceptfdsp
,
675 (char *) &exceptfds
, sizeof(exceptfds
)) != sizeof(exceptfds
))
682 translate_endian((void *) &timeout
, sizeof(timeout
));
683 if ((s
.write_mem
) (cb
, &s
, (unsigned long) ttimeoutp
,
684 (char *) &timeout
, sizeof(timeout
)) != sizeof(timeout
))
693 result
= symlink((char *) t2h_addr(cb
, &s
, arg1
),
694 (char *) t2h_addr(cb
, &s
, arg2
));
699 result
= readlink((char *) t2h_addr(cb
, &s
, arg1
),
700 (char *) t2h_addr(cb
, &s
, arg2
),
706 result
= (int) readdir((DIR *) t2h_addr(cb
, &s
, arg1
));
713 result
= (int) mmap((void *) t2h_addr(cb
, &s
, arg1
),
714 arg2
, arg3
, arg4
, arg5
, arg6
);
719 sim_core_attach (sd
, NULL
,
720 0, access_read_write_exec
, 0,
721 result
, arg2
, 0, NULL
, NULL
);
730 int prot
, flags
, fildes
;
733 addr
= (void *) t2h_addr(cb
, &s
, arg1
);
740 result
= (int) mmap(addr
, len
, prot
, flags
, fildes
, off
);
745 if (sim_core_read_buffer (sd
, NULL
, read_map
, &c
, result
, 1) == 0)
746 sim_core_attach (sd
, NULL
,
747 0, access_read_write_exec
, 0,
748 result
, len
, 0, NULL
, NULL
);
757 int prot
, flags
, fildes
;
760 addr
= *((void **) t2h_addr(cb
, &s
, arg1
));
761 len
= *((size_t *) t2h_addr(cb
, &s
, arg1
+ 4));
762 prot
= *((int *) t2h_addr(cb
, &s
, arg1
+ 8));
763 flags
= *((int *) t2h_addr(cb
, &s
, arg1
+ 12));
764 fildes
= *((int *) t2h_addr(cb
, &s
, arg1
+ 16));
765 off
= *((off_t
*) t2h_addr(cb
, &s
, arg1
+ 20));
767 addr
= (void *) conv_endian((unsigned int) addr
);
768 len
= conv_endian(len
);
769 prot
= conv_endian(prot
);
770 flags
= conv_endian(flags
);
771 fildes
= conv_endian(fildes
);
772 off
= conv_endian(off
);
774 //addr = (void *) t2h_addr(cb, &s, (unsigned int) addr);
775 result
= (int) mmap(addr
, len
, prot
, flags
, fildes
, off
);
782 if (sim_core_read_buffer (sd
, NULL
, read_map
, &c
, result
, 1) == 0)
783 sim_core_attach (sd
, NULL
,
784 0, access_read_write_exec
, 0,
785 result
, len
, 0, NULL
, NULL
);
792 result
= munmap((void *)arg1
, arg2
);
796 sim_core_detach (sd
, NULL
, 0, arg2
, result
);
802 result
= truncate((char *) t2h_addr(cb
, &s
, arg1
), arg2
);
807 result
= ftruncate(arg1
, arg2
);
812 result
= fchmod(arg1
, arg2
);
818 result
= fchown(arg1
, arg2
, arg3
);
824 struct statfs statbuf
;
826 result
= statfs((char *) t2h_addr(cb
, &s
, arg1
), &statbuf
);
832 translate_endian((void *) &statbuf
, sizeof(statbuf
));
833 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &statbuf
, sizeof(statbuf
))
844 struct statfs statbuf
;
846 result
= fstatfs(arg1
, &statbuf
);
852 translate_endian((void *) &statbuf
, sizeof(statbuf
));
853 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &statbuf
, sizeof(statbuf
))
863 result
= syslog(arg1
, (char *) t2h_addr(cb
, &s
, arg2
));
869 struct itimerval value
, ovalue
;
871 value
= *((struct itimerval
*) t2h_addr(cb
, &s
, arg2
));
872 translate_endian((void *) &value
, sizeof(value
));
876 result
= setitimer(arg1
, &value
, NULL
);
881 result
= setitimer(arg1
, &value
, &ovalue
);
887 translate_endian((void *) &ovalue
, sizeof(ovalue
));
888 if ((s
.write_mem
) (cb
, &s
, arg3
, (char *) &ovalue
, sizeof(ovalue
))
900 struct itimerval value
;
902 result
= getitimer(arg1
, &value
);
908 translate_endian((void *) &value
, sizeof(value
));
909 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &value
, sizeof(value
))
924 result
= stat((char *) t2h_addr(cb
, &s
, arg1
), &statbuf
);
929 buflen
= cb_host_to_target_stat (cb
, NULL
, NULL
);
930 buf
= xmalloc (buflen
);
931 if (cb_host_to_target_stat (cb
, &statbuf
, buf
) != buflen
)
933 /* The translation failed. This is due to an internal
934 host program error, not the target's fault. */
940 if ((s
.write_mem
) (cb
, &s
, arg2
, buf
, buflen
) != buflen
)
957 result
= lstat((char *) t2h_addr(cb
, &s
, arg1
), &statbuf
);
962 buflen
= cb_host_to_target_stat (cb
, NULL
, NULL
);
963 buf
= xmalloc (buflen
);
964 if (cb_host_to_target_stat (cb
, &statbuf
, buf
) != buflen
)
966 /* The translation failed. This is due to an internal
967 host program error, not the target's fault. */
973 if ((s
.write_mem
) (cb
, &s
, arg2
, buf
, buflen
) != buflen
)
990 result
= fstat(arg1
, &statbuf
);
995 buflen
= cb_host_to_target_stat (cb
, NULL
, NULL
);
996 buf
= xmalloc (buflen
);
997 if (cb_host_to_target_stat (cb
, &statbuf
, buf
) != buflen
)
999 /* The translation failed. This is due to an internal
1000 host program error, not the target's fault. */
1006 if ((s
.write_mem
) (cb
, &s
, arg2
, buf
, buflen
) != buflen
)
1019 struct sysinfo info
;
1021 result
= sysinfo(&info
);
1027 info
.uptime
= conv_endian(info
.uptime
);
1028 info
.loads
[0] = conv_endian(info
.loads
[0]);
1029 info
.loads
[1] = conv_endian(info
.loads
[1]);
1030 info
.loads
[2] = conv_endian(info
.loads
[2]);
1031 info
.totalram
= conv_endian(info
.totalram
);
1032 info
.freeram
= conv_endian(info
.freeram
);
1033 info
.sharedram
= conv_endian(info
.sharedram
);
1034 info
.bufferram
= conv_endian(info
.bufferram
);
1035 info
.totalswap
= conv_endian(info
.totalswap
);
1036 info
.freeswap
= conv_endian(info
.freeswap
);
1037 info
.procs
= conv_endian16(info
.procs
);
1038 #if LINUX_VERSION_CODE >= 0x20400
1039 info
.totalhigh
= conv_endian(info
.totalhigh
);
1040 info
.freehigh
= conv_endian(info
.freehigh
);
1041 info
.mem_unit
= conv_endian(info
.mem_unit
);
1043 if ((s
.write_mem
) (cb
, &s
, arg1
, (char *) &info
, sizeof(info
))
1055 result
= ipc(arg1
, arg2
, arg3
, arg4
,
1056 (void *) t2h_addr(cb
, &s
, arg5
), arg6
);
1063 result
= fsync(arg1
);
1068 /* utsname contains only arrays of char, so it is not necessary
1069 to translate endian. */
1070 result
= uname((struct utsname
*) t2h_addr(cb
, &s
, arg1
));
1078 result
= adjtimex(&buf
);
1084 translate_endian((void *) &buf
, sizeof(buf
));
1085 if ((s
.write_mem
) (cb
, &s
, arg1
, (char *) &buf
, sizeof(buf
))
1095 result
= mprotect((void *) arg1
, arg2
, arg3
);
1100 result
= fchdir(arg1
);
1104 case __NR_setfsuid32
:
1106 result
= setfsuid(arg1
);
1110 case __NR_setfsgid32
:
1112 result
= setfsgid(arg1
);
1121 result
= _llseek(arg1
, arg2
, arg3
, &buf
, arg5
);
1127 translate_endian((void *) &buf
, sizeof(buf
));
1128 if ((s
.write_mem
) (cb
, &s
, t2h_addr(cb
, &s
, arg4
),
1129 (char *) &buf
, sizeof(buf
)) != sizeof(buf
))
1141 result
= getdents(arg1
, &dir
, arg3
);
1147 dir
.d_ino
= conv_endian(dir
.d_ino
);
1148 dir
.d_off
= conv_endian(dir
.d_off
);
1149 dir
.d_reclen
= conv_endian16(dir
.d_reclen
);
1150 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &dir
, sizeof(dir
))
1161 result
= flock(arg1
, arg2
);
1166 result
= msync((void *) arg1
, arg2
, arg3
);
1172 struct iovec vector
;
1174 vector
= *((struct iovec
*) t2h_addr(cb
, &s
, arg2
));
1175 translate_endian((void *) &vector
, sizeof(vector
));
1177 result
= readv(arg1
, &vector
, arg3
);
1184 struct iovec vector
;
1186 vector
= *((struct iovec
*) t2h_addr(cb
, &s
, arg2
));
1187 translate_endian((void *) &vector
, sizeof(vector
));
1189 result
= writev(arg1
, &vector
, arg3
);
1194 case __NR_fdatasync
:
1195 result
= fdatasync(arg1
);
1200 result
= mlock((void *) t2h_addr(cb
, &s
, arg1
), arg2
);
1205 result
= munlock((void *) t2h_addr(cb
, &s
, arg1
), arg2
);
1209 case __NR_nanosleep
:
1211 struct timespec req
, rem
;
1213 req
= *((struct timespec
*) t2h_addr(cb
, &s
, arg2
));
1214 translate_endian((void *) &req
, sizeof(req
));
1216 result
= nanosleep(&req
, &rem
);
1222 translate_endian((void *) &rem
, sizeof(rem
));
1223 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &rem
, sizeof(rem
))
1232 case __NR_mremap
: /* FIXME */
1233 result
= (int) mremap((void *) t2h_addr(cb
, &s
, arg1
), arg2
, arg3
, arg4
);
1237 case __NR_getresuid32
:
1238 case __NR_getresuid
:
1240 uid_t ruid
, euid
, suid
;
1242 result
= getresuid(&ruid
, &euid
, &suid
);
1248 *((uid_t
*) t2h_addr(cb
, &s
, arg1
)) = conv_endian(ruid
);
1249 *((uid_t
*) t2h_addr(cb
, &s
, arg2
)) = conv_endian(euid
);
1250 *((uid_t
*) t2h_addr(cb
, &s
, arg3
)) = conv_endian(suid
);
1258 ufds
= *((struct pollfd
*) t2h_addr(cb
, &s
, arg1
));
1259 ufds
.fd
= conv_endian(ufds
.fd
);
1260 ufds
.events
= conv_endian16(ufds
.events
);
1261 ufds
.revents
= conv_endian16(ufds
.revents
);
1263 result
= poll(&ufds
, arg2
, arg3
);
1268 case __NR_getresgid32
:
1269 case __NR_getresgid
:
1271 uid_t rgid
, egid
, sgid
;
1273 result
= getresgid(&rgid
, &egid
, &sgid
);
1279 *((uid_t
*) t2h_addr(cb
, &s
, arg1
)) = conv_endian(rgid
);
1280 *((uid_t
*) t2h_addr(cb
, &s
, arg2
)) = conv_endian(egid
);
1281 *((uid_t
*) t2h_addr(cb
, &s
, arg3
)) = conv_endian(sgid
);
1286 result
= pread(arg1
, (void *) t2h_addr(cb
, &s
, arg2
), arg3
, arg4
);
1291 result
= pwrite(arg1
, (void *) t2h_addr(cb
, &s
, arg2
), arg3
, arg4
);
1297 result
= chown((char *) t2h_addr(cb
, &s
, arg1
), arg2
, arg3
);
1302 result
= (int) getcwd((char *) t2h_addr(cb
, &s
, arg1
), arg2
);
1310 offset
= *((off_t
*) t2h_addr(cb
, &s
, arg3
));
1311 offset
= conv_endian(offset
);
1313 result
= sendfile(arg1
, arg2
, &offset
, arg3
);
1319 *((off_t
*) t2h_addr(cb
, &s
, arg3
)) = conv_endian(offset
);
1330 m32rbf_h_gr_set (current_cpu
, 0, -errcode
);
1332 m32rbf_h_gr_set (current_cpu
, 0, result
);
1336 case TRAP_BREAKPOINT
:
1337 sim_engine_halt (sd
, current_cpu
, NULL
, pc
,
1338 sim_stopped
, SIM_SIGTRAP
);
1341 case TRAP_FLUSH_CACHE
:
1347 /* Use cr5 as EVB (EIT Vector Base) register. */
1348 USI new_pc
= m32rbf_h_cr_get (current_cpu
, 5) + 0x40 + num
* 4;
1353 /* Fake an "rte" insn. */
1354 /* FIXME: Should duplicate all of rte processing. */
1355 return (pc
& -4) + 4;