8fee2a04b54a48d57e2b309ee2d6b5ac262b19a2
1 /* m32r exception, interrupt, and trap (EIT) support
2 Copyright (C) 1998-2015 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/>. */
21 #include "sim-syscall.h"
23 #include "targ-vals.h"
32 #include <sys/resource.h>
33 #include <sys/sysinfo.h>
36 #include <sys/timeb.h>
37 #include <sys/timex.h>
38 #include <sys/types.h>
40 #include <sys/utsname.h>
42 #include <linux/sysctl.h>
43 #include <linux/types.h>
44 #include <linux/unistd.h>
46 #define TRAP_ELF_SYSCALL 0
47 #define TRAP_LINUX_SYSCALL 2
48 #define TRAP_FLUSH_CACHE 12
50 /* The semantic code invokes this for invalid (unrecognized) instructions. */
53 sim_engine_invalid_insn (SIM_CPU
*current_cpu
, IADDR cia
, SEM_PC vpc
)
55 SIM_DESC sd
= CPU_STATE (current_cpu
);
58 if (STATE_ENVIRONMENT (sd
) == OPERATING_ENVIRONMENT
)
60 h_bsm_set (current_cpu
, h_sm_get (current_cpu
));
61 h_bie_set (current_cpu
, h_ie_get (current_cpu
));
62 h_bcond_set (current_cpu
, h_cond_get (current_cpu
));
64 h_ie_set (current_cpu
, 0);
65 h_cond_set (current_cpu
, 0);
67 h_bpc_set (current_cpu
, cia
);
69 sim_engine_restart (CPU_STATE (current_cpu
), current_cpu
, NULL
,
74 sim_engine_halt (sd
, current_cpu
, NULL
, cia
, sim_stopped
, SIM_SIGILL
);
78 /* Process an address exception. */
81 m32r_core_signal (SIM_DESC sd
, SIM_CPU
*current_cpu
, sim_cia cia
,
82 unsigned int map
, int nr_bytes
, address_word addr
,
83 transfer_type transfer
, sim_core_signals sig
)
85 if (STATE_ENVIRONMENT (sd
) == OPERATING_ENVIRONMENT
)
87 m32rbf_h_cr_set (current_cpu
, H_CR_BBPC
,
88 m32rbf_h_cr_get (current_cpu
, H_CR_BPC
));
89 if (MACH_NUM (CPU_MACH (current_cpu
)) == MACH_M32R
)
91 m32rbf_h_bpsw_set (current_cpu
, m32rbf_h_psw_get (current_cpu
));
93 m32rbf_h_psw_set (current_cpu
, m32rbf_h_psw_get (current_cpu
) & 0x80);
95 else if (MACH_NUM (CPU_MACH (current_cpu
)) == MACH_M32RX
)
97 m32rxf_h_bpsw_set (current_cpu
, m32rxf_h_psw_get (current_cpu
));
99 m32rxf_h_psw_set (current_cpu
, m32rxf_h_psw_get (current_cpu
) & 0x80);
103 m32r2f_h_bpsw_set (current_cpu
, m32r2f_h_psw_get (current_cpu
));
105 m32r2f_h_psw_set (current_cpu
, m32r2f_h_psw_get (current_cpu
) & 0x80);
107 m32rbf_h_cr_set (current_cpu
, H_CR_BPC
, cia
);
109 sim_engine_restart (CPU_STATE (current_cpu
), current_cpu
, NULL
,
113 sim_core_signal (sd
, current_cpu
, cia
, map
, nr_bytes
, addr
,
117 /* Translate target's address to host's address. */
120 t2h_addr (host_callback
*cb
, struct cb_syscall
*sc
,
124 SIM_DESC sd
= (SIM_DESC
) sc
->p1
;
125 SIM_CPU
*cpu
= (SIM_CPU
*) sc
->p2
;
130 return sim_core_trans_addr (sd
, cpu
, read_map
, taddr
);
134 conv_endian (unsigned int tvalue
)
137 unsigned int t1
, t2
, t3
, t4
;
139 if (CURRENT_HOST_BYTE_ORDER
== LITTLE_ENDIAN
)
141 t1
= tvalue
& 0xff000000;
142 t2
= tvalue
& 0x00ff0000;
143 t3
= tvalue
& 0x0000ff00;
144 t4
= tvalue
& 0x000000ff;
157 static unsigned short
158 conv_endian16 (unsigned short tvalue
)
160 unsigned short hvalue
;
161 unsigned short t1
, t2
;
163 if (CURRENT_HOST_BYTE_ORDER
== LITTLE_ENDIAN
)
165 t1
= tvalue
& 0xff00;
166 t2
= tvalue
& 0x00ff;
178 translate_endian(void *addr
, size_t size
)
180 unsigned int *p
= (unsigned int *) addr
;
183 for (i
= 0; i
<= size
- 4; i
+= 4,p
++)
184 *p
= conv_endian(*p
);
187 *((unsigned short *) p
) = conv_endian16(*((unsigned short *) p
));
191 The result is the pc address to continue at.
192 Preprocessing like saving the various registers has already been done. */
195 m32r_trap (SIM_CPU
*current_cpu
, PCADDR pc
, int num
)
197 SIM_DESC sd
= CPU_STATE (current_cpu
);
198 host_callback
*cb
= STATE_CALLBACK (sd
);
200 #ifdef SIM_HAVE_BREAKPOINTS
201 /* Check for breakpoints "owned" by the simulator first, regardless
203 if (num
== TRAP_BREAKPOINT
)
205 /* First try sim-break.c. If it's a breakpoint the simulator "owns"
206 it doesn't return. Otherwise it returns and let's us try. */
207 sim_handle_breakpoint (sd
, current_cpu
, pc
);
214 case TRAP_ELF_SYSCALL
:
216 long result
, result2
;
219 sim_syscall_multi (current_cpu
,
220 m32rbf_h_gr_get (current_cpu
, 0),
221 m32rbf_h_gr_get (current_cpu
, 1),
222 m32rbf_h_gr_get (current_cpu
, 2),
223 m32rbf_h_gr_get (current_cpu
, 3),
224 m32rbf_h_gr_get (current_cpu
, 4),
225 &result
, &result2
, &errcode
);
227 m32rbf_h_gr_set (current_cpu
, 2, errcode
);
228 m32rbf_h_gr_set (current_cpu
, 0, result
);
229 m32rbf_h_gr_set (current_cpu
, 1, result2
);
233 case TRAP_LINUX_SYSCALL
:
236 unsigned int func
, arg1
, arg2
, arg3
, arg4
, arg5
, arg6
, arg7
;
237 int result
, result2
, errcode
;
239 if (STATE_ENVIRONMENT (sd
) == OPERATING_ENVIRONMENT
)
241 /* The new pc is the trap vector entry.
242 We assume there's a branch there to some handler.
243 Use cr5 as EVB (EIT Vector Base) register. */
244 USI new_pc
= m32rbf_h_cr_get (current_cpu
, 5) + 0x40 + num
* 4;
248 func
= m32rbf_h_gr_get (current_cpu
, 7);
249 arg1
= m32rbf_h_gr_get (current_cpu
, 0);
250 arg2
= m32rbf_h_gr_get (current_cpu
, 1);
251 arg3
= m32rbf_h_gr_get (current_cpu
, 2);
252 arg4
= m32rbf_h_gr_get (current_cpu
, 3);
253 arg5
= m32rbf_h_gr_get (current_cpu
, 4);
254 arg6
= m32rbf_h_gr_get (current_cpu
, 5);
255 arg7
= m32rbf_h_gr_get (current_cpu
, 6);
257 CB_SYSCALL_INIT (&s
);
264 s
.p2
= (PTR
) current_cpu
;
265 s
.read_mem
= sim_syscall_read_mem
;
266 s
.write_mem
= sim_syscall_write_mem
;
275 sim_engine_halt (sd
, current_cpu
, NULL
, pc
, sim_exited
, arg1
);
279 result
= read(arg1
, t2h_addr(cb
, &s
, arg2
), arg3
);
284 result
= write(arg1
, t2h_addr(cb
, &s
, arg2
), arg3
);
289 result
= open((char *) t2h_addr(cb
, &s
, arg1
), arg2
, arg3
);
294 result
= close(arg1
);
299 result
= creat((char *) t2h_addr(cb
, &s
, arg1
), arg2
);
304 result
= link((char *) t2h_addr(cb
, &s
, arg1
),
305 (char *) t2h_addr(cb
, &s
, arg2
));
310 result
= unlink((char *) t2h_addr(cb
, &s
, arg1
));
315 result
= chdir((char *) t2h_addr(cb
, &s
, arg1
));
325 result
= (int) time(NULL
);
330 result
= (int) time(&t
);
336 translate_endian((void *) &t
, sizeof(t
));
337 if ((s
.write_mem
) (cb
, &s
, arg1
, (char *) &t
, sizeof(t
)) != sizeof(t
))
347 result
= mknod((char *) t2h_addr(cb
, &s
, arg1
),
348 (mode_t
) arg2
, (dev_t
) arg3
);
353 result
= chmod((char *) t2h_addr(cb
, &s
, arg1
), (mode_t
) arg2
);
359 result
= lchown((char *) t2h_addr(cb
, &s
, arg1
),
360 (uid_t
) arg2
, (gid_t
) arg3
);
365 result
= (int) lseek(arg1
, (off_t
) arg2
, arg3
);
386 result
= utime((char *) t2h_addr(cb
, &s
, arg1
), NULL
);
391 buf
= *((struct utimbuf
*) t2h_addr(cb
, &s
, arg2
));
392 translate_endian((void *) &buf
, sizeof(buf
));
393 result
= utime((char *) t2h_addr(cb
, &s
, arg1
), &buf
);
400 result
= access((char *) t2h_addr(cb
, &s
, arg1
), arg2
);
414 t
.time
= conv_endian(t
.time
);
415 t
.millitm
= conv_endian16(t
.millitm
);
416 t
.timezone
= conv_endian16(t
.timezone
);
417 t
.dstflag
= conv_endian16(t
.dstflag
);
418 if ((s
.write_mem
) (cb
, &s
, arg1
, (char *) &t
, sizeof(t
))
432 result
= rename((char *) t2h_addr(cb
, &s
, arg1
),
433 (char *) t2h_addr(cb
, &s
, arg2
));
438 result
= mkdir((char *) t2h_addr(cb
, &s
, arg1
), arg2
);
443 result
= rmdir((char *) t2h_addr(cb
, &s
, arg1
));
453 result
= brk((void *) arg1
);
477 result
= ioctl(arg1
, arg2
, arg3
);
482 result
= fcntl(arg1
, arg2
, arg3
);
487 result
= dup2(arg1
, arg2
);
505 result
= getrlimit(arg1
, &rlim
);
511 translate_endian((void *) &rlim
, sizeof(rlim
));
512 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &rlim
, sizeof(rlim
))
525 result
= getrusage(arg1
, &usage
);
531 translate_endian((void *) &usage
, sizeof(usage
));
532 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &usage
, sizeof(usage
))
541 case __NR_gettimeofday
:
546 result
= gettimeofday(&tv
, &tz
);
552 translate_endian((void *) &tv
, sizeof(tv
));
553 if ((s
.write_mem
) (cb
, &s
, arg1
, (char *) &tv
, sizeof(tv
))
560 translate_endian((void *) &tz
, sizeof(tz
));
561 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &tz
, sizeof(tz
))
570 case __NR_getgroups32
:
576 list
= (gid_t
*) malloc(arg1
* sizeof(gid_t
));
578 result
= getgroups(arg1
, list
);
584 translate_endian((void *) list
, arg1
* sizeof(gid_t
));
586 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) list
, arg1
* sizeof(gid_t
))
587 != arg1
* sizeof(gid_t
))
607 struct timeval
*ttimeoutp
;
608 struct timeval timeout
;
612 treadfdsp
= (fd_set
*) arg2
;
613 if (treadfdsp
!= NULL
)
615 readfds
= *((fd_set
*) t2h_addr(cb
, &s
, (unsigned int) treadfdsp
));
616 translate_endian((void *) &readfds
, sizeof(readfds
));
617 hreadfdsp
= &readfds
;
622 twritefdsp
= (fd_set
*) arg3
;
623 if (twritefdsp
!= NULL
)
625 writefds
= *((fd_set
*) t2h_addr(cb
, &s
, (unsigned int) twritefdsp
));
626 translate_endian((void *) &writefds
, sizeof(writefds
));
627 hwritefdsp
= &writefds
;
632 texceptfdsp
= (fd_set
*) arg4
;
633 if (texceptfdsp
!= NULL
)
635 exceptfds
= *((fd_set
*) t2h_addr(cb
, &s
, (unsigned int) texceptfdsp
));
636 translate_endian((void *) &exceptfds
, sizeof(exceptfds
));
637 hexceptfdsp
= &exceptfds
;
642 ttimeoutp
= (struct timeval
*) arg5
;
643 timeout
= *((struct timeval
*) t2h_addr(cb
, &s
, (unsigned int) ttimeoutp
));
644 translate_endian((void *) &timeout
, sizeof(timeout
));
646 result
= select(n
, hreadfdsp
, hwritefdsp
, hexceptfdsp
, &timeout
);
652 if (treadfdsp
!= NULL
)
654 translate_endian((void *) &readfds
, sizeof(readfds
));
655 if ((s
.write_mem
) (cb
, &s
, (unsigned long) treadfdsp
,
656 (char *) &readfds
, sizeof(readfds
)) != sizeof(readfds
))
663 if (twritefdsp
!= NULL
)
665 translate_endian((void *) &writefds
, sizeof(writefds
));
666 if ((s
.write_mem
) (cb
, &s
, (unsigned long) twritefdsp
,
667 (char *) &writefds
, sizeof(writefds
)) != sizeof(writefds
))
674 if (texceptfdsp
!= NULL
)
676 translate_endian((void *) &exceptfds
, sizeof(exceptfds
));
677 if ((s
.write_mem
) (cb
, &s
, (unsigned long) texceptfdsp
,
678 (char *) &exceptfds
, sizeof(exceptfds
)) != sizeof(exceptfds
))
685 translate_endian((void *) &timeout
, sizeof(timeout
));
686 if ((s
.write_mem
) (cb
, &s
, (unsigned long) ttimeoutp
,
687 (char *) &timeout
, sizeof(timeout
)) != sizeof(timeout
))
696 result
= symlink((char *) t2h_addr(cb
, &s
, arg1
),
697 (char *) t2h_addr(cb
, &s
, arg2
));
702 result
= readlink((char *) t2h_addr(cb
, &s
, arg1
),
703 (char *) t2h_addr(cb
, &s
, arg2
),
709 result
= (int) readdir((DIR *) t2h_addr(cb
, &s
, arg1
));
716 result
= (int) mmap((void *) t2h_addr(cb
, &s
, arg1
),
717 arg2
, arg3
, arg4
, arg5
, arg6
);
722 sim_core_attach (sd
, NULL
,
723 0, access_read_write_exec
, 0,
724 result
, arg2
, 0, NULL
, NULL
);
733 int prot
, flags
, fildes
;
736 addr
= (void *) t2h_addr(cb
, &s
, arg1
);
743 result
= (int) mmap(addr
, len
, prot
, flags
, fildes
, off
);
748 if (sim_core_read_buffer (sd
, NULL
, read_map
, &c
, result
, 1) == 0)
749 sim_core_attach (sd
, NULL
,
750 0, access_read_write_exec
, 0,
751 result
, len
, 0, NULL
, NULL
);
760 int prot
, flags
, fildes
;
763 addr
= *((void **) t2h_addr(cb
, &s
, arg1
));
764 len
= *((size_t *) t2h_addr(cb
, &s
, arg1
+ 4));
765 prot
= *((int *) t2h_addr(cb
, &s
, arg1
+ 8));
766 flags
= *((int *) t2h_addr(cb
, &s
, arg1
+ 12));
767 fildes
= *((int *) t2h_addr(cb
, &s
, arg1
+ 16));
768 off
= *((off_t
*) t2h_addr(cb
, &s
, arg1
+ 20));
770 addr
= (void *) conv_endian((unsigned int) addr
);
771 len
= conv_endian(len
);
772 prot
= conv_endian(prot
);
773 flags
= conv_endian(flags
);
774 fildes
= conv_endian(fildes
);
775 off
= conv_endian(off
);
777 //addr = (void *) t2h_addr(cb, &s, (unsigned int) addr);
778 result
= (int) mmap(addr
, len
, prot
, flags
, fildes
, off
);
785 if (sim_core_read_buffer (sd
, NULL
, read_map
, &c
, result
, 1) == 0)
786 sim_core_attach (sd
, NULL
,
787 0, access_read_write_exec
, 0,
788 result
, len
, 0, NULL
, NULL
);
795 result
= munmap((void *)arg1
, arg2
);
799 sim_core_detach (sd
, NULL
, 0, arg2
, result
);
805 result
= truncate((char *) t2h_addr(cb
, &s
, arg1
), arg2
);
810 result
= ftruncate(arg1
, arg2
);
815 result
= fchmod(arg1
, arg2
);
821 result
= fchown(arg1
, arg2
, arg3
);
827 struct statfs statbuf
;
829 result
= statfs((char *) t2h_addr(cb
, &s
, arg1
), &statbuf
);
835 translate_endian((void *) &statbuf
, sizeof(statbuf
));
836 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &statbuf
, sizeof(statbuf
))
847 struct statfs statbuf
;
849 result
= fstatfs(arg1
, &statbuf
);
855 translate_endian((void *) &statbuf
, sizeof(statbuf
));
856 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &statbuf
, sizeof(statbuf
))
866 result
= syslog(arg1
, (char *) t2h_addr(cb
, &s
, arg2
));
872 struct itimerval value
, ovalue
;
874 value
= *((struct itimerval
*) t2h_addr(cb
, &s
, arg2
));
875 translate_endian((void *) &value
, sizeof(value
));
879 result
= setitimer(arg1
, &value
, NULL
);
884 result
= setitimer(arg1
, &value
, &ovalue
);
890 translate_endian((void *) &ovalue
, sizeof(ovalue
));
891 if ((s
.write_mem
) (cb
, &s
, arg3
, (char *) &ovalue
, sizeof(ovalue
))
903 struct itimerval value
;
905 result
= getitimer(arg1
, &value
);
911 translate_endian((void *) &value
, sizeof(value
));
912 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &value
, sizeof(value
))
927 result
= stat((char *) t2h_addr(cb
, &s
, arg1
), &statbuf
);
932 buflen
= cb_host_to_target_stat (cb
, NULL
, NULL
);
933 buf
= xmalloc (buflen
);
934 if (cb_host_to_target_stat (cb
, &statbuf
, buf
) != buflen
)
936 /* The translation failed. This is due to an internal
937 host program error, not the target's fault. */
943 if ((s
.write_mem
) (cb
, &s
, arg2
, buf
, buflen
) != buflen
)
960 result
= lstat((char *) t2h_addr(cb
, &s
, arg1
), &statbuf
);
965 buflen
= cb_host_to_target_stat (cb
, NULL
, NULL
);
966 buf
= xmalloc (buflen
);
967 if (cb_host_to_target_stat (cb
, &statbuf
, buf
) != buflen
)
969 /* The translation failed. This is due to an internal
970 host program error, not the target's fault. */
976 if ((s
.write_mem
) (cb
, &s
, arg2
, buf
, buflen
) != buflen
)
993 result
= fstat(arg1
, &statbuf
);
998 buflen
= cb_host_to_target_stat (cb
, NULL
, NULL
);
999 buf
= xmalloc (buflen
);
1000 if (cb_host_to_target_stat (cb
, &statbuf
, buf
) != buflen
)
1002 /* The translation failed. This is due to an internal
1003 host program error, not the target's fault. */
1009 if ((s
.write_mem
) (cb
, &s
, arg2
, buf
, buflen
) != buflen
)
1022 struct sysinfo info
;
1024 result
= sysinfo(&info
);
1030 info
.uptime
= conv_endian(info
.uptime
);
1031 info
.loads
[0] = conv_endian(info
.loads
[0]);
1032 info
.loads
[1] = conv_endian(info
.loads
[1]);
1033 info
.loads
[2] = conv_endian(info
.loads
[2]);
1034 info
.totalram
= conv_endian(info
.totalram
);
1035 info
.freeram
= conv_endian(info
.freeram
);
1036 info
.sharedram
= conv_endian(info
.sharedram
);
1037 info
.bufferram
= conv_endian(info
.bufferram
);
1038 info
.totalswap
= conv_endian(info
.totalswap
);
1039 info
.freeswap
= conv_endian(info
.freeswap
);
1040 info
.procs
= conv_endian16(info
.procs
);
1041 #if LINUX_VERSION_CODE >= 0x20400
1042 info
.totalhigh
= conv_endian(info
.totalhigh
);
1043 info
.freehigh
= conv_endian(info
.freehigh
);
1044 info
.mem_unit
= conv_endian(info
.mem_unit
);
1046 if ((s
.write_mem
) (cb
, &s
, arg1
, (char *) &info
, sizeof(info
))
1058 result
= ipc(arg1
, arg2
, arg3
, arg4
,
1059 (void *) t2h_addr(cb
, &s
, arg5
), arg6
);
1066 result
= fsync(arg1
);
1071 /* utsname contains only arrays of char, so it is not necessary
1072 to translate endian. */
1073 result
= uname((struct utsname
*) t2h_addr(cb
, &s
, arg1
));
1081 result
= adjtimex(&buf
);
1087 translate_endian((void *) &buf
, sizeof(buf
));
1088 if ((s
.write_mem
) (cb
, &s
, arg1
, (char *) &buf
, sizeof(buf
))
1098 result
= mprotect((void *) arg1
, arg2
, arg3
);
1103 result
= fchdir(arg1
);
1107 case __NR_setfsuid32
:
1109 result
= setfsuid(arg1
);
1113 case __NR_setfsgid32
:
1115 result
= setfsgid(arg1
);
1124 result
= _llseek(arg1
, arg2
, arg3
, &buf
, arg5
);
1130 translate_endian((void *) &buf
, sizeof(buf
));
1131 if ((s
.write_mem
) (cb
, &s
, t2h_addr(cb
, &s
, arg4
),
1132 (char *) &buf
, sizeof(buf
)) != sizeof(buf
))
1144 result
= getdents(arg1
, &dir
, arg3
);
1150 dir
.d_ino
= conv_endian(dir
.d_ino
);
1151 dir
.d_off
= conv_endian(dir
.d_off
);
1152 dir
.d_reclen
= conv_endian16(dir
.d_reclen
);
1153 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &dir
, sizeof(dir
))
1164 result
= flock(arg1
, arg2
);
1169 result
= msync((void *) arg1
, arg2
, arg3
);
1175 struct iovec vector
;
1177 vector
= *((struct iovec
*) t2h_addr(cb
, &s
, arg2
));
1178 translate_endian((void *) &vector
, sizeof(vector
));
1180 result
= readv(arg1
, &vector
, arg3
);
1187 struct iovec vector
;
1189 vector
= *((struct iovec
*) t2h_addr(cb
, &s
, arg2
));
1190 translate_endian((void *) &vector
, sizeof(vector
));
1192 result
= writev(arg1
, &vector
, arg3
);
1197 case __NR_fdatasync
:
1198 result
= fdatasync(arg1
);
1203 result
= mlock((void *) t2h_addr(cb
, &s
, arg1
), arg2
);
1208 result
= munlock((void *) t2h_addr(cb
, &s
, arg1
), arg2
);
1212 case __NR_nanosleep
:
1214 struct timespec req
, rem
;
1216 req
= *((struct timespec
*) t2h_addr(cb
, &s
, arg2
));
1217 translate_endian((void *) &req
, sizeof(req
));
1219 result
= nanosleep(&req
, &rem
);
1225 translate_endian((void *) &rem
, sizeof(rem
));
1226 if ((s
.write_mem
) (cb
, &s
, arg2
, (char *) &rem
, sizeof(rem
))
1235 case __NR_mremap
: /* FIXME */
1236 result
= (int) mremap((void *) t2h_addr(cb
, &s
, arg1
), arg2
, arg3
, arg4
);
1240 case __NR_getresuid32
:
1241 case __NR_getresuid
:
1243 uid_t ruid
, euid
, suid
;
1245 result
= getresuid(&ruid
, &euid
, &suid
);
1251 *((uid_t
*) t2h_addr(cb
, &s
, arg1
)) = conv_endian(ruid
);
1252 *((uid_t
*) t2h_addr(cb
, &s
, arg2
)) = conv_endian(euid
);
1253 *((uid_t
*) t2h_addr(cb
, &s
, arg3
)) = conv_endian(suid
);
1261 ufds
= *((struct pollfd
*) t2h_addr(cb
, &s
, arg1
));
1262 ufds
.fd
= conv_endian(ufds
.fd
);
1263 ufds
.events
= conv_endian16(ufds
.events
);
1264 ufds
.revents
= conv_endian16(ufds
.revents
);
1266 result
= poll(&ufds
, arg2
, arg3
);
1271 case __NR_getresgid32
:
1272 case __NR_getresgid
:
1274 uid_t rgid
, egid
, sgid
;
1276 result
= getresgid(&rgid
, &egid
, &sgid
);
1282 *((uid_t
*) t2h_addr(cb
, &s
, arg1
)) = conv_endian(rgid
);
1283 *((uid_t
*) t2h_addr(cb
, &s
, arg2
)) = conv_endian(egid
);
1284 *((uid_t
*) t2h_addr(cb
, &s
, arg3
)) = conv_endian(sgid
);
1289 result
= pread(arg1
, (void *) t2h_addr(cb
, &s
, arg2
), arg3
, arg4
);
1294 result
= pwrite(arg1
, (void *) t2h_addr(cb
, &s
, arg2
), arg3
, arg4
);
1300 result
= chown((char *) t2h_addr(cb
, &s
, arg1
), arg2
, arg3
);
1305 result
= (int) getcwd((char *) t2h_addr(cb
, &s
, arg1
), arg2
);
1313 offset
= *((off_t
*) t2h_addr(cb
, &s
, arg3
));
1314 offset
= conv_endian(offset
);
1316 result
= sendfile(arg1
, arg2
, &offset
, arg3
);
1322 *((off_t
*) t2h_addr(cb
, &s
, arg3
)) = conv_endian(offset
);
1333 m32rbf_h_gr_set (current_cpu
, 0, -errcode
);
1335 m32rbf_h_gr_set (current_cpu
, 0, result
);
1339 case TRAP_BREAKPOINT
:
1340 sim_engine_halt (sd
, current_cpu
, NULL
, pc
,
1341 sim_stopped
, SIM_SIGTRAP
);
1344 case TRAP_FLUSH_CACHE
:
1350 /* Use cr5 as EVB (EIT Vector Base) register. */
1351 USI new_pc
= m32rbf_h_cr_get (current_cpu
, 5) + 0x40 + num
* 4;
1356 /* Fake an "rte" insn. */
1357 /* FIXME: Should duplicate all of rte processing. */
1358 return (pc
& -4) + 4;
This page took 0.256995 seconds and 4 git commands to generate.