Commit 048f6b4df7ca3be292f40f7f56fd4e48edcabbe9

Authored by bellard
1 parent eeef26cd

mips user emulation


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1668 c046a42c-6fe2-441c-8c8c-71466251a162
Changelog
... ... @@ -13,6 +13,7 @@ version 0.7.3:
13 13 - Linux host serial port access
14 14 - Linux host low level parallel port access
15 15 - New network emulation code supporting VLANs.
  16 + - MIPS User Linux emulation
16 17  
17 18 version 0.7.2:
18 19  
... ...
configure
... ... @@ -230,7 +230,7 @@ if test -z "$target_list" ; then
230 230 target_list="i386-softmmu ppc-softmmu sparc-softmmu x86_64-softmmu mips-softmmu arm-softmmu"
231 231 # the following are Linux specific
232 232 if [ "$linux" = "yes" ] ; then
233   - target_list="i386-user arm-user armeb-user sparc-user ppc-user $target_list"
  233 + target_list="i386-user arm-user armeb-user sparc-user ppc-user mips-user $target_list"
234 234 fi
235 235 else
236 236 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
... ...
linux-user/elfload.c
... ... @@ -247,6 +247,31 @@ static inline void init_thread(struct target_pt_regs *_regs, struct image_info *
247 247  
248 248 #endif
249 249  
  250 +#ifdef TARGET_MIPS
  251 +
  252 +#define ELF_START_MMAP 0x80000000
  253 +
  254 +#define elf_check_arch(x) ( (x) == EM_MIPS )
  255 +
  256 +#define ELF_CLASS ELFCLASS32
  257 +#ifdef TARGET_WORDS_BIGENDIAN
  258 +#define ELF_DATA ELFDATA2MSB
  259 +#else
  260 +#define ELF_DATA ELFDATA2LSB
  261 +#endif
  262 +#define ELF_ARCH EM_MIPS
  263 +
  264 +#define ELF_PLAT_INIT(_r)
  265 +
  266 +static inline void init_thread(struct target_pt_regs *regs, struct image_info *infop)
  267 +{
  268 + regs->cp0_status = CP0St_UM;
  269 + regs->cp0_epc = infop->entry;
  270 + regs->regs[29] = infop->start_stack;
  271 +}
  272 +
  273 +#endif /* TARGET_MIPS */
  274 +
250 275 #ifndef ELF_PLATFORM
251 276 #define ELF_PLATFORM (NULL)
252 277 #endif
... ...
linux-user/main.c
... ... @@ -977,6 +977,404 @@ void cpu_loop(CPUPPCState *env)
977 977 }
978 978 #endif
979 979  
  980 +#ifdef TARGET_MIPS
  981 +
  982 +#define MIPS_SYS(name, args) args,
  983 +
  984 +static const uint8_t mips_syscall_args[] = {
  985 + MIPS_SYS(sys_syscall , 0) /* 4000 */
  986 + MIPS_SYS(sys_exit , 1)
  987 + MIPS_SYS(sys_fork , 0)
  988 + MIPS_SYS(sys_read , 3)
  989 + MIPS_SYS(sys_write , 3)
  990 + MIPS_SYS(sys_open , 3) /* 4005 */
  991 + MIPS_SYS(sys_close , 1)
  992 + MIPS_SYS(sys_waitpid , 3)
  993 + MIPS_SYS(sys_creat , 2)
  994 + MIPS_SYS(sys_link , 2)
  995 + MIPS_SYS(sys_unlink , 1) /* 4010 */
  996 + MIPS_SYS(sys_execve , 0)
  997 + MIPS_SYS(sys_chdir , 1)
  998 + MIPS_SYS(sys_time , 1)
  999 + MIPS_SYS(sys_mknod , 3)
  1000 + MIPS_SYS(sys_chmod , 2) /* 4015 */
  1001 + MIPS_SYS(sys_lchown , 3)
  1002 + MIPS_SYS(sys_ni_syscall , 0)
  1003 + MIPS_SYS(sys_ni_syscall , 0) /* was sys_stat */
  1004 + MIPS_SYS(sys_lseek , 3)
  1005 + MIPS_SYS(sys_getpid , 0) /* 4020 */
  1006 + MIPS_SYS(sys_mount , 5)
  1007 + MIPS_SYS(sys_oldumount , 1)
  1008 + MIPS_SYS(sys_setuid , 1)
  1009 + MIPS_SYS(sys_getuid , 0)
  1010 + MIPS_SYS(sys_stime , 1) /* 4025 */
  1011 + MIPS_SYS(sys_ptrace , 4)
  1012 + MIPS_SYS(sys_alarm , 1)
  1013 + MIPS_SYS(sys_ni_syscall , 0) /* was sys_fstat */
  1014 + MIPS_SYS(sys_pause , 0)
  1015 + MIPS_SYS(sys_utime , 2) /* 4030 */
  1016 + MIPS_SYS(sys_ni_syscall , 0)
  1017 + MIPS_SYS(sys_ni_syscall , 0)
  1018 + MIPS_SYS(sys_access , 2)
  1019 + MIPS_SYS(sys_nice , 1)
  1020 + MIPS_SYS(sys_ni_syscall , 0) /* 4035 */
  1021 + MIPS_SYS(sys_sync , 0)
  1022 + MIPS_SYS(sys_kill , 2)
  1023 + MIPS_SYS(sys_rename , 2)
  1024 + MIPS_SYS(sys_mkdir , 2)
  1025 + MIPS_SYS(sys_rmdir , 1) /* 4040 */
  1026 + MIPS_SYS(sys_dup , 1)
  1027 + MIPS_SYS(sys_pipe , 0)
  1028 + MIPS_SYS(sys_times , 1)
  1029 + MIPS_SYS(sys_ni_syscall , 0)
  1030 + MIPS_SYS(sys_brk , 1) /* 4045 */
  1031 + MIPS_SYS(sys_setgid , 1)
  1032 + MIPS_SYS(sys_getgid , 0)
  1033 + MIPS_SYS(sys_ni_syscall , 0) /* was signal(2) */
  1034 + MIPS_SYS(sys_geteuid , 0)
  1035 + MIPS_SYS(sys_getegid , 0) /* 4050 */
  1036 + MIPS_SYS(sys_acct , 0)
  1037 + MIPS_SYS(sys_umount , 2)
  1038 + MIPS_SYS(sys_ni_syscall , 0)
  1039 + MIPS_SYS(sys_ioctl , 3)
  1040 + MIPS_SYS(sys_fcntl , 3) /* 4055 */
  1041 + MIPS_SYS(sys_ni_syscall , 2)
  1042 + MIPS_SYS(sys_setpgid , 2)
  1043 + MIPS_SYS(sys_ni_syscall , 0)
  1044 + MIPS_SYS(sys_olduname , 1)
  1045 + MIPS_SYS(sys_umask , 1) /* 4060 */
  1046 + MIPS_SYS(sys_chroot , 1)
  1047 + MIPS_SYS(sys_ustat , 2)
  1048 + MIPS_SYS(sys_dup2 , 2)
  1049 + MIPS_SYS(sys_getppid , 0)
  1050 + MIPS_SYS(sys_getpgrp , 0) /* 4065 */
  1051 + MIPS_SYS(sys_setsid , 0)
  1052 + MIPS_SYS(sys_sigaction , 3)
  1053 + MIPS_SYS(sys_sgetmask , 0)
  1054 + MIPS_SYS(sys_ssetmask , 1)
  1055 + MIPS_SYS(sys_setreuid , 2) /* 4070 */
  1056 + MIPS_SYS(sys_setregid , 2)
  1057 + MIPS_SYS(sys_sigsuspend , 0)
  1058 + MIPS_SYS(sys_sigpending , 1)
  1059 + MIPS_SYS(sys_sethostname , 2)
  1060 + MIPS_SYS(sys_setrlimit , 2) /* 4075 */
  1061 + MIPS_SYS(sys_getrlimit , 2)
  1062 + MIPS_SYS(sys_getrusage , 2)
  1063 + MIPS_SYS(sys_gettimeofday, 2)
  1064 + MIPS_SYS(sys_settimeofday, 2)
  1065 + MIPS_SYS(sys_getgroups , 2) /* 4080 */
  1066 + MIPS_SYS(sys_setgroups , 2)
  1067 + MIPS_SYS(sys_ni_syscall , 0) /* old_select */
  1068 + MIPS_SYS(sys_symlink , 2)
  1069 + MIPS_SYS(sys_ni_syscall , 0) /* was sys_lstat */
  1070 + MIPS_SYS(sys_readlink , 3) /* 4085 */
  1071 + MIPS_SYS(sys_uselib , 1)
  1072 + MIPS_SYS(sys_swapon , 2)
  1073 + MIPS_SYS(sys_reboot , 3)
  1074 + MIPS_SYS(old_readdir , 3)
  1075 + MIPS_SYS(old_mmap , 6) /* 4090 */
  1076 + MIPS_SYS(sys_munmap , 2)
  1077 + MIPS_SYS(sys_truncate , 2)
  1078 + MIPS_SYS(sys_ftruncate , 2)
  1079 + MIPS_SYS(sys_fchmod , 2)
  1080 + MIPS_SYS(sys_fchown , 3) /* 4095 */
  1081 + MIPS_SYS(sys_getpriority , 2)
  1082 + MIPS_SYS(sys_setpriority , 3)
  1083 + MIPS_SYS(sys_ni_syscall , 0)
  1084 + MIPS_SYS(sys_statfs , 2)
  1085 + MIPS_SYS(sys_fstatfs , 2) /* 4100 */
  1086 + MIPS_SYS(sys_ni_syscall , 0) /* was ioperm(2) */
  1087 + MIPS_SYS(sys_socketcall , 2)
  1088 + MIPS_SYS(sys_syslog , 3)
  1089 + MIPS_SYS(sys_setitimer , 3)
  1090 + MIPS_SYS(sys_getitimer , 2) /* 4105 */
  1091 + MIPS_SYS(sys_newstat , 2)
  1092 + MIPS_SYS(sys_newlstat , 2)
  1093 + MIPS_SYS(sys_newfstat , 2)
  1094 + MIPS_SYS(sys_uname , 1)
  1095 + MIPS_SYS(sys_ni_syscall , 0) /* 4110 was iopl(2) */
  1096 + MIPS_SYS(sys_vhangup , 0)
  1097 + MIPS_SYS(sys_ni_syscall , 0) /* was sys_idle() */
  1098 + MIPS_SYS(sys_ni_syscall , 0) /* was sys_vm86 */
  1099 + MIPS_SYS(sys_wait4 , 4)
  1100 + MIPS_SYS(sys_swapoff , 1) /* 4115 */
  1101 + MIPS_SYS(sys_sysinfo , 1)
  1102 + MIPS_SYS(sys_ipc , 6)
  1103 + MIPS_SYS(sys_fsync , 1)
  1104 + MIPS_SYS(sys_sigreturn , 0)
  1105 + MIPS_SYS(sys_clone , 0) /* 4120 */
  1106 + MIPS_SYS(sys_setdomainname, 2)
  1107 + MIPS_SYS(sys_newuname , 1)
  1108 + MIPS_SYS(sys_ni_syscall , 0) /* sys_modify_ldt */
  1109 + MIPS_SYS(sys_adjtimex , 1)
  1110 + MIPS_SYS(sys_mprotect , 3) /* 4125 */
  1111 + MIPS_SYS(sys_sigprocmask , 3)
  1112 + MIPS_SYS(sys_ni_syscall , 0) /* was create_module */
  1113 + MIPS_SYS(sys_init_module , 5)
  1114 + MIPS_SYS(sys_delete_module, 1)
  1115 + MIPS_SYS(sys_ni_syscall , 0) /* 4130 was get_kernel_syms */
  1116 + MIPS_SYS(sys_quotactl , 0)
  1117 + MIPS_SYS(sys_getpgid , 1)
  1118 + MIPS_SYS(sys_fchdir , 1)
  1119 + MIPS_SYS(sys_bdflush , 2)
  1120 + MIPS_SYS(sys_sysfs , 3) /* 4135 */
  1121 + MIPS_SYS(sys_personality , 1)
  1122 + MIPS_SYS(sys_ni_syscall , 0) /* for afs_syscall */
  1123 + MIPS_SYS(sys_setfsuid , 1)
  1124 + MIPS_SYS(sys_setfsgid , 1)
  1125 + MIPS_SYS(sys_llseek , 5) /* 4140 */
  1126 + MIPS_SYS(sys_getdents , 3)
  1127 + MIPS_SYS(sys_select , 5)
  1128 + MIPS_SYS(sys_flock , 2)
  1129 + MIPS_SYS(sys_msync , 3)
  1130 + MIPS_SYS(sys_readv , 3) /* 4145 */
  1131 + MIPS_SYS(sys_writev , 3)
  1132 + MIPS_SYS(sys_cacheflush , 3)
  1133 + MIPS_SYS(sys_cachectl , 3)
  1134 + MIPS_SYS(sys_sysmips , 4)
  1135 + MIPS_SYS(sys_ni_syscall , 0) /* 4150 */
  1136 + MIPS_SYS(sys_getsid , 1)
  1137 + MIPS_SYS(sys_fdatasync , 0)
  1138 + MIPS_SYS(sys_sysctl , 1)
  1139 + MIPS_SYS(sys_mlock , 2)
  1140 + MIPS_SYS(sys_munlock , 2) /* 4155 */
  1141 + MIPS_SYS(sys_mlockall , 1)
  1142 + MIPS_SYS(sys_munlockall , 0)
  1143 + MIPS_SYS(sys_sched_setparam, 2)
  1144 + MIPS_SYS(sys_sched_getparam, 2)
  1145 + MIPS_SYS(sys_sched_setscheduler, 3) /* 4160 */
  1146 + MIPS_SYS(sys_sched_getscheduler, 1)
  1147 + MIPS_SYS(sys_sched_yield , 0)
  1148 + MIPS_SYS(sys_sched_get_priority_max, 1)
  1149 + MIPS_SYS(sys_sched_get_priority_min, 1)
  1150 + MIPS_SYS(sys_sched_rr_get_interval, 2) /* 4165 */
  1151 + MIPS_SYS(sys_nanosleep, 2)
  1152 + MIPS_SYS(sys_mremap , 4)
  1153 + MIPS_SYS(sys_accept , 3)
  1154 + MIPS_SYS(sys_bind , 3)
  1155 + MIPS_SYS(sys_connect , 3) /* 4170 */
  1156 + MIPS_SYS(sys_getpeername , 3)
  1157 + MIPS_SYS(sys_getsockname , 3)
  1158 + MIPS_SYS(sys_getsockopt , 5)
  1159 + MIPS_SYS(sys_listen , 2)
  1160 + MIPS_SYS(sys_recv , 4) /* 4175 */
  1161 + MIPS_SYS(sys_recvfrom , 6)
  1162 + MIPS_SYS(sys_recvmsg , 3)
  1163 + MIPS_SYS(sys_send , 4)
  1164 + MIPS_SYS(sys_sendmsg , 3)
  1165 + MIPS_SYS(sys_sendto , 6) /* 4180 */
  1166 + MIPS_SYS(sys_setsockopt , 5)
  1167 + MIPS_SYS(sys_shutdown , 2)
  1168 + MIPS_SYS(sys_socket , 3)
  1169 + MIPS_SYS(sys_socketpair , 4)
  1170 + MIPS_SYS(sys_setresuid , 3) /* 4185 */
  1171 + MIPS_SYS(sys_getresuid , 3)
  1172 + MIPS_SYS(sys_ni_syscall , 0) /* was sys_query_module */
  1173 + MIPS_SYS(sys_poll , 3)
  1174 + MIPS_SYS(sys_nfsservctl , 3)
  1175 + MIPS_SYS(sys_setresgid , 3) /* 4190 */
  1176 + MIPS_SYS(sys_getresgid , 3)
  1177 + MIPS_SYS(sys_prctl , 5)
  1178 + MIPS_SYS(sys_rt_sigreturn, 0)
  1179 + MIPS_SYS(sys_rt_sigaction, 4)
  1180 + MIPS_SYS(sys_rt_sigprocmask, 4) /* 4195 */
  1181 + MIPS_SYS(sys_rt_sigpending, 2)
  1182 + MIPS_SYS(sys_rt_sigtimedwait, 4)
  1183 + MIPS_SYS(sys_rt_sigqueueinfo, 3)
  1184 + MIPS_SYS(sys_rt_sigsuspend, 0)
  1185 + MIPS_SYS(sys_pread64 , 6) /* 4200 */
  1186 + MIPS_SYS(sys_pwrite64 , 6)
  1187 + MIPS_SYS(sys_chown , 3)
  1188 + MIPS_SYS(sys_getcwd , 2)
  1189 + MIPS_SYS(sys_capget , 2)
  1190 + MIPS_SYS(sys_capset , 2) /* 4205 */
  1191 + MIPS_SYS(sys_sigaltstack , 0)
  1192 + MIPS_SYS(sys_sendfile , 4)
  1193 + MIPS_SYS(sys_ni_syscall , 0)
  1194 + MIPS_SYS(sys_ni_syscall , 0)
  1195 + MIPS_SYS(sys_mmap2 , 6) /* 4210 */
  1196 + MIPS_SYS(sys_truncate64 , 4)
  1197 + MIPS_SYS(sys_ftruncate64 , 4)
  1198 + MIPS_SYS(sys_stat64 , 2)
  1199 + MIPS_SYS(sys_lstat64 , 2)
  1200 + MIPS_SYS(sys_fstat64 , 2) /* 4215 */
  1201 + MIPS_SYS(sys_pivot_root , 2)
  1202 + MIPS_SYS(sys_mincore , 3)
  1203 + MIPS_SYS(sys_madvise , 3)
  1204 + MIPS_SYS(sys_getdents64 , 3)
  1205 + MIPS_SYS(sys_fcntl64 , 3) /* 4220 */
  1206 + MIPS_SYS(sys_ni_syscall , 0)
  1207 + MIPS_SYS(sys_gettid , 0)
  1208 + MIPS_SYS(sys_readahead , 5)
  1209 + MIPS_SYS(sys_setxattr , 5)
  1210 + MIPS_SYS(sys_lsetxattr , 5) /* 4225 */
  1211 + MIPS_SYS(sys_fsetxattr , 5)
  1212 + MIPS_SYS(sys_getxattr , 4)
  1213 + MIPS_SYS(sys_lgetxattr , 4)
  1214 + MIPS_SYS(sys_fgetxattr , 4)
  1215 + MIPS_SYS(sys_listxattr , 3) /* 4230 */
  1216 + MIPS_SYS(sys_llistxattr , 3)
  1217 + MIPS_SYS(sys_flistxattr , 3)
  1218 + MIPS_SYS(sys_removexattr , 2)
  1219 + MIPS_SYS(sys_lremovexattr, 2)
  1220 + MIPS_SYS(sys_fremovexattr, 2) /* 4235 */
  1221 + MIPS_SYS(sys_tkill , 2)
  1222 + MIPS_SYS(sys_sendfile64 , 5)
  1223 + MIPS_SYS(sys_futex , 2)
  1224 + MIPS_SYS(sys_sched_setaffinity, 3)
  1225 + MIPS_SYS(sys_sched_getaffinity, 3) /* 4240 */
  1226 + MIPS_SYS(sys_io_setup , 2)
  1227 + MIPS_SYS(sys_io_destroy , 1)
  1228 + MIPS_SYS(sys_io_getevents, 5)
  1229 + MIPS_SYS(sys_io_submit , 3)
  1230 + MIPS_SYS(sys_io_cancel , 3) /* 4245 */
  1231 + MIPS_SYS(sys_exit_group , 1)
  1232 + MIPS_SYS(sys_lookup_dcookie, 3)
  1233 + MIPS_SYS(sys_epoll_create, 1)
  1234 + MIPS_SYS(sys_epoll_ctl , 4)
  1235 + MIPS_SYS(sys_epoll_wait , 3) /* 4250 */
  1236 + MIPS_SYS(sys_remap_file_pages, 5)
  1237 + MIPS_SYS(sys_set_tid_address, 1)
  1238 + MIPS_SYS(sys_restart_syscall, 0)
  1239 + MIPS_SYS(sys_fadvise64_64, 7)
  1240 + MIPS_SYS(sys_statfs64 , 3) /* 4255 */
  1241 + MIPS_SYS(sys_fstatfs64 , 2)
  1242 + MIPS_SYS(sys_timer_create, 3)
  1243 + MIPS_SYS(sys_timer_settime, 4)
  1244 + MIPS_SYS(sys_timer_gettime, 2)
  1245 + MIPS_SYS(sys_timer_getoverrun, 1) /* 4260 */
  1246 + MIPS_SYS(sys_timer_delete, 1)
  1247 + MIPS_SYS(sys_clock_settime, 2)
  1248 + MIPS_SYS(sys_clock_gettime, 2)
  1249 + MIPS_SYS(sys_clock_getres, 2)
  1250 + MIPS_SYS(sys_clock_nanosleep, 4) /* 4265 */
  1251 + MIPS_SYS(sys_tgkill , 3)
  1252 + MIPS_SYS(sys_utimes , 2)
  1253 + MIPS_SYS(sys_mbind , 4)
  1254 + MIPS_SYS(sys_ni_syscall , 0) /* sys_get_mempolicy */
  1255 + MIPS_SYS(sys_ni_syscall , 0) /* 4270 sys_set_mempolicy */
  1256 + MIPS_SYS(sys_mq_open , 4)
  1257 + MIPS_SYS(sys_mq_unlink , 1)
  1258 + MIPS_SYS(sys_mq_timedsend, 5)
  1259 + MIPS_SYS(sys_mq_timedreceive, 5)
  1260 + MIPS_SYS(sys_mq_notify , 2) /* 4275 */
  1261 + MIPS_SYS(sys_mq_getsetattr, 3)
  1262 + MIPS_SYS(sys_ni_syscall , 0) /* sys_vserver */
  1263 + MIPS_SYS(sys_waitid , 4)
  1264 + MIPS_SYS(sys_ni_syscall , 0) /* available, was setaltroot */
  1265 + MIPS_SYS(sys_add_key , 5)
  1266 + MIPS_SYS(sys_request_key , 4)
  1267 + MIPS_SYS(sys_keyctl , 5)
  1268 +};
  1269 +
  1270 +#undef MIPS_SYS
  1271 +
  1272 +void cpu_loop(CPUMIPSState *env)
  1273 +{
  1274 + target_siginfo_t info;
  1275 + int trapnr, ret, nb_args;
  1276 + unsigned int syscall_num;
  1277 + target_ulong arg5, arg6, sp_reg;
  1278 +
  1279 + for(;;) {
  1280 + trapnr = cpu_mips_exec(env);
  1281 + switch(trapnr) {
  1282 + case EXCP_SYSCALL:
  1283 + {
  1284 + syscall_num = env->gpr[2] - 4000;
  1285 + if (syscall_num >= sizeof(mips_syscall_args)) {
  1286 + ret = -ENOSYS;
  1287 + } else {
  1288 + nb_args = mips_syscall_args[syscall_num];
  1289 + if (nb_args >= 5) {
  1290 + sp_reg = env->gpr[29];
  1291 + /* these arguments are taken from the stack */
  1292 + if (get_user(arg5, (target_ulong *)(sp_reg + 16))) {
  1293 + ret = -EFAULT;
  1294 + goto fail;
  1295 + }
  1296 + if (nb_args >= 6) {
  1297 + if (get_user(arg6, (target_ulong *)(sp_reg + 20))) {
  1298 + ret = -EFAULT;
  1299 + goto fail;
  1300 + }
  1301 + } else {
  1302 + arg6 = 0;
  1303 + }
  1304 + } else {
  1305 + arg5 = 0;
  1306 + arg6 = 0;
  1307 + }
  1308 + ret = do_syscall(env,
  1309 + env->gpr[2],
  1310 + env->gpr[4],
  1311 + env->gpr[5],
  1312 + env->gpr[6],
  1313 + env->gpr[7],
  1314 + arg5,
  1315 + arg6);
  1316 + }
  1317 + fail:
  1318 + env->PC += 4;
  1319 + if ((unsigned int)ret >= (unsigned int)(-1133)) {
  1320 + env->gpr[7] = 1; /* error flag */
  1321 + ret = -ret;
  1322 + env->gpr[0] = ret;
  1323 + env->gpr[2] = ret;
  1324 + } else {
  1325 + env->gpr[7] = 0; /* error flag */
  1326 + env->gpr[2] = ret;
  1327 + }
  1328 + }
  1329 + break;
  1330 + case EXCP_RI:
  1331 + {
  1332 + uint32_t insn, op;
  1333 +
  1334 + if (get_user(insn, (uint32_t *)env->PC) < 0)
  1335 + goto sigill;
  1336 + op = insn >> 26;
  1337 + // printf("insn=%08x op=%02x\n", insn, op);
  1338 + /* XXX: totally dummy FP ops just to be able to launch
  1339 + a few executables */
  1340 + switch(op) {
  1341 + case 0x31: /* LWC1 */
  1342 + env->PC += 4;
  1343 + break;
  1344 + case 0x39: /* SWC1 */
  1345 + env->PC += 4;
  1346 + break;
  1347 + case 0x11:
  1348 + switch((insn >> 21) & 0x1f) {
  1349 + case 0x02: /* CFC1 */
  1350 + env->PC += 4;
  1351 + break;
  1352 + default:
  1353 + goto sigill;
  1354 + }
  1355 + break;
  1356 + default:
  1357 + sigill:
  1358 + info.si_signo = TARGET_SIGILL;
  1359 + info.si_errno = 0;
  1360 + info.si_code = 0;
  1361 + queue_signal(info.si_signo, &info);
  1362 + break;
  1363 + }
  1364 + }
  1365 + break;
  1366 + default:
  1367 + // error:
  1368 + fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",
  1369 + trapnr);
  1370 + cpu_dump_state(env, stderr, fprintf, 0);
  1371 + abort();
  1372 + }
  1373 + process_pending_signals(env);
  1374 + }
  1375 +}
  1376 +#endif
  1377 +
