packet.hh (5735:a88e8e7dec75) packet.hh (5745:6b0f8306704b)
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)
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 : cmd(_cmd), req(_req), data(NULL), addr(_req->paddr),
465 size(_req->size), dest(_dest), time(curTick), senderState(NULL)
464 : flags(VALID_DST), cmd(_cmd), req(_req), data(NULL),
465 addr(_req->paddr), size(_req->size), dest(_dest), time(curTick),
466 senderState(NULL)
466 {
467 {
468 if (req->flags.any(Request::VALID_PADDR))
469 flags.set(VALID_ADDR|VALID_SIZE);
467 }
468
469 /**
470 * Alternate constructor if you are trying to create a packet with
471 * a request that is for a whole block, not the address from the
472 * req. this allows for overriding the size/addr of the req.
473 */
474 Packet(Request *_req, MemCmd _cmd, NodeID _dest, int _blkSize)
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)
475 : cmd(_cmd), req(_req), data(NULL),
478 : flags(VALID_DST), cmd(_cmd), req(_req), data(NULL),
476 addr(_req->paddr & ~(_blkSize - 1)), size(_blkSize), dest(_dest),
477 time(curTick), senderState(NULL)
478 {
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);
479 }
480
481 /**
482 * Alternate constructor for copying a packet. Copy all fields
483 * *except* if the original packet's data was dynamic, don't copy
484 * that, as we can't guarantee that the new packet's lifetime is
485 * less than that of the original packet. In this case the new
486 * packet should allocate its own data.

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

539 */
540 void
541 makeResponse()
542 {
543 assert(needsResponse());
544 assert(isRequest());
545 origCmd = cmd;
546 cmd = cmd.responseCommand();
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();
547 if (flags.any(VALID_SRC)) {
548 dest = src;
549 flags.set(VALID_DST);
550 flags.clear(VALID_SRC);
551 } else {
552 flags.clear(VALID_DST);
553 }
552
553 dest = src;
554 flags.set(VALID_DST, flags.any(VALID_SRC));
555 flags.clear(VALID_SRC);
554 }
555
556 void
557 makeAtomicResponse()
558 {
559 makeResponse();
560 }
561

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

685 * matter how data was allocted.
686 */
687 void
688 deleteData()
689 {
690 if (flags.any(ARRAY_DATA))
691 delete [] data;
692 else if (flags.any(DYNAMIC_DATA))
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))
693
694 delete data;
695
696 flags.clear(STATIC_DATA|DYNAMIC_DATA|ARRAY_DATA);
697 data = NULL;
698 }
699
700 /** If there isn't data in the packet, allocate some. */
701 void
702 allocate()
703 {
704 if (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) {
705 assert(flags.none(STATIC_DATA|DYNAMIC_DATA));
706 } else {
707 flags.set(DYNAMIC_DATA|ARRAY_DATA);
708 data = new uint8_t[getSize()];
706 assert(flags.any(STATIC_DATA|DYNAMIC_DATA));
707 return;
709 }
708 }
709
710 assert(flags.none(STATIC_DATA|DYNAMIC_DATA));
711 flags.set(DYNAMIC_DATA|ARRAY_DATA);
712 data = new uint8_t[getSize()];
710 }
711
712
713 /**
714 * Check a functional request against a memory value represented
715 * by a base/size pair and an associated data array. If the
716 * functional request is a read, it may be satisfied by the memory
717 * value. If the functional request is a write, it may update the

--- 41 unchanged lines hidden ---
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 ---