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