980 1378 void usage(void)
981 1379 {
982 1380 printf("qemu-" TARGET_ARCH " version " QEMU_VERSION ", Copyright (c) 2003-2005 Fabrice Bellard\n"
... ... @@ -1245,6 +1643,15 @@ int main(int argc, char **argv)
1245 1643 env->gpr[i] = regs->gpr[i];
1246 1644 }
1247 1645 }
  1646 +#elif defined(TARGET_MIPS)
  1647 + {
  1648 + int i;
  1649 +
  1650 + for(i = 0; i < 32; i++) {
  1651 + env->gpr[i] = regs->regs[i];
  1652 + }
  1653 + env->PC = regs->cp0_epc;
  1654 + }
1248 1655 #else
1249 1656 #error unsupported target CPU
1250 1657 #endif
... ...
linux-user/mips/syscall.h 0 โ†’ 100644
  1 +
  2 +/* this struct defines the way the registers are stored on the
  3 + stack during a system call. */
  4 +
  5 +struct target_pt_regs {
  6 +#if 1
  7 + /* Pad bytes for argument save space on the stack. */
  8 + target_ulong pad0[6];
  9 +#endif
  10 +
  11 + /* Saved main processor registers. */
  12 + target_ulong regs[32];
  13 +
  14 + /* Saved special registers. */
  15 + target_ulong cp0_status;
  16 + target_ulong lo;
  17 + target_ulong hi;
  18 + target_ulong cp0_badvaddr;
  19 + target_ulong cp0_cause;
  20 + target_ulong cp0_epc;
  21 +};
  22 +
  23 +#define UNAME_MACHINE "mips"
