📄 emul_netbsd.c
字号:
do_getuid(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia){ SYS(getuid); emul_write_status(processor, (int)getuid(), 0);}#endif#ifndef HAVE_GETEUID#define do_geteuid 0#elsestatic voiddo_geteuid(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia){ SYS(geteuid); emul_write_status(processor, (int)geteuid(), 0);}#endif#ifndef HAVE_KILL#define do_kill 0#elsestatic voiddo_kill(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia){ pid_t pid = cpu_registers(processor)->gpr[arg0]; int sig = cpu_registers(processor)->gpr[arg0+1]; if (WITH_TRACE && ppc_trace[trace_os_emul]) printf_filtered ("%d, %d", (int)pid, sig); SYS(kill); printf_filtered("SYS_kill at 0x%lx - more to this than just being killed\n", (long)cia); cpu_halt(processor, cia, was_signalled, sig);}#endif#ifndef HAVE_DUP#define do_dup 0#elsestatic voiddo_dup(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia){ int oldd = cpu_registers(processor)->gpr[arg0]; int status = dup(oldd); int err = errno; if (WITH_TRACE && ppc_trace[trace_os_emul]) printf_filtered ("%d", oldd); SYS(dup); emul_write_status(processor, status, err);}#endif#ifndef HAVE_GETEGID#define do_getegid 0#elsestatic voiddo_getegid(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia){ SYS(getegid); emul_write_status(processor, (int)getegid(), 0);}#endif#ifndef HAVE_GETGID#define do_getgid 0#elsestatic voiddo_getgid(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia){ SYS(getgid); emul_write_status(processor, (int)getgid(), 0);}#endif#ifndef HAVE_SIGPROCMASK#define do_sigprocmask 0#elsestatic voiddo_sigprocmask(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia){ natural_word how = cpu_registers(processor)->gpr[arg0]; unsigned_word set = cpu_registers(processor)->gpr[arg0+1]; unsigned_word oset = cpu_registers(processor)->gpr[arg0+2];#ifdef SYS_sigprocmask SYS(sigprocmask);#endif if (WITH_TRACE && ppc_trace[trace_os_emul]) printf_filtered ("%ld, 0x%ld, 0x%ld", (long)how, (long)set, (long)oset); emul_write_status(processor, 0, 0); cpu_registers(processor)->gpr[4] = set;}#endif#ifndef HAVE_IOCTL#define do_ioctl 0#elsestatic voiddo_ioctl(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia){ int d = cpu_registers(processor)->gpr[arg0]; unsigned request = cpu_registers(processor)->gpr[arg0+1]; unsigned_word argp_addr = cpu_registers(processor)->gpr[arg0+2];#if !WITH_NetBSD_HOST cpu_registers(processor)->gpr[arg0] = 0; /* just succeed */#else unsigned dir = request & IOC_DIRMASK; int status; SYS(ioctl); /* what we haven't done */ if (dir & IOC_IN /* write into the io device */ || dir & IOC_OUT || !(dir & IOC_VOID)) error("do_ioctl() read or write of parameter not implemented\n"); status = ioctl(d, request, NULL); emul_write_status(processor, status, errno);#endif if (WITH_TRACE && ppc_trace[trace_os_emul]) printf_filtered ("%d, 0x%x, 0x%lx", d, request, (long)argp_addr);}#endif#ifndef HAVE_UMASK#define do_umask 0#elsestatic voiddo_umask(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia){ int mask = cpu_registers(processor)->gpr[arg0]; if (WITH_TRACE && ppc_trace[trace_os_emul]) printf_filtered ("0%o", mask); SYS(umask); emul_write_status(processor, umask(mask), 0);}#endif#ifndef HAVE_DUP2#define do_dup2 0#elsestatic voiddo_dup2(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia){ int oldd = cpu_registers(processor)->gpr[arg0]; int newd = cpu_registers(processor)->gpr[arg0+1]; int status = dup2(oldd, newd); int err = errno; if (WITH_TRACE && ppc_trace[trace_os_emul]) printf_filtered ("%d, %d", oldd, newd); SYS(dup2); emul_write_status(processor, status, err);}#endif#ifndef HAVE_FCNTL#define do_fcntl 0#elsestatic voiddo_fcntl(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia){ int fd = cpu_registers(processor)->gpr[arg0]; int cmd = cpu_registers(processor)->gpr[arg0+1]; int arg = cpu_registers(processor)->gpr[arg0+2]; int status; if (WITH_TRACE && ppc_trace[trace_os_emul]) printf_filtered ("%d, %d, %d", fd, cmd, arg); SYS(fcntl); status = fcntl(fd, cmd, arg); emul_write_status(processor, status, errno);}#endif#ifndef HAVE_GETTIMEOFDAY#define do_gettimeofday 0#elsestatic voiddo_gettimeofday(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia){ unsigned_word t_addr = cpu_registers(processor)->gpr[arg0]; unsigned_word tz_addr = cpu_registers(processor)->gpr[arg0+1]; struct timeval t; struct timezone tz; int status = gettimeofday((t_addr != 0 ? &t : NULL), (tz_addr != 0 ? &tz : NULL)); int err = errno; if (WITH_TRACE && ppc_trace[trace_os_emul]) printf_filtered ("0x%lx, 0x%lx", (long)t_addr, (long)tz_addr); SYS(gettimeofday); emul_write_status(processor, status, err); if (status == 0) { if (t_addr != 0) write_timeval(t_addr, t, processor, cia); if (tz_addr != 0) write_timezone(tz_addr, tz, processor, cia); }}#endif#ifndef HAVE_GETRUSAGE#define do_getrusage 0#elsestatic voiddo_getrusage(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia){ int who = cpu_registers(processor)->gpr[arg0]; unsigned_word rusage_addr = cpu_registers(processor)->gpr[arg0+1]; struct rusage rusage; int status = getrusage(who, (rusage_addr != 0 ? &rusage : NULL)); int err = errno; if (WITH_TRACE && ppc_trace[trace_os_emul]) printf_filtered ("%d, 0x%lx", who, (long)rusage_addr); SYS(getrusage); emul_write_status(processor, status, err); if (status == 0) { if (rusage_addr != 0) write_rusage(rusage_addr, rusage, processor, cia); }}#endif#ifndef HAVE_FSTATFS#define do_fstatfs 0#elsestatic voiddo_fstatfs(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia){ int fd = cpu_registers(processor)->gpr[arg0]; unsigned_word buf_addr = cpu_registers(processor)->gpr[arg0+1]; struct statfs buf; int status; if (WITH_TRACE && ppc_trace[trace_os_emul]) printf_filtered ("%d, 0x%lx", fd, (long)buf_addr); SYS(fstatfs); status = fstatfs(fd, (buf_addr == 0 ? NULL : &buf)); emul_write_status(processor, status, errno); if (status == 0) { if (buf_addr != 0) write_statfs(buf_addr, buf, processor, cia); }}#endif#ifndef HAVE_STAT#define do_stat 0#elsestatic voiddo_stat(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia){ char path_buf[PATH_MAX]; unsigned_word path_addr = cpu_registers(processor)->gpr[arg0]; unsigned_word stat_buf_addr = cpu_registers(processor)->gpr[arg0+1]; char *path = emul_read_string(path_buf, path_addr, PATH_MAX, processor, cia); struct stat buf; int status;#ifdef SYS_stat SYS(stat);#endif status = stat(path, &buf); emul_write_status(processor, status, errno); if (status == 0) write_stat(stat_buf_addr, buf, processor, cia);}#endif#ifndef HAVE_FSTAT#define do_fstat 0#elsestatic voiddo_fstat(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia){ int fd = cpu_registers(processor)->gpr[arg0]; unsigned_word stat_buf_addr = cpu_registers(processor)->gpr[arg0+1]; struct stat buf; int status;#ifdef SYS_fstat SYS(fstat);#endif /* Can't combine these statements, cuz fstat sets errno. */ status = fstat(fd, &buf); emul_write_status(processor, status, errno); write_stat(stat_buf_addr, buf, processor, cia);}#endif#ifndef HAVE_LSTAT#define do_lstat 0#elsestatic voiddo_lstat(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia){ char path_buf[PATH_MAX]; unsigned_word path_addr = cpu_registers(processor)->gpr[arg0]; char *path = emul_read_string(path_buf, path_addr, PATH_MAX, processor, cia); unsigned_word stat_buf_addr = cpu_registers(processor)->gpr[arg0+1]; struct stat buf; int status;#ifdef SYS_lstat SYS(lstat);#endif /* Can't combine these statements, cuz lstat sets errno. */ status = lstat(path, &buf); emul_write_status(processor, status, errno); write_stat(stat_buf_addr, buf, processor, cia);}#endif#ifndef HAVE_GETDIRENTRIES#define do_getdirentries 0#elsestatic voiddo_getdirentries(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia){ int fd = cpu_registers(processor)->gpr[arg0]; unsigned_word buf_addr = cpu_registers(processor)->gpr[arg0+1]; char *buf; int nbytes = cpu_registers(processor)->gpr[arg0+2]; unsigned_word basep_addr = cpu_registers(processor)->gpr[arg0+3]; long basep; int status;#ifdef SYS_getdirentries SYS(getdirentries);#endif if (buf_addr != 0 && nbytes >= 0) buf = zalloc(nbytes); else buf = NULL; status = getdirentries(fd, (buf_addr == 0 ? NULL : buf), nbytes, (basep_addr == 0 ? NULL : &basep)); emul_write_status(processor, status, errno); if (basep_addr != 0) emul_write_word(basep_addr, basep, processor, cia); if (status > 0) write_direntries(buf_addr, buf, status, processor, cia); if (buf != NULL) zfree(buf);}#endifstatic voiddo___syscall(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia){ SYS(__syscall); emul_do_system_call(emul, emul->syscalls, cpu_registers(processor)->gpr[arg0], arg0 + 1, processor, cia);}#ifndef HAVE_LSEEK#define do_lseek 0#elsestatic voiddo_lseek(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia){ int fildes = cpu_registers(processor)->gpr[arg0]; off_t offset = emul_read_gpr64(processor, arg0+2); int whence = cpu_registers(processor)->gpr[arg0+4]; off_t status; SYS(lseek); status = lseek(fildes, offset, whence); if (status == -1) emul_write_status(processor, -1, errno); else { emul_write_status(processor, 0, 0); /* success */ emul_write_gpr64(processor, 3, status); }}#endifstatic voiddo___sysctl(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia){ /* call the arguments by their real name */ unsigned_word name = cpu_registers(processor)->gpr[arg0]; natural_word namelen = cpu_registers(processor)->gpr[arg0+1]; unsigned_word oldp = cpu_registers(processor)->gpr[arg0+2]; unsigned_word oldlenp = cpu_registers(processor)->gpr[arg0+3]; natural_word oldlen; natural_word mib; natural_word int_val; SYS(__sysctl); /* pluck out the management information base id */ if (namelen < 1) error("system_call()SYS___sysctl bad name[0]\n"); mib = vm_data_map_read_word(cpu_data_map(processor),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -