48 #ifndef __ARCH_RISCV_LOCKED_MEM_HH__ 49 #define __ARCH_RISCV_LOCKED_MEM_HH__ 52 #include <unordered_map> 54 #include "arch/registers.hh" 57 #include "debug/LLSC.hh" 71 extern std::unordered_map<int, std::stack<Addr>>
locked_addrs;
73 template <
class XC>
inline void 76 std::stack<Addr>& locked_addr_stack = locked_addrs[xc->contextId()];
78 if (locked_addr_stack.empty())
81 DPRINTF(LLSC,
"Locked snoop on address %x.\n", snoop_addr);
82 if ((locked_addr_stack.top() & cacheBlockMask) == snoop_addr)
83 locked_addr_stack.pop();
87 template <
class XC>
inline void 90 std::stack<Addr>& locked_addr_stack = locked_addrs[xc->contextId()];
92 locked_addr_stack.push(req->getPaddr() & ~0xF);
93 DPRINTF(LLSC,
"[cid:%d]: Reserved address %x.\n",
94 req->contextId(), req->getPaddr() & ~0xF);
97 template <
class XC>
inline void 101 template <
class XC>
inline bool 104 std::stack<Addr>& locked_addr_stack = locked_addrs[xc->contextId()];
111 DPRINTF(LLSC,
"[cid:%d]: locked_addrs empty? %s.\n", req->contextId(),
112 locked_addr_stack.empty() ?
"yes" :
"no");
113 if (!locked_addr_stack.empty()) {
114 DPRINTF(LLSC,
"[cid:%d]: addr = %x.\n", req->contextId(),
115 req->getPaddr() & ~0xF);
116 DPRINTF(LLSC,
"[cid:%d]: last locked addr = %x.\n", req->contextId(),
117 locked_addr_stack.top());
119 if (locked_addr_stack.empty()
120 || locked_addr_stack.top() != ((req->getPaddr() & ~0xF))) {
121 req->setExtraData(0);
122 int stCondFailures = xc->readStCondFailures();
123 xc->setStCondFailures(++stCondFailures);
124 if (stCondFailures % WARN_FAILURE == 0) {
125 warn(
"%i: context %d: %d consecutive SC failures.\n",
126 curTick(), xc->contextId(), stCondFailures);
130 if (req->isUncacheable()) {
131 req->setExtraData(2);
140 xc->getCpuPtr()->wakeup(xc->threadId());
145 #endif // __ARCH_RISCV_LOCKED_MEM_HH__
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
std::shared_ptr< Request > RequestPtr
void handleLockedRead(XC *xc, const RequestPtr &req)
bool handleLockedWrite(XC *xc, const RequestPtr &req, Addr cacheBlockMask)
std::unordered_map< int, std::stack< Addr > > locked_addrs
Tick curTick()
The current simulated tick.
void handleLockedSnoop(XC *xc, PacketPtr pkt, Addr cacheBlockMask)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
void globalClearExclusive(XC *xc)
void handleLockedSnoopHit(XC *xc)
Declaration of the Packet class.