... ...
linux-user/mips/syscall_nr.h 0 โ†’ 100644
  1 +/*
  2 + * Linux o32 style syscalls are in the range from 4000 to 4999.
  3 + */
  4 +#define TARGET_NR_Linux 4000
  5 +#define TARGET_NR_syscall (TARGET_NR_Linux + 0)
  6 +#define TARGET_NR_exit (TARGET_NR_Linux + 1)
  7 +#define TARGET_NR_fork (TARGET_NR_Linux + 2)
  8 +#define TARGET_NR_read (TARGET_NR_Linux + 3)
  9 +#define TARGET_NR_write (TARGET_NR_Linux + 4)
  10 +#define TARGET_NR_open (TARGET_NR_Linux + 5)
  11 +#define TARGET_NR_close (TARGET_NR_Linux + 6)
  12 +#define TARGET_NR_waitpid (TARGET_NR_Linux + 7)
  13 +#define TARGET_NR_creat (TARGET_NR_Linux + 8)
  14 +#define TARGET_NR_link (TARGET_NR_Linux + 9)
  15 +#define TARGET_NR_unlink (TARGET_NR_Linux + 10)
  16 +#define TARGET_NR_execve (TARGET_NR_Linux + 11)
  17 +#define TARGET_NR_chdir (TARGET_NR_Linux + 12)
  18 +#define TARGET_NR_time (TARGET_NR_Linux + 13)
  19 +#define TARGET_NR_mknod (TARGET_NR_Linux + 14)
  20 +#define TARGET_NR_chmod (TARGET_NR_Linux + 15)
  21 +#define TARGET_NR_lchown (TARGET_NR_Linux + 16)
  22 +#define TARGET_NR_break (TARGET_NR_Linux + 17)
  23 +#define TARGET_NR_unused18 (TARGET_NR_Linux + 18)
  24 +#define TARGET_NR_lseek (TARGET_NR_Linux + 19)
  25 +#define TARGET_NR_getpid (TARGET_NR_Linux + 20)
  26 +#define TARGET_NR_mount (TARGET_NR_Linux + 21)
  27 +#define TARGET_NR_umount (TARGET_NR_Linux + 22)
  28 +#define TARGET_NR_setuid (TARGET_NR_Linux + 23)
  29 +#define TARGET_NR_getuid (TARGET_NR_Linux + 24)
  30 +#define TARGET_NR_stime (TARGET_NR_Linux + 25)
  31 +#define TARGET_NR_ptrace (TARGET_NR_Linux + 26)
  32 +#define TARGET_NR_alarm (TARGET_NR_Linux + 27)
  33 +#define TARGET_NR_unused28 (TARGET_NR_Linux + 28)
  34 +#define TARGET_NR_pause (TARGET_NR_Linux + 29)
  35 +#define TARGET_NR_utime (TARGET_NR_Linux + 30)
  36 +#define TARGET_NR_stty (TARGET_NR_Linux + 31)
  37 +#define TARGET_NR_gtty (TARGET_NR_Linux + 32)
  38 +#define TARGET_NR_access (TARGET_NR_Linux + 33)
  39 +#define TARGET_NR_nice (TARGET_NR_Linux + 34)
  40 +#define TARGET_NR_ftime (TARGET_NR_Linux + 35)
  41 +#define TARGET_NR_sync (TARGET_NR_Linux + 36)
  42 +#define TARGET_NR_kill (TARGET_NR_Linux + 37)
  43 +#define TARGET_NR_rename (TARGET_NR_Linux + 38)
  44 +#define TARGET_NR_mkdir (TARGET_NR_Linux + 39)
  45 +#define TARGET_NR_rmdir (TARGET_NR_Linux + 40)
  46 +#define TARGET_NR_dup (TARGET_NR_Linux + 41)
  47 +#define TARGET_NR_pipe (TARGET_NR_Linux + 42)
  48 +#define TARGET_NR_times (TARGET_NR_Linux + 43)
  49 +#define TARGET_NR_prof (TARGET_NR_Linux + 44)
  50 +#define TARGET_NR_brk (TARGET_NR_Linux + 45)
  51 +#define TARGET_NR_setgid (TARGET_NR_Linux + 46)
  52 +#define TARGET_NR_getgid (TARGET_NR_Linux + 47)
  53 +#define TARGET_NR_signal (TARGET_NR_Linux + 48)
  54 +#define TARGET_NR_geteuid (TARGET_NR_Linux + 49)
  55 +#define TARGET_NR_getegid (TARGET_NR_Linux + 50)
  56 +#define TARGET_NR_acct (TARGET_NR_Linux + 51)
  57 +#define TARGET_NR_umount2 (TARGET_NR_Linux + 52)
  58 +#define TARGET_NR_lock (TARGET_NR_Linux + 53)
  59 +#define TARGET_NR_ioctl (TARGET_NR_Linux + 54)
  60 +#define TARGET_NR_fcntl (TARGET_NR_Linux + 55)
  61 +#define TARGET_NR_mpx (TARGET_NR_Linux + 56)
  62 +#define TARGET_NR_setpgid (TARGET_NR_Linux + 57)
  63 +#define TARGET_NR_ulimit (TARGET_NR_Linux + 58)
  64 +#define TARGET_NR_unused59 (TARGET_NR_Linux + 59)
  65 +#define TARGET_NR_umask (TARGET_NR_Linux + 60)
  66 +#define TARGET_NR_chroot (TARGET_NR_Linux + 61)
  67 +#define TARGET_NR_ustat (TARGET_NR_Linux + 62)
  68 +#define TARGET_NR_dup2 (TARGET_NR_Linux + 63)
  69 +#define TARGET_NR_getppid (TARGET_NR_Linux + 64)
  70 +#define TARGET_NR_getpgrp (TARGET_NR_Linux + 65)
  71 +#define TARGET_NR_setsid (TARGET_NR_Linux + 66)
  72 +#define TARGET_NR_sigaction (TARGET_NR_Linux + 67)
  73 +#define TARGET_NR_sgetmask (TARGET_NR_Linux + 68)
  74 +#define TARGET_NR_ssetmask (TARGET_NR_Linux + 69)
  75 +#define TARGET_NR_setreuid (TARGET_NR_Linux + 70)
  76 +#define TARGET_NR_setregid (TARGET_NR_Linux + 71)
  77 +#define TARGET_NR_sigsuspend (TARGET_NR_Linux + 72)
  78 +#define TARGET_NR_sigpending (TARGET_NR_Linux + 73)
  79 +#define TARGET_NR_sethostname (TARGET_NR_Linux + 74)
  80 +#define TARGET_NR_setrlimit (TARGET_NR_Linux + 75)
  81 +#define TARGET_NR_getrlimit (TARGET_NR_Linux + 76)
  82 +#define TARGET_NR_getrusage (TARGET_NR_Linux + 77)
  83 +#define TARGET_NR_gettimeofday (TARGET_NR_Linux + 78)
  84 +#define TARGET_NR_settimeofday (TARGET_NR_Linux + 79)
  85 +#define TARGET_NR_getgroups (TARGET_NR_Linux + 80)
  86 +#define TARGET_NR_setgroups (TARGET_NR_Linux + 81)
  87 +#define TARGET_NR_reserved82 (TARGET_NR_Linux + 82)
  88 +#define TARGET_NR_symlink (TARGET_NR_Linux + 83)
  89 +#define TARGET_NR_unused84 (TARGET_NR_Linux + 84)
  90 +#define TARGET_NR_readlink (TARGET_NR_Linux + 85)
  91 +#define TARGET_NR_uselib (TARGET_NR_Linux + 86)
  92 +#define TARGET_NR_swapon (TARGET_NR_Linux + 87)
  93 +#define TARGET_NR_reboot (TARGET_NR_Linux + 88)
  94 +#define TARGET_NR_readdir (TARGET_NR_Linux + 89)
  95 +#define TARGET_NR_mmap (TARGET_NR_Linux + 90)
  96 +#define TARGET_NR_munmap (TARGET_NR_Linux + 91)
  97 +#define TARGET_NR_truncate (TARGET_NR_Linux + 92)
  98 +#define TARGET_NR_ftruncate (TARGET_NR_Linux + 93)
  99 +#define TARGET_NR_fchmod (TARGET_NR_Linux + 94)
  100 +#define TARGET_NR_fchown (TARGET_NR_Linux + 95)
  101 +#define TARGET_NR_getpriority (TARGET_NR_Linux + 96)
  102 +#define TARGET_NR_setpriority (TARGET_NR_Linux + 97)
  103 +#define TARGET_NR_profil (TARGET_NR_Linux + 98)
  104 +#define TARGET_NR_statfs (TARGET_NR_Linux + 99)
  105 +#define TARGET_NR_fstatfs (TARGET_NR_Linux + 100)
  106 +#define TARGET_NR_ioperm (TARGET_NR_Linux + 101)
  107 +#define TARGET_NR_socketcall (TARGET_NR_Linux + 102)
  108 +#define TARGET_NR_syslog (TARGET_NR_Linux + 103)
  109 +#define TARGET_NR_setitimer (TARGET_NR_Linux + 104)
  110 +#define TARGET_NR_getitimer (TARGET_NR_Linux + 105)
  111 +#define TARGET_NR_stat (TARGET_NR_Linux + 106)
  112 +#define TARGET_NR_lstat (TARGET_NR_Linux + 107)
  113 +#define TARGET_NR_fstat (TARGET_NR_Linux + 108)
  114 +#define TARGET_NR_unused109 (TARGET_NR_Linux + 109)
  115 +#define TARGET_NR_iopl (TARGET_NR_Linux + 110)
  116 +#define TARGET_NR_vhangup (TARGET_NR_Linux + 111)
  117 +#define TARGET_NR_idle (TARGET_NR_Linux + 112)
  118 +#define TARGET_NR_vm86 (TARGET_NR_Linux + 113)
  119 +#define TARGET_NR_wait4 (TARGET_NR_Linux + 114)
  120 +#define TARGET_NR_swapoff (TARGET_NR_Linux + 115)
  121 +#define TARGET_NR_sysinfo (TARGET_NR_Linux + 116)
  122 +#define TARGET_NR_ipc (TARGET_NR_Linux + 117)
  123 +#define TARGET_NR_fsync (TARGET_NR_Linux + 118)
  124 +#define TARGET_NR_sigreturn (TARGET_NR_Linux + 119)
  125 +#define TARGET_NR_clone (TARGET_NR_Linux + 120)
  126 +#define TARGET_NR_setdomainname (TARGET_NR_Linux + 121)
  127 +#define TARGET_NR_uname (TARGET_NR_Linux + 122)
  128 +#define TARGET_NR_modify_ldt (TARGET_NR_Linux + 123)
  129 +#define TARGET_NR_adjtimex (TARGET_NR_Linux + 124)
  130 +#define TARGET_NR_mprotect (TARGET_NR_Linux + 125)
  131 +#define TARGET_NR_sigprocmask (TARGET_NR_Linux + 126)
  132 +#define TARGET_NR_create_module (TARGET_NR_Linux + 127)
  133 +#define TARGET_NR_init_module (TARGET_NR_Linux + 128)
  134 +#define TARGET_NR_delete_module (TARGET_NR_Linux + 129)
  135 +#define TARGET_NR_get_kernel_syms (TARGET_NR_Linux + 130)
  136 +#define TARGET_NR_quotactl (TARGET_NR_Linux + 131)
  137 +#define TARGET_NR_getpgid (TARGET_NR_Linux + 132)
  138 +#define TARGET_NR_fchdir (TARGET_NR_Linux + 133)
  139 +#define TARGET_NR_bdflush (TARGET_NR_Linux + 134)
  140 +#define TARGET_NR_sysfs (TARGET_NR_Linux + 135)
  141 +#define TARGET_NR_personality (TARGET_NR_Linux + 136)
  142 +#define TARGET_NR_afs_syscall (TARGET_NR_Linux + 137) /* Syscall for Andrew File System */
  143 +#define TARGET_NR_setfsuid (TARGET_NR_Linux + 138)
  144 +#define TARGET_NR_setfsgid (TARGET_NR_Linux + 139)
  145 +#define TARGET_NR__llseek (TARGET_NR_Linux + 140)
  146 +#define TARGET_NR_getdents (TARGET_NR_Linux + 141)
  147 +#define TARGET_NR__newselect (TARGET_NR_Linux + 142)
  148 +#define TARGET_NR_flock (TARGET_NR_Linux + 143)
  149 +#define TARGET_NR_msync (TARGET_NR_Linux + 144)
  150 +#define TARGET_NR_readv (TARGET_NR_Linux + 145)
  151 +#define TARGET_NR_writev (TARGET_NR_Linux + 146)
  152 +#define TARGET_NR_cacheflush (TARGET_NR_Linux + 147)
  153 +#define TARGET_NR_cachectl (TARGET_NR_Linux + 148)
  154 +#define TARGET_NR_sysmips (TARGET_NR_Linux + 149)
  155 +#define TARGET_NR_unused150 (TARGET_NR_Linux + 150)
  156 +#define TARGET_NR_getsid (TARGET_NR_Linux + 151)
  157 +#define TARGET_NR_fdatasync (TARGET_NR_Linux + 152)
  158 +#define TARGET_NR__sysctl (TARGET_NR_Linux + 153)
  159 +#define TARGET_NR_mlock (TARGET_NR_Linux + 154)
  160 +#define TARGET_NR_munlock (TARGET_NR_Linux + 155)
  161 +#define TARGET_NR_mlockall (TARGET_NR_Linux + 156)
  162 +#define TARGET_NR_munlockall (TARGET_NR_Linux + 157)
  163 +#define TARGET_NR_sched_setparam (TARGET_NR_Linux + 158)
  164 +#define TARGET_NR_sched_getparam (TARGET_NR_Linux + 159)
  165 +#define TARGET_NR_sched_setscheduler (TARGET_NR_Linux + 160)
  166 +#define TARGET_NR_sched_getscheduler (TARGET_NR_Linux + 161)
  167 +#define TARGET_NR_sched_yield (TARGET_NR_Linux + 162)
  168 +#define TARGET_NR_sched_get_priority_max (TARGET_NR_Linux + 163)
  169 +#define TARGET_NR_sched_get_priority_min (TARGET_NR_Linux + 164)
  170 +#define TARGET_NR_sched_rr_get_interval (TARGET_NR_Linux + 165)
  171 +#define TARGET_NR_nanosleep (TARGET_NR_Linux + 166)
  172 +#define TARGET_NR_mremap (TARGET_NR_Linux + 167)
  173 +#define TARGET_NR_accept (TARGET_NR_Linux + 168)
  174 +#define TARGET_NR_bind (TARGET_NR_Linux + 169)
  175 +#define TARGET_NR_connect (TARGET_NR_Linux + 170)
  176 +#define TARGET_NR_getpeername (TARGET_NR_Linux + 171)
  177 +#define TARGET_NR_getsockname (TARGET_NR_Linux + 172)
  178 +#define TARGET_NR_getsockopt (TARGET_NR_Linux + 173)
  179 +#define TARGET_NR_listen (TARGET_NR_Linux + 174)
  180 +#define TARGET_NR_recv (TARGET_NR_Linux + 175)
  181 +#define TARGET_NR_recvfrom (TARGET_NR_Linux + 176)
  182 +#define TARGET_NR_recvmsg (TARGET_NR_Linux + 177)
  183 +#define TARGET_NR_send (TARGET_NR_Linux + 178)
  184 +#define TARGET_NR_sendmsg (TARGET_NR_Linux + 179)
  185 +#define TARGET_NR_sendto (TARGET_NR_Linux + 180)
  186 +#define TARGET_NR_setsockopt (TARGET_NR_Linux + 181)
  187 +#define TARGET_NR_shutdown (TARGET_NR_Linux + 182)
  188 +#define TARGET_NR_socket (TARGET_NR_Linux + 183)
  189 +#define TARGET_NR_socketpair (TARGET_NR_Linux + 184)
  190 +#define TARGET_NR_setresuid (TARGET_NR_Linux + 185)
  191 +#define TARGET_NR_getresuid (TARGET_NR_Linux + 186)
  192 +#define TARGET_NR_query_module (TARGET_NR_Linux + 187)
  193 +#define TARGET_NR_poll (TARGET_NR_Linux + 188)
  194 +#define TARGET_NR_nfsservctl (TARGET_NR_Linux + 189)
  195 +#define TARGET_NR_setresgid (TARGET_NR_Linux + 190)
  196 +#define TARGET_NR_getresgid (TARGET_NR_Linux + 191)
  197 +#define TARGET_NR_prctl (TARGET_NR_Linux + 192)
  198 +#define TARGET_NR_rt_sigreturn (TARGET_NR_Linux + 193)
  199 +#define TARGET_NR_rt_sigaction (TARGET_NR_Linux + 194)
  200 +#define TARGET_NR_rt_sigprocmask (TARGET_NR_Linux + 195)
  201 +#define TARGET_NR_rt_sigpending (TARGET_NR_Linux + 196)
  202 +#define TARGET_NR_rt_sigtimedwait (TARGET_NR_Linux + 197)
  203 +#define TARGET_NR_rt_sigqueueinfo (TARGET_NR_Linux + 198)
  204 +#define TARGET_NR_rt_sigsuspend (TARGET_NR_Linux + 199)
  205 +#define TARGET_NR_pread64 (TARGET_NR_Linux + 200)
  206 +#define TARGET_NR_pwrite64 (TARGET_NR_Linux + 201)
  207 +#define TARGET_NR_chown (TARGET_NR_Linux + 202)
  208 +#define TARGET_NR_getcwd (TARGET_NR_Linux + 203)
  209 +#define TARGET_NR_capget (TARGET_NR_Linux + 204)
  210 +#define TARGET_NR_capset (TARGET_NR_Linux + 205)
  211 +#define TARGET_NR_sigaltstack (TARGET_NR_Linux + 206)
  212 +#define TARGET_NR_sendfile (TARGET_NR_Linux + 207)
  213 +#define TARGET_NR_getpmsg (TARGET_NR_Linux + 208)
  214 +#define TARGET_NR_putpmsg (TARGET_NR_Linux + 209)
  215 +#define TARGET_NR_mmap2 (TARGET_NR_Linux + 210)
  216 +#define TARGET_NR_truncate64 (TARGET_NR_Linux + 211)
  217 +#define TARGET_NR_ftruncate64 (TARGET_NR_Linux + 212)
  218 +#define TARGET_NR_stat64 (TARGET_NR_Linux + 213)
  219 +#define TARGET_NR_lstat64 (TARGET_NR_Linux + 214)
  220 +#define TARGET_NR_fstat64 (TARGET_NR_Linux + 215)
  221 +#define TARGET_NR_pivot_root (TARGET_NR_Linux + 216)
  222 +#define TARGET_NR_mincore (TARGET_NR_Linux + 217)
  223 +#define TARGET_NR_madvise (TARGET_NR_Linux + 218)
  224 +#define TARGET_NR_getdents64 (TARGET_NR_Linux + 219)
  225 +#define TARGET_NR_fcntl64 (TARGET_NR_Linux + 220)
  226 +#define TARGET_NR_reserved221 (TARGET_NR_Linux + 221)
  227 +#define TARGET_NR_gettid (TARGET_NR_Linux + 222)
  228 +#define TARGET_NR_readahead (TARGET_NR_Linux + 223)
  229 +#define TARGET_NR_setxattr (TARGET_NR_Linux + 224)
  230 +#define TARGET_NR_lsetxattr (TARGET_NR_Linux + 225)
  231 +#define TARGET_NR_fsetxattr (TARGET_NR_Linux + 226)
  232 +#define TARGET_NR_getxattr (TARGET_NR_Linux + 227)
  233 +#define TARGET_NR_lgetxattr (TARGET_NR_Linux + 228)
  234 +#define TARGET_NR_fgetxattr (TARGET_NR_Linux + 229)
  235 +#define TARGET_NR_listxattr (TARGET_NR_Linux + 230)
  236 +#define TARGET_NR_llistxattr (TARGET_NR_Linux + 231)
  237 +#define TARGET_NR_flistxattr (TARGET_NR_Linux + 232)
  238 +#define TARGET_NR_removexattr (TARGET_NR_Linux + 233)
  239 +#define TARGET_NR_lremovexattr (TARGET_NR_Linux + 234)
  240 +#define TARGET_NR_fremovexattr (TARGET_NR_Linux + 235)
  241 +#define TARGET_NR_tkill (TARGET_NR_Linux + 236)
  242 +#define TARGET_NR_sendfile64 (TARGET_NR_Linux + 237)
  243 +#define TARGET_NR_futex (TARGET_NR_Linux + 238)
  244 +#define TARGET_NR_sched_setaffinity (TARGET_NR_Linux + 239)
  245 +#define TARGET_NR_sched_getaffinity (TARGET_NR_Linux + 240)
  246 +#define TARGET_NR_io_setup (TARGET_NR_Linux + 241)
  247 +#define TARGET_NR_io_destroy (TARGET_NR_Linux + 242)
  248 +#define TARGET_NR_io_getevents (TARGET_NR_Linux + 243)
  249 +#define TARGET_NR_io_submit (TARGET_NR_Linux + 244)
  250 +#define TARGET_NR_io_cancel (TARGET_NR_Linux + 245)
  251 +#define TARGET_NR_exit_group (TARGET_NR_Linux + 246)
  252 +#define TARGET_NR_lookup_dcookie (TARGET_NR_Linux + 247)
  253 +#define TARGET_NR_epoll_create (TARGET_NR_Linux + 248)
  254 +#define TARGET_NR_epoll_ctl (TARGET_NR_Linux + 249)
  255 +#define TARGET_NR_epoll_wait (TARGET_NR_Linux + 250)
  256 +#define TARGET_NR_remap_file_pages (TARGET_NR_Linux + 251)
  257 +#define TARGET_NR_set_tid_address (TARGET_NR_Linux + 252)
  258 +#define TARGET_NR_restart_syscall (TARGET_NR_Linux + 253)
  259 +#define TARGET_NR_fadvise64 (TARGET_NR_Linux + 254)
  260 +#define TARGET_NR_statfs64 (TARGET_NR_Linux + 255)
  261 +#define TARGET_NR_fstatfs64 (TARGET_NR_Linux + 256)
  262 +#define TARGET_NR_timer_create (TARGET_NR_Linux + 257)
  263 +#define TARGET_NR_timer_settime (TARGET_NR_Linux + 258)
  264 +#define TARGET_NR_timer_gettime (TARGET_NR_Linux + 259)
  265 +#define TARGET_NR_timer_getoverrun (TARGET_NR_Linux + 260)
  266 +#define TARGET_NR_timer_delete (TARGET_NR_Linux + 261)
  267 +#define TARGET_NR_clock_settime (TARGET_NR_Linux + 262)
  268 +#define TARGET_NR_clock_gettime (TARGET_NR_Linux + 263)
  269 +#define TARGET_NR_clock_getres (TARGET_NR_Linux + 264)
  270 +#define TARGET_NR_clock_nanosleep (TARGET_NR_Linux + 265)
  271 +#define TARGET_NR_tgkill (TARGET_NR_Linux + 266)
  272 +#define TARGET_NR_utimes (TARGET_NR_Linux + 267)
  273 +#define TARGET_NR_mbind (TARGET_NR_Linux + 268)
  274 +#define TARGET_NR_get_mempolicy (TARGET_NR_Linux + 269)
  275 +#define TARGET_NR_set_mempolicy (TARGET_NR_Linux + 270)
  276 +#define TARGET_NR_mq_open (TARGET_NR_Linux + 271)
  277 +#define TARGET_NR_mq_unlink (TARGET_NR_Linux + 272)
  278 +#define TARGET_NR_mq_timedsend (TARGET_NR_Linux + 273)
  279 +#define TARGET_NR_mq_timedreceive (TARGET_NR_Linux + 274)
  280 +#define TARGET_NR_mq_notify (TARGET_NR_Linux + 275)
  281 +#define TARGET_NR_mq_getsetattr (TARGET_NR_Linux + 276)
  282 +#define TARGET_NR_vserver (TARGET_NR_Linux + 277)
  283 +#define TARGET_NR_waitid (TARGET_NR_Linux + 278)
  284 +/* #define TARGET_NR_sys_setaltroot (TARGET_NR_Linux + 279) */
  285 +#define TARGET_NR_add_key (TARGET_NR_Linux + 280)
  286 +#define TARGET_NR_request_key (TARGET_NR_Linux + 281)
  287 +#define TARGET_NR_keyctl (TARGET_NR_Linux + 282)
  288 +
