physical.cc (6076:e141cc7896ce) physical.cc (6102:7fbf97dc6540)
1/*
2 * Copyright (c) 2001-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 148 unchanged lines hidden (view full) ---

157// store-conditional operations. Check for conventional stores which
158// conflict with locked addresses, and for success/failure of store
159// conditionals.
160bool
161PhysicalMemory::checkLockedAddrList(PacketPtr pkt)
162{
163 Request *req = pkt->req;
164 Addr paddr = LockedAddr::mask(req->getPaddr());
1/*
2 * Copyright (c) 2001-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 148 unchanged lines hidden (view full) ---

157// store-conditional operations. Check for conventional stores which
158// conflict with locked addresses, and for success/failure of store
159// conditionals.
160bool
161PhysicalMemory::checkLockedAddrList(PacketPtr pkt)
162{
163 Request *req = pkt->req;
164 Addr paddr = LockedAddr::mask(req->getPaddr());
165 bool isLlsc = pkt->isLlsc();
165 bool isLLSC = pkt->isLLSC();
166
167 // Initialize return value. Non-conditional stores always
168 // succeed. Assume conditional stores will fail until proven
169 // otherwise.
166
167 // Initialize return value. Non-conditional stores always
168 // succeed. Assume conditional stores will fail until proven
169 // otherwise.
170 bool success = !isLlsc;
170 bool success = !isLLSC;
171
172 // Iterate over list. Note that there could be multiple matching
173 // records, as more than one context could have done a load locked
174 // to this location.
175 list<LockedAddr>::iterator i = lockedAddrList.begin();
176
177 while (i != lockedAddrList.end()) {
178
179 if (i->addr == paddr) {
180 // we have a matching address
181
171
172 // Iterate over list. Note that there could be multiple matching
173 // records, as more than one context could have done a load locked
174 // to this location.
175 list<LockedAddr>::iterator i = lockedAddrList.begin();
176
177 while (i != lockedAddrList.end()) {
178
179 if (i->addr == paddr) {
180 // we have a matching address
181
182 if (isLlsc && i->matchesContext(req)) {
182 if (isLLSC && i->matchesContext(req)) {
183 // it's a store conditional, and as far as the memory
184 // system can tell, the requesting context's lock is
185 // still valid.
186 DPRINTF(LLSC, "StCond success: context %d addr %#x\n",
187 req->contextId(), paddr);
188 success = true;
189 }
190
191 // Get rid of our record of this lock and advance to next
192 DPRINTF(LLSC, "Erasing lock record: context %d addr %#x\n",
193 i->contextId, paddr);
194 i = lockedAddrList.erase(i);
195 }
196 else {
197 // no match: advance to next record
198 ++i;
199 }
200 }
201
183 // it's a store conditional, and as far as the memory
184 // system can tell, the requesting context's lock is
185 // still valid.
186 DPRINTF(LLSC, "StCond success: context %d addr %#x\n",
187 req->contextId(), paddr);
188 success = true;
189 }
190
191 // Get rid of our record of this lock and advance to next
192 DPRINTF(LLSC, "Erasing lock record: context %d addr %#x\n",
193 i->contextId, paddr);
194 i = lockedAddrList.erase(i);
195 }
196 else {
197 // no match: advance to next record
198 ++i;
199 }
200 }
201
202 if (isLlsc) {
202 if (isLLSC) {
203 req->setExtraData(success ? 1 : 0);
204 }
205
206 return success;
207}
208
209
210#if TRACING_ON

--- 68 unchanged lines hidden (view full) ---

279 }
280
281 if (overwrite_mem)
282 std::memcpy(hostAddr, &overwrite_val, pkt->getSize());
283
284 TRACE_PACKET("Read/Write");
285 } else if (pkt->isRead()) {
286 assert(!pkt->isWrite());
203 req->setExtraData(success ? 1 : 0);
204 }
205
206 return success;
207}
208
209
210#if TRACING_ON

--- 68 unchanged lines hidden (view full) ---

279 }
280
281 if (overwrite_mem)
282 std::memcpy(hostAddr, &overwrite_val, pkt->getSize());
283
284 TRACE_PACKET("Read/Write");
285 } else if (pkt->isRead()) {
286 assert(!pkt->isWrite());
287 if (pkt->isLlsc()) {
287 if (pkt->isLLSC()) {
288 trackLoadLocked(pkt);
289 }
290 if (pmemAddr)
291 memcpy(pkt->getPtr<uint8_t>(), hostAddr, pkt->getSize());
292 TRACE_PACKET("Read");
293 } else if (pkt->isWrite()) {
294 if (writeOK(pkt)) {
295 if (pmemAddr)

--- 275 unchanged lines hidden ---
288 trackLoadLocked(pkt);
289 }
290 if (pmemAddr)
291 memcpy(pkt->getPtr<uint8_t>(), hostAddr, pkt->getSize());
292 TRACE_PACKET("Read");
293 } else if (pkt->isWrite()) {
294 if (writeOK(pkt)) {
295 if (pmemAddr)

--- 275 unchanged lines hidden ---