gem5
v21.1.0.2
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
gem5
40
{
41
42
namespace
43
{
44
45
class
LinuxLoader :
public
Process::Loader
46
{
47
public
:
48
Process *
49
load(
const
ProcessParams ¶ms, loader::ObjectFile *obj)
override
50
{
51
auto
arch = obj->getArch();
52
auto
opsys = obj->getOpSys();
53
54
if
(arch !=
loader::SPARC64
&& arch !=
loader::SPARC32
)
55
return
nullptr
;
56
57
if
(opsys ==
loader::UnknownOpSys
) {
58
warn
(
"Unknown operating system; assuming Linux."
);
59
opsys =
loader::Linux
;
60
}
61
62
if
(opsys !=
loader::Linux
)
63
return
nullptr
;
64
65
if
(arch ==
loader::SPARC64
)
66
return
new
Sparc64Process(params, obj);
67
else
68
return
new
Sparc32Process(params, obj);
69
}
70
};
71
72
LinuxLoader linuxLoader;
73
74
}
// anonymous namespace
75
76
namespace
SparcISA
77
{
78
79
EmuLinux::EmuLinux
(
const
Params
&
p
) :
SEWorkload
(
p
)
80
{}
81
82
void
83
EmuLinux::handleTrap
(
ThreadContext
*tc,
int
trapNum)
84
{
85
if
(
is64
(tc)) {
86
switch
(trapNum) {
87
// case 0x10: // Linux 32 bit syscall trap
88
case
0x6d:
// Linux 64 bit syscall trap
89
syscall64
(tc);
90
return
;
91
case
0x6e:
// Linux 64 bit getcontext trap
92
warn
(
"The getcontext trap is not implemented on SPARC"
);
93
return
;
94
case
0x6f:
// Linux 64 bit setcontext trap
95
panic
(
"The setcontext trap is not implemented on SPARC"
);
96
default
:
97
break
;
98
}
99
}
else
{
100
switch
(trapNum) {
101
case
0x10:
//Linux 32 bit syscall trap
102
syscall32
(tc);
103
return
;
104
default
:
105
break
;
106
}
107
}
108
SEWorkload::handleTrap
(tc, trapNum);
109
}
110
111
void
112
EmuLinux::syscall32
(
ThreadContext
*tc)
113
{
114
Process
*process = tc->
getProcessPtr
();
115
// Call the syscall function in the base Process class to update stats.
116
// This will move into the base SEWorkload function at some point.
117
process->Process::syscall(tc);
118
119
syscall32Descs
.get(tc->
readIntReg
(1))->doSyscall(tc);
120
}
121
122
void
123
EmuLinux::syscall64
(
ThreadContext
*tc)
124
{
125
Process
*process = tc->
getProcessPtr
();
126
// Call the syscall function in the base Process class to update stats.
127
// This will move into the base SEWorkload function at some point.
128
process->Process::syscall(tc);
129
130
syscallDescs
.get(tc->
readIntReg
(1))->doSyscall(tc);
131
}
132
133
void
134
EmuLinux::syscall
(
ThreadContext
*tc)
135
{
136
if
(
is64
(tc))
137
syscall64
(tc);
138
else
139
syscall32
(tc);
140
}
141
142
}
// namespace SparcISA
143
}
// namespace gem5
gem5::SparcISA::EmuLinux::syscall
void syscall(ThreadContext *tc) override
Definition:
se_workload.cc:134
gem5::SparcISA::EmuLinux::syscall64
void syscall64(ThreadContext *tc)
Definition:
se_workload.cc:123
gem5::SparcISA::EmuLinux::handleTrap
void handleTrap(ThreadContext *tc, int trapNum) override
Definition:
se_workload.cc:83
warn
#define warn(...)
Definition:
logging.hh:245
process.hh
gem5::SparcISA::EmuLinux::syscall32
void syscall32(ThreadContext *tc)
Definition:
se_workload.cc:112
gem5::loader::SPARC64
@ SPARC64
Definition:
object_file.hh:53
gem5::SparcISA::EmuLinux::syscall32Descs
static SyscallDescTable< SEWorkload::SyscallABI32 > syscall32Descs
32 bit compatibility syscall descriptors, indexed by call number.
Definition:
se_workload.hh:50
gem5::loader::UnknownOpSys
@ UnknownOpSys
Definition:
object_file.hh:71
gem5::ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition:
thread_context.hh:93
gem5::MipsISA::p
Bitfield< 0 > p
Definition:
pra_constants.hh:326
gem5::SparcISA::SEWorkload
Definition:
se_workload.hh:47
gem5::SparcISA::EmuLinux::EmuLinux
EmuLinux(const Params &p)
Definition:
se_workload.cc:79
gem5::ThreadContext::readIntReg
virtual RegVal readIntReg(RegIndex reg_idx) const =0
gem5::ArmISA::SEWorkload::Params
ArmSEWorkloadParams Params
Definition:
se_workload.hh:45
gem5::Process
Definition:
process.hh:67
gem5::ThreadContext::getProcessPtr
virtual Process * getProcessPtr()=0
gem5::loader::SPARC32
@ SPARC32
Definition:
object_file.hh:54
trace.hh
gem5::SparcISA::SEWorkload::handleTrap
virtual void handleTrap(ThreadContext *tc, int trapNum)
Definition:
se_workload.cc:54
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition:
decoder.cc:40
se_workload.hh
gem5::SparcISA::SEWorkload::is64
bool is64(ThreadContext *tc)
Definition:
se_workload.cc:48
object_file.hh
thread_context.hh
gem5::loader::Linux
@ Linux
Definition:
object_file.hh:73
syscall_desc.hh
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition:
logging.hh:177
gem5::SparcISA::EmuLinux::syscallDescs
static SyscallDescTable< SEWorkload::SyscallABI64 > syscallDescs
64 bit syscall descriptors, indexed by call number.
Definition:
se_workload.hh:47
Generated on Tue Sep 21 2021 12:24:34 for gem5 by
doxygen
1.8.17