... ...
linux-user/mips/termbits.h 0 โ†’ 100644
  1 +/* from asm/termbits.h */
  2 +
  3 +#define TARGET_NCCS 23
  4 +
  5 +struct target_termios {
  6 + unsigned int c_iflag; /* input mode flags */
  7 + unsigned int c_oflag; /* output mode flags */
  8 + unsigned int c_cflag; /* control mode flags */
  9 + unsigned int c_lflag; /* local mode flags */
  10 + unsigned char c_line; /* line discipline */
  11 + unsigned char c_cc[TARGET_NCCS]; /* control characters */
  12 +};
  13 +
  14 +/* c_iflag bits */
  15 +#define TARGET_IGNBRK 0000001
  16 +#define TARGET_BRKINT 0000002
  17 +#define TARGET_IGNPAR 0000004
  18 +#define TARGET_PARMRK 0000010
  19 +#define TARGET_INPCK 0000020
  20 +#define TARGET_ISTRIP 0000040
  21 +#define TARGET_INLCR 0000100
  22 +#define TARGET_IGNCR 0000200
  23 +#define TARGET_ICRNL 0000400
  24 +#define TARGET_IUCLC 0001000
  25 +#define TARGET_IXON 0002000
  26 +#define TARGET_IXANY 0004000
  27 +#define TARGET_IXOFF 0010000
  28 +#define TARGET_IMAXBEL 0020000
  29 +
  30 +/* c_oflag bits */
  31 +#define TARGET_OPOST 0000001
  32 +#define TARGET_OLCUC 0000002
  33 +#define TARGET_ONLCR 0000004
  34 +#define TARGET_OCRNL 0000010
  35 +#define TARGET_ONOCR 0000020
  36 +#define TARGET_ONLRET 0000040
  37 +#define TARGET_OFILL 0000100
  38 +#define TARGET_OFDEL 0000200
  39 +#define TARGET_NLDLY 0000400
  40 +#define TARGET_NL0 0000000
  41 +#define TARGET_NL1 0000400
  42 +#define TARGET_CRDLY 0003000
  43 +#define TARGET_CR0 0000000
  44 +#define TARGET_CR1 0001000
  45 +#define TARGET_CR2 0002000
  46 +#define TARGET_CR3 0003000
  47 +#define TARGET_TABDLY 0014000
  48 +#define TARGET_TAB0 0000000
  49 +#define TARGET_TAB1 0004000
  50 +#define TARGET_TAB2 0010000
  51 +#define TARGET_TAB3 0014000
  52 +#define TARGET_XTABS 0014000
  53 +#define TARGET_BSDLY 0020000
  54 +#define TARGET_BS0 0000000
  55 +#define TARGET_BS1 0020000
  56 +#define TARGET_VTDLY 0040000
  57 +#define TARGET_VT0 0000000
  58 +#define TARGET_VT1 0040000
  59 +#define TARGET_FFDLY 0100000
  60 +#define TARGET_FF0 0000000
  61 +#define TARGET_FF1 0100000
  62 +
  63 +/* c_cflag bit meaning */
  64 +#define TARGET_CBAUD 0010017
  65 +#define TARGET_B0 0000000 /* hang up */
  66 +#define TARGET_B50 0000001
  67 +#define TARGET_B75 0000002
  68 +#define TARGET_B110 0000003
  69 +#define TARGET_B134 0000004
  70 +#define TARGET_B150 0000005
  71 +#define TARGET_B200 0000006
  72 +#define TARGET_B300 0000007
  73 +#define TARGET_B600 0000010
  74 +#define TARGET_B1200 0000011
  75 +#define TARGET_B1800 0000012
  76 +#define TARGET_B2400 0000013
  77 +#define TARGET_B4800 0000014
  78 +#define TARGET_B9600 0000015
  79 +#define TARGET_B19200 0000016
  80 +#define TARGET_B38400 0000017
  81 +#define TARGET_EXTA B19200
  82 +#define TARGET_EXTB B38400
  83 +#define TARGET_CSIZE 0000060
  84 +#define TARGET_CS5 0000000
  85 +#define TARGET_CS6 0000020
  86 +#define TARGET_CS7 0000040
  87 +#define TARGET_CS8 0000060
  88 +#define TARGET_CSTOPB 0000100
  89 +#define TARGET_CREAD 0000200
  90 +#define TARGET_PARENB 0000400
  91 +#define TARGET_PARODD 0001000
  92 +#define TARGET_HUPCL 0002000
  93 +#define TARGET_CLOCAL 0004000
  94 +#define TARGET_CBAUDEX 0010000
  95 +#define TARGET_B57600 0010001
  96 +#define TARGET_B115200 0010002
  97 +#define TARGET_B230400 0010003
  98 +#define TARGET_B460800 0010004
  99 +#define TARGET_CIBAUD 002003600000 /* input baud rate (not used) */
  100 +#define TARGET_CRTSCTS 020000000000 /* flow control */
  101 +
  102 +/* c_lflag bits */
  103 +#define TARGET_ISIG 0000001
  104 +#define TARGET_ICANON 0000002
  105 +#define TARGET_XCASE 0000004
  106 +#define TARGET_ECHO 0000010
  107 +#define TARGET_ECHOE 0000020
  108 +#define TARGET_ECHOK 0000040
  109 +#define TARGET_ECHONL 0000100
  110 +#define TARGET_NOFLSH 0000200
  111 +#define TARGET_TOSTOP 0000400
  112 +#define TARGET_ECHOCTL 0001000
  113 +#define TARGET_ECHOPRT 0002000
  114 +#define TARGET_ECHOKE 0004000
  115 +#define TARGET_FLUSHO 0010000
  116 +#define TARGET_PENDIN 0040000
  117 +#define TARGET_IEXTEN 0100000
  118 +
  119 +/* c_cc character offsets */
  120 +#define TARGET_VINTR 0
  121 +#define TARGET_VQUIT 1
  122 +#define TARGET_VERASE 2
  123 +#define TARGET_VKILL 3
  124 +#define TARGET_VEOF 4
  125 +#define TARGET_VTIME 5
  126 +#define TARGET_VMIN 6
  127 +#define TARGET_VSWTC 7
  128 +#define TARGET_VSTART 8
  129 +#define TARGET_VSTOP 9
  130 +#define TARGET_VSUSP 10
  131 +#define TARGET_VEOL 11
  132 +#define TARGET_VREPRINT 12
  133 +#define TARGET_VDISCARD 13
  134 +#define TARGET_VWERASE 14
  135 +#define TARGET_VLNEXT 15
  136 +#define TARGET_VEOL2 16
  137 +
  138 +/* ioctls */
  139 +
  140 +#define TARGET_TCGETS 0x5401
  141 +#define TARGET_TCSETS 0x5402
  142 +#define TARGET_TCSETSW 0x5403
  143 +#define TARGET_TCSETSF 0x5404
  144 +#define TARGET_TCGETA 0x5405
  145 +#define TARGET_TCSETA 0x5406
  146 +#define TARGET_TCSETAW 0x5407
  147 +#define TARGET_TCSETAF 0x5408
  148 +#define TARGET_TCSBRK 0x5409
  149 +#define TARGET_TCXONC 0x540A
  150 +#define TARGET_TCFLSH 0x540B
  151 +
  152 +#define TARGET_TIOCEXCL 0x540C
  153 +#define TARGET_TIOCNXCL 0x540D
  154 +#define TARGET_TIOCSCTTY 0x540E
  155 +#define TARGET_TIOCGPGRP 0x540F
  156 +#define TARGET_TIOCSPGRP 0x5410
  157 +#define TARGET_TIOCOUTQ 0x5411
  158 +#define TARGET_TIOCSTI 0x5412
  159 +#define TARGET_TIOCGWINSZ 0x5413
  160 +#define TARGET_TIOCSWINSZ 0x5414
  161 +#define TARGET_TIOCMGET 0x5415
  162 +#define TARGET_TIOCMBIS 0x5416
  163 +#define TARGET_TIOCMBIC 0x5417
  164 +#define TARGET_TIOCMSET 0x5418
  165 +#define TARGET_TIOCGSOFTCAR 0x5419
  166 +#define TARGET_TIOCSSOFTCAR 0x541A
  167 +#define TARGET_FIONREAD 0x541B
  168 +#define TARGET_TIOCINQ TARGET_FIONREAD
  169 +#define TARGET_TIOCLINUX 0x541C
  170 +#define TARGET_TIOCCONS 0x541D
  171 +#define TARGET_TIOCGSERIAL 0x541E
  172 +#define TARGET_TIOCSSERIAL 0x541F
  173 +#define TARGET_TIOCPKT 0x5420
  174 +#define TARGET_FIONBIO 0x5421
  175 +#define TARGET_TIOCNOTTY 0x5422
  176 +#define TARGET_TIOCSETD 0x5423
  177 +#define TARGET_TIOCGETD 0x5424
  178 +#define TARGET_TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
  179 +#define TARGET_TIOCTTYGSTRUCT 0x5426 /* For debugging only */
  180 +#define TARGET_TIOCSBRK 0x5427 /* BSD compatibility */
  181 +#define TARGET_TIOCCBRK 0x5428 /* BSD compatibility */
  182 +#define TARGET_TIOCGSID 0x5429 /* Return the session ID of FD */
  183 +#define TARGET_TIOCGPTN TARGET_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
  184 +#define TARGET_TIOCSPTLCK TARGET_IOW('T',0x31, int) /* Lock/unlock Pty */
  185 +
  186 +#define TARGET_FIONCLEX 0x5450 /* these numbers need to be adjusted. */
  187 +#define TARGET_FIOCLEX 0x5451
  188 +#define TARGET_FIOASYNC 0x5452
  189 +#define TARGET_TIOCSERCONFIG 0x5453
  190 +#define TARGET_TIOCSERGWILD 0x5454
  191 +#define TARGET_TIOCSERSWILD 0x5455
  192 +#define TARGET_TIOCGLCKTRMIOS 0x5456
  193 +#define TARGET_TIOCSLCKTRMIOS 0x5457
  194 +#define TARGET_TIOCSERGSTRUCT 0x5458 /* For debugging only */
  195 +#define TARGET_TIOCSERGETLSR 0x5459 /* Get line status register */
  196 +#define TARGET_TIOCSERGETMULTI 0x545A /* Get multiport config */
  197 +#define TARGET_TIOCSERSETMULTI 0x545B /* Set multiport config */
  198 +
  199 +#define TARGET_TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
  200 +#define TARGET_TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
  201 +#define TARGET_TIOCGHAYESESP 0x545E /* Get Hayes ESP configuration */
  202 +#define TARGET_TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */
  203 +
  204 +/* Used for packet mode */
  205 +#define TARGET_TIOCPKT_DATA 0
  206 +#define TARGET_TIOCPKT_FLUSHREAD 1
  207 +#define TARGET_TIOCPKT_FLUSHWRITE 2
  208 +#define TARGET_TIOCPKT_STOP 4
  209 +#define TARGET_TIOCPKT_START 8
  210 +#define TARGET_TIOCPKT_NOSTOP 16
  211 +#define TARGET_TIOCPKT_DOSTOP 32
  212 +
  213 +#define TARGET_TIOCSER_TEMT 0x01 /* Transmitter physically empty */
  214 +
