46 #ifndef __ARCH_RISCV_LOCKED_MEM_HH__ 47 #define __ARCH_RISCV_LOCKED_MEM_HH__ 50 #include <unordered_map> 52 #include "arch/registers.hh" 55 #include "debug/LLSC.hh" 69 extern std::unordered_map<int, std::stack<Addr>>
locked_addrs;
71 template <
class XC>
inline void 74 std::stack<Addr>& locked_addr_stack = locked_addrs[xc->contextId()];
76 if (locked_addr_stack.empty())
79 DPRINTF(LLSC,
"Locked snoop on address %x.\n", snoop_addr);
80 if ((locked_addr_stack.top() & cacheBlockMask) == snoop_addr)
81 locked_addr_stack.pop();
85 template <
class XC>
inline void 88 std::stack<Addr>& locked_addr_stack = locked_addrs[xc->contextId()];
90 locked_addr_stack.push(req->getPaddr() & ~0xF);
91 DPRINTF(LLSC,
"[cid:%d]: Reserved address %x.\n",
92 req->contextId(), req->getPaddr() & ~0xF);
95 template <
class XC>
inline void 99 template <
class XC>
inline bool 102 std::stack<Addr>& locked_addr_stack = locked_addrs[xc->contextId()];
109 DPRINTF(LLSC,
"[cid:%d]: locked_addrs empty? %s.\n", req->contextId(),
110 locked_addr_stack.empty() ?
"yes" :
"no");
111 if (!locked_addr_stack.empty()) {
112 DPRINTF(LLSC,
"[cid:%d]: addr = %x.\n", req->contextId(),
113 req->getPaddr() & ~0xF);
114 DPRINTF(LLSC,
"[cid:%d]: last locked addr = %x.\n", req->contextId(),
115 locked_addr_stack.top());
117 if (locked_addr_stack.empty()
118 || locked_addr_stack.top() != ((req->getPaddr() & ~0xF))) {
119 req->setExtraData(0);
120 int stCondFailures = xc->readStCondFailures();
121 xc->setStCondFailures(++stCondFailures);
122 if (stCondFailures % WARN_FAILURE == 0) {
123 warn(
"%i: context %d: %d consecutive SC failures.\n",
124 curTick(), xc->contextId(), stCondFailures);
128 if (req->isUncacheable()) {
129 req->setExtraData(2);
138 xc->getCpuPtr()->wakeup(xc->threadId());
143 #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.