1/* 2 * Copyright (c) 2006 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; --- 448 unchanged lines hidden (view full) --- 457 /** 458 * Constructor. Note that a Request object must be constructed 459 * first, but the Requests's physical address and size fields need 460 * not be valid. The command and destination addresses must be 461 * supplied. 462 */ 463 Packet(Request *_req, MemCmd _cmd, NodeID _dest) 464 : flags(VALID_DST), cmd(_cmd), req(_req), data(NULL), |
465 dest(_dest), time(curTick), senderState(NULL) |
466 { |
467 if (req->hasPaddr()) { 468 addr = req->getPaddr(); 469 flags.set(VALID_ADDR); 470 } 471 if (req->hasSize()) { 472 size = req->getSize(); 473 flags.set(VALID_SIZE); 474 } |
475 } 476 477 /** 478 * Alternate constructor if you are trying to create a packet with 479 * a request that is for a whole block, not the address from the 480 * req. this allows for overriding the size/addr of the req. 481 */ 482 Packet(Request *_req, MemCmd _cmd, NodeID _dest, int _blkSize) 483 : flags(VALID_DST), cmd(_cmd), req(_req), data(NULL), |
484 dest(_dest), time(curTick), senderState(NULL) |
485 { |
486 if (req->hasPaddr()) { 487 addr = req->getPaddr() & ~(_blkSize - 1); 488 flags.set(VALID_ADDR); 489 } 490 size = _blkSize; 491 flags.set(VALID_SIZE); |
492 } 493 494 /** 495 * Alternate constructor for copying a packet. Copy all fields 496 * *except* if the original packet's data was dynamic, don't copy 497 * that, as we can't guarantee that the new packet's lifetime is 498 * less than that of the original packet. In this case the new 499 * packet should allocate its own data. --- 29 unchanged lines hidden (view full) --- 529 * Request object, and reset other fields that may have been 530 * modified by a previous transaction. Typically called when a 531 * statically allocated Request/Packet pair is reused for multiple 532 * transactions. 533 */ 534 void 535 reinitFromRequest() 536 { |
537 assert(req->hasPaddr()); |
538 flags = 0; |
539 addr = req->getPaddr(); 540 size = req->getSize(); 541 time = req->getTime(); |
542 543 flags.set(VALID_ADDR|VALID_SIZE); 544 deleteData(); 545 } 546 547 /** 548 * Take a request packet and modify it in place to be suitable for 549 * returning as a response to that request. The source and --- 220 unchanged lines hidden --- |