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-syscall.h"
27 #include "targ-vals.h"
36 #include <sys/resource.h>
37 #include <sys/sysinfo.h>
40 #include <sys/timeb.h>
41 #include <sys/timex.h>
42 #include <sys/types.h>
44 #include <sys/utsname.h>
46 #include <linux/sysctl.h>
47 #include <linux/types.h>
48 #include <linux/unistd.h>
50 #define TRAP_ELF_SYSCALL 0
51 #define TRAP_LINUX_SYSCALL 2
52 #define TRAP_FLUSH_CACHE 12
54 /* The semantic code invokes this for invalid (unrecognized) instructions. */
57 sim_engine_invalid_insn (SIM_CPU
*current_cpu
, IADDR cia
, SEM_PC vpc
)
59 SIM_DESC sd
= CPU_STATE (current_cpu
);
62 if (STATE_ENVIRONMENT (sd
) == OPERATING_ENVIRONMENT
)
64 h_bsm_set (current_cpu
, h_sm_get (current_cpu
));
65 h_bie_set (current_cpu
, h_ie_get (current_cpu
));
66 h_bcond_set (current_cpu
, h_cond_get (current_cpu
));
68 h_ie_set (current_cpu
, 0);
69 h_cond_set (current_cpu
, 0);
71 h_bpc_set (current_cpu
, cia
);
73 sim_engine_restart (CPU_STATE (current_cpu
), current_cpu
, NULL
,
78 sim_engine_halt (sd
, current_cpu
, NULL
, cia
, sim_stopped
, SIM_SIGILL
);
82 /* Process an address exception. */
85 m32r_core_signal (SIM_DESC sd
, SIM_CPU
*current_cpu
, sim_cia cia
,
86 unsigned int map
, int nr_bytes
, address_word addr
,
87 transfer_type transfer
, sim_core_signals sig
)
89 if (STATE_ENVIRONMENT (sd
) == OPERATING_ENVIRONMENT
)
91 m32rbf_h_cr_set (current_cpu
, H_CR_BBPC
,
92 m32rbf_h_cr_get (current_cpu
, H_CR_BPC
));
93 if (MACH_NUM (CPU_MACH (current_cpu
)) == MACH_M32R
)
95 m32rbf_h_bpsw_set (current_cpu
, m32rbf_h_psw_get (current_cpu
));
97 m32rbf_h_psw_set (current_cpu
, m32rbf_h_psw_get (current_cpu
) & 0x80);
99 else if (MACH_NUM (CPU_MACH (current_cpu
)) == MACH_M32RX
)
101 m32rxf_h_bpsw_set (current_cpu
, m32rxf_h_psw_get (current_cpu
));
103 m32rxf_h_psw_set (current_cpu
, m32rxf_h_psw_get (current_cpu
) & 0x80);
107 m32r2f_h_bpsw_set (current_cpu
, m32r2f_h_psw_get (current_cpu
));
109 m32r2f_h_psw_set (current_cpu
, m32r2f_h_psw_get (current_cpu
) & 0x80);
111 m32rbf_h_cr_set (current_cpu
, H_CR_BPC
, cia
);
113 sim_engine_restart (CPU_STATE (current_cpu
), current_cpu
, NULL
,
117 sim_core_signal (sd
, current_cpu
, cia
, map
, nr_bytes
, addr
,
121 /* Translate target's address to host's address. */
124 t2h_addr (host_callback
*cb
, struct cb_syscall
*sc
,
128 SIM_DESC sd
= (SIM_DESC
) sc
->p1
;
129 SIM_CPU
*cpu
= (SIM_CPU
*) sc
->p2
;
134 return sim_core_trans_addr (sd
, cpu
, read_map
, taddr
);
138 conv_endian (unsigned int tvalue
)
141 unsigned int t1
, t2
, t3
, t4
;
143 if (HOST_BYTE_ORDER
== BFD_ENDIAN_LITTLE
)
145 t1
= tvalue
& 0xff000000;
146 t2
= tvalue
& 0x00ff0000;
147 t3
= tvalue
& 0x0000ff00;
148 t4
= tvalue
& 0x000000ff;
161 static unsigned short
162 conv_endian16 (unsigned short tvalue
)
164 unsigned short hvalue
;
165 unsigned short t1
, t2
;
167 if (HOST_BYTE_ORDER
== BFD_ENDIAN_LITTLE
)
169 t1
= tvalue
& 0xff00;
170 t2
= tvalue
& 0x00ff;
182 translate_endian(void *addr
, size_t size
)
184 unsigned int *p
= (unsigned int *) addr
;
187 for (i
= 0; i
<= size
- 4; i
+= 4,p
++)
188 *p
= conv_endian(*p
);
191 *((unsigned short *) p
) = conv_endian16(*((unsigned short *) p
));
195 The result is the pc address to continue at.
196 Preprocessing like saving the various registers has already been done. */
199 m32r_trap (SIM_CPU
*current_cpu
, PCADDR pc
, int num
)
201 SIM_DESC sd
= CPU_STATE (current_cpu
);
202 host_callback
*cb
= STATE_CALLBACK (sd
);
206 case TRAP_ELF_SYSCALL
:
208 long result
, result2
;
211 sim_syscall_multi (current_cpu
,
212 m32rbf_h_gr_get (current_cpu
, 0),
213 m32rbf_h_gr_get (current_cpu
, 1),
214 m32rbf_h_gr_get (current_cpu
, 2),
215 m32rbf_h_gr_get (current_cpu
, 3),
216 m32rbf_h_gr_get (current_cpu
, 4),
217 &result
, &result2
, &errcode
);
219 m32rbf_h_gr_set (current_cpu
, 2, errcode
);
220 m32rbf_h_gr_set (current_cpu
, 0, result
);
221 m32rbf_h_gr_set (current_cpu
, 1, result2
);
225 case TRAP_LINUX_SYSCALL
:
228 unsigned int func
, arg1
, arg2
, arg3
, arg4
, arg5
, arg6
, arg7
;
229 int result
, result2
, errcode
;
231 if (STATE_ENVIRONMENT (sd
) == OPERATING_ENVIRONMENT
)
233 /* The new pc is the trap vector entry.
234 We assume there's a branch there to some handler.
235 Use cr5 as EVB (EIT Vector Base) register. */
236 USI new_pc
= m32rbf_h_cr_get (current_cpu
, 5) + 0x40 + num
* 4;
240 func
= m32rbf_h_gr_get (current_cpu
, 7);
241 arg1
= m32rbf_h_gr_get (current_cpu
, 0);
242 arg2
= m32rbf_h_gr_get (current_cpu
, 1);
243 arg3
= m32rbf_h_gr_get (current_cpu
, 2);
244 arg4
= m32rbf_h_gr_get (current_cpu
, 3);
245 arg5
= m32rbf_h_gr_get (current_cpu
, 4);
246 arg6
= m32rbf_h_gr_get (current_cpu
, 5);
247 arg7
= m32rbf_h_gr_get (current_cpu
, 6);
249 CB_SYSCALL_INIT (&s
);
256 s
.p2
= (PTR
) current_cpu
;
257 s
.read_mem
= sim_syscall_read_mem
;
258 s
.write_mem
= sim_syscall_write_mem
;
267 sim_engine_halt (sd
, current_cpu
, NULL
, pc
, sim_exited
, arg1
);
271 result
= read(arg1
, t2h_addr(cb
, &s
, arg2
), arg3
);
276 result
= write(arg1
, t2h_addr(cb
, &s
, arg2
), arg3
);
281 result
= open((char *) t2h_addr(cb
, &s
, arg1
), arg2
, arg3
);
286 result
= close(arg1
);
291 result
= creat((char *) t2h_addr(cb
, &s
, arg1
), arg2
);
296 result
= link((char *) t2h_addr(cb
, &s
, arg1
),
297 (char *) t2h_addr(cb
, &s
, arg2
));
302 result
= unlink((char *) t2h_addr(cb
, &s
, arg1
));
307 result
= chdir((char *) t2h_addr(cb
, &s
, arg1
));
317 result
= (int) time(NULL
);
322 result
= (int) time(&t
);
328 translate_endian((void *) &t
, sizeof(t
));
329 if ((s
.write_mem
) (cb
, &s
, arg1
, (char *) &t
, sizeof(t
)) != sizeof(t
))
339 result
= mknod((char *) t2h_addr(cb
, &s
, arg1
),
340 (mode_t
) arg2
, (dev_t
) arg3
);
345 result
= chmod((char *) t2h_addr(cb
, &s
, arg1
), (mode_t
) arg2
);
351 result
= lchown((char *) t2h_addr(cb
, &s
, arg1
),
352 (uid_t
) arg2
, (gid_t
) arg3
);
357 result
= (int) lseek(arg1
, (off_t
) arg2
, arg3
);
378 result
= utime((char *) t2h_addr(cb
, &s
, arg1
), NULL
);
383 buf
= *((struct utimbuf
*) t2h_addr(cb
, &s
, arg2
));
384 translate_endian((void *) &buf
, sizeof(buf
));
385 result
= utime((char *) t2h_addr(cb
, &s
, arg1
), &buf
);
392 result
= access((char *) t2h_addr(cb
, &s
, arg1
), arg2
);
406 t
.time
= conv_endian(t
.time
);
407 t
.millitm
= conv_endian16(t
.millitm
);
408 t
.timezone
= conv_endian16(t
.timezone
);
409 t
.dstflag
= conv_endian16(t
.dstflag
);
410 if ((s
.write_mem
) (cb
, &s
, arg1
, (char *) &t
, sizeof(t
))
424 result
= rename((char *) t2h_addr(cb
, &s
, arg1
),
425 (char *) t2h_addr(cb
, &s
, arg2
));
430 result
= mkdir((char *) t2h_addr(cb
, &s
, arg1
), arg2
);
435 result
= rmdir((char *) t2h_addr(cb
, &s
, arg1
));
445 result
= brk((void *) arg1
);
469 result
= ioctl(arg1
, arg2
, arg3
);
474 result
= fcntl(arg1
, arg2
, arg3
);
479 result
= dup2(arg1
, arg2
);
497 result
= getrlimit(arg1
, &rlim
);
503 translate_endian((void *) &rlim
, sizeof(rlim
));
504 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &rlim
, sizeof(rlim
))
517 result
= getrusage(arg1
, &usage
);
523 translate_endian((void *) &usage
, sizeof(usage
));
524 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &usage
, sizeof(usage
))
533 case __NR_gettimeofday
:
538 result
= gettimeofday(&tv
, &tz
);
544 translate_endian((void *) &tv
, sizeof(tv
));
545 if ((s
.write_mem
) (cb
, &s
, arg1
, (char *) &tv
, sizeof(tv
))
552 translate_endian((void *) &tz
, sizeof(tz
));
553 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &tz
, sizeof(tz
))
562 case __NR_getgroups32
:
568 list
= (gid_t
*) malloc(arg1
* sizeof(gid_t
));
570 result
= getgroups(arg1
, list
);
576 translate_endian((void *) list
, arg1
* sizeof(gid_t
));
578 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) list
, arg1
* sizeof(gid_t
))
579 != arg1
* sizeof(gid_t
))
599 struct timeval
*ttimeoutp
;
600 struct timeval timeout
;
604 treadfdsp
= (fd_set
*) arg2
;
605 if (treadfdsp
!= NULL
)
607 readfds
= *((fd_set
*) t2h_addr(cb
, &s
, (unsigned int) treadfdsp
));
608 translate_endian((void *) &readfds
, sizeof(readfds
));
609 hreadfdsp
= &readfds
;
614 twritefdsp
= (fd_set
*) arg3
;
615 if (twritefdsp
!= NULL
)
617 writefds
= *((fd_set
*) t2h_addr(cb
, &s
, (unsigned int) twritefdsp
));
618 translate_endian((void *) &writefds
, sizeof(writefds
));
619 hwritefdsp
= &writefds
;
624 texceptfdsp
= (fd_set
*) arg4
;
625 if (texceptfdsp
!= NULL
)
627 exceptfds
= *((fd_set
*) t2h_addr(cb
, &s
, (unsigned int) texceptfdsp
));
628 translate_endian((void *) &exceptfds
, sizeof(exceptfds
));
629 hexceptfdsp
= &exceptfds
;
634 ttimeoutp
= (struct timeval
*) arg5
;
635 timeout
= *((struct timeval
*) t2h_addr(cb
, &s
, (unsigned int) ttimeoutp
));
636 translate_endian((void *) &timeout
, sizeof(timeout
));
638 result
= select(n
, hreadfdsp
, hwritefdsp
, hexceptfdsp
, &timeout
);
644 if (treadfdsp
!= NULL
)
646 translate_endian((void *) &readfds
, sizeof(readfds
));
647 if ((s
.write_mem
) (cb
, &s
, (unsigned long) treadfdsp
,
648 (char *) &readfds
, sizeof(readfds
)) != sizeof(readfds
))
655 if (twritefdsp
!= NULL
)
657 translate_endian((void *) &writefds
, sizeof(writefds
));
658 if ((s
.write_mem
) (cb
, &s
, (unsigned long) twritefdsp
,
659 (char *) &writefds
, sizeof(writefds
)) != sizeof(writefds
))
666 if (texceptfdsp
!= NULL
)
668 translate_endian((void *) &exceptfds
, sizeof(exceptfds
));
669 if ((s
.write_mem
) (cb
, &s
, (unsigned long) texceptfdsp
,
670 (char *) &exceptfds
, sizeof(exceptfds
)) != sizeof(exceptfds
))
677 translate_endian((void *) &timeout
, sizeof(timeout
));
678 if ((s
.write_mem
) (cb
, &s
, (unsigned long) ttimeoutp
,
679 (char *) &timeout
, sizeof(timeout
)) != sizeof(timeout
))
688 result
= symlink((char *) t2h_addr(cb
, &s
, arg1
),
689 (char *) t2h_addr(cb
, &s
, arg2
));
694 result
= readlink((char *) t2h_addr(cb
, &s
, arg1
),
695 (char *) t2h_addr(cb
, &s
, arg2
),
701 result
= (int) readdir((DIR *) t2h_addr(cb
, &s
, arg1
));
708 result
= (int) mmap((void *) t2h_addr(cb
, &s
, arg1
),
709 arg2
, arg3
, arg4
, arg5
, arg6
);
714 sim_core_attach (sd
, NULL
,
715 0, access_read_write_exec
, 0,
716 result
, arg2
, 0, NULL
, NULL
);
725 int prot
, flags
, fildes
;
728 addr
= (void *) t2h_addr(cb
, &s
, arg1
);
735 result
= (int) mmap(addr
, len
, prot
, flags
, fildes
, off
);
740 if (sim_core_read_buffer (sd
, NULL
, read_map
, &c
, result
, 1) == 0)
741 sim_core_attach (sd
, NULL
,
742 0, access_read_write_exec
, 0,
743 result
, len
, 0, NULL
, NULL
);
752 int prot
, flags
, fildes
;
755 addr
= *((void **) t2h_addr(cb
, &s
, arg1
));
756 len
= *((size_t *) t2h_addr(cb
, &s
, arg1
+ 4));
757 prot
= *((int *) t2h_addr(cb
, &s
, arg1
+ 8));
758 flags
= *((int *) t2h_addr(cb
, &s
, arg1
+ 12));
759 fildes
= *((int *) t2h_addr(cb
, &s
, arg1
+ 16));
760 off
= *((off_t
*) t2h_addr(cb
, &s
, arg1
+ 20));
762 addr
= (void *) conv_endian((unsigned int) addr
);
763 len
= conv_endian(len
);
764 prot
= conv_endian(prot
);
765 flags
= conv_endian(flags
);
766 fildes
= conv_endian(fildes
);
767 off
= conv_endian(off
);
769 //addr = (void *) t2h_addr(cb, &s, (unsigned int) addr);
770 result
= (int) mmap(addr
, len
, prot
, flags
, fildes
, off
);
777 if (sim_core_read_buffer (sd
, NULL
, read_map
, &c
, result
, 1) == 0)
778 sim_core_attach (sd
, NULL
,
779 0, access_read_write_exec
, 0,
780 result
, len
, 0, NULL
, NULL
);
787 result
= munmap((void *)arg1
, arg2
);
791 sim_core_detach (sd
, NULL
, 0, arg2
, result
);
797 result
= truncate((char *) t2h_addr(cb
, &s
, arg1
), arg2
);
802 result
= ftruncate(arg1
, arg2
);
807 result
= fchmod(arg1
, arg2
);
813 result
= fchown(arg1
, arg2
, arg3
);
819 struct statfs statbuf
;
821 result
= statfs((char *) t2h_addr(cb
, &s
, arg1
), &statbuf
);
827 translate_endian((void *) &statbuf
, sizeof(statbuf
));
828 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &statbuf
, sizeof(statbuf
))
839 struct statfs statbuf
;
841 result
= fstatfs(arg1
, &statbuf
);
847 translate_endian((void *) &statbuf
, sizeof(statbuf
));
848 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &statbuf
, sizeof(statbuf
))
858 result
= syslog(arg1
, (char *) t2h_addr(cb
, &s
, arg2
));
864 struct itimerval value
, ovalue
;
866 value
= *((struct itimerval
*) t2h_addr(cb
, &s
, arg2
));
867 translate_endian((void *) &value
, sizeof(value
));
871 result
= setitimer(arg1
, &value
, NULL
);
876 result
= setitimer(arg1
, &value
, &ovalue
);
882 translate_endian((void *) &ovalue
, sizeof(ovalue
));
883 if ((s
.write_mem
) (cb
, &s
, arg3
, (char *) &ovalue
, sizeof(ovalue
))
895 struct itimerval value
;
897 result
= getitimer(arg1
, &value
);
903 translate_endian((void *) &value
, sizeof(value
));
904 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &value
, sizeof(value
))
919 result
= stat((char *) t2h_addr(cb
, &s
, arg1
), &statbuf
);
924 buflen
= cb_host_to_target_stat (cb
, NULL
, NULL
);
925 buf
= xmalloc (buflen
);
926 if (cb_host_to_target_stat (cb
, &statbuf
, buf
) != buflen
)
928 /* The translation failed. This is due to an internal
929 host program error, not the target's fault. */
935 if ((s
.write_mem
) (cb
, &s
, arg2
, buf
, buflen
) != buflen
)
952 result
= lstat((char *) t2h_addr(cb
, &s
, arg1
), &statbuf
);
957 buflen
= cb_host_to_target_stat (cb
, NULL
, NULL
);
958 buf
= xmalloc (buflen
);
959 if (cb_host_to_target_stat (cb
, &statbuf
, buf
) != buflen
)
961 /* The translation failed. This is due to an internal
962 host program error, not the target's fault. */
968 if ((s
.write_mem
) (cb
, &s
, arg2
, buf
, buflen
) != buflen
)
985 result
= fstat(arg1
, &statbuf
);
990 buflen
= cb_host_to_target_stat (cb
, NULL
, NULL
);
991 buf
= xmalloc (buflen
);
992 if (cb_host_to_target_stat (cb
, &statbuf
, buf
) != buflen
)
994 /* The translation failed. This is due to an internal
995 host program error, not the target's fault. */
1001 if ((s
.write_mem
) (cb
, &s
, arg2
, buf
, buflen
) != buflen
)
1014 struct sysinfo info
;
1016 result
= sysinfo(&info
);
1022 info
.uptime
= conv_endian(info
.uptime
);
1023 info
.loads
[0] = conv_endian(info
.loads
[0]);
1024 info
.loads
[1] = conv_endian(info
.loads
[1]);
1025 info
.loads
[2] = conv_endian(info
.loads
[2]);
1026 info
.totalram
= conv_endian(info
.totalram
);
1027 info
.freeram
= conv_endian(info
.freeram
);
1028 info
.sharedram
= conv_endian(info
.sharedram
);
1029 info
.bufferram
= conv_endian(info
.bufferram
);
1030 info
.totalswap
= conv_endian(info
.totalswap
);
1031 info
.freeswap
= conv_endian(info
.freeswap
);
1032 info
.procs
= conv_endian16(info
.procs
);
1033 #if LINUX_VERSION_CODE >= 0x20400
1034 info
.totalhigh
= conv_endian(info
.totalhigh
);
1035 info
.freehigh
= conv_endian(info
.freehigh
);
1036 info
.mem_unit
= conv_endian(info
.mem_unit
);
1038 if ((s
.write_mem
) (cb
, &s
, arg1
, (char *) &info
, sizeof(info
))
1050 result
= ipc(arg1
, arg2
, arg3
, arg4
,
1051 (void *) t2h_addr(cb
, &s
, arg5
), arg6
);
1058 result
= fsync(arg1
);
1063 /* utsname contains only arrays of char, so it is not necessary
1064 to translate endian. */
1065 result
= uname((struct utsname
*) t2h_addr(cb
, &s
, arg1
));
1073 result
= adjtimex(&buf
);
1079 translate_endian((void *) &buf
, sizeof(buf
));
1080 if ((s
.write_mem
) (cb
, &s
, arg1
, (char *) &buf
, sizeof(buf
))
1090 result
= mprotect((void *) arg1
, arg2
, arg3
);
1095 result
= fchdir(arg1
);
1099 case __NR_setfsuid32
:
1101 result
= setfsuid(arg1
);
1105 case __NR_setfsgid32
:
1107 result
= setfsgid(arg1
);
1116 result
= _llseek(arg1
, arg2
, arg3
, &buf
, arg5
);
1122 translate_endian((void *) &buf
, sizeof(buf
));
1123 if ((s
.write_mem
) (cb
, &s
, t2h_addr(cb
, &s
, arg4
),
1124 (char *) &buf
, sizeof(buf
)) != sizeof(buf
))
1136 result
= getdents(arg1
, &dir
, arg3
);
1142 dir
.d_ino
= conv_endian(dir
.d_ino
);
1143 dir
.d_off
= conv_endian(dir
.d_off
);
1144 dir
.d_reclen
= conv_endian16(dir
.d_reclen
);
1145 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &dir
, sizeof(dir
))
1156 result
= flock(arg1
, arg2
);
1161 result
= msync((void *) arg1
, arg2
, arg3
);
1167 struct iovec vector
;
1169 vector
= *((struct iovec
*) t2h_addr(cb
, &s
, arg2
));
1170 translate_endian((void *) &vector
, sizeof(vector
));
1172 result
= readv(arg1
, &vector
, arg3
);
1179 struct iovec vector
;
1181 vector
= *((struct iovec
*) t2h_addr(cb
, &s
, arg2
));
1182 translate_endian((void *) &vector
, sizeof(vector
));
1184 result
= writev(arg1
, &vector
, arg3
);
1189 case __NR_fdatasync
:
1190 result
= fdatasync(arg1
);
1195 result
= mlock((void *) t2h_addr(cb
, &s
, arg1
), arg2
);
1200 result
= munlock((void *) t2h_addr(cb
, &s
, arg1
), arg2
);
1204 case __NR_nanosleep
:
1206 struct timespec req
, rem
;
1208 req
= *((struct timespec
*) t2h_addr(cb
, &s
, arg2
));
1209 translate_endian((void *) &req
, sizeof(req
));
1211 result
= nanosleep(&req
, &rem
);
1217 translate_endian((void *) &rem
, sizeof(rem
));
1218 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &rem
, sizeof(rem
))
1227 case __NR_mremap
: /* FIXME */
1228 result
= (int) mremap((void *) t2h_addr(cb
, &s
, arg1
), arg2
, arg3
, arg4
);
1232 case __NR_getresuid32
:
1233 case __NR_getresuid
:
1235 uid_t ruid
, euid
, suid
;
1237 result
= getresuid(&ruid
, &euid
, &suid
);
1243 *((uid_t
*) t2h_addr(cb
, &s
, arg1
)) = conv_endian(ruid
);
1244 *((uid_t
*) t2h_addr(cb
, &s
, arg2
)) = conv_endian(euid
);
1245 *((uid_t
*) t2h_addr(cb
, &s
, arg3
)) = conv_endian(suid
);
1253 ufds
= *((struct pollfd
*) t2h_addr(cb
, &s
, arg1
));
1254 ufds
.fd
= conv_endian(ufds
.fd
);
1255 ufds
.events
= conv_endian16(ufds
.events
);
1256 ufds
.revents
= conv_endian16(ufds
.revents
);
1258 result
= poll(&ufds
, arg2
, arg3
);
1263 case __NR_getresgid32
:
1264 case __NR_getresgid
:
1266 uid_t rgid
, egid
, sgid
;
1268 result
= getresgid(&rgid
, &egid
, &sgid
);
1274 *((uid_t
*) t2h_addr(cb
, &s
, arg1
)) = conv_endian(rgid
);
1275 *((uid_t
*) t2h_addr(cb
, &s
, arg2
)) = conv_endian(egid
);
1276 *((uid_t
*) t2h_addr(cb
, &s
, arg3
)) = conv_endian(sgid
);
1281 result
= pread(arg1
, (void *) t2h_addr(cb
, &s
, arg2
), arg3
, arg4
);
1286 result
= pwrite(arg1
, (void *) t2h_addr(cb
, &s
, arg2
), arg3
, arg4
);
1292 result
= chown((char *) t2h_addr(cb
, &s
, arg1
), arg2
, arg3
);
1297 result
= (int) getcwd((char *) t2h_addr(cb
, &s
, arg1
), arg2
);
1305 offset
= *((off_t
*) t2h_addr(cb
, &s
, arg3
));
1306 offset
= conv_endian(offset
);
1308 result
= sendfile(arg1
, arg2
, &offset
, arg3
);
1314 *((off_t
*) t2h_addr(cb
, &s
, arg3
)) = conv_endian(offset
);
1325 m32rbf_h_gr_set (current_cpu
, 0, -errcode
);
1327 m32rbf_h_gr_set (current_cpu
, 0, result
);
1331 case TRAP_BREAKPOINT
:
1332 sim_engine_halt (sd
, current_cpu
, NULL
, pc
,
1333 sim_stopped
, SIM_SIGTRAP
);
1336 case TRAP_FLUSH_CACHE
:
1342 /* Use cr5 as EVB (EIT Vector Base) register. */
1343 USI new_pc
= m32rbf_h_cr_get (current_cpu
, 5) + 0x40 + num
* 4;
1348 /* Fake an "rte" insn. */
1349 /* FIXME: Should duplicate all of rte processing. */
1350 return (pc
& -4) + 4;