gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
74{
77 GuestAddr(Addr _addr) : addr(_addr) {}
78};
79
80inline std::ostream&
81operator<<(std::ostream& os, const GuestAddr addr)
82{
83 return os << addr.addr;
84}
85
86void arm(ThreadContext *tc);
87void quiesce(ThreadContext *tc);
89void quiesceNs(ThreadContext *tc, uint64_t ns);
90void quiesceCycles(ThreadContext *tc, uint64_t cycles);
91uint64_t quiesceTime(ThreadContext *tc);
92uint64_t readfile(ThreadContext *tc, GuestAddr vaddr, uint64_t len,
93 uint64_t offset);
94uint64_t writefile(ThreadContext *tc, GuestAddr vaddr, uint64_t len,
95 uint64_t offset, GuestAddr filenameAddr);
97void addsymbol(ThreadContext *tc, GuestAddr addr, GuestAddr symbolAddr);
98uint64_t initParam(ThreadContext *xc, uint64_t key_str1, uint64_t key_str2);
99uint64_t rpns(ThreadContext *tc);
100void wakeCPU(ThreadContext *tc, uint64_t cpuid);
101void m5exit(ThreadContext *tc, Tick delay);
102void m5fail(ThreadContext *tc, Tick delay, uint64_t code);
103uint64_t m5sum(ThreadContext *tc, uint64_t a, uint64_t b, uint64_t c,
104 uint64_t d, uint64_t e, uint64_t f);
105void resetstats(ThreadContext *tc, Tick delay, Tick period);
106void dumpstats(ThreadContext *tc, Tick delay, Tick period);
107void dumpresetstats(ThreadContext *tc, Tick delay, Tick period);
108void m5checkpoint(ThreadContext *tc, Tick delay, Tick period);
109void debugbreak(ThreadContext *tc);
110void switchcpu(ThreadContext *tc);
111void workbegin(ThreadContext *tc, uint64_t workid, uint64_t threadid);
112void workend(ThreadContext *tc, uint64_t workid, uint64_t threadid);
114void togglesync(ThreadContext *tc);
116
117
131template <typename ABI, bool store_ret>
132bool
133pseudoInstWork(ThreadContext *tc, uint8_t func, uint64_t &result)
134{
135 DPRINTF(PseudoInst, "pseudo_inst::pseudoInst(%i)\n", func);
136
137 result = 0;
138
139 switch (func) {
140 case M5OP_ARM:
142 return true;
143
144 case M5OP_QUIESCE:
146 return true;
147
148 case M5OP_QUIESCE_NS:
150 return true;
151
152 case M5OP_QUIESCE_CYCLE:
154 return true;
155
156 case M5OP_QUIESCE_TIME:
158 return true;
159
160 case M5OP_RPNS:
162 return true;
163
164 case M5OP_WAKE_CPU:
166 return true;
167
168 case M5OP_EXIT:
170 return true;
171
172 case M5OP_FAIL:
174 return true;
175
176 // M5OP_SUM is for sanity checking the gem5 op interface.
177 case M5OP_SUM:
179 return true;
180
181 case M5OP_INIT_PARAM:
183 return true;
184
185 case M5OP_LOAD_SYMBOL:
187 return true;
188
189 case M5OP_RESET_STATS:
191 return true;
192
193 case M5OP_DUMP_STATS:
195 return true;
196
197 case M5OP_DUMP_RESET_STATS:
199 return true;
200
201 case M5OP_CHECKPOINT:
203 return true;
204
205 case M5OP_WRITE_FILE:
207 return true;
208
209 case M5OP_READ_FILE:
211 return true;
212
213 case M5OP_DEBUG_BREAK:
215 return true;
216
217 case M5OP_SWITCH_CPU:
219 return true;
220
221 case M5OP_ADD_SYMBOL:
223 return true;
224
225 case M5OP_PANIC:
226 panic("M5 panic instruction called at %s\n", tc->pcState());
227
228 case M5OP_WORK_BEGIN:
230 return true;
231
232 case M5OP_WORK_END:
234 return true;
235
236 case M5OP_RESERVED1:
237 case M5OP_RESERVED2:
238 case M5OP_RESERVED3:
239 case M5OP_RESERVED4:
240 case M5OP_RESERVED5:
241 warn("Unimplemented m5 op (%#x)\n", func);
242 return false;
243
244 /* dist-gem5 functions */
245 case M5OP_DIST_TOGGLE_SYNC:
247 return true;
248
249 case M5OP_WORKLOAD:
251 return true;
252
253 default:
254 warn("Unhandled m5 op: %#x\n", func);
255 return false;
256 }
257}
258
259template <typename ABI, bool store_ret=false>
260bool
261pseudoInst(ThreadContext *tc, uint8_t func, uint64_t &result)
262{
263 return pseudoInstWork<ABI, store_ret>(tc, func, result);
264}
265
266template <typename ABI, bool store_ret=true>
267bool
268pseudoInst(ThreadContext *tc, uint8_t func)
269{
270 uint64_t result;
271 return pseudoInstWork<ABI, store_ret>(tc, func, result);
272}
273
274} // namespace pseudo_inst
275} // namespace gem5
276
277#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:79
#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< 17 > os
Definition misc.hh:838
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 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)
std::ostream & operator<<(std::ostream &os, const GuestAddr addr)
uint64_t writefile(ThreadContext *tc, GuestAddr vaddr, uint64_t len, uint64_t offset, GuestAddr filename_addr)
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)
void addsymbol(ThreadContext *tc, GuestAddr addr, GuestAddr symbolAddr)
uint64_t quiesceTime(ThreadContext *tc)
void wakeCPU(ThreadContext *tc, uint64_t cpuid)
uint64_t readfile(ThreadContext *tc, GuestAddr vaddr, uint64_t len, uint64_t offset)
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)
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
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
Ret invokeSimcall(ThreadContext *tc, std::function< Ret(ThreadContext *, Args...)> target)
Definition guest_abi.hh:50
This struct wrapper for Addr enables m5ops for systems with 32 bit pointer, since it allows to distin...
GuestAddr(Addr _addr)
Constructor is necessary to cast from uint64_t to GuestAddr.

Generated on Tue Jun 18 2024 16:24:06 for gem5 by doxygen 1.11.0