gem5
v21.0.1.0
arch
sparc
linux
se_workload.cc
Go to the documentation of this file.
1
/*
2
* Copyright 2003-2005 The Regents of The University of Michigan
3
* Copyright 2020 Google Inc.
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;
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.
15
*
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.
27
*/
28
29
#include "
arch/sparc/linux/se_workload.hh
"
30
31
#include <sys/syscall.h>
32
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
"
38
39
namespace
40
{
41
42
class
LinuxLoader :
public
Process::Loader
43
{
44
public
:
45
Process
*
46
load
(
const
ProcessParams ¶ms, ::
Loader::ObjectFile
*obj)
override
47
{
48
auto
arch = obj->
getArch
();
49
auto
opsys = obj->
getOpSys
();
50
51
if
(arch != ::
Loader::SPARC64
&& arch != ::
Loader::SPARC32
)
52
return
nullptr
;
53
54
if
(opsys == ::
Loader::UnknownOpSys
) {
55
warn
(
"Unknown operating system; assuming Linux."
);
56
opsys =
::Loader::Linux
;
57
}
58
59
if
(opsys != ::
Loader::Linux
)
60
return
nullptr
;
61
62
if
(arch == ::
Loader::SPARC64
)
63
return
new
Sparc64Process
(params, obj);
64
else
65
return
new
Sparc32Process
(params, obj);
66
}
67
};
68
69
LinuxLoader loader;
70
71
}
// anonymous namespace
72
73
namespace
SparcISA
74
{
75
76
EmuLinux::EmuLinux
(
const
Params
&
p
) :
SEWorkload
(
p
)
77
{}
78
79
void
80
EmuLinux::handleTrap
(
ThreadContext
*tc,
int
trapNum)
81
{
82
if
(
is64
(tc)) {
83
switch
(trapNum) {
84
// case 0x10: // Linux 32 bit syscall trap
85
case
0x6d:
// Linux 64 bit syscall trap
86
syscall64
(tc);
87
return
;
88
case
0x6e:
// Linux 64 bit getcontext trap
89
warn
(
"The getcontext trap is not implemented on SPARC"
);
90
return
;
91
case
0x6f:
// Linux 64 bit setcontext trap
92
panic
(
"The setcontext trap is not implemented on SPARC"
);
93
default
:
94
break
;
95
}
96
}
else
{
97
switch
(trapNum) {
98
case
0x10:
//Linux 32 bit syscall trap
99
syscall32
(tc);
100
return
;
101
default
:
102
break
;
103
}
104
}
105
SEWorkload::handleTrap
(tc, trapNum);
106
}
107
108
void
109
EmuLinux::syscall32
(
ThreadContext
*tc)
110
{
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);
115
116
syscall32Descs
.get(tc->
readIntReg
(1))->doSyscall(tc);
117
}
118
119
void
120
EmuLinux::syscall64
(
ThreadContext
*tc)
121
{
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);
126
127
syscallDescs
.get(tc->
readIntReg
(1))->doSyscall(tc);
128
}
129
130
void
131
EmuLinux::syscall
(
ThreadContext
*tc)
132
{
133
if
(
is64
(tc))
134
syscall64
(tc);
135
else
136
syscall32
(tc);
137
}
138
139
}
// namespace SparcISA
Loader::Linux
@ Linux
Definition:
object_file.hh:64
Process::Loader
Each instance of a Loader subclass will have a chance to try to load an object file when tryLoaders i...
Definition:
process.hh:180
Loader::SPARC32
@ SPARC32
Definition:
object_file.hh:47
warn
#define warn(...)
Definition:
logging.hh:239
process.hh
Process
Definition:
process.hh:65
SparcISA::SEWorkload::handleTrap
virtual void handleTrap(ThreadContext *tc, int trapNum)
Definition:
se_workload.cc:50
SparcISA::EmuLinux::EmuLinux
EmuLinux(const Params &p)
Definition:
se_workload.cc:76
ThreadContext::getProcessPtr
virtual Process * getProcessPtr()=0
Loader::SPARC64
@ SPARC64
Definition:
object_file.hh:46
SparcISA::EmuLinux::handleTrap
void handleTrap(ThreadContext *tc, int trapNum) override
Definition:
se_workload.cc:80
SparcISA::EmuLinux::syscall32
void syscall32(ThreadContext *tc)
Definition:
se_workload.cc:109
SparcISA
Definition:
asi.cc:31
Loader::ObjectFile
Definition:
object_file.hh:74
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition:
thread_context.hh:88
SparcISA::EmuLinux::syscall
void syscall(ThreadContext *tc) override
Definition:
se_workload.cc:131
SparcISA::SEWorkload
Definition:
se_workload.hh:42
SparcISA::EmuLinux::syscallDescs
static SyscallDescTable< SEWorkload::SyscallABI64 > syscallDescs
64 bit syscall descriptors, indexed by call number.
Definition:
se_workload.hh:44
Loader::UnknownOpSys
@ UnknownOpSys
Definition:
object_file.hh:62
SparcISA::EmuLinux::syscall32Descs
static SyscallDescTable< SEWorkload::SyscallABI32 > syscall32Descs
32 bit compatibility syscall descriptors, indexed by call number.
Definition:
se_workload.hh:47
SparcISA::SEWorkload::is64
bool is64(ThreadContext *tc)
Definition:
se_workload.cc:44
Sparc64Process
Definition:
process.hh:100
Loader::ObjectFile::getArch
Arch getArch() const
Definition:
object_file.hh:103
Process::Loader::load
virtual Process * load(const ProcessParams ¶ms, ::Loader::ObjectFile *obj_file)=0
Each subclass needs to implement this method.
Loader::ObjectFile::getOpSys
OpSys getOpSys() const
Definition:
object_file.hh:104
trace.hh
MipsISA::p
Bitfield< 0 > p
Definition:
pra_constants.hh:323
SparcISA::EmuLinux::syscall64
void syscall64(ThreadContext *tc)
Definition:
se_workload.cc:120
ThreadContext::readIntReg
virtual RegVal readIntReg(RegIndex reg_idx) const =0
se_workload.hh
SparcISA::EmuLinux::Params
SparcEmuLinuxParams Params
Definition:
se_workload.hh:53
object_file.hh
Sparc32Process
Definition:
process.hh:64
thread_context.hh
syscall_desc.hh
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition:
logging.hh:171
Generated on Tue Jun 22 2021 15:28:20 for gem5 by
doxygen
1.8.17