... ...
linux-user/syscall.c
... ... @@ -1497,6 +1497,8 @@ int do_fork(CPUState *env, unsigned int flags, unsigned long newsp)
1497 1497 new_env->regs[0] = 0;
1498 1498 #elif defined(TARGET_SPARC)
1499 1499 printf ("HELPME: %s:%d\n", __FILE__, __LINE__);
  1500 +#elif defined(TARGET_MIPS)
  1501 + printf ("HELPME: %s:%d\n", __FILE__, __LINE__);
1500 1502 #elif defined(TARGET_PPC)
1501 1503 if (!newsp)
1502 1504 newsp = env->gpr[1];
... ... @@ -2184,6 +2186,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
2184 2186 ret = get_errno(settimeofday(&tv, NULL));
2185 2187 }
2186 2188 break;
  2189 +#ifdef TARGET_NR_select
2187 2190 case TARGET_NR_select:
2188 2191 {
2189 2192 struct target_sel_arg_struct *sel = (void *)arg1;
... ... @@ -2196,6 +2199,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
2196 2199 (void *)sel->exp, (void *)sel->tvp);
2197 2200 }
2198 2201 break;
  2202 +#endif
2199 2203 case TARGET_NR_symlink:
2200 2204 ret = get_errno(symlink((const char *)arg1, (const char *)arg2));
2201 2205 break;
... ... @@ -2802,9 +2806,11 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
2802 2806 case TARGET_NR_putpmsg:
2803 2807 goto unimplemented;
2804 2808 #endif
  2809 +#ifdef TARGET_NR_vfork
