📄 emul_netbsd.c
字号:
name, processor, cia); name += sizeof(mib); /* see what to do with it ... */ switch ((int)mib) { case 6/*CTL_HW*/:#if WITH_NetBSD_HOST && (CTL_HW != 6)# error "CTL_HW"#endif if (namelen < 2) error("system_call()SYS___sysctl - CTL_HW - bad name[1]\n"); mib = vm_data_map_read_word(cpu_data_map(processor), name, processor, cia); name += sizeof(mib); switch ((int)mib) { case 7/*HW_PAGESIZE*/:#if WITH_NetBSD_HOST && (HW_PAGESIZE != 7)# error "HW_PAGESIZE"#endif oldlen = vm_data_map_read_word(cpu_data_map(processor), oldlenp, processor, cia); if (sizeof(natural_word) > oldlen) error("system_call()sysctl - CTL_HW.HW_PAGESIZE - to small\n"); int_val = 8192; oldlen = sizeof(int_val); emul_write_word(oldp, int_val, processor, cia); emul_write_word(oldlenp, oldlen, processor, cia); break; default: error("sysctl() CTL_HW.%d unknown\n", mib); break; } break; default: error("sysctl() name[0]=%d unknown\n", (int)mib); break; } emul_write_status(processor, 0, 0); /* always succeed */}static emul_syscall_descriptor netbsd_descriptors[] = { /* 0 */ { 0, "syscall" }, /* 1 */ { do_exit, "exit" }, /* 2 */ { 0, "fork" }, /* 3 */ { do_read, "read" }, /* 4 */ { do_write, "write" }, /* 5 */ { do_open, "open" }, /* 6 */ { do_close, "close" }, /* 7 */ { 0, "wait4" }, { 0, }, /* 8 is old creat */ /* 9 */ { 0, "link" }, /* 10 */ { 0, "unlink" }, { 0, }, /* 11 is obsolete execv */ /* 12 */ { 0, "chdir" }, /* 13 */ { 0, "fchdir" }, /* 14 */ { 0, "mknod" }, /* 15 */ { 0, "chmod" }, /* 16 */ { 0, "chown" }, /* 17 */ { do_break, "break" }, /* 18 */ { 0, "getfsstat" }, { 0, }, /* 19 is old lseek */ /* 20 */ { do_getpid, "getpid" }, /* 21 */ { 0, "mount" }, /* 22 */ { 0, "unmount" }, /* 23 */ { 0, "setuid" }, /* 24 */ { do_getuid, "getuid" }, /* 25 */ { do_geteuid, "geteuid" }, /* 26 */ { 0, "ptrace" }, /* 27 */ { 0, "recvmsg" }, /* 28 */ { 0, "sendmsg" }, /* 29 */ { 0, "recvfrom" }, /* 30 */ { 0, "accept" }, /* 31 */ { 0, "getpeername" }, /* 32 */ { 0, "getsockname" }, /* 33 */ { 0, "access" }, /* 34 */ { 0, "chflags" }, /* 35 */ { 0, "fchflags" }, /* 36 */ { 0, "sync" }, /* 37 */ { do_kill, "kill" }, { 0, }, /* 38 is old stat */ /* 39 */ { 0, "getppid" }, { 0, }, /* 40 is old lstat */ /* 41 */ { do_dup, "dup" }, /* 42 */ { 0, "pipe" }, /* 43 */ { do_getegid, "getegid" }, /* 44 */ { 0, "profil" }, /* 45 */ { 0, "ktrace" }, /* 46 */ { 0, "sigaction" }, /* 47 */ { do_getgid, "getgid" }, /* 48 */ { do_sigprocmask, "sigprocmask" }, /* 49 */ { 0, "getlogin" }, /* 50 */ { 0, "setlogin" }, /* 51 */ { 0, "acct" }, /* 52 */ { 0, "sigpending" }, /* 53 */ { 0, "sigaltstack" }, /* 54 */ { do_ioctl, "ioctl" }, /* 55 */ { 0, "reboot" }, /* 56 */ { 0, "revoke" }, /* 57 */ { 0, "symlink" }, /* 58 */ { 0, "readlink" }, /* 59 */ { 0, "execve" }, /* 60 */ { do_umask, "umask" }, /* 61 */ { 0, "chroot" }, { 0, }, /* 62 is old fstat */ { 0, }, /* 63 is old getkerninfo */ { 0, }, /* 64 is old getpagesize */ /* 65 */ { 0, "msync" }, /* 66 */ { 0, "vfork" }, { 0, }, /* 67 is obsolete vread */ { 0, }, /* 68 is obsolete vwrite */ /* 69 */ { 0, "sbrk" }, /* 70 */ { 0, "sstk" }, { 0, }, /* 71 is old mmap */ /* 72 */ { 0, "vadvise" }, /* 73 */ { 0, "munmap" }, /* 74 */ { 0, "mprotect" }, /* 75 */ { 0, "madvise" }, { 0, }, /* 76 is obsolete vhangup */ { 0, }, /* 77 is obsolete vlimit */ /* 78 */ { 0, "mincore" }, /* 79 */ { 0, "getgroups" }, /* 80 */ { 0, "setgroups" }, /* 81 */ { 0, "getpgrp" }, /* 82 */ { 0, "setpgid" }, /* 83 */ { 0, "setitimer" }, { 0, }, /* 84 is old wait */ /* 85 */ { 0, "swapon" }, /* 86 */ { 0, "getitimer" }, { 0, }, /* 87 is old gethostname */ { 0, }, /* 88 is old sethostname */ { 0, }, /* 89 is old getdtablesize */ { do_dup2, "dup2" }, { 0, }, /* 91 */ /* 92 */ { do_fcntl, "fcntl" }, /* 93 */ { 0, "select" }, { 0, }, /* 94 */ /* 95 */ { 0, "fsync" }, /* 96 */ { 0, "setpriority" }, /* 97 */ { 0, "socket" }, /* 98 */ { 0, "connect" }, { 0, }, /* 99 is old accept */ /* 100 */ { 0, "getpriority" }, { 0, }, /* 101 is old send */ { 0, }, /* 102 is old recv */ /* 103 */ { 0, "sigreturn" }, /* 104 */ { 0, "bind" }, /* 105 */ { 0, "setsockopt" }, /* 106 */ { 0, "listen" }, { 0, }, /* 107 is obsolete vtimes */ { 0, }, /* 108 is old sigvec */ { 0, }, /* 109 is old sigblock */ { 0, }, /* 110 is old sigsetmask */ /* 111 */ { 0, "sigsuspend" }, { 0, }, /* 112 is old sigstack */ { 0, }, /* 113 is old recvmsg */ { 0, }, /* 114 is old sendmsg */ /* - is obsolete vtrace */ { 0, "vtrace 115" }, /* 116 */ { do_gettimeofday, "gettimeofday" }, /* 117 */ { do_getrusage, "getrusage" }, /* 118 */ { 0, "getsockopt" }, /* 119 */ { 0, "resuba" }, /* 120 */ { 0, "readv" }, /* 121 */ { 0, "writev" }, /* 122 */ { 0, "settimeofday" }, /* 123 */ { 0, "fchown" }, /* 124 */ { 0, "fchmod" }, { 0, }, /* 125 is old recvfrom */ { 0, }, /* 126 is old setreuid */ { 0, }, /* 127 is old setregid */ /* 128 */ { 0, "rename" }, { 0, }, /* 129 is old truncate */ { 0, }, /* 130 is old ftruncate */ /* 131 */ { 0, "flock" }, /* 132 */ { 0, "mkfifo" }, /* 133 */ { 0, "sendto" }, /* 134 */ { 0, "shutdown" }, /* 135 */ { 0, "socketpair" }, /* 136 */ { 0, "mkdir" }, /* 137 */ { 0, "rmdir" }, /* 138 */ { 0, "utimes" }, { 0, }, /* 139 is obsolete 4.2 sigreturn */ /* 140 */ { 0, "adjtime" }, { 0, }, /* 141 is old getpeername */ { 0, }, /* 142 is old gethostid */ { 0, }, /* 143 is old sethostid */ { 0, }, /* 144 is old getrlimit */ { 0, }, /* 145 is old setrlimit */ { 0, }, /* 146 is old killpg */ /* 147 */ { 0, "setsid" }, /* 148 */ { 0, "quotactl" }, { 0, }, /* 149 is old quota */ { 0, }, /* 150 is old getsockname */ { 0, }, /* 151 */ { 0, }, /* 152 */ { 0, }, /* 153 */ { 0, }, /* 154 */ /* 155 */ { 0, "nfssvc" }, { 0, }, /* 156 is old getdirentries */ /* 157 */ { 0, "statfs" }, /* 158 */ { do_fstatfs, "fstatfs" }, { 0, }, /* 159 */ { 0, }, /* 160 */ /* 161 */ { 0, "getfh" }, { 0, }, /* 162 is old getdomainname */ { 0, }, /* 163 is old setdomainname */ { 0, }, /* 164 is old uname */ /* 165 */ { 0, "sysarch" }, { 0, }, /* 166 */ { 0, }, /* 167 */ { 0, }, /* 168 */ /* 169 */ { 0, "semsys" }, /* 170 */ { 0, "msgsys" }, /* 171 */ { 0, "shmsys" }, { 0, }, /* 172 */ { 0, }, /* 173 */ { 0, }, /* 174 */ { 0, }, /* 175 */ { 0, }, /* 176 */ { 0, }, /* 177 */ { 0, }, /* 178 */ { 0, }, /* 179 */ { 0, }, /* 180 */ /* 181 */ { 0, "setgid" }, /* 182 */ { 0, "setegid" }, /* 183 */ { 0, "seteuid" }, /* 184 */ { 0, "lfs_bmapv" }, /* 185 */ { 0, "lfs_markv" }, /* 186 */ { 0, "lfs_segclean" }, /* 187 */ { 0, "lfs_segwait" }, /* 188 */ { do_stat, "stat" }, /* 189 */ { do_fstat, "fstat" }, /* 190 */ { do_lstat, "lstat" }, /* 191 */ { 0, "pathconf" }, /* 192 */ { 0, "fpathconf" }, { 0, }, /* 193 */ /* 194 */ { 0, "getrlimit" }, /* 195 */ { 0, "setrlimit" }, /* 196 */ { do_getdirentries, "getdirentries" }, /* 197 */ { 0, "mmap" }, /* 198 */ { do___syscall, "__syscall" }, /* 199 */ { do_lseek, "lseek" }, /* 200 */ { 0, "truncate" }, /* 201 */ { 0, "ftruncate" }, /* 202 */ { do___sysctl, "__sysctl" }, /* 203 */ { 0, "mlock" }, /* 204 */ { 0, "munlock" },};static char *(netbsd_error_names[]) = { /* 0 */ "ESUCCESS", /* 1 */ "EPERM", /* 2 */ "ENOENT", /* 3 */ "ESRCH", /* 4 */ "EINTR", /* 5 */ "EIO", /* 6 */ "ENXIO", /* 7 */ "E2BIG", /* 8 */ "ENOEXEC", /* 9 */ "EBADF", /* 10 */ "ECHILD", /* 11 */ "EDEADLK", /* 12 */ "ENOMEM", /* 13 */ "EACCES", /* 14 */ "EFAULT", /* 15 */ "ENOTBLK", /* 16 */ "EBUSY", /* 17 */ "EEXIST", /* 18 */ "EXDEV", /* 19 */ "ENODEV", /* 20 */ "ENOTDIR", /* 21 */ "EISDIR", /* 22 */ "EINVAL", /* 23 */ "ENFILE", /* 24 */ "EMFILE", /* 25 */ "ENOTTY", /* 26 */ "ETXTBSY", /* 27 */ "EFBIG", /* 28 */ "ENOSPC", /* 29 */ "ESPIPE", /* 30 */ "EROFS", /* 31 */ "EMLINK", /* 32 */ "EPIPE", /* 33 */ "EDOM", /* 34 */ "ERANGE", /* 35 */ "EAGAIN", /* 36 */ "EINPROGRESS", /* 37 */ "EALREADY", /* 38 */ "ENOTSOCK", /* 39 */ "EDESTADDRREQ", /* 40 */ "EMSGSIZE", /* 41 */ "EPROTOTYPE", /* 42 */ "ENOPROTOOPT", /* 43 */ "EPROTONOSUPPORT", /* 44 */ "ESOCKTNOSUPPORT", /* 45 */ "EOPNOTSUPP", /* 46 */ "EPFNOSUPPORT", /* 47 */ "EAFNOSUPPORT", /* 48 */ "EADDRINUSE", /* 49 */ "EADDRNOTAVAIL", /* 50 */ "ENETDOWN", /* 51 */ "ENETUNREACH", /* 52 */ "ENETRESET", /* 53 */ "ECONNABORTED", /* 54 */ "ECONNRESET", /* 55 */ "ENOBUFS", /* 56 */ "EISCONN", /* 57 */ "ENOTCONN", /* 58 */ "ESHUTDOWN", /* 59 */ "ETOOMANYREFS", /* 60 */ "ETIMEDOUT", /* 61 */ "ECONNREFUSED", /* 62 */ "ELOOP", /* 63 */ "ENAMETOOLONG", /* 64 */ "EHOSTDOWN", /* 65 */ "EHOSTUNREACH", /* 66 */ "ENOTEMPTY", /* 67 */ "EPROCLIM", /* 68 */ "EUSERS", /* 69 */ "EDQUOT", /* 70 */ "ESTALE", /* 71 */ "EREMOTE", /* 72 */ "EBADRPC", /* 73 */ "ERPCMISMATCH", /* 74 */ "EPROGUNAVAIL", /* 75 */ "EPROGMISMATCH", /* 76 */ "EPROCUNAVAIL", /* 77 */ "ENOLCK", /* 78 */ "ENOSYS", /* 79 */ "EFTYPE", /* 80 */ "EAUTH", /* 81 */ "ENEEDAUTH", /* 81 */ "ELAST",};static char *(netbsd_signal_names[]) = { /* 0 */ 0, /* 1 */ "SIGHUP", /* 2 */ "SIGINT", /* 3 */ "SIGQUIT", /* 4 */ "SIGILL", /* 5 */ "SIGTRAP", /* 6 */ "SIGABRT", /* 7 */ "SIGEMT", /* 8 */ "SIGFPE", /* 9 */ "SIGKILL", /* 10 */ "SIGBUS", /* 11 */ "SIGSEGV", /* 12 */ "SIGSYS", /* 13 */ "SIGPIPE", /* 14 */ "SIGALRM", /* 15 */ "SIGTERM", /* 16 */ "SIGURG", /* 17 */ "SIGSTOP", /* 18 */ "SIGTSTP", /* 19 */ "SIGCONT", /* 20 */ "SIGCHLD", /* 21 */ "SIGTTIN", /* 22 */ "SIGTTOU", /* 23 */ "SIGIO", /* 24 */ "SIGXCPU", /* 25 */ "SIGXFSZ", /* 26 */ "SIGVTALRM", /* 27 */ "SIGPROF", /* 28 */ "SIGWINCH", /* 29 */ "SIGINFO", /* 30 */ "SIGUSR1", /* 31 */ "SIGUSR2",};static emul_syscall emul_netbsd_syscalls = { netbsd_descriptors, sizeof(netbsd_descriptors) / sizeof(netbsd_descriptors[0]), netbsd_error_names, sizeof(netbsd_error_names) / sizeof(netbsd_error_names[0]), netbsd_signal_names, sizeof(netbsd_signal_names) / sizeof(netbsd_signal_names[0]),};/* NetBSD's os_emul interface, most are just passed on to the generic syscall stuff */static os_emul_data *emul_netbsd_create(device *root, bfd *image, const char *name){ unsigned_word top_of_stack; unsigned stack_size; int elf_binary; os_emul_data *bsd_data; device *vm; /* check that this emulation is really for us */ if (name != NULL && strcmp(name, "netbsd") != 0) return NULL; if (image == NULL) return NULL; /* merge any emulation specific entries into the device tree */ /* establish a few defaults */ if (image->xvec->flavour == bfd_target_elf_flavour) { elf_binary = 1; top_of_stack = 0xe0000000; stack_size = 0x00100000; } else { elf_binary = 0; top_of_stack = 0x20000000; stack_size = 0x00100000; } /* options */ emul_add_tree_options(root, image, "netbsd", (WITH_ENVIRONMENT == USER_ENVIRONMENT ? "user" : "virtual"), 0 /*oea-interrupt-prefix*/); /* virtual memory - handles growth of stack/heap */ vm = tree_parse(root, "/openprom/vm"); tree_parse(vm, "./stack-base 0x%lx", (unsigned long)(top_of_stack - stack_size)); tree_parse(vm, "./nr-bytes 0x%x", stack_size); tree_parse(root, "/openprom/vm/map-binary/file-name %s", bfd_get_filename(image)); /* finish the init */ tree_parse(root, "/openprom/init/register/pc 0x%lx", (unsigned long)bfd_get_start_address(image)); tree_parse(root, "/openprom/init/register/sp 0x%lx", (unsigned long)top_of_stack); tree_parse(root, "/openprom/init/register/msr 0x%x", ((tree_find_boolean_property(root, "/options/little-endian?") ? msr_little_endian_mode : 0) | (tree_find_boolean_property(root, "/openprom/options/floating-point?") ? (msr_floating_point_available | msr_floating_point_exception_mode_0 | msr_floating_point_exception_mode_1) : 0))); tree_parse(root, "/openprom/init/stack/stack-type %s", (elf_binary ? "ppc-elf" : "ppc-xcoff")); /* finally our emulation data */ bsd_data = ZALLOC(os_emul_data); bsd_data->vm = vm; bsd_data->syscalls = &emul_netbsd_syscalls; return bsd_data;}static voidemul_netbsd_init(os_emul_data *emul_data, int nr_cpus){ /* nothing yet */}static voidemul_netbsd_system_call(cpu *processor, unsigned_word cia, os_emul_data *emul_data){ emul_do_system_call(emul_data, emul_data->syscalls, cpu_registers(processor)->gpr[0], 3, /*r3 contains arg0*/ processor, cia);}const os_emul emul_netbsd = { "netbsd", emul_netbsd_create, emul_netbsd_init, emul_netbsd_system_call, 0, /*instruction_call*/ 0 /*data*/};#endif /* _EMUL_NETBSD_C_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -