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. */
24 #include "sim-syscall.h"
26 #include "targ-vals.h"
35 #include <sys/resource.h>
36 #include <sys/sysinfo.h>
39 #include <sys/timeb.h>
40 #include <sys/timex.h>
41 #include <sys/types.h>
43 #include <sys/utsname.h>
45 #include <linux/sysctl.h>
46 #include <linux/types.h>
47 #include <linux/unistd.h>
49 #define TRAP_ELF_SYSCALL 0
50 #define TRAP_LINUX_SYSCALL 2
51 #define TRAP_FLUSH_CACHE 12
53 /* The semantic code invokes this for invalid (unrecognized) instructions. */
56 sim_engine_invalid_insn (SIM_CPU
*current_cpu
, IADDR cia
, SEM_PC vpc
)
58 SIM_DESC sd
= CPU_STATE (current_cpu
);
61 if (STATE_ENVIRONMENT (sd
) == OPERATING_ENVIRONMENT
)
63 h_bsm_set (current_cpu
, h_sm_get (current_cpu
));
64 h_bie_set (current_cpu
, h_ie_get (current_cpu
));
65 h_bcond_set (current_cpu
, h_cond_get (current_cpu
));
67 h_ie_set (current_cpu
, 0);
68 h_cond_set (current_cpu
, 0);
70 h_bpc_set (current_cpu
, cia
);
72 sim_engine_restart (CPU_STATE (current_cpu
), current_cpu
, NULL
,
77 sim_engine_halt (sd
, current_cpu
, NULL
, cia
, sim_stopped
, SIM_SIGILL
);
81 /* Process an address exception. */
84 m32r_core_signal (SIM_DESC sd
, SIM_CPU
*current_cpu
, sim_cia cia
,
85 unsigned int map
, int nr_bytes
, address_word addr
,
86 transfer_type transfer
, sim_core_signals sig
)
88 if (STATE_ENVIRONMENT (sd
) == OPERATING_ENVIRONMENT
)
90 m32rbf_h_cr_set (current_cpu
, H_CR_BBPC
,
91 m32rbf_h_cr_get (current_cpu
, H_CR_BPC
));
92 if (MACH_NUM (CPU_MACH (current_cpu
)) == MACH_M32R
)
94 m32rbf_h_bpsw_set (current_cpu
, m32rbf_h_psw_get (current_cpu
));
96 m32rbf_h_psw_set (current_cpu
, m32rbf_h_psw_get (current_cpu
) & 0x80);
98 else if (MACH_NUM (CPU_MACH (current_cpu
)) == MACH_M32RX
)
100 m32rxf_h_bpsw_set (current_cpu
, m32rxf_h_psw_get (current_cpu
));
102 m32rxf_h_psw_set (current_cpu
, m32rxf_h_psw_get (current_cpu
) & 0x80);
106 m32r2f_h_bpsw_set (current_cpu
, m32r2f_h_psw_get (current_cpu
));
108 m32r2f_h_psw_set (current_cpu
, m32r2f_h_psw_get (current_cpu
) & 0x80);
110 m32rbf_h_cr_set (current_cpu
, H_CR_BPC
, cia
);
112 sim_engine_restart (CPU_STATE (current_cpu
), current_cpu
, NULL
,
116 sim_core_signal (sd
, current_cpu
, cia
, map
, nr_bytes
, addr
,
120 /* Translate target's address to host's address. */
123 t2h_addr (host_callback
*cb
, struct cb_syscall
*sc
,
127 SIM_DESC sd
= (SIM_DESC
) sc
->p1
;
128 SIM_CPU
*cpu
= (SIM_CPU
*) sc
->p2
;
133 return sim_core_trans_addr (sd
, cpu
, read_map
, taddr
);
137 conv_endian (unsigned int tvalue
)
140 unsigned int t1
, t2
, t3
, t4
;
142 if (HOST_BYTE_ORDER
== BFD_ENDIAN_LITTLE
)
144 t1
= tvalue
& 0xff000000;
145 t2
= tvalue
& 0x00ff0000;
146 t3
= tvalue
& 0x0000ff00;
147 t4
= tvalue
& 0x000000ff;
160 static unsigned short
161 conv_endian16 (unsigned short tvalue
)
163 unsigned short hvalue
;
164 unsigned short t1
, t2
;
166 if (HOST_BYTE_ORDER
== BFD_ENDIAN_LITTLE
)
168 t1
= tvalue
& 0xff00;
169 t2
= tvalue
& 0x00ff;
181 translate_endian(void *addr
, size_t size
)
183 unsigned int *p
= (unsigned int *) addr
;
186 for (i
= 0; i
<= size
- 4; i
+= 4,p
++)
187 *p
= conv_endian(*p
);
190 *((unsigned short *) p
) = conv_endian16(*((unsigned short *) p
));
194 The result is the pc address to continue at.
195 Preprocessing like saving the various registers has already been done. */
198 m32r_trap (SIM_CPU
*current_cpu
, PCADDR pc
, int num
)
200 SIM_DESC sd
= CPU_STATE (current_cpu
);
201 host_callback
*cb
= STATE_CALLBACK (sd
);
205 case TRAP_ELF_SYSCALL
:
207 long result
, result2
;
210 sim_syscall_multi (current_cpu
,
211 m32rbf_h_gr_get (current_cpu
, 0),
212 m32rbf_h_gr_get (current_cpu
, 1),
213 m32rbf_h_gr_get (current_cpu
, 2),
214 m32rbf_h_gr_get (current_cpu
, 3),
215 m32rbf_h_gr_get (current_cpu
, 4),
216 &result
, &result2
, &errcode
);
218 m32rbf_h_gr_set (current_cpu
, 2, errcode
);
219 m32rbf_h_gr_set (current_cpu
, 0, result
);
220 m32rbf_h_gr_set (current_cpu
, 1, result2
);
224 case TRAP_LINUX_SYSCALL
:
227 unsigned int func
, arg1
, arg2
, arg3
, arg4
, arg5
, arg6
, arg7
;
228 int result
, result2
, errcode
;
230 if (STATE_ENVIRONMENT (sd
) == OPERATING_ENVIRONMENT
)
232 /* The new pc is the trap vector entry.
233 We assume there's a branch there to some handler.
234 Use cr5 as EVB (EIT Vector Base) register. */
235 USI new_pc
= m32rbf_h_cr_get (current_cpu
, 5) + 0x40 + num
* 4;
239 func
= m32rbf_h_gr_get (current_cpu
, 7);
240 arg1
= m32rbf_h_gr_get (current_cpu
, 0);
241 arg2
= m32rbf_h_gr_get (current_cpu
, 1);
242 arg3
= m32rbf_h_gr_get (current_cpu
, 2);
243 arg4
= m32rbf_h_gr_get (current_cpu
, 3);
244 arg5
= m32rbf_h_gr_get (current_cpu
, 4);
245 arg6
= m32rbf_h_gr_get (current_cpu
, 5);
246 arg7
= m32rbf_h_gr_get (current_cpu
, 6);
248 CB_SYSCALL_INIT (&s
);
255 s
.p2
= (PTR
) current_cpu
;
256 s
.read_mem
= sim_syscall_read_mem
;
257 s
.write_mem
= sim_syscall_write_mem
;
266 sim_engine_halt (sd
, current_cpu
, NULL
, pc
, sim_exited
, arg1
);
270 result
= read(arg1
, t2h_addr(cb
, &s
, arg2
), arg3
);
275 result
= write(arg1
, t2h_addr(cb
, &s
, arg2
), arg3
);
280 result
= open((char *) t2h_addr(cb
, &s
, arg1
), arg2
, arg3
);
285 result
= close(arg1
);
290 result
= creat((char *) t2h_addr(cb
, &s
, arg1
), arg2
);
295 result
= link((char *) t2h_addr(cb
, &s
, arg1
),
296 (char *) t2h_addr(cb
, &s
, arg2
));
301 result
= unlink((char *) t2h_addr(cb
, &s
, arg1
));
306 result
= chdir((char *) t2h_addr(cb
, &s
, arg1
));
316 result
= (int) time(NULL
);
321 result
= (int) time(&t
);
327 translate_endian((void *) &t
, sizeof(t
));
328 if ((s
.write_mem
) (cb
, &s
, arg1
, (char *) &t
, sizeof(t
)) != sizeof(t
))
338 result
= mknod((char *) t2h_addr(cb
, &s
, arg1
),
339 (mode_t
) arg2
, (dev_t
) arg3
);
344 result
= chmod((char *) t2h_addr(cb
, &s
, arg1
), (mode_t
) arg2
);
350 result
= lchown((char *) t2h_addr(cb
, &s
, arg1
),
351 (uid_t
) arg2
, (gid_t
) arg3
);
356 result
= (int) lseek(arg1
, (off_t
) arg2
, arg3
);
377 result
= utime((char *) t2h_addr(cb
, &s
, arg1
), NULL
);
382 buf
= *((struct utimbuf
*) t2h_addr(cb
, &s
, arg2
));
383 translate_endian((void *) &buf
, sizeof(buf
));
384 result
= utime((char *) t2h_addr(cb
, &s
, arg1
), &buf
);
391 result
= access((char *) t2h_addr(cb
, &s
, arg1
), arg2
);
405 t
.time
= conv_endian(t
.time
);
406 t
.millitm
= conv_endian16(t
.millitm
);
407 t
.timezone
= conv_endian16(t
.timezone
);
408 t
.dstflag
= conv_endian16(t
.dstflag
);
409 if ((s
.write_mem
) (cb
, &s
, arg1
, (char *) &t
, sizeof(t
))
423 result
= rename((char *) t2h_addr(cb
, &s
, arg1
),
424 (char *) t2h_addr(cb
, &s
, arg2
));
429 result
= mkdir((char *) t2h_addr(cb
, &s
, arg1
), arg2
);
434 result
= rmdir((char *) t2h_addr(cb
, &s
, arg1
));
444 result
= brk((void *) arg1
);
468 result
= ioctl(arg1
, arg2
, arg3
);
473 result
= fcntl(arg1
, arg2
, arg3
);
478 result
= dup2(arg1
, arg2
);
496 result
= getrlimit(arg1
, &rlim
);
502 translate_endian((void *) &rlim
, sizeof(rlim
));
503 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &rlim
, sizeof(rlim
))
516 result
= getrusage(arg1
, &usage
);
522 translate_endian((void *) &usage
, sizeof(usage
));
523 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &usage
, sizeof(usage
))
532 case __NR_gettimeofday
:
537 result
= gettimeofday(&tv
, &tz
);
543 translate_endian((void *) &tv
, sizeof(tv
));
544 if ((s
.write_mem
) (cb
, &s
, arg1
, (char *) &tv
, sizeof(tv
))
551 translate_endian((void *) &tz
, sizeof(tz
));
552 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &tz
, sizeof(tz
))
561 case __NR_getgroups32
:
567 list
= (gid_t
*) malloc(arg1
* sizeof(gid_t
));
569 result
= getgroups(arg1
, list
);
575 translate_endian((void *) list
, arg1
* sizeof(gid_t
));
577 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) list
, arg1
* sizeof(gid_t
))
578 != arg1
* sizeof(gid_t
))
598 struct timeval
*ttimeoutp
;
599 struct timeval timeout
;
603 treadfdsp
= (fd_set
*) arg2
;
604 if (treadfdsp
!= NULL
)
606 readfds
= *((fd_set
*) t2h_addr(cb
, &s
, (unsigned int) treadfdsp
));
607 translate_endian((void *) &readfds
, sizeof(readfds
));
608 hreadfdsp
= &readfds
;
613 twritefdsp
= (fd_set
*) arg3
;
614 if (twritefdsp
!= NULL
)
616 writefds
= *((fd_set
*) t2h_addr(cb
, &s
, (unsigned int) twritefdsp
));
617 translate_endian((void *) &writefds
, sizeof(writefds
));
618 hwritefdsp
= &writefds
;
623 texceptfdsp
= (fd_set
*) arg4
;
624 if (texceptfdsp
!= NULL
)
626 exceptfds
= *((fd_set
*) t2h_addr(cb
, &s
, (unsigned int) texceptfdsp
));
627 translate_endian((void *) &exceptfds
, sizeof(exceptfds
));
628 hexceptfdsp
= &exceptfds
;
633 ttimeoutp
= (struct timeval
*) arg5
;
634 timeout
= *((struct timeval
*) t2h_addr(cb
, &s
, (unsigned int) ttimeoutp
));
635 translate_endian((void *) &timeout
, sizeof(timeout
));
637 result
= select(n
, hreadfdsp
, hwritefdsp
, hexceptfdsp
, &timeout
);
643 if (treadfdsp
!= NULL
)
645 translate_endian((void *) &readfds
, sizeof(readfds
));
646 if ((s
.write_mem
) (cb
, &s
, (unsigned long) treadfdsp
,
647 (char *) &readfds
, sizeof(readfds
)) != sizeof(readfds
))
654 if (twritefdsp
!= NULL
)
656 translate_endian((void *) &writefds
, sizeof(writefds
));
657 if ((s
.write_mem
) (cb
, &s
, (unsigned long) twritefdsp
,
658 (char *) &writefds
, sizeof(writefds
)) != sizeof(writefds
))
665 if (texceptfdsp
!= NULL
)
667 translate_endian((void *) &exceptfds
, sizeof(exceptfds
));
668 if ((s
.write_mem
) (cb
, &s
, (unsigned long) texceptfdsp
,
669 (char *) &exceptfds
, sizeof(exceptfds
)) != sizeof(exceptfds
))
676 translate_endian((void *) &timeout
, sizeof(timeout
));
677 if ((s
.write_mem
) (cb
, &s
, (unsigned long) ttimeoutp
,
678 (char *) &timeout
, sizeof(timeout
)) != sizeof(timeout
))
687 result
= symlink((char *) t2h_addr(cb
, &s
, arg1
),
688 (char *) t2h_addr(cb
, &s
, arg2
));
693 result
= readlink((char *) t2h_addr(cb
, &s
, arg1
),
694 (char *) t2h_addr(cb
, &s
, arg2
),
700 result
= (int) readdir((DIR *) t2h_addr(cb
, &s
, arg1
));
707 result
= (int) mmap((void *) t2h_addr(cb
, &s
, arg1
),
708 arg2
, arg3
, arg4
, arg5
, arg6
);
713 sim_core_attach (sd
, NULL
,
714 0, access_read_write_exec
, 0,
715 result
, arg2
, 0, NULL
, NULL
);
724 int prot
, flags
, fildes
;
727 addr
= (void *) t2h_addr(cb
, &s
, arg1
);
734 result
= (int) mmap(addr
, len
, prot
, flags
, fildes
, off
);
739 if (sim_core_read_buffer (sd
, NULL
, read_map
, &c
, result
, 1) == 0)
740 sim_core_attach (sd
, NULL
,
741 0, access_read_write_exec
, 0,
742 result
, len
, 0, NULL
, NULL
);
751 int prot
, flags
, fildes
;
754 addr
= *((void **) t2h_addr(cb
, &s
, arg1
));
755 len
= *((size_t *) t2h_addr(cb
, &s
, arg1
+ 4));
756 prot
= *((int *) t2h_addr(cb
, &s
, arg1
+ 8));
757 flags
= *((int *) t2h_addr(cb
, &s
, arg1
+ 12));
758 fildes
= *((int *) t2h_addr(cb
, &s
, arg1
+ 16));
759 off
= *((off_t
*) t2h_addr(cb
, &s
, arg1
+ 20));
761 addr
= (void *) conv_endian((unsigned int) addr
);
762 len
= conv_endian(len
);
763 prot
= conv_endian(prot
);
764 flags
= conv_endian(flags
);
765 fildes
= conv_endian(fildes
);
766 off
= conv_endian(off
);
768 //addr = (void *) t2h_addr(cb, &s, (unsigned int) addr);
769 result
= (int) mmap(addr
, len
, prot
, flags
, fildes
, off
);
776 if (sim_core_read_buffer (sd
, NULL
, read_map
, &c
, result
, 1) == 0)
777 sim_core_attach (sd
, NULL
,
778 0, access_read_write_exec
, 0,
779 result
, len
, 0, NULL
, NULL
);
786 result
= munmap((void *)arg1
, arg2
);
790 sim_core_detach (sd
, NULL
, 0, arg2
, result
);
796 result
= truncate((char *) t2h_addr(cb
, &s
, arg1
), arg2
);
801 result
= ftruncate(arg1
, arg2
);
806 result
= fchmod(arg1
, arg2
);
812 result
= fchown(arg1
, arg2
, arg3
);
818 struct statfs statbuf
;
820 result
= statfs((char *) t2h_addr(cb
, &s
, arg1
), &statbuf
);
826 translate_endian((void *) &statbuf
, sizeof(statbuf
));
827 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &statbuf
, sizeof(statbuf
))
838 struct statfs statbuf
;
840 result
= fstatfs(arg1
, &statbuf
);
846 translate_endian((void *) &statbuf
, sizeof(statbuf
));
847 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &statbuf
, sizeof(statbuf
))
857 result
= syslog(arg1
, (char *) t2h_addr(cb
, &s
, arg2
));
863 struct itimerval value
, ovalue
;
865 value
= *((struct itimerval
*) t2h_addr(cb
, &s
, arg2
));
866 translate_endian((void *) &value
, sizeof(value
));
870 result
= setitimer(arg1
, &value
, NULL
);
875 result
= setitimer(arg1
, &value
, &ovalue
);
881 translate_endian((void *) &ovalue
, sizeof(ovalue
));
882 if ((s
.write_mem
) (cb
, &s
, arg3
, (char *) &ovalue
, sizeof(ovalue
))
894 struct itimerval value
;
896 result
= getitimer(arg1
, &value
);
902 translate_endian((void *) &value
, sizeof(value
));
903 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &value
, sizeof(value
))
918 result
= stat((char *) t2h_addr(cb
, &s
, arg1
), &statbuf
);
923 buflen
= cb_host_to_target_stat (cb
, NULL
, NULL
);
924 buf
= xmalloc (buflen
);
925 if (cb_host_to_target_stat (cb
, &statbuf
, buf
) != buflen
)
927 /* The translation failed. This is due to an internal
928 host program error, not the target's fault. */
934 if ((s
.write_mem
) (cb
, &s
, arg2
, buf
, buflen
) != buflen
)
951 result
= lstat((char *) t2h_addr(cb
, &s
, arg1
), &statbuf
);
956 buflen
= cb_host_to_target_stat (cb
, NULL
, NULL
);
957 buf
= xmalloc (buflen
);
958 if (cb_host_to_target_stat (cb
, &statbuf
, buf
) != buflen
)
960 /* The translation failed. This is due to an internal
961 host program error, not the target's fault. */
967 if ((s
.write_mem
) (cb
, &s
, arg2
, buf
, buflen
) != buflen
)
984 result
= fstat(arg1
, &statbuf
);
989 buflen
= cb_host_to_target_stat (cb
, NULL
, NULL
);
990 buf
= xmalloc (buflen
);
991 if (cb_host_to_target_stat (cb
, &statbuf
, buf
) != buflen
)
993 /* The translation failed. This is due to an internal
994 host program error, not the target's fault. */
1000 if ((s
.write_mem
) (cb
, &s
, arg2
, buf
, buflen
) != buflen
)
1013 struct sysinfo info
;
1015 result
= sysinfo(&info
);
1021 info
.uptime
= conv_endian(info
.uptime
);
1022 info
.loads
[0] = conv_endian(info
.loads
[0]);
1023 info
.loads
[1] = conv_endian(info
.loads
[1]);
1024 info
.loads
[2] = conv_endian(info
.loads
[2]);
1025 info
.totalram
= conv_endian(info
.totalram
);
1026 info
.freeram
= conv_endian(info
.freeram
);
1027 info
.sharedram
= conv_endian(info
.sharedram
);
1028 info
.bufferram
= conv_endian(info
.bufferram
);
1029 info
.totalswap
= conv_endian(info
.totalswap
);
1030 info
.freeswap
= conv_endian(info
.freeswap
);
1031 info
.procs
= conv_endian16(info
.procs
);
1032 #if LINUX_VERSION_CODE >= 0x20400
1033 info
.totalhigh
= conv_endian(info
.totalhigh
);
1034 info
.freehigh
= conv_endian(info
.freehigh
);
1035 info
.mem_unit
= conv_endian(info
.mem_unit
);
1037 if ((s
.write_mem
) (cb
, &s
, arg1
, (char *) &info
, sizeof(info
))
1049 result
= ipc(arg1
, arg2
, arg3
, arg4
,
1050 (void *) t2h_addr(cb
, &s
, arg5
), arg6
);
1057 result
= fsync(arg1
);
1062 /* utsname contains only arrays of char, so it is not necessary
1063 to translate endian. */
1064 result
= uname((struct utsname
*) t2h_addr(cb
, &s
, arg1
));
1072 result
= adjtimex(&buf
);
1078 translate_endian((void *) &buf
, sizeof(buf
));
1079 if ((s
.write_mem
) (cb
, &s
, arg1
, (char *) &buf
, sizeof(buf
))
1089 result
= mprotect((void *) arg1
, arg2
, arg3
);
1094 result
= fchdir(arg1
);
1098 case __NR_setfsuid32
:
1100 result
= setfsuid(arg1
);
1104 case __NR_setfsgid32
:
1106 result
= setfsgid(arg1
);
1115 result
= _llseek(arg1
, arg2
, arg3
, &buf
, arg5
);
1121 translate_endian((void *) &buf
, sizeof(buf
));
1122 if ((s
.write_mem
) (cb
, &s
, t2h_addr(cb
, &s
, arg4
),
1123 (char *) &buf
, sizeof(buf
)) != sizeof(buf
))
1135 result
= getdents(arg1
, &dir
, arg3
);
1141 dir
.d_ino
= conv_endian(dir
.d_ino
);
1142 dir
.d_off
= conv_endian(dir
.d_off
);
1143 dir
.d_reclen
= conv_endian16(dir
.d_reclen
);
1144 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &dir
, sizeof(dir
))
1155 result
= flock(arg1
, arg2
);
1160 result
= msync((void *) arg1
, arg2
, arg3
);
1166 struct iovec vector
;
1168 vector
= *((struct iovec
*) t2h_addr(cb
, &s
, arg2
));
1169 translate_endian((void *) &vector
, sizeof(vector
));
1171 result
= readv(arg1
, &vector
, arg3
);
1178 struct iovec vector
;
1180 vector
= *((struct iovec
*) t2h_addr(cb
, &s
, arg2
));
1181 translate_endian((void *) &vector
, sizeof(vector
));
1183 result
= writev(arg1
, &vector
, arg3
);
1188 case __NR_fdatasync
:
1189 result
= fdatasync(arg1
);
1194 result
= mlock((void *) t2h_addr(cb
, &s
, arg1
), arg2
);
1199 result
= munlock((void *) t2h_addr(cb
, &s
, arg1
), arg2
);
1203 case __NR_nanosleep
:
1205 struct timespec req
, rem
;
1207 req
= *((struct timespec
*) t2h_addr(cb
, &s
, arg2
));
1208 translate_endian((void *) &req
, sizeof(req
));
1210 result
= nanosleep(&req
, &rem
);
1216 translate_endian((void *) &rem
, sizeof(rem
));
1217 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &rem
, sizeof(rem
))
1226 case __NR_mremap
: /* FIXME */
1227 result
= (int) mremap((void *) t2h_addr(cb
, &s
, arg1
), arg2
, arg3
, arg4
);
1231 case __NR_getresuid32
:
1232 case __NR_getresuid
:
1234 uid_t ruid
, euid
, suid
;
1236 result
= getresuid(&ruid
, &euid
, &suid
);
1242 *((uid_t
*) t2h_addr(cb
, &s
, arg1
)) = conv_endian(ruid
);
1243 *((uid_t
*) t2h_addr(cb
, &s
, arg2
)) = conv_endian(euid
);
1244 *((uid_t
*) t2h_addr(cb
, &s
, arg3
)) = conv_endian(suid
);
1252 ufds
= *((struct pollfd
*) t2h_addr(cb
, &s
, arg1
));
1253 ufds
.fd
= conv_endian(ufds
.fd
);
1254 ufds
.events
= conv_endian16(ufds
.events
);
1255 ufds
.revents
= conv_endian16(ufds
.revents
);
1257 result
= poll(&ufds
, arg2
, arg3
);
1262 case __NR_getresgid32
:
1263 case __NR_getresgid
:
1265 uid_t rgid
, egid
, sgid
;
1267 result
= getresgid(&rgid
, &egid
, &sgid
);
1273 *((uid_t
*) t2h_addr(cb
, &s
, arg1
)) = conv_endian(rgid
);
1274 *((uid_t
*) t2h_addr(cb
, &s
, arg2
)) = conv_endian(egid
);
1275 *((uid_t
*) t2h_addr(cb
, &s
, arg3
)) = conv_endian(sgid
);
1280 result
= pread(arg1
, (void *) t2h_addr(cb
, &s
, arg2
), arg3
, arg4
);
1285 result
= pwrite(arg1
, (void *) t2h_addr(cb
, &s
, arg2
), arg3
, arg4
);
1291 result
= chown((char *) t2h_addr(cb
, &s
, arg1
), arg2
, arg3
);
1296 result
= (int) getcwd((char *) t2h_addr(cb
, &s
, arg1
), arg2
);
1304 offset
= *((off_t
*) t2h_addr(cb
, &s
, arg3
));
1305 offset
= conv_endian(offset
);
1307 result
= sendfile(arg1
, arg2
, &offset
, arg3
);
1313 *((off_t
*) t2h_addr(cb
, &s
, arg3
)) = conv_endian(offset
);
1324 m32rbf_h_gr_set (current_cpu
, 0, -errcode
);
1326 m32rbf_h_gr_set (current_cpu
, 0, result
);
1330 case TRAP_BREAKPOINT
:
1331 sim_engine_halt (sd
, current_cpu
, NULL
, pc
,
1332 sim_stopped
, SIM_SIGTRAP
);
1335 case TRAP_FLUSH_CACHE
:
1341 /* Use cr5 as EVB (EIT Vector Base) register. */
1342 USI new_pc
= m32rbf_h_cr_get (current_cpu
, 5) + 0x40 + num
* 4;
1347 /* Fake an "rte" insn. */
1348 /* FIXME: Should duplicate all of rte processing. */
1349 return (pc
& -4) + 4;