gem5  v21.1.0.2
pc_event.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2002-2005 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;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef __PC_EVENT_HH__
30 #define __PC_EVENT_HH__
31 
32 #include <vector>
33 
34 #include "base/logging.hh"
35 #include "base/types.hh"
36 
37 namespace gem5
38 {
39 
40 class ThreadContext;
41 class PCEventQueue;
42 class System;
43 class PCEventScope;
44 
45 class PCEvent
46 {
47  protected:
48  std::string description;
51 
52  public:
53  PCEvent(PCEventScope *q, const std::string &desc, Addr pc);
54 
55  virtual ~PCEvent() { if (scope) remove(); }
56 
57  // for DPRINTF
58  virtual const std::string name() const { return description; }
59 
60  std::string descr() const { return description; }
61  Addr pc() const { return evpc; }
62 
63  bool remove();
64  virtual void process(ThreadContext *tc) = 0;
65 };
66 
68 {
69  public:
70  virtual bool remove(PCEvent *event) = 0;
71  virtual bool schedule(PCEvent *event) = 0;
72 };
73 
74 class PCEventQueue : public PCEventScope
75 {
76  protected:
77  class MapCompare
78  {
79  public:
80  bool
81  operator()(PCEvent * const &l, PCEvent * const &r) const
82  {
83  return l->pc() < r->pc();
84  }
85  bool
86  operator()(PCEvent * const &l, Addr pc) const
87  {
88  return l->pc() < pc;
89  }
90  bool
91  operator()(Addr pc, PCEvent * const &r) const
92  {
93  return pc < r->pc();
94  }
95  };
97 
98  public:
99  typedef Map::iterator iterator;
100  typedef Map::const_iterator const_iterator;
101 
102  protected:
105 
106  protected:
108 
109  bool doService(Addr pc, ThreadContext *tc);
110 
111  public:
112  PCEventQueue();
113  ~PCEventQueue();
114 
115  bool remove(PCEvent *event) override;
116  bool schedule(PCEvent *event) override;
118  {
119  if (pcMap.empty())
120  return false;
121 
122  return doService(pc, tc);
123  }
124 
127 
128  void dump() const;
129 };
130 
131 
132 inline
133 PCEvent::PCEvent(PCEventScope *s, const std::string &desc, Addr pc)
134  : description(desc), scope(s), evpc(pc)
135 {
136  scope->schedule(this);
137 }
138 
139 inline bool
141 {
142  if (!scope)
143  panic("cannot remove an uninitialized event;");
144 
145  return scope->remove(this);
146 }
147 
148 class BreakPCEvent : public PCEvent
149 {
150  protected:
151  bool remove;
152 
153  public:
154  BreakPCEvent(PCEventScope *s, const std::string &desc, Addr addr,
155  bool del = false);
156  virtual void process(ThreadContext *tc);
157 };
158 
159 class PanicPCEvent : public PCEvent
160 {
161  public:
162  PanicPCEvent(PCEventScope *s, const std::string &desc, Addr pc);
163  virtual void process(ThreadContext *tc);
164 };
165 
166 } // namespace gem5
167 
168 #endif // __PC_EVENT_HH__
gem5::BreakPCEvent::remove
bool remove
Definition: pc_event.hh:151
gem5::PCEventQueue::range_t
std::pair< iterator, iterator > range_t
Definition: pc_event.hh:103
gem5::PCEventQueue::dump
void dump() const
Definition: pc_event.cc:101
gem5::PCEvent::descr
std::string descr() const
Definition: pc_event.hh:60
gem5::PCEvent::~PCEvent
virtual ~PCEvent()
Definition: pc_event.hh:55
gem5::BreakPCEvent
Definition: pc_event.hh:148
gem5::PCEventQueue::const_range_t
std::pair< const_iterator, const_iterator > const_range_t
Definition: pc_event.hh:104
gem5::PCEventQueue::~PCEventQueue
~PCEventQueue()
Definition: pc_event.cc:47
gem5::MipsISA::event
Bitfield< 10, 5 > event
Definition: pra_constants.hh:300
gem5::PCEventQueue::remove
bool remove(PCEvent *event) override
Definition: pc_event.cc:51
gem5::PCEvent::process
virtual void process(ThreadContext *tc)=0
gem5::PCEventQueue::schedule
bool schedule(PCEvent *event) override
Definition: pc_event.cc:71
gem5::PanicPCEvent::process
virtual void process(ThreadContext *tc)
Definition: pc_event.cc:139
std::vector< PCEvent * >
gem5::PCEventQueue::PCEventQueue
PCEventQueue()
Definition: pc_event.cc:44
gem5::PCEventQueue::service
bool service(Addr pc, ThreadContext *tc)
Definition: pc_event.hh:117
gem5::PCEventQueue::iterator
Map::iterator iterator
Definition: pc_event.hh:99
gem5::PCEventQueue::Map
std::vector< PCEvent * > Map
Definition: pc_event.hh:96
gem5::PanicPCEvent::PanicPCEvent
PanicPCEvent(PCEventScope *s, const std::string &desc, Addr pc)
Definition: pc_event.cc:133
gem5::PCEventQueue::MapCompare::operator()
bool operator()(Addr pc, PCEvent *const &r) const
Definition: pc_event.hh:91
gem5::PCEventScope::remove
virtual bool remove(PCEvent *event)=0
gem5::ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:93
gem5::BreakPCEvent::BreakPCEvent
BreakPCEvent(PCEventScope *s, const std::string &desc, Addr addr, bool del=false)
Definition: pc_event.cc:117
gem5::PCEvent::pc
Addr pc() const
Definition: pc_event.hh:61
gem5::PCEvent
Definition: pc_event.hh:45
gem5::ArmISA::s
Bitfield< 4 > s
Definition: misc_types.hh:561
gem5::PCEventQueue
Definition: pc_event.hh:74
gem5::PCEventQueue::equal_range
range_t equal_range(PCEvent *event)
Definition: pc_event.hh:126
gem5::MipsISA::l
Bitfield< 5 > l
Definition: pra_constants.hh:323
gem5::PCEventQueue::equal_range
range_t equal_range(Addr pc)
Definition: pc_event.cc:112
std::pair
STL pair class.
Definition: stl.hh:58
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::PanicPCEvent
Definition: pc_event.hh:159
gem5::PCEvent::PCEvent
PCEvent(PCEventScope *q, const std::string &desc, Addr pc)
Definition: pc_event.hh:133
gem5::BreakPCEvent::process
virtual void process(ThreadContext *tc)
Definition: pc_event.cc:124
gem5::PCEventQueue::MapCompare::operator()
bool operator()(PCEvent *const &l, PCEvent *const &r) const
Definition: pc_event.hh:81
gem5::PCEvent::description
std::string description
Definition: pc_event.hh:48
gem5::ArmISA::q
Bitfield< 27 > q
Definition: misc_types.hh:55
gem5::PCEventQueue::MapCompare::operator()
bool operator()(PCEvent *const &l, Addr pc) const
Definition: pc_event.hh:86
types.hh
gem5::MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:243
logging.hh
gem5::MipsISA::r
r
Definition: pra_constants.hh:98
gem5::PCEventScope::schedule
virtual bool schedule(PCEvent *event)=0
gem5::PCEvent::remove
bool remove()
Definition: pc_event.hh:140
gem5::PCEvent::evpc
Addr evpc
Definition: pc_event.hh:50
gem5::PCEventQueue::MapCompare
Definition: pc_event.hh:77
gem5::PCEventQueue::pcMap
Map pcMap
Definition: pc_event.hh:107
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::PCEventQueue::const_iterator
Map::const_iterator const_iterator
Definition: pc_event.hh:100
gem5::PCEventQueue::doService
bool doService(Addr pc, ThreadContext *tc)
Definition: pc_event.cc:83
gem5::PCEventScope
Definition: pc_event.hh:67
gem5::PCEvent::scope
PCEventScope * scope
Definition: pc_event.hh:49
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:177
gem5::PCEvent::name
virtual const std::string name() const
Definition: pc_event.hh:58
gem5::X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:84

Generated on Tue Sep 21 2021 12:25:05 for gem5 by doxygen 1.8.17