gem5  v22.1.0.0
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 
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"
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 &params, 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 
82 {}
83 
84 void
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
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
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
137 {
138  if (is64(tc))
139  syscall64(tc);
140  else
141  syscall32(tc);
142 }
143 
144 } // namespace SparcISA
145 } // namespace gem5
EmuLinux(const Params &p)
Definition: se_workload.cc:81
SparcEmuLinuxParams Params
Definition: se_workload.hh:56
void handleTrap(ThreadContext *tc, int trapNum) override
Definition: se_workload.cc:85
void syscall32(ThreadContext *tc)
Definition: se_workload.cc:114
void syscall(ThreadContext *tc) override
Definition: se_workload.cc:136
static SyscallDescTable< SEWorkload::SyscallABI64 > syscallDescs
64 bit syscall descriptors, indexed by call number.
Definition: se_workload.hh:47
void syscall64(ThreadContext *tc)
Definition: se_workload.cc:125
static SyscallDescTable< SEWorkload::SyscallABI32 > syscall32Descs
32 bit compatibility syscall descriptors, indexed by call number.
Definition: se_workload.hh:50
virtual void handleTrap(ThreadContext *tc, int trapNum)
Definition: se_workload.cc:56
bool is64(ThreadContext *tc)
Definition: se_workload.cc:50
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual RegVal getReg(const RegId &reg) const
virtual Process * getProcessPtr()=0
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:178
#define warn(...)
Definition: logging.hh:246
constexpr RegId G1
Definition: int.hh:92
const Addr PageShift
Definition: page_size.hh:40
Bitfield< 54 > p
Definition: pagetable.hh:70
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....

Generated on Wed Dec 21 2022 10:22:25 for gem5 by doxygen 1.9.1