gem5  v22.1.0.0
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__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
BreakPCEvent(PCEventScope *s, const std::string &desc, Addr addr, bool del=false)
Definition: pc_event.cc:117
virtual void process(ThreadContext *tc)
Definition: pc_event.cc:124
bool operator()(PCEvent *const &l, PCEvent *const &r) const
Definition: pc_event.hh:81
bool operator()(Addr pc, PCEvent *const &r) const
Definition: pc_event.hh:91
bool operator()(PCEvent *const &l, Addr pc) const
Definition: pc_event.hh:86
range_t equal_range(PCEvent *event)
Definition: pc_event.hh:126
range_t equal_range(Addr pc)
Definition: pc_event.cc:112
Map::iterator iterator
Definition: pc_event.hh:99
std::pair< iterator, iterator > range_t
Definition: pc_event.hh:103
Map::const_iterator const_iterator
Definition: pc_event.hh:100
bool remove(PCEvent *event) override
Definition: pc_event.cc:51
void dump() const
Definition: pc_event.cc:101
std::vector< PCEvent * > Map
Definition: pc_event.hh:96
std::pair< const_iterator, const_iterator > const_range_t
Definition: pc_event.hh:104
bool service(Addr pc, ThreadContext *tc)
Definition: pc_event.hh:117
bool doService(Addr pc, ThreadContext *tc)
Definition: pc_event.cc:83
bool schedule(PCEvent *event) override
Definition: pc_event.cc:71
virtual bool schedule(PCEvent *event)=0
virtual bool remove(PCEvent *event)=0
virtual const std::string name() const
Definition: pc_event.hh:58
bool remove()
Definition: pc_event.hh:140
PCEventScope * scope
Definition: pc_event.hh:49
virtual ~PCEvent()
Definition: pc_event.hh:55
Addr pc() const
Definition: pc_event.hh:61
PCEvent(PCEventScope *q, const std::string &desc, Addr pc)
Definition: pc_event.hh:133
std::string description
Definition: pc_event.hh:48
virtual void process(ThreadContext *tc)=0
std::string descr() const
Definition: pc_event.hh:60
PanicPCEvent(PCEventScope *s, const std::string &desc, Addr pc)
Definition: pc_event.cc:133
virtual void process(ThreadContext *tc)
Definition: pc_event.cc:139
ThreadContext is the external interface to all thread state for anything outside of the CPU.
STL pair class.
Definition: stl.hh:58
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:178
Bitfield< 27 > q
Definition: misc_types.hh:55
Bitfield< 4 > pc
Bitfield< 10, 5 > event
Bitfield< 5 > r
Definition: pagetable.hh:60
Bitfield< 1 > s
Definition: pagetable.hh:64
Bitfield< 55 > l
Definition: pagetable.hh:54
Bitfield< 3 > addr
Definition: types.hh:84
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147

Generated on Wed Dec 21 2022 10:22:31 for gem5 by doxygen 1.9.1