abstract_mem.cc (13346:67e56546fd5a) abstract_mem.cc (13377:2e04ce7d3fd4)
1/*
2 * Copyright (c) 2010-2012,2017 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

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

332 assert(AddrRange(pkt->getAddr(),
333 pkt->getAddr() + (pkt->getSize() - 1)).isSubset(range));
334
335 uint8_t *hostAddr = pmemAddr + pkt->getAddr() - range.start();
336
337 if (pkt->cmd == MemCmd::SwapReq) {
338 if (pkt->isAtomicOp()) {
339 if (pmemAddr) {
1/*
2 * Copyright (c) 2010-2012,2017 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

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

332 assert(AddrRange(pkt->getAddr(),
333 pkt->getAddr() + (pkt->getSize() - 1)).isSubset(range));
334
335 uint8_t *hostAddr = pmemAddr + pkt->getAddr() - range.start();
336
337 if (pkt->cmd == MemCmd::SwapReq) {
338 if (pkt->isAtomicOp()) {
339 if (pmemAddr) {
340 memcpy(pkt->getPtr<uint8_t>(), hostAddr, pkt->getSize());
340 pkt->setData(hostAddr);
341 (*(pkt->getAtomicOp()))(hostAddr);
342 }
343 } else {
344 std::vector<uint8_t> overwrite_val(pkt->getSize());
345 uint64_t condition_val64;
346 uint32_t condition_val32;
347
341 (*(pkt->getAtomicOp()))(hostAddr);
342 }
343 } else {
344 std::vector<uint8_t> overwrite_val(pkt->getSize());
345 uint64_t condition_val64;
346 uint32_t condition_val32;
347
348 if (!pmemAddr)
349 panic("Swap only works if there is real memory (i.e. null=False)");
348 panic_if(!pmemAddr, "Swap only works if there is real memory " \
349 "(i.e. null=False)");
350
351 bool overwrite_mem = true;
352 // keep a copy of our possible write value, and copy what is at the
353 // memory address into the packet
350
351 bool overwrite_mem = true;
352 // keep a copy of our possible write value, and copy what is at the
353 // memory address into the packet
354 std::memcpy(&overwrite_val[0], pkt->getConstPtr<uint8_t>(),
355 pkt->getSize());
356 std::memcpy(pkt->getPtr<uint8_t>(), hostAddr, pkt->getSize());
354 pkt->writeData(&overwrite_val[0]);
355 pkt->setData(hostAddr);
357
358 if (pkt->req->isCondSwap()) {
359 if (pkt->getSize() == sizeof(uint64_t)) {
360 condition_val64 = pkt->req->getExtraData();
361 overwrite_mem = !std::memcmp(&condition_val64, hostAddr,
362 sizeof(uint64_t));
363 } else if (pkt->getSize() == sizeof(uint32_t)) {
364 condition_val32 = (uint32_t)pkt->req->getExtraData();

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

378 } else if (pkt->isRead()) {
379 assert(!pkt->isWrite());
380 if (pkt->isLLSC()) {
381 assert(!pkt->fromCache());
382 // if the packet is not coming from a cache then we have
383 // to do the LL/SC tracking here
384 trackLoadLocked(pkt);
385 }
356
357 if (pkt->req->isCondSwap()) {
358 if (pkt->getSize() == sizeof(uint64_t)) {
359 condition_val64 = pkt->req->getExtraData();
360 overwrite_mem = !std::memcmp(&condition_val64, hostAddr,
361 sizeof(uint64_t));
362 } else if (pkt->getSize() == sizeof(uint32_t)) {
363 condition_val32 = (uint32_t)pkt->req->getExtraData();

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

377 } else if (pkt->isRead()) {
378 assert(!pkt->isWrite());
379 if (pkt->isLLSC()) {
380 assert(!pkt->fromCache());
381 // if the packet is not coming from a cache then we have
382 // to do the LL/SC tracking here
383 trackLoadLocked(pkt);
384 }
386 if (pmemAddr)
387 memcpy(pkt->getPtr<uint8_t>(), hostAddr, pkt->getSize());
385 if (pmemAddr) {
386 pkt->setData(hostAddr);
387 }
388 TRACE_PACKET(pkt->req->isInstFetch() ? "IFetch" : "Read");
389 numReads[pkt->req->masterId()]++;
390 bytesRead[pkt->req->masterId()] += pkt->getSize();
391 if (pkt->req->isInstFetch())
392 bytesInstRead[pkt->req->masterId()] += pkt->getSize();
393 } else if (pkt->isInvalidate() || pkt->isClean()) {
394 assert(!pkt->isWrite());
395 // in a fastmem system invalidating and/or cleaning packets
396 // can be seen due to cache maintenance requests
397
398 // no need to do anything
399 } else if (pkt->isWrite()) {
400 if (writeOK(pkt)) {
401 if (pmemAddr) {
388 TRACE_PACKET(pkt->req->isInstFetch() ? "IFetch" : "Read");
389 numReads[pkt->req->masterId()]++;
390 bytesRead[pkt->req->masterId()] += pkt->getSize();
391 if (pkt->req->isInstFetch())
392 bytesInstRead[pkt->req->masterId()] += pkt->getSize();
393 } else if (pkt->isInvalidate() || pkt->isClean()) {
394 assert(!pkt->isWrite());
395 // in a fastmem system invalidating and/or cleaning packets
396 // can be seen due to cache maintenance requests
397
398 // no need to do anything
399 } else if (pkt->isWrite()) {
400 if (writeOK(pkt)) {
401 if (pmemAddr) {
402 memcpy(hostAddr, pkt->getConstPtr<uint8_t>(), pkt->getSize());
402 pkt->writeData(hostAddr);
403 DPRINTF(MemoryAccess, "%s wrote %i bytes to address %x\n",
404 __func__, pkt->getSize(), pkt->getAddr());
405 }
406 assert(!pkt->req->isInstFetch());
407 TRACE_PACKET("Write");
408 numWrites[pkt->req->masterId()]++;
409 bytesWritten[pkt->req->masterId()] += pkt->getSize();
410 }

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

421AbstractMemory::functionalAccess(PacketPtr pkt)
422{
423 assert(AddrRange(pkt->getAddr(),
424 pkt->getAddr() + pkt->getSize() - 1).isSubset(range));
425
426 uint8_t *hostAddr = pmemAddr + pkt->getAddr() - range.start();
427
428 if (pkt->isRead()) {
403 DPRINTF(MemoryAccess, "%s wrote %i bytes to address %x\n",
404 __func__, pkt->getSize(), pkt->getAddr());
405 }
406 assert(!pkt->req->isInstFetch());
407 TRACE_PACKET("Write");
408 numWrites[pkt->req->masterId()]++;
409 bytesWritten[pkt->req->masterId()] += pkt->getSize();
410 }

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

421AbstractMemory::functionalAccess(PacketPtr pkt)
422{
423 assert(AddrRange(pkt->getAddr(),
424 pkt->getAddr() + pkt->getSize() - 1).isSubset(range));
425
426 uint8_t *hostAddr = pmemAddr + pkt->getAddr() - range.start();
427
428 if (pkt->isRead()) {
429 if (pmemAddr)
430 memcpy(pkt->getPtr<uint8_t>(), hostAddr, pkt->getSize());
429 if (pmemAddr) {
430 pkt->setData(hostAddr);
431 }
431 TRACE_PACKET("Read");
432 pkt->makeResponse();
433 } else if (pkt->isWrite()) {
432 TRACE_PACKET("Read");
433 pkt->makeResponse();
434 } else if (pkt->isWrite()) {
434 if (pmemAddr)
435 memcpy(hostAddr, pkt->getConstPtr<uint8_t>(), pkt->getSize());
435 if (pmemAddr) {
436 pkt->writeData(hostAddr);
437 }
436 TRACE_PACKET("Write");
437 pkt->makeResponse();
438 } else if (pkt->isPrint()) {
439 Packet::PrintReqState *prs =
440 dynamic_cast<Packet::PrintReqState*>(pkt->senderState);
441 assert(prs);
442 // Need to call printLabels() explicitly since we're not going
443 // through printObj().
444 prs->printLabels();
445 // Right now we just print the single byte at the specified address.
446 ccprintf(prs->os, "%s%#x\n", prs->curPrefix(), *hostAddr);
447 } else {
448 panic("AbstractMemory: unimplemented functional command %s",
449 pkt->cmdString());
450 }
451}
438 TRACE_PACKET("Write");
439 pkt->makeResponse();
440 } else if (pkt->isPrint()) {
441 Packet::PrintReqState *prs =
442 dynamic_cast<Packet::PrintReqState*>(pkt->senderState);
443 assert(prs);
444 // Need to call printLabels() explicitly since we're not going
445 // through printObj().
446 prs->printLabels();
447 // Right now we just print the single byte at the specified address.
448 ccprintf(prs->os, "%s%#x\n", prs->curPrefix(), *hostAddr);
449 } else {
450 panic("AbstractMemory: unimplemented functional command %s",
451 pkt->cmdString());
452 }
453}