1 /* m32r exception, interrupt, and trap (EIT) support
2 Copyright (C) 1998-2014 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/>. */
22 #include "targ-vals.h"
31 #include <sys/resource.h>
32 #include <sys/sysinfo.h>
35 #include <sys/timeb.h>
36 #include <sys/timex.h>
37 #include <sys/types.h>
39 #include <sys/utsname.h>
41 #include <linux/sysctl.h>
42 #include <linux/types.h>
43 #include <linux/unistd.h>
45 #define TRAP_ELF_SYSCALL 0
46 #define TRAP_LINUX_SYSCALL 2
47 #define TRAP_FLUSH_CACHE 12
49 /* The semantic code invokes this for invalid (unrecognized) instructions. */
52 sim_engine_invalid_insn (SIM_CPU *current_cpu, IADDR cia, SEM_PC vpc)
54 SIM_DESC sd = CPU_STATE (current_cpu);
57 if (STATE_ENVIRONMENT (sd) == OPERATING_ENVIRONMENT)
59 h_bsm_set (current_cpu, h_sm_get (current_cpu));
60 h_bie_set (current_cpu, h_ie_get (current_cpu));
61 h_bcond_set (current_cpu, h_cond_get (current_cpu));
63 h_ie_set (current_cpu, 0);
64 h_cond_set (current_cpu, 0);
66 h_bpc_set (current_cpu, cia);
68 sim_engine_restart (CPU_STATE (current_cpu), current_cpu, NULL,
73 sim_engine_halt (sd, current_cpu, NULL, cia, sim_stopped, SIM_SIGILL);
77 /* Process an address exception. */
80 m32r_core_signal (SIM_DESC sd, SIM_CPU *current_cpu, sim_cia cia,
81 unsigned int map, int nr_bytes, address_word addr,
82 transfer_type transfer, sim_core_signals sig)
84 if (STATE_ENVIRONMENT (sd) == OPERATING_ENVIRONMENT)
86 m32rbf_h_cr_set (current_cpu, H_CR_BBPC,
87 m32rbf_h_cr_get (current_cpu, H_CR_BPC));
88 if (MACH_NUM (CPU_MACH (current_cpu)) == MACH_M32R)
90 m32rbf_h_bpsw_set (current_cpu, m32rbf_h_psw_get (current_cpu));
92 m32rbf_h_psw_set (current_cpu, m32rbf_h_psw_get (current_cpu) & 0x80);
94 else if (MACH_NUM (CPU_MACH (current_cpu)) == MACH_M32RX)
96 m32rxf_h_bpsw_set (current_cpu, m32rxf_h_psw_get (current_cpu));
98 m32rxf_h_psw_set (current_cpu, m32rxf_h_psw_get (current_cpu) & 0x80);
102 m32r2f_h_bpsw_set (current_cpu, m32r2f_h_psw_get (current_cpu));
104 m32r2f_h_psw_set (current_cpu, m32r2f_h_psw_get (current_cpu) & 0x80);
106 m32rbf_h_cr_set (current_cpu, H_CR_BPC, cia);
108 sim_engine_restart (CPU_STATE (current_cpu), current_cpu, NULL,
112 sim_core_signal (sd, current_cpu, cia, map, nr_bytes, addr,
116 /* Read/write functions for system call interface. */
119 syscall_read_mem (host_callback *cb, struct cb_syscall *sc,
120 unsigned long taddr, char *buf, int bytes)
122 SIM_DESC sd = (SIM_DESC) sc->p1;
123 SIM_CPU *cpu = (SIM_CPU *) sc->p2;
125 return sim_core_read_buffer (sd, cpu, read_map, buf, taddr, bytes);
129 syscall_write_mem (host_callback *cb, struct cb_syscall *sc,
130 unsigned long taddr, const char *buf, int bytes)
132 SIM_DESC sd = (SIM_DESC) sc->p1;
133 SIM_CPU *cpu = (SIM_CPU *) sc->p2;
135 return sim_core_write_buffer (sd, cpu, write_map, buf, taddr, bytes);
138 /* Translate target's address to host's address. */
141 t2h_addr (host_callback *cb, struct cb_syscall *sc,
145 SIM_DESC sd = (SIM_DESC) sc->p1;
146 SIM_CPU *cpu = (SIM_CPU *) sc->p2;
151 return sim_core_trans_addr (sd, cpu, read_map, taddr);
155 conv_endian (unsigned int tvalue)
158 unsigned int t1, t2, t3, t4;
160 if (CURRENT_HOST_BYTE_ORDER == LITTLE_ENDIAN)
162 t1 = tvalue & 0xff000000;
163 t2 = tvalue & 0x00ff0000;
164 t3 = tvalue & 0x0000ff00;
165 t4 = tvalue & 0x000000ff;
178 static unsigned short
179 conv_endian16 (unsigned short tvalue)
181 unsigned short hvalue;
182 unsigned short t1, t2;
184 if (CURRENT_HOST_BYTE_ORDER == LITTLE_ENDIAN)
186 t1 = tvalue & 0xff00;
187 t2 = tvalue & 0x00ff;
199 translate_endian(void *addr, size_t size)
201 unsigned int *p = (unsigned int *) addr;
204 for (i = 0; i <= size - 4; i += 4,p++)
205 *p = conv_endian(*p);
208 *((unsigned short *) p) = conv_endian16(*((unsigned short *) p));
212 The result is the pc address to continue at.
213 Preprocessing like saving the various registers has already been done. */
216 m32r_trap (SIM_CPU *current_cpu, PCADDR pc, int num)
218 SIM_DESC sd = CPU_STATE (current_cpu);
219 host_callback *cb = STATE_CALLBACK (sd);
221 #ifdef SIM_HAVE_BREAKPOINTS
222 /* Check for breakpoints "owned" by the simulator first, regardless
224 if (num == TRAP_BREAKPOINT)
226 /* First try sim-break.c. If it's a breakpoint the simulator "owns"
227 it doesn't return. Otherwise it returns and let's us try. */
228 sim_handle_breakpoint (sd, current_cpu, pc);
235 case TRAP_ELF_SYSCALL :
239 CB_SYSCALL_INIT (&s);
240 s.func = m32rbf_h_gr_get (current_cpu, 0);
241 s.arg1 = m32rbf_h_gr_get (current_cpu, 1);
242 s.arg2 = m32rbf_h_gr_get (current_cpu, 2);
243 s.arg3 = m32rbf_h_gr_get (current_cpu, 3);
245 if (s.func == TARGET_SYS_exit)
247 sim_engine_halt (sd, current_cpu, NULL, pc, sim_exited, s.arg1);
251 s.p2 = (PTR) current_cpu;
252 s.read_mem = syscall_read_mem;
253 s.write_mem = syscall_write_mem;
255 m32rbf_h_gr_set (current_cpu, 2, s.errcode);
256 m32rbf_h_gr_set (current_cpu, 0, s.result);
257 m32rbf_h_gr_set (current_cpu, 1, s.result2);
261 case TRAP_LINUX_SYSCALL :
264 unsigned int func, arg1, arg2, arg3, arg4, arg5, arg6, arg7;
265 int result, result2, errcode;
267 if (STATE_ENVIRONMENT (sd) == OPERATING_ENVIRONMENT)
269 /* The new pc is the trap vector entry.
270 We assume there's a branch there to some handler.
271 Use cr5 as EVB (EIT Vector Base) register. */
272 USI new_pc = m32rbf_h_cr_get (current_cpu, 5) + 0x40 + num * 4;
276 func = m32rbf_h_gr_get (current_cpu, 7);
277 arg1 = m32rbf_h_gr_get (current_cpu, 0);
278 arg2 = m32rbf_h_gr_get (current_cpu, 1);
279 arg3 = m32rbf_h_gr_get (current_cpu, 2);
280 arg4 = m32rbf_h_gr_get (current_cpu, 3);
281 arg5 = m32rbf_h_gr_get (current_cpu, 4);
282 arg6 = m32rbf_h_gr_get (current_cpu, 5);
283 arg7 = m32rbf_h_gr_get (current_cpu, 6);
285 CB_SYSCALL_INIT (&s);
292 s.p2 = (PTR) current_cpu;
293 s.read_mem = syscall_read_mem;
294 s.write_mem = syscall_write_mem;
303 sim_engine_halt (sd, current_cpu, NULL, pc, sim_exited, arg1);
307 result = read(arg1, t2h_addr(cb, &s, arg2), arg3);
312 result = write(arg1, t2h_addr(cb, &s, arg2), arg3);
317 result = open((char *) t2h_addr(cb, &s, arg1), arg2, arg3);
322 result = close(arg1);
327 result = creat((char *) t2h_addr(cb, &s, arg1), arg2);
332 result = link((char *) t2h_addr(cb, &s, arg1),
333 (char *) t2h_addr(cb, &s, arg2));
338 result = unlink((char *) t2h_addr(cb, &s, arg1));
343 result = chdir((char *) t2h_addr(cb, &s, arg1));
353 result = (int) time(NULL);
358 result = (int) time(&t);
364 translate_endian((void *) &t, sizeof(t));
365 if ((s.write_mem) (cb, &s, arg1, (char *) &t, sizeof(t)) != sizeof(t))
375 result = mknod((char *) t2h_addr(cb, &s, arg1),
376 (mode_t) arg2, (dev_t) arg3);
381 result = chmod((char *) t2h_addr(cb, &s, arg1), (mode_t) arg2);
387 result = lchown((char *) t2h_addr(cb, &s, arg1),
388 (uid_t) arg2, (gid_t) arg3);
393 result = (int) lseek(arg1, (off_t) arg2, arg3);
414 result = utime((char *) t2h_addr(cb, &s, arg1), NULL);
419 buf = *((struct utimbuf *) t2h_addr(cb, &s, arg2));
420 translate_endian((void *) &buf, sizeof(buf));
421 result = utime((char *) t2h_addr(cb, &s, arg1), &buf);
428 result = access((char *) t2h_addr(cb, &s, arg1), arg2);
442 t.time = conv_endian(t.time);
443 t.millitm = conv_endian16(t.millitm);
444 t.timezone = conv_endian16(t.timezone);
445 t.dstflag = conv_endian16(t.dstflag);
446 if ((s.write_mem) (cb, &s, arg1, (char *) &t, sizeof(t))
460 result = rename((char *) t2h_addr(cb, &s, arg1),
461 (char *) t2h_addr(cb, &s, arg2));
466 result = mkdir((char *) t2h_addr(cb, &s, arg1), arg2);
471 result = rmdir((char *) t2h_addr(cb, &s, arg1));
481 result = brk((void *) arg1);
505 result = ioctl(arg1, arg2, arg3);
510 result = fcntl(arg1, arg2, arg3);
515 result = dup2(arg1, arg2);
533 result = getrlimit(arg1, &rlim);
539 translate_endian((void *) &rlim, sizeof(rlim));
540 if ((s.write_mem) (cb, &s, arg2, (char *) &rlim, sizeof(rlim))
553 result = getrusage(arg1, &usage);
559 translate_endian((void *) &usage, sizeof(usage));
560 if ((s.write_mem) (cb, &s, arg2, (char *) &usage, sizeof(usage))
569 case __NR_gettimeofday:
574 result = gettimeofday(&tv, &tz);
580 translate_endian((void *) &tv, sizeof(tv));
581 if ((s.write_mem) (cb, &s, arg1, (char *) &tv, sizeof(tv))
588 translate_endian((void *) &tz, sizeof(tz));
589 if ((s.write_mem) (cb, &s, arg2, (char *) &tz, sizeof(tz))
598 case __NR_getgroups32:
604 list = (gid_t *) malloc(arg1 * sizeof(gid_t));
606 result = getgroups(arg1, list);
612 translate_endian((void *) list, arg1 * sizeof(gid_t));
614 if ((s.write_mem) (cb, &s, arg2, (char *) list, arg1 * sizeof(gid_t))
615 != arg1 * sizeof(gid_t))
635 struct timeval *ttimeoutp;
636 struct timeval timeout;
640 treadfdsp = (fd_set *) arg2;
641 if (treadfdsp != NULL)
643 readfds = *((fd_set *) t2h_addr(cb, &s, (unsigned int) treadfdsp));
644 translate_endian((void *) &readfds, sizeof(readfds));
645 hreadfdsp = &readfds;
650 twritefdsp = (fd_set *) arg3;
651 if (twritefdsp != NULL)
653 writefds = *((fd_set *) t2h_addr(cb, &s, (unsigned int) twritefdsp));
654 translate_endian((void *) &writefds, sizeof(writefds));
655 hwritefdsp = &writefds;
660 texceptfdsp = (fd_set *) arg4;
661 if (texceptfdsp != NULL)
663 exceptfds = *((fd_set *) t2h_addr(cb, &s, (unsigned int) texceptfdsp));
664 translate_endian((void *) &exceptfds, sizeof(exceptfds));
665 hexceptfdsp = &exceptfds;
670 ttimeoutp = (struct timeval *) arg5;
671 timeout = *((struct timeval *) t2h_addr(cb, &s, (unsigned int) ttimeoutp));
672 translate_endian((void *) &timeout, sizeof(timeout));
674 result = select(n, hreadfdsp, hwritefdsp, hexceptfdsp, &timeout);
680 if (treadfdsp != NULL)
682 translate_endian((void *) &readfds, sizeof(readfds));
683 if ((s.write_mem) (cb, &s, (unsigned long) treadfdsp,
684 (char *) &readfds, sizeof(readfds)) != sizeof(readfds))
691 if (twritefdsp != NULL)
693 translate_endian((void *) &writefds, sizeof(writefds));
694 if ((s.write_mem) (cb, &s, (unsigned long) twritefdsp,
695 (char *) &writefds, sizeof(writefds)) != sizeof(writefds))
702 if (texceptfdsp != NULL)
704 translate_endian((void *) &exceptfds, sizeof(exceptfds));
705 if ((s.write_mem) (cb, &s, (unsigned long) texceptfdsp,
706 (char *) &exceptfds, sizeof(exceptfds)) != sizeof(exceptfds))
713 translate_endian((void *) &timeout, sizeof(timeout));
714 if ((s.write_mem) (cb, &s, (unsigned long) ttimeoutp,
715 (char *) &timeout, sizeof(timeout)) != sizeof(timeout))
724 result = symlink((char *) t2h_addr(cb, &s, arg1),
725 (char *) t2h_addr(cb, &s, arg2));
730 result = readlink((char *) t2h_addr(cb, &s, arg1),
731 (char *) t2h_addr(cb, &s, arg2),
737 result = (int) readdir((DIR *) t2h_addr(cb, &s, arg1));
744 result = (int) mmap((void *) t2h_addr(cb, &s, arg1),
745 arg2, arg3, arg4, arg5, arg6);
750 sim_core_attach (sd, NULL,
751 0, access_read_write_exec, 0,
752 result, arg2, 0, NULL, NULL);
761 int prot, flags, fildes;
764 addr = (void *) t2h_addr(cb, &s, arg1);
771 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);
788 int prot, flags, fildes;
791 addr = *((void **) t2h_addr(cb, &s, arg1));
792 len = *((size_t *) t2h_addr(cb, &s, arg1 + 4));
793 prot = *((int *) t2h_addr(cb, &s, arg1 + 8));
794 flags = *((int *) t2h_addr(cb, &s, arg1 + 12));
795 fildes = *((int *) t2h_addr(cb, &s, arg1 + 16));
796 off = *((off_t *) t2h_addr(cb, &s, arg1 + 20));
798 addr = (void *) conv_endian((unsigned int) addr);
799 len = conv_endian(len);
800 prot = conv_endian(prot);
801 flags = conv_endian(flags);
802 fildes = conv_endian(fildes);
803 off = conv_endian(off);
805 //addr = (void *) t2h_addr(cb, &s, (unsigned int) addr);
806 result = (int) mmap(addr, len, prot, flags, fildes, off);
813 if (sim_core_read_buffer (sd, NULL, read_map, &c, result, 1) == 0)
814 sim_core_attach (sd, NULL,
815 0, access_read_write_exec, 0,
816 result, len, 0, NULL, NULL);
823 result = munmap((void *)arg1, arg2);
827 sim_core_detach (sd, NULL, 0, arg2, result);
833 result = truncate((char *) t2h_addr(cb, &s, arg1), arg2);
838 result = ftruncate(arg1, arg2);
843 result = fchmod(arg1, arg2);
849 result = fchown(arg1, arg2, arg3);
855 struct statfs statbuf;
857 result = statfs((char *) t2h_addr(cb, &s, arg1), &statbuf);
863 translate_endian((void *) &statbuf, sizeof(statbuf));
864 if ((s.write_mem) (cb, &s, arg2, (char *) &statbuf, sizeof(statbuf))
875 struct statfs statbuf;
877 result = fstatfs(arg1, &statbuf);
883 translate_endian((void *) &statbuf, sizeof(statbuf));
884 if ((s.write_mem) (cb, &s, arg2, (char *) &statbuf, sizeof(statbuf))
894 result = syslog(arg1, (char *) t2h_addr(cb, &s, arg2));
900 struct itimerval value, ovalue;
902 value = *((struct itimerval *) t2h_addr(cb, &s, arg2));
903 translate_endian((void *) &value, sizeof(value));
907 result = setitimer(arg1, &value, NULL);
912 result = setitimer(arg1, &value, &ovalue);
918 translate_endian((void *) &ovalue, sizeof(ovalue));
919 if ((s.write_mem) (cb, &s, arg3, (char *) &ovalue, sizeof(ovalue))
931 struct itimerval value;
933 result = getitimer(arg1, &value);
939 translate_endian((void *) &value, sizeof(value));
940 if ((s.write_mem) (cb, &s, arg2, (char *) &value, sizeof(value))
955 result = stat((char *) t2h_addr(cb, &s, arg1), &statbuf);
960 buflen = cb_host_to_target_stat (cb, NULL, NULL);
961 buf = xmalloc (buflen);
962 if (cb_host_to_target_stat (cb, &statbuf, buf) != buflen)
964 /* The translation failed. This is due to an internal
965 host program error, not the target's fault. */
971 if ((s.write_mem) (cb, &s, arg2, buf, buflen) != buflen)
988 result = lstat((char *) t2h_addr(cb, &s, arg1), &statbuf);
993 buflen = cb_host_to_target_stat (cb, NULL, NULL);
994 buf = xmalloc (buflen);
995 if (cb_host_to_target_stat (cb, &statbuf, buf) != buflen)
997 /* The translation failed. This is due to an internal
998 host program error, not the target's fault. */
1004 if ((s.write_mem) (cb, &s, arg2, buf, buflen) != buflen)
1019 struct stat statbuf;
1021 result = fstat(arg1, &statbuf);
1026 buflen = cb_host_to_target_stat (cb, NULL, NULL);
1027 buf = xmalloc (buflen);
1028 if (cb_host_to_target_stat (cb, &statbuf, buf) != buflen)
1030 /* The translation failed. This is due to an internal
1031 host program error, not the target's fault. */
1037 if ((s.write_mem) (cb, &s, arg2, buf, buflen) != buflen)
1050 struct sysinfo info;
1052 result = sysinfo(&info);
1058 info.uptime = conv_endian(info.uptime);
1059 info.loads[0] = conv_endian(info.loads[0]);
1060 info.loads[1] = conv_endian(info.loads[1]);
1061 info.loads[2] = conv_endian(info.loads[2]);
1062 info.totalram = conv_endian(info.totalram);
1063 info.freeram = conv_endian(info.freeram);
1064 info.sharedram = conv_endian(info.sharedram);
1065 info.bufferram = conv_endian(info.bufferram);
1066 info.totalswap = conv_endian(info.totalswap);
1067 info.freeswap = conv_endian(info.freeswap);
1068 info.procs = conv_endian16(info.procs);
1069 #if LINUX_VERSION_CODE >= 0x20400
1070 info.totalhigh = conv_endian(info.totalhigh);
1071 info.freehigh = conv_endian(info.freehigh);
1072 info.mem_unit = conv_endian(info.mem_unit);
1074 if ((s.write_mem) (cb, &s, arg1, (char *) &info, sizeof(info))
1086 result = ipc(arg1, arg2, arg3, arg4,
1087 (void *) t2h_addr(cb, &s, arg5), arg6);
1094 result = fsync(arg1);
1099 /* utsname contains only arrays of char, so it is not necessary
1100 to translate endian. */
1101 result = uname((struct utsname *) t2h_addr(cb, &s, arg1));
1109 result = adjtimex(&buf);
1115 translate_endian((void *) &buf, sizeof(buf));
1116 if ((s.write_mem) (cb, &s, arg1, (char *) &buf, sizeof(buf))
1126 result = mprotect((void *) arg1, arg2, arg3);
1131 result = fchdir(arg1);
1135 case __NR_setfsuid32:
1137 result = setfsuid(arg1);
1141 case __NR_setfsgid32:
1143 result = setfsgid(arg1);
1152 result = _llseek(arg1, arg2, arg3, &buf, arg5);
1158 translate_endian((void *) &buf, sizeof(buf));
1159 if ((s.write_mem) (cb, &s, t2h_addr(cb, &s, arg4),
1160 (char *) &buf, sizeof(buf)) != sizeof(buf))
1172 result = getdents(arg1, &dir, arg3);
1178 dir.d_ino = conv_endian(dir.d_ino);
1179 dir.d_off = conv_endian(dir.d_off);
1180 dir.d_reclen = conv_endian16(dir.d_reclen);
1181 if ((s.write_mem) (cb, &s, arg2, (char *) &dir, sizeof(dir))
1192 result = flock(arg1, arg2);
1197 result = msync((void *) arg1, arg2, arg3);
1203 struct iovec vector;
1205 vector = *((struct iovec *) t2h_addr(cb, &s, arg2));
1206 translate_endian((void *) &vector, sizeof(vector));
1208 result = readv(arg1, &vector, arg3);
1215 struct iovec vector;
1217 vector = *((struct iovec *) t2h_addr(cb, &s, arg2));
1218 translate_endian((void *) &vector, sizeof(vector));
1220 result = writev(arg1, &vector, arg3);
1225 case __NR_fdatasync:
1226 result = fdatasync(arg1);
1231 result = mlock((void *) t2h_addr(cb, &s, arg1), arg2);
1236 result = munlock((void *) t2h_addr(cb, &s, arg1), arg2);
1240 case __NR_nanosleep:
1242 struct timespec req, rem;
1244 req = *((struct timespec *) t2h_addr(cb, &s, arg2));
1245 translate_endian((void *) &req, sizeof(req));
1247 result = nanosleep(&req, &rem);
1253 translate_endian((void *) &rem, sizeof(rem));
1254 if ((s.write_mem) (cb, &s, arg2, (char *) &rem, sizeof(rem))
1263 case __NR_mremap: /* FIXME */
1264 result = (int) mremap((void *) t2h_addr(cb, &s, arg1), arg2, arg3, arg4);
1268 case __NR_getresuid32:
1269 case __NR_getresuid:
1271 uid_t ruid, euid, suid;
1273 result = getresuid(&ruid, &euid, &suid);
1279 *((uid_t *) t2h_addr(cb, &s, arg1)) = conv_endian(ruid);
1280 *((uid_t *) t2h_addr(cb, &s, arg2)) = conv_endian(euid);
1281 *((uid_t *) t2h_addr(cb, &s, arg3)) = conv_endian(suid);
1289 ufds = *((struct pollfd *) t2h_addr(cb, &s, arg1));
1290 ufds.fd = conv_endian(ufds.fd);
1291 ufds.events = conv_endian16(ufds.events);
1292 ufds.revents = conv_endian16(ufds.revents);
1294 result = poll(&ufds, arg2, arg3);
1299 case __NR_getresgid32:
1300 case __NR_getresgid:
1302 uid_t rgid, egid, sgid;
1304 result = getresgid(&rgid, &egid, &sgid);
1310 *((uid_t *) t2h_addr(cb, &s, arg1)) = conv_endian(rgid);
1311 *((uid_t *) t2h_addr(cb, &s, arg2)) = conv_endian(egid);
1312 *((uid_t *) t2h_addr(cb, &s, arg3)) = conv_endian(sgid);
1317 result = pread(arg1, (void *) t2h_addr(cb, &s, arg2), arg3, arg4);
1322 result = pwrite(arg1, (void *) t2h_addr(cb, &s, arg2), arg3, arg4);
1328 result = chown((char *) t2h_addr(cb, &s, arg1), arg2, arg3);
1333 result = (int) getcwd((char *) t2h_addr(cb, &s, arg1), arg2);
1341 offset = *((off_t *) t2h_addr(cb, &s, arg3));
1342 offset = conv_endian(offset);
1344 result = sendfile(arg1, arg2, &offset, arg3);
1350 *((off_t *) t2h_addr(cb, &s, arg3)) = conv_endian(offset);
1361 m32rbf_h_gr_set (current_cpu, 0, -errcode);
1363 m32rbf_h_gr_set (current_cpu, 0, result);
1367 case TRAP_BREAKPOINT:
1368 sim_engine_halt (sd, current_cpu, NULL, pc,
1369 sim_stopped, SIM_SIGTRAP);
1372 case TRAP_FLUSH_CACHE:
1378 /* Use cr5 as EVB (EIT Vector Base) register. */
1379 USI new_pc = m32rbf_h_cr_get (current_cpu, 5) + 0x40 + num * 4;
1384 /* Fake an "rte" insn. */
1385 /* FIXME: Should duplicate all of rte processing. */
1386 return (pc & -4) + 4;