gem5
v24.0.0.0
Loading...
Searching...
No Matches
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 "
arch/sparc/regs/int.hh
"
36
#include "
base/loader/object_file.hh
"
37
#include "
base/trace.hh
"
38
#include "
cpu/thread_context.hh
"
39
#include "
sim/syscall_desc.hh
"
40
41
namespace
gem5
42
{
43
44
namespace
45
{
46
47
class
LinuxLoader :
public
Process::Loader
48
{
49
public
:
50
Process *
51
load(
const
ProcessParams ¶ms, loader::ObjectFile *obj)
override
52
{
53
auto
arch = obj->getArch();
54
auto
opsys = obj->getOpSys();
55
56
if
(arch !=
loader::SPARC64
&& arch !=
loader::SPARC32
)
57
return
nullptr
;
58
59
if
(opsys ==
loader::UnknownOpSys
) {
60
warn
(
"Unknown operating system; assuming Linux."
);
61
opsys =
loader::Linux
;
62
}
63
64
if
(opsys !=
loader::Linux
)
65
return
nullptr
;
66
67
if
(arch ==
loader::SPARC64
)
68
return
new
Sparc64Process(params, obj);
69
else
70
return
new
Sparc32Process(params, obj);
71
}
72
};
73
74
LinuxLoader linuxLoader;
75
76
}
// anonymous namespace
77
78
namespace
SparcISA
79
{
80
81
EmuLinux::EmuLinux
(
const
Params
&
p
) :
SEWorkload
(
p
,
PageShift
)
82
{}
83
84
void
85
EmuLinux::handleTrap
(
ThreadContext
*tc,
int
trapNum)
86
{
87
if
(
is64
(tc)) {
88
switch
(trapNum) {
89
// case 0x10: // Linux 32 bit syscall trap
90
case
0x6d:
// Linux 64 bit syscall trap
91
syscall64
(tc);
92
return
;
93
case
0x6e:
// Linux 64 bit getcontext trap
94
warn
(
"The getcontext trap is not implemented on SPARC"
);
95
return
;
96
case
0x6f:
// Linux 64 bit setcontext trap
97
panic
(
"The setcontext trap is not implemented on SPARC"
);
98
default
:
99
break
;
100
}
101
}
else
{
102
switch
(trapNum) {
103
case
0x10:
//Linux 32 bit syscall trap
104
syscall32
(tc);
105
return
;
106
default
:
107
break
;
108
}
109
}
110
SEWorkload::handleTrap
(tc, trapNum);
111
}
112
113
void
114
EmuLinux::syscall32
(
ThreadContext
*tc)
115
{
116
Process
*process = tc->
getProcessPtr
();
117
// Call the syscall function in the base Process class to update stats.
118
// This will move into the base SEWorkload function at some point.
119
process->Process::syscall(tc);
120
121
syscall32Descs
.get(tc->
getReg
(
int_reg::G1
))->doSyscall(tc);
122
}
123
124
void
125
EmuLinux::syscall64
(
ThreadContext
*tc)
126
{
127
Process
*process = tc->
getProcessPtr
();
128
// Call the syscall function in the base Process class to update stats.
129
// This will move into the base SEWorkload function at some point.
130
process->Process::syscall(tc);
131
132
syscallDescs
.get(tc->
getReg
(
int_reg::G1
))->doSyscall(tc);
133
}
134
135
void
136
EmuLinux::syscall
(
ThreadContext
*tc)
137
{
138
if
(
is64
(tc))
139
syscall64
(tc);
140
else
141
syscall32
(tc);
142
}
143
144
}
// namespace SparcISA
145
}
// namespace gem5
se_workload.hh
process.hh
trace.hh
gem5::Process
Definition
process.hh:68
gem5::SparcISA::EmuLinux::EmuLinux
EmuLinux(const Params &p)
Definition
se_workload.cc:81
gem5::SparcISA::EmuLinux::Params
SparcEmuLinuxParams Params
Definition
se_workload.hh:56
gem5::SparcISA::EmuLinux::handleTrap
void handleTrap(ThreadContext *tc, int trapNum) override
Definition
se_workload.cc:85
gem5::SparcISA::EmuLinux::syscall32
void syscall32(ThreadContext *tc)
Definition
se_workload.cc:114
gem5::SparcISA::EmuLinux::syscall
void syscall(ThreadContext *tc) override
Definition
se_workload.cc:136
gem5::SparcISA::EmuLinux::syscallDescs
static SyscallDescTable< SEWorkload::SyscallABI64 > syscallDescs
64 bit syscall descriptors, indexed by call number.
Definition
se_workload.hh:47
gem5::SparcISA::EmuLinux::syscall64
void syscall64(ThreadContext *tc)
Definition
se_workload.cc:125
gem5::SparcISA::EmuLinux::syscall32Descs
static SyscallDescTable< SEWorkload::SyscallABI32 > syscall32Descs
32 bit compatibility syscall descriptors, indexed by call number.
Definition
se_workload.hh:50
gem5::SparcISA::SEWorkload
Definition
se_workload.hh:49
gem5::SparcISA::SEWorkload::handleTrap
virtual void handleTrap(ThreadContext *tc, int trapNum)
Definition
se_workload.cc:56
gem5::SparcISA::SEWorkload::is64
bool is64(ThreadContext *tc)
Definition
se_workload.cc:50
gem5::ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition
guest_abi.test.cc:41
gem5::ThreadContext::getReg
virtual RegVal getReg(const RegId ®) const
Definition
thread_context.cc:180
gem5::ThreadContext::getProcessPtr
virtual Process * getProcessPtr()=0
thread_context.hh
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition
logging.hh:188
warn
#define warn(...)
Definition
logging.hh:256
gem5::MipsISA::p
Bitfield< 0 > p
Definition
pra_constants.hh:326
gem5::SparcISA::int_reg::G1
constexpr RegId G1
Definition
int.hh:92
gem5::SparcISA::PageShift
const Addr PageShift
Definition
page_size.hh:40
gem5::loader::SPARC32
@ SPARC32
Definition
object_file.hh:65
gem5::loader::SPARC64
@ SPARC64
Definition
object_file.hh:64
gem5::loader::UnknownOpSys
@ UnknownOpSys
Definition
object_file.hh:82
gem5::loader::Linux
@ Linux
Definition
object_file.hh:84
gem5
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition
binary32.hh:36
object_file.hh
page_size.hh
int.hh
syscall_desc.hh
Generated on Tue Jun 18 2024 16:23:57 for gem5 by
doxygen
1.11.0