gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cpuevent.hh
Go to the documentation of this file.
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;
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  * Authors: Ali Saidi
29  */
30 
31 #ifndef __CPU_CPUEVENT_HH__
32 #define __CPU_CPUEVENT_HH__
33 
34 #include <vector>
35 
36 #include "sim/eventq.hh"
37 
38 class ThreadContext;
39 
48 class CpuEvent : public Event
49 {
50  protected:
53 
57 
60 
61  public:
63  : Event(p), tc(_tc)
64  { cpuEventList.push_back(this); }
65 
67  ~CpuEvent();
68 
73  static void replaceThreadContext(ThreadContext *oldTc,
74  ThreadContext *newTc);
75  ThreadContext* getTC() { return tc; }
76 };
77 
78 template <class T, void (T::* F)(ThreadContext *tc)>
79 class CpuEventWrapper : public CpuEvent
80 {
81  private:
82  T *object;
83 
84  public:
86  : CpuEvent(_tc, p), object(obj)
87  { }
88  void process() { (object->*F)(tc); }
89 };
90 
91 #endif // __CPU_CPUEVENT_HH__
92 
static void replaceThreadContext(ThreadContext *oldTc, ThreadContext *newTc)
Update all events switching old tc to new tc.
Definition: cpuevent.cc:51
CpuEvent(ThreadContext *_tc, Priority p=Default_Pri)
Definition: cpuevent.hh:62
int8_t Priority
Definition: eventq.hh:116
ThreadContext * getTC()
Definition: cpuevent.hh:75
ThreadContext is the external interface to all thread state for anything outside of the CPU...
STL vector class.
Definition: stl.hh:40
This class creates a global list of events that need a pointer to a thread context.
Definition: cpuevent.hh:48
~CpuEvent()
delete the cpu event from the global list.
Definition: cpuevent.cc:37
std::vector< CpuEvent * > CpuEventList
type of global list of cpu events.
Definition: cpuevent.hh:52
static CpuEventList cpuEventList
Static list of cpu events that is searched every time a cpu switch happens.
Definition: cpuevent.hh:56
CpuEventWrapper(T *obj, ThreadContext *_tc, Priority p=Default_Pri)
Definition: cpuevent.hh:85
ThreadContext * tc
The thread context that is switched to the new cpus.
Definition: cpuevent.hh:59
Definition: eventq.hh:185
static const Priority Default_Pri
Default is zero for historical reasons.
Definition: eventq.hh:148
Bitfield< 0 > p
void process()
Definition: cpuevent.hh:88

Generated on Fri Jun 9 2017 13:03:42 for gem5 by doxygen 1.8.6