gem5 v24.0.0.0
Loading...
Searching...
No Matches
standard.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 RISC-V Foundation
3 * Copyright (c) 2017 The University of Virginia
4 * Copyright (c) 2020 Barkhausen Institut
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
9 * met: redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer;
11 * redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution;
14 * neither the name of the copyright holders nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
32
33#include <sstream>
34#include <string>
35
36#include "arch/riscv/faults.hh"
40#include "arch/riscv/utility.hh"
41#include "cpu/static_inst.hh"
42
43namespace gem5
44{
45
46namespace RiscvISA
47{
48
49std::string
51{
52 std::stringstream ss;
53 ss << mnemonic << ' ' << registerName(destRegIdx(0)) << ", " <<
55 if (_numSrcRegs >= 2)
56 ss << ", " << registerName(srcRegIdx(1));
57 if (_numSrcRegs >= 3)
58 ss << ", " << registerName(srcRegIdx(2));
59 return ss.str();
60}
61
62std::string
64{
65 std::stringstream ss;
66 ss << mnemonic << ' ' << registerName(destRegIdx(0)) << ", ";
67 auto data = CSRData.find(csr);
68 if (data != CSRData.end())
69 ss << data->second.name;
70 else
71 ss << "?? (" << std::hex << "0x" << csr << std::dec << ")";
72 if (_numSrcRegs > 0)
73 ss << ", " << registerName(srcRegIdx(0));
74 else
75 ss << uimm;
76 return ss.str();
77}
78
79std::string
81{
82 if (strcmp(mnemonic, "fence_vma") == 0) {
83 std::stringstream ss;
84 ss << mnemonic << ' ' << registerName(srcRegIdx(0)) << ", " <<
86 return ss.str();
87 }
88
89 return mnemonic;
90}
91
94{
95 // If semihosting is enabled, we may need to execute a semihosting
96 // operation instead of raising a breakpoint fault.
97 ThreadContext *tc = xc->tcBase();
98 if (auto *semihosting = dynamic_cast<RiscvSemihosting *>(
100 if (semihosting->isSemihostingEBreak(xc) && semihosting->call(tc)) {
101 return NoFault;
102 }
103 }
104 // No semihosting, raise a standard breakpoint exception.
105 return std::make_shared<BreakpointFault>(xc->pcState());
106}
107
108} // namespace RiscvISA
109} // namespace gem5
const char data[]
The ExecContext is an abstract base class the provides the interface used by the ISA to manipulate th...
virtual ThreadContext * tcBase() const =0
Returns a pointer to the ThreadContext.
virtual const PCStateBase & pcState() const =0
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition standard.cc:63
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition standard.cc:50
Fault executeEBreakOrSemihosting(ExecContext *xc) const
Definition standard.cc:93
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition standard.cc:80
Semihosting for RV32 and RV64.
uint8_t _numSrcRegs
See numSrcRegs().
const RegId & destRegIdx(int i) const
Return logical index (architectural reg num) of i'th destination reg.
const char * mnemonic
Base mnemonic (e.g., "add").
const RegId & srcRegIdx(int i) const
Return logical index (architectural reg num) of i'th source reg.
Workload * workload
OS kernel.
Definition system.hh:326
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual System * getSystemPtr()=0
virtual SimObject * getSemihosting() const
Returns the semihosting interface if supported by the current workload.
Definition workload.hh:107
std::string registerName(RegId reg)
Definition utility.hh:130
const std::unordered_map< int, CSRMetadata > CSRData
Definition misc.hh:536
Bitfield< 11, 8 > ss
Bitfield< 4 > pc
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
std::shared_ptr< FaultBase > Fault
Definition types.hh:249
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
constexpr decltype(nullptr) NoFault
Definition types.hh:253

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