Gabe Black has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/26603 )
Change subject: sim: Provide an implementation for the pread64 system call.
......................................................................
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.pore...@amd.com>
Maintainer: Bobby R. Bruce <bbr...@ucdavis.edu>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/sim/syscall_emul.hh
1 file changed, 21 insertions(+), 0 deletions(-)
Approvals:
Matthew Poremba: Looks good to me, approved
Bobby R. Bruce: Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index 2503635..f999e45 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -1818,6 +1818,27 @@
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,
int tgt_fd, Addr bufPtr, int nbytes, int offset)
{
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/26603
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I4f8ec9d83bf2339f9c84e31f25309c58e6157304
Gerrit-Change-Number: 26603
Gerrit-PatchSet: 3
Gerrit-Owner: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Bobby Bruce <b.br...@cs.ucla.edu>
Gerrit-Reviewer: Bobby R. Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Brandon Potter <ambitiousc...@gmail.com>
Gerrit-Reviewer: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Matthew Poremba <matthew.pore...@amd.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev