add fcntl64Func
authorKorey Sewell <ksewell@umich.edu>
Fri, 9 Jun 2006 21:07:13 +0000 (17:07 -0400)
committerKorey Sewell <ksewell@umich.edu>
Fri, 9 Jun 2006 21:07:13 +0000 (17:07 -0400)
use ThreadContext rename

src/arch/mips/isa/formats/branch.isa:
src/arch/mips/isa/formats/fp.isa:
src/arch/mips/isa/includes.isa:
    Use ThreadContext
src/sim/syscall_emul.cc:
    fcntl64 function using TC
src/sim/syscall_emul.hh:
    Add fcntl64func

--HG--
extra : convert_revision : b5e2348530473704388b1c5a2b59bf78360260a9

src/arch/mips/isa/formats/branch.isa
src/arch/mips/isa/formats/fp.isa
src/arch/mips/isa/includes.isa
src/sim/syscall_emul.cc
src/sim/syscall_emul.hh

index 6f8cebed0f5c35d64606006cdd521e9d619a47b2..e8843da03fe63d98b07c2a7e1e13c15ba7419d70 100644 (file)
@@ -88,7 +88,7 @@ output header {{
         {
         }
 
-        Addr branchTarget(ExecContext *xc) const;
+        Addr branchTarget(ThreadContext *tc) const;
 
         std::string
         generateDisassembly(Addr pc, const SymbolTable *symtab) const;
@@ -103,10 +103,10 @@ output decoder {{
     }
 
     Addr
-    Jump::branchTarget(ExecContext *xc) const
+    Jump::branchTarget(ThreadContext *tc) const
     {
-        Addr NPC = xc->readPC() + 4;
-        uint64_t Rb = xc->readIntReg(_srcRegIdx[0]);
+        Addr NPC = tc->readPC() + 4;
+        uint64_t Rb = tc->readIntReg(_srcRegIdx[0]);
         return (Rb & ~3) | (NPC & 1);
     }
 
index 6647f93619f05cfb2f4068d291414340db29be90..1803c0e73d13a616bc97fb39784e61277791c40c 100644 (file)
@@ -95,7 +95,7 @@ output exec {{
 
         template <class T>
         bool
-        fpInvalidOp(FPOp *inst, %(CPU_exec_context)s *xc, const T dest_val,
+        fpInvalidOp(FPOp *inst, %(CPU_exec_context)s *cpu, const T dest_val,
                     Trace::InstRecord *traceData)
         {
             uint64_t mips_nan = 0;
@@ -111,13 +111,13 @@ output exec {{
                 }
 
                 //Set value to QNAN
-                xc->setFloatRegBits(inst, 0, mips_nan, size);
+                cpu->setFloatRegBits(inst, 0, mips_nan, size);
 
                 //Read FCSR from FloatRegFile
-                uint32_t fcsr_bits = xc->cpuXC->readFloatRegBits(FCSR);
+                uint32_t fcsr_bits = cpu->tc->readFloatRegBits(FCSR);
 
                 //Write FCSR from FloatRegFile
-                xc->cpuXC->setFloatRegBits(FCSR, genInvalidVector(fcsr_bits));
+                cpu->tc->setFloatRegBits(FCSR, genInvalidVector(fcsr_bits));
 
                 if (traceData) { traceData->setData(mips_nan); }
                 return true;
@@ -127,15 +127,15 @@ output exec {{
         }
 
         void
-        fpResetCauseBits(%(CPU_exec_context)s *xc)
+        fpResetCauseBits(%(CPU_exec_context)s *cpu)
         {
             //Read FCSR from FloatRegFile
-            uint32_t fcsr = xc->cpuXC->readFloatRegBits(FCSR);
+            uint32_t fcsr = cpu->tc->readFloatRegBits(FCSR);
 
             fcsr = bits(fcsr, 31, 18) << 18 | bits(fcsr, 11, 0);
 
             //Write FCSR from FloatRegFile
-            xc->cpuXC->setFloatRegBits(FCSR, fcsr);
+            cpu->tc->setFloatRegBits(FCSR, fcsr);
         }
 }};
 
index fe21d65cb170e0e75b15a5f682754d1ea833ed1b..126929e19603fc0d922a9c0b6bcc1bd4e1c5a379 100644 (file)
@@ -18,7 +18,7 @@ output decoder {{
 #include "arch/mips/isa_traits.hh"
 #include "base/cprintf.hh"
 #include "base/loader/symtab.hh"
-#include "cpu/exec_context.hh"  // for Jump::branchTarget()
+#include "cpu/thread_context.hh"
 #include "arch/mips/faults.hh"
 #include "arch/mips/isa_traits.hh"
 #include "arch/mips/utility.hh"
index 888c133c0600065dbec4955866906af5d31b3dda..e32295131053d2ebff66d5ae9a69ecaf932acd5f 100644 (file)
@@ -340,6 +340,35 @@ fcntlFunc(SyscallDesc *desc, int num, Process *process,
     }
 }
 
+SyscallReturn
+fcntl64Func(SyscallDesc *desc, int num, Process *process,
+            ThreadContext *tc)
+{
+    int fd = tc->getSyscallArg(0);
+
+    if (fd < 0 || process->sim_fd(fd) < 0)
+        return -EBADF;
+
+    int cmd = tc->getSyscallArg(1);
+    switch (cmd) {
+      case 33: //F_GETLK64
+        warn("fcntl64(%d, F_GETLK64) not supported, error returned\n", fd);
+        return -EMFILE;
+
+      case 34: // F_SETLK64
+      case 35: // F_SETLKW64
+        warn("fcntl64(%d, F_SETLK(W)64) not supported, error returned\n", fd);
+        return -EMFILE;
+
+      default:
+        // not sure if this is totally valid, but we'll pass it through
+        // to the underlying OS
+        warn("fcntl64(%d, %d) passed through to host\n", fd, cmd);
+        return fcntl(process->sim_fd(fd), cmd);
+        // return 0;
+    }
+}
+
 SyscallReturn
 pipePseudoFunc(SyscallDesc *desc, int callnum, Process *process,
          ThreadContext *tc)
index 874eaf6a4d0ff5bbb0d917099a4f12837b1a1ded..ffd12dd83b3ca7a7fe5cb3f0161d19f741ac377b 100644 (file)
@@ -249,6 +249,10 @@ SyscallReturn fchownFunc(SyscallDesc *desc, int num,
 SyscallReturn fcntlFunc(SyscallDesc *desc, int num,
                         Process *process, ThreadContext *tc);
 
+/// Target fcntl64() handler.
+SyscallReturn fcntl64Func(SyscallDesc *desc, int num,
+                        Process *process, ThreadContext *tc);
+
 /// Target setuid() handler.
 SyscallReturn setuidFunc(SyscallDesc *desc, int num,
                                Process *p, ThreadContext *tc);