gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
pseudo_inst.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Copyright (c) 2003-2006 The Regents of The University of Michigan
15  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions are
19  * met: redistributions of source code must retain the above copyright
20  * notice, this list of conditions and the following disclaimer;
21  * redistributions in binary form must reproduce the above copyright
22  * notice, this list of conditions and the following disclaimer in the
23  * documentation and/or other materials provided with the distribution;
24  * neither the name of the copyright holders nor the names of its
25  * contributors may be used to endorse or promote products derived from
26  * this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  *
40  * Authors: Nathan Binkert
41  */
42 
43 #ifndef __SIM_PSEUDO_INST_HH__
44 #define __SIM_PSEUDO_INST_HH__
45 
46 #include <gem5/asm/generic/m5ops.h>
47 
48 class ThreadContext;
49 
50 #include "arch/pseudo_inst.hh"
51 #include "arch/utility.hh"
52 #include "base/types.hh" // For Tick and Addr data types.
53 #include "debug/PseudoInst.hh"
54 #include "sim/guest_abi.hh"
55 
57 {
58  using Position = int;
59 };
60 
61 namespace GuestABI
62 {
63 
64 template <typename T>
66 {
67  static void
68  store(ThreadContext *tc, const T &ret)
69  {
70  // Don't do anything with the pseudo inst results by default.
71  }
72 };
73 
74 template <>
75 struct Argument<PseudoInstABI, uint64_t>
76 {
77  static uint64_t
79  {
80  uint64_t result = TheISA::getArgument(tc, position, sizeof(uint64_t),
81  false);
82  position++;
83  return result;
84  }
85 };
86 
87 } // namespace GuestABI
88 
89 namespace PseudoInst
90 {
91 
92 static inline void
93 decodeAddrOffset(Addr offset, uint8_t &func)
94 {
95  func = bits(offset, 15, 8);
96 }
97 
98 void arm(ThreadContext *tc);
99 void quiesce(ThreadContext *tc);
100 void quiesceSkip(ThreadContext *tc);
101 void quiesceNs(ThreadContext *tc, uint64_t ns);
102 void quiesceCycles(ThreadContext *tc, uint64_t cycles);
103 uint64_t quiesceTime(ThreadContext *tc);
104 uint64_t readfile(ThreadContext *tc, Addr vaddr, uint64_t len,
105  uint64_t offset);
106 uint64_t writefile(ThreadContext *tc, Addr vaddr, uint64_t len,
107  uint64_t offset, Addr filenameAddr);
108 void loadsymbol(ThreadContext *xc);
109 void addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr);
110 uint64_t initParam(ThreadContext *xc, uint64_t key_str1, uint64_t key_str2);
111 uint64_t rpns(ThreadContext *tc);
112 void wakeCPU(ThreadContext *tc, uint64_t cpuid);
113 void m5exit(ThreadContext *tc, Tick delay);
114 void m5fail(ThreadContext *tc, Tick delay, uint64_t code);
115 void resetstats(ThreadContext *tc, Tick delay, Tick period);
116 void dumpstats(ThreadContext *tc, Tick delay, Tick period);
117 void dumpresetstats(ThreadContext *tc, Tick delay, Tick period);
118 void m5checkpoint(ThreadContext *tc, Tick delay, Tick period);
119 void debugbreak(ThreadContext *tc);
120 void switchcpu(ThreadContext *tc);
121 void workbegin(ThreadContext *tc, uint64_t workid, uint64_t threadid);
122 void workend(ThreadContext *tc, uint64_t workid, uint64_t threadid);
123 void m5Syscall(ThreadContext *tc);
124 void togglesync(ThreadContext *tc);
125 
137 template <typename ABI>
138 uint64_t
139 pseudoInst(ThreadContext *tc, uint8_t func)
140 {
141  DPRINTF(PseudoInst, "PseudoInst::pseudoInst(%i)\n", func);
142 
143  switch (func) {
144  case M5OP_ARM:
145  invokeSimcall<ABI>(tc, arm);
146  break;
147 
148  case M5OP_QUIESCE:
149  invokeSimcall<ABI>(tc, quiesce);
150  break;
151 
152  case M5OP_QUIESCE_NS:
153  invokeSimcall<ABI>(tc, quiesceNs);
154  break;
155 
156  case M5OP_QUIESCE_CYCLE:
157  invokeSimcall<ABI>(tc, quiesceCycles);
158  break;
159 
160  case M5OP_QUIESCE_TIME:
161  return invokeSimcall<ABI>(tc, quiesceTime);
162 
163  case M5OP_RPNS:
164  return invokeSimcall<ABI>(tc, rpns);
165 
166  case M5OP_WAKE_CPU:
167  invokeSimcall<ABI>(tc, wakeCPU);
168  break;
169 
170  case M5OP_EXIT:
171  invokeSimcall<ABI>(tc, m5exit);
172  break;
173 
174  case M5OP_FAIL:
175  invokeSimcall<ABI>(tc, m5fail);
176  break;
177 
178  case M5OP_INIT_PARAM:
179  return invokeSimcall<ABI>(tc, initParam);
180 
181  case M5OP_LOAD_SYMBOL:
182  invokeSimcall<ABI>(tc, loadsymbol);
183  break;
184 
185  case M5OP_RESET_STATS:
186  invokeSimcall<ABI>(tc, resetstats);
187  break;
188 
189  case M5OP_DUMP_STATS:
190  invokeSimcall<ABI>(tc, dumpstats);
191  break;
192 
193  case M5OP_DUMP_RESET_STATS:
194  invokeSimcall<ABI>(tc, dumpresetstats);
195  break;
196 
197  case M5OP_CHECKPOINT:
198  invokeSimcall<ABI>(tc, m5checkpoint);
199  break;
200 
201  case M5OP_WRITE_FILE:
202  return invokeSimcall<ABI>(tc, writefile);
203 
204  case M5OP_READ_FILE:
205  return invokeSimcall<ABI>(tc, readfile);
206 
207  case M5OP_DEBUG_BREAK:
208  invokeSimcall<ABI>(tc, debugbreak);
209  break;
210 
211  case M5OP_SWITCH_CPU:
212  invokeSimcall<ABI>(tc, switchcpu);
213  break;
214 
215  case M5OP_ADD_SYMBOL:
216  invokeSimcall<ABI>(tc, addsymbol);
217  break;
218 
219  case M5OP_PANIC:
220  panic("M5 panic instruction called at %s\n", tc->pcState());
221 
222  case M5OP_WORK_BEGIN:
223  invokeSimcall<ABI>(tc, workbegin);
224  break;
225 
226  case M5OP_WORK_END:
227  invokeSimcall<ABI>(tc, workend);
228  break;
229 
230  case M5OP_ANNOTATE:
231  case M5OP_RESERVED2:
232  case M5OP_RESERVED3:
233  case M5OP_RESERVED4:
234  case M5OP_RESERVED5:
235  warn("Unimplemented m5 op (%#x)\n", func);
236  break;
237 
238  /* SE mode functions */
239  case M5OP_SE_SYSCALL:
240  invokeSimcall<ABI>(tc, m5Syscall);
241  break;
242 
243  case M5OP_SE_PAGE_FAULT:
244  invokeSimcall<ABI>(tc, TheISA::m5PageFault);
245  break;
246 
247  /* dist-gem5 functions */
248  case M5OP_DIST_TOGGLE_SYNC:
249  invokeSimcall<ABI>(tc, togglesync);
250  break;
251 
252  default:
253  warn("Unhandled m5 op: %#x\n", func);
254  break;
255  }
256 
257  return 0;
258 }
259 
260 } // namespace PseudoInst
261 
262 #endif // __SIM_PSEUDO_INST_HH__
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:167
void m5fail(ThreadContext *tc, Tick delay, uint64_t code)
Definition: pseudo_inst.cc:173
#define DPRINTF(x,...)
Definition: trace.hh:229
void m5PageFault(ThreadContext *tc)
Definition: pseudo_inst.cc:40
void quiesceNs(ThreadContext *tc, uint64_t ns)
Definition: pseudo_inst.cc:116
void arm(ThreadContext *tc)
Definition: pseudo_inst.cc:91
static void decodeAddrOffset(Addr offset, uint8_t &func)
Definition: pseudo_inst.hh:93
ip6_addr_t addr
Definition: inet.hh:335
void dumpresetstats(ThreadContext *tc, Tick delay, Tick period)
Definition: pseudo_inst.cc:323
uint64_t quiesceTime(ThreadContext *tc)
Definition: pseudo_inst.cc:130
void quiesceSkip(ThreadContext *tc)
Definition: pseudo_inst.cc:109
void m5checkpoint(ThreadContext *tc, Tick delay, Tick period)
Definition: pseudo_inst.cc:337
uint64_t getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp)
Definition: utility.cc:41
uint64_t writefile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset, Addr filename_addr)
Definition: pseudo_inst.cc:393
Bitfield< 23, 0 > offset
Definition: types.hh:154
Bitfield< 28, 21 > cpuid
Definition: dt_constants.hh:94
void quiesceCycles(ThreadContext *tc, uint64_t cycles)
Definition: pseudo_inst.cc:123
ThreadContext is the external interface to all thread state for anything outside of the CPU...
void togglesync(ThreadContext *tc)
Definition: pseudo_inst.cc:462
uint64_t initParam(ThreadContext *tc, uint64_t key_str1, uint64_t key_str2)
Definition: pseudo_inst.cc:250
Bitfield< 0 > ns
void quiesce(ThreadContext *tc)
Definition: pseudo_inst.cc:102
uint64_t Tick
Tick count type.
Definition: types.hh:63
void switchcpu(ThreadContext *tc)
Definition: pseudo_inst.cc:443
static void store(ThreadContext *tc, const T &ret)
Definition: pseudo_inst.hh:68
Bitfield< 18, 16 > len
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
uint64_t pseudoInst(ThreadContext *tc, uint8_t func)
Execute a decoded M5 pseudo instruction.
Definition: pseudo_inst.hh:139
void debugbreak(ThreadContext *tc)
Definition: pseudo_inst.cc:436
void workbegin(ThreadContext *tc, uint64_t workid, uint64_t threadid)
Definition: pseudo_inst.cc:474
void resetstats(ThreadContext *tc, Tick delay, Tick period)
Definition: pseudo_inst.cc:295
uint64_t readfile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset)
Definition: pseudo_inst.cc:351
void wakeCPU(ThreadContext *tc, uint64_t cpuid)
Definition: pseudo_inst.cc:146
void dumpstats(ThreadContext *tc, Tick delay, Tick period)
Definition: pseudo_inst.cc:309
#define warn(...)
Definition: logging.hh:212
void m5exit(ThreadContext *tc, Tick delay)
Definition: pseudo_inst.cc:163
T bits(T val, int first, int last)
Extract the bitfield from position &#39;first&#39; to &#39;last&#39; (inclusive) from &#39;val&#39; and right justify it...
Definition: bitfield.hh:72
void addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr)
Definition: pseudo_inst.cc:233
void loadsymbol(ThreadContext *tc)
Definition: pseudo_inst.cc:181
void workend(ThreadContext *tc, uint64_t workid, uint64_t threadid)
Definition: pseudo_inst.cc:537
void m5Syscall(ThreadContext *tc)
Definition: pseudo_inst.cc:454
uint64_t rpns(ThreadContext *tc)
Definition: pseudo_inst.cc:139

Generated on Fri Feb 28 2020 16:26:56 for gem5 by doxygen 1.8.13