2805 2810 case TARGET_NR_vfork:
2806 2811 ret = get_errno(do_fork(cpu_env, CLONE_VFORK | CLONE_VM | SIGCHLD, 0));
2807 2812 break;
  2813 +#endif
2808 2814 #ifdef TARGET_NR_ugetrlimit
2809 2815 case TARGET_NR_ugetrlimit:
2810 2816 {
... ...
linux-user/syscall_defs.h
... ... @@ -57,7 +57,8 @@
57 57 #define TARGET_IOC_WRITE 1U
58 58 #define TARGET_IOC_READ 2U
59 59  
60   -#elif defined(TARGET_PPC) || defined(TARGET_ALPHA) || defined(TARGET_SPARC)
  60 +#elif defined(TARGET_PPC) || defined(TARGET_ALPHA) || \
  61 + defined(TARGET_SPARC) || defined(TARGET_MIPS)
61 62  
62 63 #define TARGET_IOC_SIZEBITS 13
63 64 #define TARGET_IOC_DIRBITS 3
... ... @@ -292,9 +293,26 @@ struct target_sigaction;
292 293 int do_sigaction(int sig, const struct target_sigaction *act,
293 294 struct target_sigaction *oact);
294 295  
295   -#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) || defined(TARGET_PPC)
  296 +#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) || defined(TARGET_PPC) || defined(TARGET_MIPS)
296 297  
297   -#if !defined(TARGET_SPARC)
  298 +#if defined(TARGET_SPARC)
  299 +#define TARGET_SA_NOCLDSTOP 8u
  300 +#define TARGET_SA_NOCLDWAIT 0x100u
  301 +#define TARGET_SA_SIGINFO 0x200u
  302 +#define TARGET_SA_ONSTACK 1u
  303 +#define TARGET_SA_RESTART 2u
  304 +#define TARGET_SA_NODEFER 0x20u
  305 +#define TARGET_SA_RESETHAND 4u
  306 +#elif defined(TARGET_MIPS)
  307 +#define TARGET_SA_NOCLDSTOP 0x00000001
  308 +#define TARGET_SA_NOCLDWAIT 0x00010000
  309 +#define TARGET_SA_SIGINFO 0x00000008
  310 +#define TARGET_SA_ONSTACK 0x08000000
  311 +#define TARGET_SA_NODEFER 0x40000000
  312 +#define TARGET_SA_RESTART 0x10000000
  313 +#define TARGET_SA_RESETHAND 0x80000000
  314 +#define TARGET_SA_RESTORER 0x04000000 /* Only for o32 */
  315 +#else
298 316 #define TARGET_SA_NOCLDSTOP 0x00000001
299 317 #define TARGET_SA_NOCLDWAIT 0x00000002 /* not supported yet */
300 318 #define TARGET_SA_SIGINFO 0x00000004
... ... @@ -303,14 +321,6 @@ int do_sigaction(int sig, const struct target_sigaction *act,
303 321 #define TARGET_SA_NODEFER 0x40000000
304 322 #define TARGET_SA_RESETHAND 0x80000000
305 323 #define TARGET_SA_RESTORER 0x04000000
306   -#else /* TARGET_SPARC */
307   -#define TARGET_SA_NOCLDSTOP 8u
308   -#define TARGET_SA_NOCLDWAIT 0x100u
309   -#define TARGET_SA_SIGINFO 0x200u
310   -#define TARGET_SA_ONSTACK 1u
311   -#define TARGET_SA_RESTART 2u
312   -#define TARGET_SA_NODEFER 0x20u
313   -#define TARGET_SA_RESETHAND 4u
314 324 #endif
315 325  
316 326 #if defined(TARGET_SPARC)
... ... @@ -353,6 +363,49 @@ int do_sigaction(int sig, const struct target_sigaction *act,
353 363 #define TARGET_SIG_UNBLOCK 0x02 /* for unblocking signals */
354 364 #define TARGET_SIG_SETMASK 0x04 /* for setting the signal mask */
355 365  
  366 +#elif defined(TARGET_MIPS)
  367 +
  368 +#define TARGET_SIGHUP 1 /* Hangup (POSIX). */
  369 +#define TARGET_SIGINT 2 /* Interrupt (ANSI). */
  370 +#define TARGET_SIGQUIT 3 /* Quit (POSIX). */
  371 +#define TARGET_SIGILL 4 /* Illegal instruction (ANSI). */
  372 +#define TARGET_SIGTRAP 5 /* Trace trap (POSIX). */
  373 +#define TARGET_SIGIOT 6 /* IOT trap (4.2 BSD). */
  374 +#define TARGET_SIGABRT TARGET_SIGIOT /* Abort (ANSI). */
  375 +#define TARGET_SIGEMT 7
  376 +#define TARGET_SIGSTKFLT 7 /* XXX: incorrect */
  377 +#define TARGET_SIGFPE 8 /* Floating-point exception (ANSI). */
  378 +#define TARGET_SIGKILL 9 /* Kill, unblockable (POSIX). */
  379 +#define TARGET_SIGBUS 10 /* BUS error (4.2 BSD). */
  380 +#define TARGET_SIGSEGV 11 /* Segmentation violation (ANSI). */
  381 +#define TARGET_SIGSYS 12
  382 +#define TARGET_SIGPIPE 13 /* Broken pipe (POSIX). */
  383 +#define TARGET_SIGALRM 14 /* Alarm clock (POSIX). */
  384 +#define TARGET_SIGTERM 15 /* Termination (ANSI). */
  385 +#define TARGET_SIGUSR1 16 /* User-defined signal 1 (POSIX). */
  386 +#define TARGET_SIGUSR2 17 /* User-defined signal 2 (POSIX). */
  387 +#define TARGET_SIGCHLD 18 /* Child status has changed (POSIX). */
  388 +#define TARGET_SIGCLD TARGET_SIGCHLD /* Same as TARGET_SIGCHLD (System V). */
  389 +#define TARGET_SIGPWR 19 /* Power failure restart (System V). */
  390 +#define TARGET_SIGWINCH 20 /* Window size change (4.3 BSD, Sun). */
  391 +#define TARGET_SIGURG 21 /* Urgent condition on socket (4.2 BSD). */
  392 +#define TARGET_SIGIO 22 /* I/O now possible (4.2 BSD). */
  393 +#define TARGET_SIGPOLL TARGET_SIGIO /* Pollable event occurred (System V). */
  394 +#define TARGET_SIGSTOP 23 /* Stop, unblockable (POSIX). */
  395 +#define TARGET_SIGTSTP 24 /* Keyboard stop (POSIX). */
  396 +#define TARGET_SIGCONT 25 /* Continue (POSIX). */
  397 +#define TARGET_SIGTTIN 26 /* Background read from tty (POSIX). */
  398 +#define TARGET_SIGTTOU 27 /* Background write to tty (POSIX). */
  399 +#define TARGET_SIGVTALRM 28 /* Virtual alarm clock (4.2 BSD). */
  400 +#define TARGET_SIGPROF 29 /* Profiling alarm clock (4.2 BSD). */
  401 +#define TARGET_SIGXCPU 30 /* CPU limit exceeded (4.2 BSD). */
  402 +#define TARGET_SIGXFSZ 31 /* File size limit exceeded (4.2 BSD). */
  403 +#define TARGET_SIGRTMIN 32
  404 +
  405 +#define TARGET_SIG_BLOCK 1 /* for blocking signals */
  406 +#define TARGET_SIG_UNBLOCK 2 /* for unblocking signals */
  407 +#define TARGET_SIG_SETMASK 3 /* for setting the signal mask */
  408 +
356 409 #else
357 410  
358 411 #define TARGET_SIGHUP 1
... ... @@ -794,13 +847,21 @@ struct target_winsize {
794 847 #define TARGET_MAP_PRIVATE 0x02 /* Changes are private */
795 848 #define TARGET_MAP_TYPE 0x0f /* Mask for type of mapping */
796 849 #define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
  850 +#if defined(TARGET_MIPS)
  851 +#define TARGET_MAP_ANONYMOUS 0x0800 /* don't use a file */
  852 +#define TARGET_MAP_GROWSDOWN 0x1000 /* stack-like segment */
  853 +#define TARGET_MAP_DENYWRITE 0x2000 /* ETXTBSY */
  854 +#define TARGET_MAP_EXECUTABLE 0x4000 /* mark it as an executable */
  855 +#define TARGET_MAP_LOCKED 0x8000 /* pages are locked */
  856 +#define TARGET_MAP_NORESERVE 0x0400 /* don't check for reservations */
  857 +#else
797 858 #define TARGET_MAP_ANONYMOUS 0x20 /* don't use a file */
798   -
799 859 #define TARGET_MAP_GROWSDOWN 0x0100 /* stack-like segment */
800 860 #define TARGET_MAP_DENYWRITE 0x0800 /* ETXTBSY */
801 861 #define TARGET_MAP_EXECUTABLE 0x1000 /* mark it as an executable */
802 862 #define TARGET_MAP_LOCKED 0x2000 /* pages are locked */
803 863 #define TARGET_MAP_NORESERVE 0x4000 /* don't check for reservations */
  864 +#endif
804 865  
805 866 #if defined(TARGET_I386) || defined(TARGET_ARM)
806 867 struct target_stat {
... ... @@ -967,7 +1028,79 @@ struct target_stat64 {
967 1028 target_ulong __unused5;
968 1029 };
969 1030  
970   -#endif /* defined(TARGET_PPC) */
  1031 +#elif defined(TARGET_MIPS)
  1032 +
  1033 +struct target_stat {
  1034 + unsigned st_dev;
  1035 + target_long st_pad1[3]; /* Reserved for network id */
  1036 + target_ulong st_ino;
  1037 + unsigned int st_mode;
  1038 + unsigned int st_nlink;
  1039 + int st_uid;
  1040 + int st_gid;
  1041 + unsigned st_rdev;
  1042 + target_long st_pad2[2];
  1043 + target_long st_size;
  1044 + target_long st_pad3;
  1045 + /*
  1046 + * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
  1047 + * but we don't have it under Linux.
  1048 + */
  1049 + target_long target_st_atime;
  1050 + target_long target_st_atime_nsec;
  1051 + target_long target_st_mtime;
  1052 + target_long target_st_mtime_nsec;
  1053 + target_long target_st_ctime;
  1054 + target_long target_st_ctime_nsec;
  1055 + target_long st_blksize;
  1056 + target_long st_blocks;
  1057 + target_long st_pad4[14];
  1058 +};
  1059 +
  1060 +/*
  1061 + * This matches struct stat64 in glibc2.1, hence the absolutely insane
  1062 + * amounts of padding around dev_t's. The memory layout is the same as of
  1063 + * struct stat of the 64-bit kernel.
  1064 + */
  1065 +
  1066 +struct target_stat64 {
  1067 + target_ulong st_dev;
  1068 + target_ulong st_pad0[3]; /* Reserved for st_dev expansion */
  1069 +
  1070 + uint64_t st_ino;
  1071 +
  1072 + unsigned int st_mode;
  1073 + unsigned int st_nlink;
  1074 +
  1075 + int st_uid;
  1076 + int st_gid;
  1077 +
  1078 + target_ulong st_rdev;
  1079 + target_ulong st_pad1[3]; /* Reserved for st_rdev expansion */
  1080 +
  1081 + int64_t st_size;
  1082 +
  1083 + /*
  1084 + * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
  1085 + * but we don't have it under Linux.
  1086 + */
  1087 + target_long target_st_atime;
  1088 + target_ulong target_st_atime_nsec; /* Reserved for st_atime expansion */
  1089 +
  1090 + target_long target_st_mtime;
  1091 + target_ulong target_st_mtime_nsec; /* Reserved for st_mtime expansion */
  1092 +
  1093 + target_long target_st_ctime;
  1094 + target_ulong target_st_ctime_nsec; /* Reserved for st_ctime expansion */
  1095 +
  1096 + target_ulong st_blksize;
  1097 + target_ulong st_pad2;
  1098 +
  1099 + int64_t st_blocks;
  1100 +};
  1101 +#else
  1102 +#error unsupported CPU
  1103 +#endif
971 1104  
972 1105 #define TARGET_F_DUPFD 0 /* dup */
973 1106 #define TARGET_F_GETFD 1 /* get close_on_exec */
... ... @@ -1007,7 +1140,7 @@ struct target_stat64 {
1007 1140 #define TARGET_O_TRUNC 01000 /* not fcntl */
1008 1141 #define TARGET_O_APPEND 02000
1009 1142 #define TARGET_O_NONBLOCK 04000
1010   -#define TARGET_O_NDELAY O_NONBLOCK
  1143 +#define TARGET_O_NDELAY TARGET_O_NONBLOCK
1011 1144 #define TARGET_O_SYNC 010000
1012 1145 #define TARGET_FASYNC 020000 /* fcntl, for BSD compatibility */
1013 1146 #define TARGET_O_DIRECTORY 040000 /* must be a directory */
... ... @@ -1025,7 +1158,7 @@ struct target_stat64 {
1025 1158 #define TARGET_O_TRUNC 01000 /* not fcntl */
1026 1159 #define TARGET_O_APPEND 02000
1027 1160 #define TARGET_O_NONBLOCK 04000
1028   -#define TARGET_O_NDELAY O_NONBLOCK
  1161 +#define TARGET_O_NDELAY TARGET_O_NONBLOCK
1029 1162 #define TARGET_O_SYNC 010000
1030 1163 #define TARGET_FASYNC 020000 /* fcntl, for BSD compatibility */
1031 1164 #define TARGET_O_DIRECTORY 040000 /* must be a directory */
... ... @@ -1044,12 +1177,31 @@ struct target_stat64 {
1044 1177 #define TARGET_O_EXCL 0x0800 /* not fcntl */
1045 1178 #define TARGET_O_SYNC 0x2000
1046 1179 #define TARGET_O_NONBLOCK 0x4000
1047   -#define TARGET_O_NDELAY (0x0004 | O_NONBLOCK)
  1180 +#define TARGET_O_NDELAY (0x0004 | TARGET_O_NONBLOCK)
1048 1181 #define TARGET_O_NOCTTY 0x8000 /* not fcntl */
1049 1182 #define TARGET_O_DIRECTORY 0x10000 /* must be a directory */
1050 1183 #define TARGET_O_NOFOLLOW 0x20000 /* don't follow links */
1051 1184 #define TARGET_O_LARGEFILE 0x40000
1052 1185 #define TARGET_O_DIRECT 0x100000 /* direct disk access hint */
  1186 +#elif defined(TARGET_MIPS)
  1187 +#define TARGET_O_ACCMODE 0x0003
  1188 +#define TARGET_O_RDONLY 0x0000
  1189 +#define TARGET_O_WRONLY 0x0001
  1190 +#define TARGET_O_RDWR 0x0002
  1191 +#define TARGET_O_APPEND 0x0008
  1192 +#define TARGET_O_SYNC 0x0010
  1193 +#define TARGET_O_NONBLOCK 0x0080
  1194 +#define TARGET_O_CREAT 0x0100 /* not fcntl */
  1195 +#define TARGET_O_TRUNC 0x0200 /* not fcntl */
  1196 +#define TARGET_O_EXCL 0x0400 /* not fcntl */
  1197 +#define TARGET_O_NOCTTY 0x0800 /* not fcntl */
  1198 +#define TARGET_FASYNC 0x1000 /* fcntl, for BSD compatibility */
  1199 +#define TARGET_O_LARGEFILE 0x2000 /* allow large file opens */
  1200 +#define TARGET_O_DIRECT 0x8000 /* direct disk access hint */
  1201 +#define TARGET_O_DIRECTORY 0x10000 /* must be a directory */
  1202 +#define TARGET_O_NOFOLLOW 0x20000 /* don't follow links */
  1203 +#define TARGET_O_NOATIME 0x40000
  1204 +#define TARGET_O_NDELAY TARGET_O_NONBLOCK
1053 1205 #else
1054 1206 #define TARGET_O_ACCMODE 0003
1055 1207 #define TARGET_O_RDONLY 00
... ... @@ -1061,7 +1213,7 @@ struct target_stat64 {
1061 1213 #define TARGET_O_TRUNC 01000 /* not fcntl */
1062 1214 #define TARGET_O_APPEND 02000
1063 1215 #define TARGET_O_NONBLOCK 04000
1064   -#define TARGET_O_NDELAY O_NONBLOCK
  1216 +#define TARGET_O_NDELAY TARGET_O_NONBLOCK
1065 1217 #define TARGET_O_SYNC 010000
1066 1218 #define TARGET_FASYNC 020000 /* fcntl, for BSD compatibility */
1067 1219 #define TARGET_O_DIRECT 040000 /* direct disk access hint */
... ...
target-mips/op_helper.c
... ... @@ -114,6 +114,37 @@ void do_msubu (void)
114 114 }
115 115 #endif
116 116  
  117 +#if defined(CONFIG_USER_ONLY)
  118 +void do_mfc0 (int reg, int sel)
  119 +{
  120 + cpu_abort(env, "mfc0 reg=%d sel=%d\n", reg, sel);
  121 +}
  122 +void do_mtc0 (int reg, int sel)
  123 +{
  124 + cpu_abort(env, "mtc0 reg=%d sel=%d\n", reg, sel);
  125 +}
  126 +
  127 +void do_tlbwi (void)
  128 +{
  129 + cpu_abort(env, "tlbwi\n");
  130 +}
  131 +
  132 +void do_tlbwr (void)
  133 +{
  134 + cpu_abort(env, "tlbwr\n");
  135 +}
  136 +
  137 +void do_tlbp (void)
  138 +{
  139 + cpu_abort(env, "tlbp\n");
  140 +}
  141 +
  142 +void do_tlbr (void)
  143 +{
  144 + cpu_abort(env, "tlbr\n");
  145 +}
  146 +#else
  147 +
117 148 /* CP0 helpers */
118 149 void do_mfc0 (int reg, int sel)
119 150 {
... ... @@ -580,6 +611,8 @@ void do_tlbr (void)
580 611 }
581 612 #endif
582 613  
  614 +#endif /* !CONFIG_USER_ONLY */
  615 +
583 616 void op_dump_ldst (const unsigned char *func)
584 617 {
585 618 if (loglevel)
... ...