packet.hh (5314:e902f12a3af1) packet.hh (5315:30997e988446)
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;

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

294 * needed to process it. A specific subclass would be derived
295 * from this to carry state specific to a particular sending
296 * device. */
297 class SenderState : public FastAlloc {
298 public:
299 virtual ~SenderState() {}
300 };
301
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;

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

294 * needed to process it. A specific subclass would be derived
295 * from this to carry state specific to a particular sending
296 * device. */
297 class SenderState : public FastAlloc {
298 public:
299 virtual ~SenderState() {}
300 };
301
302 /**
303 * Object used to maintain state of a PrintReq. The senderState
304 * field of a PrintReq should always be of this type.
305 */
302 class PrintReqState : public SenderState {
306 class PrintReqState : public SenderState {
307 /** An entry in the label stack. */
303 class LabelStackEntry {
304 public:
305 const std::string label;
306 std::string *prefix;
307 bool labelPrinted;
308 LabelStackEntry(const std::string &_label,
309 std::string *_prefix);
310 };

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

316
317 public:
318 std::ostream &os;
319 const int verbosity;
320
321 PrintReqState(std::ostream &os, int verbosity = 0);
322 ~PrintReqState();
323
308 class LabelStackEntry {
309 public:
310 const std::string label;
311 std::string *prefix;
312 bool labelPrinted;
313 LabelStackEntry(const std::string &_label,
314 std::string *_prefix);
315 };

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

321
322 public:
323 std::ostream &os;
324 const int verbosity;
325
326 PrintReqState(std::ostream &os, int verbosity = 0);
327 ~PrintReqState();
328
329 /** Returns the current line prefix. */
324 const std::string &curPrefix() { return *curPrefixPtr; }
330 const std::string &curPrefix() { return *curPrefixPtr; }
331
332 /** Push a label onto the label stack, and prepend the given
333 * prefix string onto the current prefix. Labels will only be
334 * printed if an object within the label's scope is
335 * printed. */
325 void pushLabel(const std::string &lbl,
326 const std::string &prefix = " ");
336 void pushLabel(const std::string &lbl,
337 const std::string &prefix = " ");
338 /** Pop a label off the label stack. */
327 void popLabel();
339 void popLabel();
340 /** Print all of the pending unprinted labels on the
341 * stack. Called by printObj(), so normally not called by
342 * users unless bypassing printObj(). */
328 void printLabels();
343 void printLabels();
344 /** Print a Printable object to os, because it matched the
345 * address on a PrintReq. */
329 void printObj(Printable *obj);
330 };
331
332 /** This packet's sender state. Devices should use dynamic_cast<>
333 * to cast to the state appropriate to the sender. */
334 SenderState *senderState;
335
336 /** Return the string name of the cmd field (for debugging and

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

608 * functional request is a read, it may be satisfied by the memory
609 * value. If the functional request is a write, it may update the
610 * memory value.
611 */
612 bool checkFunctional(Printable *obj, Addr base, int size, uint8_t *data);
613
614 /**
615 * Check a functional request against a memory value stored in
346 void printObj(Printable *obj);
347 };
348
349 /** This packet's sender state. Devices should use dynamic_cast<>
350 * to cast to the state appropriate to the sender. */
351 SenderState *senderState;
352
353 /** Return the string name of the cmd field (for debugging and

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

625 * functional request is a read, it may be satisfied by the memory
626 * value. If the functional request is a write, it may update the
627 * memory value.
628 */
629 bool checkFunctional(Printable *obj, Addr base, int size, uint8_t *data);
630
631 /**
632 * Check a functional request against a memory value stored in
616 * another packet (i.e. an in-transit request or response). If
617 * possible, the request will be satisfied and transformed
618 * in-place into a response (at which point no further checking
619 * need be done).
620 *
621 * @return True if the memory location addressed by the request
622 * overlaps with the location addressed by otherPkt.
633 * another packet (i.e. an in-transit request or response).
623 */
624 bool checkFunctional(PacketPtr otherPkt) {
625 return checkFunctional(otherPkt,
626 otherPkt->getAddr(), otherPkt->getSize(),
627 otherPkt->hasData() ?
628 otherPkt->getPtr<uint8_t>() : NULL);
629 }
630
634 */
635 bool checkFunctional(PacketPtr otherPkt) {
636 return checkFunctional(otherPkt,
637 otherPkt->getAddr(), otherPkt->getSize(),
638 otherPkt->hasData() ?
639 otherPkt->getPtr<uint8_t>() : NULL);
640 }
641
642 /**
643 * Push label for PrintReq (safe to call unconditionally).
644 */
631 void pushLabel(const std::string &lbl) {
632 if (isPrint()) {
633 dynamic_cast<PrintReqState*>(senderState)->pushLabel(lbl);
634 }
635 }
636
645 void pushLabel(const std::string &lbl) {
646 if (isPrint()) {
647 dynamic_cast<PrintReqState*>(senderState)->pushLabel(lbl);
648 }
649 }
650
651 /**
652 * Pop label for PrintReq (safe to call unconditionally).
653 */
637 void popLabel() {
638 if (isPrint()) {
639 dynamic_cast<PrintReqState*>(senderState)->popLabel();
640 }
641 }
642
643 void print(std::ostream &o, int verbosity = 0,
644 const std::string &prefix = "") const;
645};
646
647#endif //__MEM_PACKET_HH
654 void popLabel() {
655 if (isPrint()) {
656 dynamic_cast<PrintReqState*>(senderState)->popLabel();
657 }
658 }
659
660 void print(std::ostream &o, int verbosity = 0,
661 const std::string &prefix = "") const;
662};
663
664#endif //__MEM_PACKET_HH