sim: Provide an implementation for the pread64 system call.
This implementation is very similar to the pwrite64 system call, just with data going the other direction as you'd expect. Change-Id: I4f8ec9d83bf2339f9c84e31f25309c58e6157304 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/26603 Reviewed-by: Matthew Poremba <matthew.poremba@amd.com> Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -1816,6 +1816,27 @@ mmapFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
return start;
|
||||
}
|
||||
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
pread64Func(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
int tgt_fd, Addr bufPtr, int nbytes, int offset)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
|
||||
auto ffdp = std::dynamic_pointer_cast<FileFDEntry>((*p->fds)[tgt_fd]);
|
||||
if (!ffdp)
|
||||
return -EBADF;
|
||||
int sim_fd = ffdp->getSimFD();
|
||||
|
||||
BufferArg bufArg(bufPtr, nbytes);
|
||||
|
||||
int bytes_read = pread(sim_fd, bufArg.bufferPtr(), nbytes, offset);
|
||||
|
||||
bufArg.copyOut(tc->getVirtProxy());
|
||||
|
||||
return (bytes_read == -1) ? -errno : bytes_read;
|
||||
}
|
||||
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
pwrite64Func(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
|
||||
Reference in New Issue
Block a user