2 * Copyright 2003-2005 The Regents of The University of Michigan
3 * Copyright 2020 Google Inc.
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;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include "arch/sparc/linux/se_workload.hh"
31 #include <sys/syscall.h>
33 #include "arch/sparc/process.hh"
34 #include "base/loader/object_file.hh"
35 #include "base/trace.hh"
36 #include "cpu/thread_context.hh"
37 #include "sim/syscall_desc.hh"
42 class LinuxLoader
: public Process::Loader
46 load(const ProcessParams
¶ms
, ::Loader::ObjectFile
*obj
) override
48 auto arch
= obj
->getArch();
49 auto opsys
= obj
->getOpSys();
51 if (arch
!= ::Loader::SPARC64
&& arch
!= ::Loader::SPARC32
)
54 if (opsys
== ::Loader::UnknownOpSys
) {
55 warn("Unknown operating system; assuming Linux.");
56 opsys
= ::Loader::Linux
;
59 if (opsys
!= ::Loader::Linux
)
62 if (arch
== ::Loader::SPARC64
)
63 return new Sparc64Process(params
, obj
);
65 return new Sparc32Process(params
, obj
);
71 } // anonymous namespace
76 EmuLinux::EmuLinux(const Params
&p
) : SEWorkload(p
), _params(p
)
80 EmuLinux::handleTrap(ThreadContext
*tc
, int trapNum
)
84 // case 0x10: // Linux 32 bit syscall trap
85 case 0x6d: // Linux 64 bit syscall trap
88 case 0x6e: // Linux 64 bit getcontext trap
89 warn("The getcontext trap is not implemented on SPARC");
91 case 0x6f: // Linux 64 bit setcontext trap
92 panic("The setcontext trap is not implemented on SPARC");
98 case 0x10: //Linux 32 bit syscall trap
105 SEWorkload::handleTrap(tc
, trapNum
);
109 EmuLinux::syscall32(ThreadContext
*tc
)
111 Process
*process
= tc
->getProcessPtr();
112 // Call the syscall function in the base Process class to update stats.
113 // This will move into the base SEWorkload function at some point.
114 process
->Process::syscall(tc
);
116 syscall32Descs
.get(tc
->readIntReg(1))->doSyscall(tc
);
120 EmuLinux::syscall64(ThreadContext
*tc
)
122 Process
*process
= tc
->getProcessPtr();
123 // Call the syscall function in the base Process class to update stats.
124 // This will move into the base SEWorkload function at some point.
125 process
->Process::syscall(tc
);
127 syscallDescs
.get(tc
->readIntReg(1))->doSyscall(tc
);
131 EmuLinux::syscall(ThreadContext
*tc
)
139 } // namespace SparcISA