From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AM1WO-0007RD-TA for qemu-devel@nongnu.org; Tue, 18 Nov 2003 03:47:40 -0500 Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AM1Vq-0006jS-M7 for qemu-devel@nongnu.org; Tue, 18 Nov 2003 03:47:37 -0500 Received: from [62.210.158.41] (helo=moscou.magic.fr) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AM1Vk-0006UT-Hq for qemu-devel@nongnu.org; Tue, 18 Nov 2003 03:47:00 -0500 Received: from 10.0.0.2 (ppp-181.net-555.magic.fr [62.210.255.181]) by moscou.magic.fr (8.11.6/8.10.1) with ESMTP id hAI7jXO03392 for ; Tue, 18 Nov 2003 08:45:33 +0100 (CET) Subject: Re: [Qemu-devel] [ADD] PPC processor emulation From: "J. Mayer" In-Reply-To: <1069140512.14646.2174.camel@rapid> References: <20031117105133.7e856e56.Jens.Arm@gmx.de> <1069140512.14646.2174.camel@rapid> Content-Type: text/plain Message-Id: <1069141816.13658.2227.camel@rapid> Mime-Version: 1.0 Date: 18 Nov 2003 08:50:16 +0100 Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org syscall.c.diff First set of fixes to handle syscalls for PPC target. Still need work. diff -urNbB -x CVS qemu-current/syscall.c qemu/syscall.c --- qemu-current/syscall.c Tue Nov 18 06:51:10 2003 +++ qemu/syscall.c Tue Nov 11 01:06:31 2003 @@ -1265,6 +1265,15 @@ new_env->regs[0] = 0; #elif defined(TARGET_SPARC) printf ("HELPME: %s:%d\n", __FILE__, __LINE__); +#elif defined(TARGET_PPC) + if (!newsp) + newsp = env->gpr[1]; + new_env->gpr[1] = newsp; + { + int i; + for (i = 7; i < 32; i++) + new_env->gpr[i] = 0; + } #else #error unsupported target CPU #endif @@ -1472,9 +1481,11 @@ case TARGET_NR_chmod: ret = get_errno(chmod((const char *)arg1, arg2)); break; +#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) case TARGET_NR_lchown: ret = get_errno(chown((const char *)arg1, arg2, arg3)); break; +#endif #ifdef TARGET_NR_break case TARGET_NR_break: goto unimplemented; @@ -1495,12 +1506,14 @@ case TARGET_NR_umount: ret = get_errno(umount((const char *)arg1)); break; +#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) case TARGET_NR_setuid: ret = get_errno(setuid(low2highuid(arg1))); break; case TARGET_NR_getuid: ret = get_errno(getuid()); break; +#endif case TARGET_NR_stime: { int *time_ptr = (int *)arg1; @@ -1596,20 +1609,24 @@ case TARGET_NR_prof: goto unimplemented; #endif +#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) case TARGET_NR_setgid: ret = get_errno(setgid(low2highgid(arg1))); break; case TARGET_NR_getgid: ret = get_errno(getgid()); break; +#endif case TARGET_NR_signal: goto unimplemented; +#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) case TARGET_NR_geteuid: ret = get_errno(geteuid()); break; case TARGET_NR_getegid: ret = get_errno(getegid()); break; +#endif case TARGET_NR_acct: goto unimplemented; case TARGET_NR_umount2: @@ -1844,12 +1861,14 @@ /* NOTE: ret is eax, so not transcoding must be done */ ret = do_rt_sigreturn(cpu_env); break; +#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) case TARGET_NR_setreuid: ret = get_errno(setreuid(arg1, arg2)); break; case TARGET_NR_setregid: ret = get_errno(setregid(arg1, arg2)); break; +#endif case TARGET_NR_sethostname: ret = get_errno(sethostname((const char *)arg1, arg2)); break; @@ -1906,6 +1925,7 @@ ret = get_errno(settimeofday(&tv, NULL)); } break; +#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) case TARGET_NR_getgroups: { int gidsetsize = arg1; @@ -1934,6 +1954,7 @@ ret = get_errno(setgroups(gidsetsize, grouplist)); } break; +#endif case TARGET_NR_select: { struct target_sel_arg_struct *sel = (void *)arg1; @@ -2026,9 +2047,11 @@ case TARGET_NR_fchmod: ret = get_errno(fchmod(arg1, arg2)); break; +#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) case TARGET_NR_fchown: ret = get_errno(fchown(arg1, arg2, arg3)); break; +#endif case TARGET_NR_getpriority: ret = get_errno(getpriority(arg1, arg2)); break; @@ -2119,12 +2142,18 @@ do_stat: if (!is_error(ret)) { struct target_stat *target_st = (void *)arg2; - target_st->st_dev = tswap16(st.st_dev); - target_st->st_ino = tswapl(st.st_ino); +#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) target_st->st_mode = tswap16(st.st_mode); - target_st->st_nlink = tswap16(st.st_nlink); target_st->st_uid = tswap16(st.st_uid); target_st->st_gid = tswap16(st.st_gid); +#elif defined(TARGET_PPC) + target_st->st_mode = tswapl(st.st_mode); + target_st->st_uid = tswap32(st.st_uid); + target_st->st_gid = tswap32(st.st_gid); +#endif + target_st->st_dev = tswap16(st.st_dev); + target_st->st_ino = tswapl(st.st_ino); + target_st->st_nlink = tswap16(st.st_nlink); target_st->st_rdev = tswap16(st.st_rdev); target_st->st_size = tswapl(st.st_size); target_st->st_blksize = tswapl(st.st_blksize); @@ -2230,12 +2259,14 @@ break; case TARGET_NR_afs_syscall: goto unimplemented; +#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) case TARGET_NR_setfsuid: ret = get_errno(setfsuid(arg1)); break; case TARGET_NR_setfsgid: ret = get_errno(setfsgid(arg1)); break; +#endif case TARGET_NR__llseek: { int64_t res; @@ -2311,6 +2342,7 @@ } #endif break; +#ifdef TARGET_NR_getdents64 case TARGET_NR_getdents64: { struct dirent64 *dirp = (void *)arg2; @@ -2334,6 +2366,7 @@ } } break; +#endif /* TARGET_NR_getdents64 */ case TARGET_NR__newselect: ret = do_select(arg1, (void *)arg2, (void *)arg3, (void *)arg4, (void *)arg5); @@ -2465,6 +2498,7 @@ } } break; +#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) #ifdef TARGET_NR_setresuid case TARGET_NR_setresuid: ret = get_errno(setresuid(low2highuid(arg1), @@ -2505,12 +2539,14 @@ } break; #endif +#endif case TARGET_NR_query_module: goto unimplemented; case TARGET_NR_nfsservctl: goto unimplemented; case TARGET_NR_prctl: goto unimplemented; +#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) case TARGET_NR_pread: page_unprotect_range((void *)arg2, arg3); ret = get_errno(pread(arg1, (void *)arg2, arg3, arg4)); @@ -2518,9 +2554,17 @@ case TARGET_NR_pwrite: ret = get_errno(pwrite(arg1, (void *)arg2, arg3, arg4)); break; +#elif defined(TARGET_PPC) + case TARGET_NR_pread64: + goto unimplemented; + case TARGET_NR_pwrite64: + goto unimplemented; +#endif +#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) case TARGET_NR_chown: ret = get_errno(chown((const char *)arg1, arg2, arg3)); break; +#endif case TARGET_NR_getcwd: ret = get_errno(sys_getcwd1((char *)arg1, arg2)); break; @@ -2573,6 +2617,7 @@ if (!is_error(ret)) { struct target_stat64 *target_st = (void *)arg2; memset(target_st, 0, sizeof(struct target_stat64)); +#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) target_st->st_dev = tswap16(st.st_dev); target_st->st_ino = tswap64(st.st_ino); #ifdef TARGET_STAT64_HAS_BROKEN_ST_INO @@ -2590,10 +2635,26 @@ target_st->target_st_atime = tswapl(st.st_atime); target_st->target_st_mtime = tswapl(st.st_mtime); target_st->target_st_ctime = tswapl(st.st_ctime); +#elif defined(TARGET_PPC) + target_st->st_dev = tswap64(st.st_dev); + target_st->st_ino = tswap64(st.st_ino); + target_st->st_mode = tswap32(st.st_mode); + target_st->st_nlink = tswap32(st.st_nlink); + target_st->st_uid = tswap32(st.st_uid); + target_st->st_gid = tswap32(st.st_gid); + target_st->st_rdev = tswap64(st.st_rdev); + target_st->st_size = tswap64(st.st_size); + target_st->st_blksize = tswapl(st.st_blksize); + target_st->st_blocks = tswap64(st.st_blocks); + target_st->target_st_atime = tswapl(st.st_atime); + target_st->target_st_mtime = tswapl(st.st_mtime); + target_st->target_st_ctime = tswapl(st.st_ctime); +#endif } } break; +#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) case TARGET_NR_lchown32: ret = get_errno(lchown((const char *)arg1, arg2, arg3)); break; @@ -2665,12 +2726,91 @@ case TARGET_NR_setfsgid32: ret = get_errno(setfsgid(arg1)); break; +#elif defined (TARGET_PPC) + case TARGET_NR_lchown: + ret = get_errno(lchown((const char *)arg1, arg2, arg3)); + break; + case TARGET_NR_getuid: + ret = get_errno(getuid()); + break; + case TARGET_NR_getgid: + ret = get_errno(getgid()); + break; + case TARGET_NR_geteuid: + ret = get_errno(geteuid()); + break; + case TARGET_NR_getegid: + ret = get_errno(getegid()); + break; + case TARGET_NR_setreuid: + ret = get_errno(setreuid(arg1, arg2)); + break; + case TARGET_NR_setregid: + ret = get_errno(setregid(arg1, arg2)); + break; + case TARGET_NR_getgroups: + goto unimplemented; + case TARGET_NR_setgroups: + goto unimplemented; + case TARGET_NR_fchown: + ret = get_errno(fchown(arg1, arg2, arg3)); + break; + case TARGET_NR_setresuid: + ret = get_errno(setresuid(arg1, arg2, arg3)); + break; + case TARGET_NR_getresuid: + { + int ruid, euid, suid; + ret = get_errno(getresuid(&ruid, &euid, &suid)); + if (!is_error(ret)) { + *(uint32_t *)arg1 = tswap32(ruid); + *(uint32_t *)arg2 = tswap32(euid); + *(uint32_t *)arg3 = tswap32(suid); + } + } + break; + case TARGET_NR_setresgid: + ret = get_errno(setresgid(arg1, arg2, arg3)); + break; + case TARGET_NR_getresgid: + { + int rgid, egid, sgid; + ret = get_errno(getresgid(&rgid, &egid, &sgid)); + if (!is_error(ret)) { + *(uint32_t *)arg1 = tswap32(rgid); + *(uint32_t *)arg2 = tswap32(egid); + *(uint32_t *)arg3 = tswap32(sgid); + } + } + break; + case TARGET_NR_chown: + ret = get_errno(chown((const char *)arg1, arg2, arg3)); + break; + case TARGET_NR_setuid: + ret = get_errno(setuid(arg1)); + break; + case TARGET_NR_setgid: + ret = get_errno(setgid(arg1)); + break; + case TARGET_NR_setfsuid: + ret = get_errno(setfsuid(arg1)); + break; + case TARGET_NR_setfsgid: + ret = get_errno(setfsgid(arg1)); + break; +#endif +#ifdef TARGET_NR_pivot_root case TARGET_NR_pivot_root: goto unimplemented; +#endif +#ifdef TARGET_NR_mincore case TARGET_NR_mincore: goto unimplemented; +#endif +#ifdef TARGET_NR_madvise case TARGET_NR_madvise: goto unimplemented; +#endif #if TARGET_LONG_BITS == 32 case TARGET_NR_fcntl64: {