gem5 v23.0.0.1
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
41#ifndef __SIM_PSEUDO_INST_HH__
42#define __SIM_PSEUDO_INST_HH__
43
44#include <gem5/asm/generic/m5ops.h>
45
46#include "base/bitfield.hh"
47#include "base/compiler.hh"
48#include "base/logging.hh"
49#include "base/trace.hh"
50#include "base/types.hh" // For Tick and Addr data types.
51#include "cpu/thread_context.hh"
52#include "debug/PseudoInst.hh"
53#include "sim/guest_abi.hh"
54
55namespace gem5
56{
57
58namespace pseudo_inst
59{
60
61static inline void
63{
64 func = bits(offset, 15, 8);
65}
66
67void arm(ThreadContext *tc);
68void quiesce(ThreadContext *tc);
70void quiesceNs(ThreadContext *tc, uint64_t ns);
71void quiesceCycles(ThreadContext *tc, uint64_t cycles);
72uint64_t quiesceTime(ThreadContext *tc);
73uint64_t readfile(ThreadContext *tc, Addr vaddr, uint64_t len,
74 uint64_t offset);
75uint64_t writefile(ThreadContext *tc, Addr vaddr, uint64_t len,
76 uint64_t offset, Addr filenameAddr);
78void addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr);
79uint64_t initParam(ThreadContext *xc, uint64_t key_str1, uint64_t key_str2);
80uint64_t rpns(ThreadContext *tc);
81void wakeCPU(ThreadContext *tc, uint64_t cpuid);
82void m5exit(ThreadContext *tc, Tick delay);
83void m5fail(ThreadContext *tc, Tick delay, uint64_t code);
84uint64_t m5sum(ThreadContext *tc, uint64_t a, uint64_t b, uint64_t c,
85 uint64_t d, uint64_t e, uint64_t f);
86void resetstats(ThreadContext *tc, Tick delay, Tick period);
87void dumpstats(ThreadContext *tc, Tick delay, Tick period);
88void dumpresetstats(ThreadContext *tc, Tick delay, Tick period);
89void m5checkpoint(ThreadContext *tc, Tick delay, Tick period);
91void switchcpu(ThreadContext *tc);
92void workbegin(ThreadContext *tc, uint64_t workid, uint64_t threadid);
93void workend(ThreadContext *tc, uint64_t workid, uint64_t threadid);
97
111template <typename ABI, bool store_ret>
112bool
113pseudoInstWork(ThreadContext *tc, uint8_t func, uint64_t &result)
114{
115 DPRINTF(PseudoInst, "pseudo_inst::pseudoInst(%i)\n", func);
116
117 result = 0;
118
119 switch (func) {
120 case M5OP_ARM:
121 invokeSimcall<ABI>(tc, arm);
122 return true;
123
124 case M5OP_QUIESCE:
125 invokeSimcall<ABI>(tc, quiesce);
126 return true;
127
128 case M5OP_QUIESCE_NS:
129 invokeSimcall<ABI>(tc, quiesceNs);
130 return true;
131
132 case M5OP_QUIESCE_CYCLE:
133 invokeSimcall<ABI>(tc, quiesceCycles);
134 return true;
135
136 case M5OP_QUIESCE_TIME:
137 result = invokeSimcall<ABI, store_ret>(tc, quiesceTime);
138 return true;
139
140 case M5OP_RPNS:
141 result = invokeSimcall<ABI, store_ret>(tc, rpns);
142 return true;
143
144 case M5OP_WAKE_CPU:
145 invokeSimcall<ABI>(tc, wakeCPU);
146 return true;
147
148 case M5OP_EXIT:
149 invokeSimcall<ABI>(tc, m5exit);
150 return true;
151
152 case M5OP_FAIL:
153 invokeSimcall<ABI>(tc, m5fail);
154 return true;
155
156 // M5OP_SUM is for sanity checking the gem5 op interface.
157 case M5OP_SUM:
158 result = invokeSimcall<ABI, store_ret>(tc, m5sum);
159 return true;
160
161 case M5OP_INIT_PARAM:
162 result = invokeSimcall<ABI, store_ret>(tc, initParam);
163 return true;
164
165 case M5OP_LOAD_SYMBOL:
166 invokeSimcall<ABI>(tc, loadsymbol);
167 return true;
168
169 case M5OP_RESET_STATS:
170 invokeSimcall<ABI>(tc, resetstats);
171 return true;
172
173 case M5OP_DUMP_STATS:
174 invokeSimcall<ABI>(tc, dumpstats);
175 return true;
176
177 case M5OP_DUMP_RESET_STATS:
178 invokeSimcall<ABI>(tc, dumpresetstats);
179 return true;
180
181 case M5OP_CHECKPOINT:
182 invokeSimcall<ABI>(tc, m5checkpoint);
183 return true;
184
185 case M5OP_WRITE_FILE:
186 result = invokeSimcall<ABI, store_ret>(tc, writefile);
187 return true;
188
189 case M5OP_READ_FILE:
190 result = invokeSimcall<ABI, store_ret>(tc, readfile);
191 return true;
192
193 case M5OP_DEBUG_BREAK:
194 invokeSimcall<ABI>(tc, debugbreak);
195 return true;
196
197 case M5OP_SWITCH_CPU:
198 invokeSimcall<ABI>(tc, switchcpu);
199 return true;
200
201 case M5OP_ADD_SYMBOL:
202 invokeSimcall<ABI>(tc, addsymbol);
203 return true;
204
205 case M5OP_PANIC:
206 panic("M5 panic instruction called at %s\n", tc->pcState());
207
208 case M5OP_WORK_BEGIN:
209 invokeSimcall<ABI>(tc, workbegin);
210 return true;
211
212 case M5OP_WORK_END:
213 invokeSimcall<ABI>(tc, workend);
214 return true;
215
216 case M5OP_RESERVED1:
217 case M5OP_RESERVED2:
218 case M5OP_RESERVED3:
219 case M5OP_RESERVED4:
220 case M5OP_RESERVED5:
221 warn("Unimplemented m5 op (%#x)\n", func);
222 return false;
223
224 /* dist-gem5 functions */
225 case M5OP_DIST_TOGGLE_SYNC:
226 invokeSimcall<ABI>(tc, togglesync);
227 return true;
228
229 case M5OP_WORKLOAD:
230 invokeSimcall<ABI>(tc, triggerWorkloadEvent);
231 return true;
232
233 default:
234 warn("Unhandled m5 op: %#x\n", func);
235 return false;
236 }
237}
238
239template <typename ABI, bool store_ret=false>
240bool
241pseudoInst(ThreadContext *tc, uint8_t func, uint64_t &result)
242{
243 return pseudoInstWork<ABI, store_ret>(tc, func, result);
244}
245
246template <typename ABI, bool store_ret=true>
247bool
248pseudoInst(ThreadContext *tc, uint8_t func)
249{
250 uint64_t result;
251 return pseudoInstWork<ABI, store_ret>(tc, func, result);
252}
253
254} // namespace pseudo_inst
255} // namespace gem5
256
257#endif // __SIM_PSEUDO_INST_HH__
#define DPRINTF(x,...)
Definition trace.hh:210
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual const PCStateBase & pcState() const =0
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition bitfield.hh:76
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:188
#define warn(...)
Definition logging.hh:256
Bitfield< 18, 16 > len
Bitfield< 7 > b
Bitfield< 23, 0 > offset
Definition types.hh:144
Bitfield< 9 > e
Definition misc_types.hh:65
Bitfield< 0 > ns
Bitfield< 29 > c
Definition misc_types.hh:53
Bitfield< 8 > a
Definition misc_types.hh:66
Bitfield< 6 > f
Definition misc_types.hh:68
Bitfield< 9 > d
Definition misc_types.hh:64
Bitfield< 28, 21 > cpuid
Bitfield< 3 > addr
Definition types.hh:84
static void decodeAddrOffset(Addr offset, uint8_t &func)
uint64_t m5sum(ThreadContext *tc, uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f)
uint64_t rpns(ThreadContext *tc)
void loadsymbol(ThreadContext *tc)
void quiesceCycles(ThreadContext *tc, uint64_t cycles)
void m5Syscall(ThreadContext *tc)
void arm(ThreadContext *tc)
void debugbreak(ThreadContext *tc)
void m5fail(ThreadContext *tc, Tick delay, uint64_t code)
void quiesce(ThreadContext *tc)
void addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr)
uint64_t writefile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset, Addr filename_addr)
uint64_t readfile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset)
void quiesceNs(ThreadContext *tc, uint64_t ns)
void m5exit(ThreadContext *tc, Tick delay)
bool pseudoInst(ThreadContext *tc, uint8_t func, uint64_t &result)
void quiesceSkip(ThreadContext *tc)
void togglesync(ThreadContext *tc)
void resetstats(ThreadContext *tc, Tick delay, Tick period)
void workend(ThreadContext *tc, uint64_t workid, uint64_t threadid)
uint64_t initParam(ThreadContext *tc, uint64_t key_str1, uint64_t key_str2)
bool pseudoInstWork(ThreadContext *tc, uint8_t func, uint64_t &result)
Execute a decoded M5 pseudo instruction.
void triggerWorkloadEvent(ThreadContext *tc)
uint64_t quiesceTime(ThreadContext *tc)
void wakeCPU(ThreadContext *tc, uint64_t cpuid)
void m5checkpoint(ThreadContext *tc, Tick delay, Tick period)
void workbegin(ThreadContext *tc, uint64_t workid, uint64_t threadid)
void switchcpu(ThreadContext *tc)
void dumpstats(ThreadContext *tc, Tick delay, Tick period)
void dumpresetstats(ThreadContext *tc, Tick delay, Tick period)
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
uint64_t Tick
Tick count type.
Definition types.hh:58

Generated on Mon Jul 10 2023 15:32:05 for gem5 by doxygen 1.9.7