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; --- 447 unchanged lines hidden (view full) --- 456 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 addr(_req->paddr), size(_req->size), dest(_dest), time(curTick), 466 senderState(NULL) |
467 { |
468 if (req->flags.any(Request::VALID_PADDR)) 469 flags.set(VALID_ADDR|VALID_SIZE); |
470 } 471 472 /** 473 * Alternate constructor if you are trying to create a packet with 474 * a request that is for a whole block, not the address from the 475 * req. this allows for overriding the size/addr of the req. 476 */ 477 Packet(Request *_req, MemCmd _cmd, NodeID _dest, int _blkSize) |
478 : flags(VALID_DST), cmd(_cmd), req(_req), data(NULL), |
479 addr(_req->paddr & ~(_blkSize - 1)), size(_blkSize), dest(_dest), 480 time(curTick), senderState(NULL) 481 { |
482 if (req->flags.any(Request::VALID_PADDR)) 483 flags.set(VALID_ADDR|VALID_SIZE); |
484 } 485 486 /** 487 * Alternate constructor for copying a packet. Copy all fields 488 * *except* if the original packet's data was dynamic, don't copy 489 * that, as we can't guarantee that the new packet's lifetime is 490 * less than that of the original packet. In this case the new 491 * packet should allocate its own data. --- 52 unchanged lines hidden (view full) --- 544 */ 545 void 546 makeResponse() 547 { 548 assert(needsResponse()); 549 assert(isRequest()); 550 origCmd = cmd; 551 cmd = cmd.responseCommand(); |
552 553 dest = src; 554 flags.set(VALID_DST, flags.any(VALID_SRC)); 555 flags.clear(VALID_SRC); |
556 } 557 558 void 559 makeAtomicResponse() 560 { 561 makeResponse(); 562 } 563 --- 123 unchanged lines hidden (view full) --- 687 * matter how data was allocted. 688 */ 689 void 690 deleteData() 691 { 692 if (flags.any(ARRAY_DATA)) 693 delete [] data; 694 else if (flags.any(DYNAMIC_DATA)) |
695 delete data; 696 697 flags.clear(STATIC_DATA|DYNAMIC_DATA|ARRAY_DATA); 698 data = NULL; 699 } 700 701 /** If there isn't data in the packet, allocate some. */ 702 void 703 allocate() 704 { 705 if (data) { |
706 assert(flags.any(STATIC_DATA|DYNAMIC_DATA)); 707 return; |
708 } |
709 710 assert(flags.none(STATIC_DATA|DYNAMIC_DATA)); 711 flags.set(DYNAMIC_DATA|ARRAY_DATA); 712 data = new uint8_t[getSize()]; |
713 } 714 715 716 /** 717 * Check a functional request against a memory value represented 718 * by a base/size pair and an associated data array. If the 719 * functional request is a read, it may be satisfied by the memory 720 * value. If the functional request is a write, it may update the --- 41 unchanged lines hidden --- |