/* 16 */ SyscallDesc("ioctl", ioctlFunc<X86Linux64>),
/* 17 */ SyscallDesc("pread64", unimplementedFunc),
/* 18 */ SyscallDesc("pwrite64", pwrite64Func<X86Linux64>),
- /* 19 */ SyscallDesc("readv", unimplementedFunc),
+ /* 19 */ SyscallDesc("readv", readvFunc<X86Linux64>),
/* 20 */ SyscallDesc("writev", writevFunc<X86Linux64>),
/* 21 */ SyscallDesc("access", ignoreFunc),
/* 22 */ SyscallDesc("pipe", pipeFunc),
/* 142 */ SyscallDesc("_newselect", unimplementedFunc),
/* 143 */ SyscallDesc("flock", unimplementedFunc),
/* 144 */ SyscallDesc("msync", unimplementedFunc),
- /* 145 */ SyscallDesc("readv", unimplementedFunc),
+ /* 145 */ SyscallDesc("readv", readvFunc<X86Linux32>),
/* 146 */ SyscallDesc("writev", writevFunc<X86Linux32>),
/* 147 */ SyscallDesc("getsid", unimplementedFunc),
/* 148 */ SyscallDesc("fdatasync", unimplementedFunc),
return 0;
}
+/// Target readv() handler.
+template <class OS>
+SyscallReturn
+readvFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
+{
+ int index = 0;
+ int tgt_fd = p->getSyscallArg(tc, index);
+
+ auto ffdp = std::dynamic_pointer_cast<FileFDEntry>((*p->fds)[tgt_fd]);
+ if (!ffdp)
+ return -EBADF;
+ int sim_fd = ffdp->getSimFD();
+
+ SETranslatingPortProxy &prox = tc->getMemProxy();
+ uint64_t tiov_base = p->getSyscallArg(tc, index);
+ size_t count = p->getSyscallArg(tc, index);
+ typename OS::tgt_iovec tiov[count];
+ struct iovec hiov[count];
+ for (size_t i = 0; i < count; ++i) {
+ prox.readBlob(tiov_base + (i * sizeof(typename OS::tgt_iovec)),
+ (uint8_t*)&tiov[i], sizeof(typename OS::tgt_iovec));
+ hiov[i].iov_len = TheISA::gtoh(tiov[i].iov_len);
+ hiov[i].iov_base = new char [hiov[i].iov_len];
+ }
+
+ int result = readv(sim_fd, hiov, count);
+ int local_errno = errno;
+
+ for (size_t i = 0; i < count; ++i) {
+ if (result != -1) {
+ prox.writeBlob(TheISA::htog(tiov[i].iov_base),
+ (uint8_t*)hiov[i].iov_base, hiov[i].iov_len);
+ }
+ delete [] (char *)hiov[i].iov_base;
+ }
+
+ return (result == -1) ? -local_errno : result;
+}
/// Target writev() handler.
template <class OS>
for (size_t i = 0; i < count; ++i)
delete [] (char *)hiov[i].iov_base;
- if (result < 0)
- return -errno;
-
- return result;
+ return (result == -1) ? -errno : result;
}
/// Real mmap handler.