gem5  v20.1.0.0
process.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003-2005 The Regents of The University of Michigan
3  * All rights reserved.
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 
30 
31 #include "arch/sparc/isa_traits.hh"
32 #include "arch/sparc/registers.hh"
34 #include "base/trace.hh"
35 #include "cpu/thread_context.hh"
36 #include "kern/linux/linux.hh"
37 #include "sim/process.hh"
38 #include "sim/syscall_desc.hh"
39 #include "sim/syscall_emul.hh"
40 
41 using namespace std;
42 using namespace SparcISA;
43 
44 namespace
45 {
46 
47 class SparcLinuxObjectFileLoader : public Process::Loader
48 {
49  public:
50  Process *
51  load(ProcessParams *params, ::Loader::ObjectFile *obj_file) override
52  {
53  auto arch = obj_file->getArch();
54  auto opsys = obj_file->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 Sparc64LinuxProcess(params, obj_file);
69  else
70  return new Sparc32LinuxProcess(params, obj_file);
71  }
72 };
73 
74 SparcLinuxObjectFileLoader loader;
75 
76 } // anonymous namespace
77 
78 Sparc32LinuxProcess::Sparc32LinuxProcess(ProcessParams * params,
79  ::Loader::ObjectFile *objFile)
80  : Sparc32Process(params, objFile)
81 {}
82 
83 void
85 {
88 }
89 
90 void
92 {
93  switch (trapNum) {
94  case 0x10: //Linux 32 bit syscall trap
95  tc->syscall();
96  break;
97  default:
98  SparcProcess::handleTrap(trapNum, tc);
99  }
100 }
101 
103  ::Loader::ObjectFile *objFile)
104  : Sparc64Process(params, objFile)
105 {}
106 
107 void
109 {
111  syscallDescs.get(tc->readIntReg(1))->doSyscall(tc);
112 }
113 
114 void
116 {
117  warn("The getcontext trap is not implemented on SPARC");
118 }
119 
120 void
122 {
123  panic("The setcontext trap is not implemented on SPARC");
124 }
125 
126 void
128 {
129  switch (trapNum) {
130  // case 0x10: // Linux 32 bit syscall trap
131  case 0x6d: // Linux 64 bit syscall trap
132  tc->syscall();
133  break;
134  case 0x6e: // Linux 64 bit getcontext trap
135  getContext(tc);
136  break;
137  case 0x6f: // Linux 64 bit setcontext trap
138  setContext(tc);
139  break;
140  default:
141  SparcProcess::handleTrap(trapNum, tc);
142  }
143 }
SparcISA::Sparc64LinuxProcess::setContext
void setContext(ThreadContext *tc)
Definition: process.cc:121
Loader::Linux
@ Linux
Definition: object_file.hh:62
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:185
SparcISA::Sparc64LinuxProcess
A process with emulated 32 bit SPARC/Linux syscalls.
Definition: process.hh:65
Loader::SPARC32
@ SPARC32
Definition: object_file.hh:47
warn
#define warn(...)
Definition: logging.hh:239
linux.hh
SparcISA::Sparc32LinuxProcess
A process with emulated SPARC/Linux syscalls.
Definition: process.hh:53
Process
Definition: process.hh:65
process.hh
SparcISA::Sparc64LinuxProcess::getContext
void getContext(ThreadContext *tc)
Definition: process.cc:115
SparcISA::Sparc32LinuxProcess::handleTrap
void handleTrap(int trapNum, ThreadContext *tc) override
Definition: process.cc:91
Loader::SPARC64
@ SPARC64
Definition: object_file.hh:46
Process::syscall
virtual void syscall(ThreadContext *tc)
Definition: process.hh:78
SparcISA::Sparc64LinuxProcess::syscall
void syscall(ThreadContext *tc) override
Definition: process.cc:108
SparcISA
Definition: asi.cc:31
Loader::ObjectFile
Definition: object_file.hh:70
SparcISA::Sparc64LinuxProcess::handleTrap
void handleTrap(int trapNum, ThreadContext *tc) override
Definition: process.cc:127
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
isa_traits.hh
process.hh
Loader::UnknownOpSys
@ UnknownOpSys
Definition: object_file.hh:60
SparcISA::Sparc64LinuxProcess::Sparc64LinuxProcess
Sparc64LinuxProcess(ProcessParams *params, ::Loader::ObjectFile *objFile)
Constructor.
Definition: process.cc:102
Sparc64Process
Definition: process.hh:181
SyscallDesc::doSyscall
void doSyscall(ThreadContext *tc)
Interface for invoking the system call funcion pointer.
Definition: syscall_desc.cc:38
SparcISA::SparcLinuxProcess::syscall32Descs
static SyscallDescTable< Sparc32Process::SyscallABI > syscall32Descs
32 bit compatibility syscall descriptors, indexed by call number.
Definition: process.hh:49
ThreadContext::syscall
virtual void syscall()=0
syscall_emul.hh
Loader::ObjectFile::getArch
Arch getArch() const
Definition: object_file.hh:99
std
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:587
Loader::ObjectFile::getOpSys
OpSys getOpSys() const
Definition: object_file.hh:100
registers.hh
trace.hh
SparcISA::SparcLinuxProcess::syscallDescs
static SyscallDescTable< Sparc64Process::SyscallABI > syscallDescs
64 bit syscall descriptors, indexed by call number.
Definition: process.hh:46
SyscallDescTable::get
SyscallDesc * get(int num, bool fatal_if_missing=true)
Definition: syscall_desc.hh:195
SparcISA::Sparc32LinuxProcess::syscall
void syscall(ThreadContext *tc) override
Definition: process.cc:84
ThreadContext::readIntReg
virtual RegVal readIntReg(RegIndex reg_idx) const =0
object_file.hh
SparcProcess::handleTrap
virtual void handleTrap(int trapNum, ThreadContext *tc)
Definition: process.cc:69
Sparc32Process
Definition: process.hh:116
thread_context.hh
syscall_desc.hh
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:171

Generated on Wed Sep 30 2020 14:01:59 for gem5 by doxygen 1.8.17