Deleted Added
sdiff udiff text old ( 14124:9742fcde81e1 ) new ( 14129:7a41ca7e465c )
full compact
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 852 unchanged lines hidden (view full) ---

861 // not sure if this is totally valid, but we'll pass it through
862 // to the underlying OS
863 warn("fcntl64(%d, %d) passed through to host\n", tgt_fd, cmd);
864 return fcntl(sim_fd, cmd);
865 }
866}
867
868SyscallReturn
869pipeImpl(SyscallDesc *desc, int callnum, ThreadContext *tc, bool pseudoPipe)
870{
871 Addr tgt_addr = 0;
872 auto p = tc->getProcessPtr();
873 if (!pseudoPipe) {
874 int index = 0;
875 tgt_addr = p->getSyscallArg(tc, index);
876 }
877
878 int sim_fds[2], tgt_fds[2];
879
880 int pipe_retval = pipe(sim_fds);
881 if (pipe_retval == -1)
882 return -errno;
883
884 auto rend = PipeFDEntry::EndType::read;
885 auto rpfd = std::make_shared<PipeFDEntry>(sim_fds[0], O_WRONLY, rend);
886 tgt_fds[0] = p->fds->allocFD(rpfd);
887
888 auto wend = PipeFDEntry::EndType::write;
889 auto wpfd = std::make_shared<PipeFDEntry>(sim_fds[1], O_RDONLY, wend);
890 tgt_fds[1] = p->fds->allocFD(wpfd);
891
892 /**
893 * Now patch the read object to record the target file descriptor chosen
894 * as the write end of the pipe.
895 */
896 rpfd->setPipeReadSource(tgt_fds[1]);
897
898 /**
899 * Alpha Linux convention for pipe() is that fd[0] is returned as
900 * the return value of the function, and fd[1] is returned in r20.
901 */
902 if (pseudoPipe) {
903 tc->setIntReg(SyscallPseudoReturnReg, tgt_fds[1]);
904 return tgt_fds[0];
905 }
906
907 /**
908 * Copy the target file descriptors into buffer space and then copy
909 * the buffer space back into the target address space.
910 */
911 BufferArg tgt_handle(tgt_addr, sizeof(int[2]));
912 int *buf_ptr = (int*)tgt_handle.bufferPtr();
913 buf_ptr[0] = tgt_fds[0];
914 buf_ptr[1] = tgt_fds[1];
915 tgt_handle.copyOut(tc->getVirtProxy());
916 return 0;
917}
918
919SyscallReturn
920pipePseudoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
921{
922 return pipeImpl(desc, callnum, tc, true);
923}
924
925SyscallReturn
926pipeFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
927{
928 return pipeImpl(desc, callnum, tc, false);
929}
930
931SyscallReturn
932setpgidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
933{
934 int index = 0;
935 auto process = tc->getProcessPtr();
936 int pid = process->getSyscallArg(tc, index);
937 int pgid = process->getSyscallArg(tc, index);
938
939 if (pgid < 0)

--- 841 unchanged lines hidden ---