gem5  v20.1.0.0
policy.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  *
37  * Author: Matteo Andreozzi
38  */
39 
40 #ifndef __MEM_QOS_POLICY_HH__
41 #define __MEM_QOS_POLICY_HH__
42 
43 #include "base/trace.hh"
44 #include "debug/QOS.hh"
45 #include "mem/qos/mem_ctrl.hh"
46 #include "mem/packet.hh"
47 #include "sim/system.hh"
48 
49 namespace QoS {
50 
58 class Policy : public SimObject
59 {
60  public:
61  using Params = QoSPolicyParams;
62  Policy(const Params* p);
63 
64  virtual ~Policy();
65 
66  virtual void regStats() override {};
67 
68  virtual void init() override {};
69 
74  void setMemCtrl(MemCtrl* mem) { memCtrl = mem; };
75 
87  template <typename Requestor, typename T>
88  std::pair<RequestorID, T> pair(Requestor requestor, T value);
89 
97  virtual uint8_t schedule(const RequestorID requestor_id,
98  const uint64_t data) = 0;
99 
107  uint8_t schedule(const PacketPtr pkt);
108 
109  protected:
112 };
113 
114 template <typename Requestor, typename T>
116 Policy::pair(Requestor requestor, T value)
117 {
118  auto id = memCtrl->system()->lookupRequestorId(requestor);
119 
121  "Unable to find requestor %s\n", requestor);
122 
123  DPRINTF(QOS,
124  "Requestor %s [id %d] associated with QoS data %d\n",
125  requestor, id, value);
126 
127  return std::pair<RequestorID, T>(id, value);
128 }
129 
130 } // namespace QoS
131 
132 #endif /* __MEM_QOS_POLICY_HH__ */
QoS
Definition: mem_ctrl.cc:42
QoS::MemCtrl
The QoS::MemCtrl is a base class for Memory objects which support QoS - it provides access to a set o...
Definition: mem_ctrl.hh:59
system.hh
data
const char data[]
Definition: circlebuf.test.cc:42
QoS::Policy::regStats
virtual void regStats() override
Callback to set stat parameters.
Definition: policy.hh:66
QoS::Policy::schedule
virtual uint8_t schedule(const RequestorID requestor_id, const uint64_t data)=0
Schedules data - must be defined by derived class.
packet.hh
System::lookupRequestorId
RequestorID lookupRequestorId(const SimObject *obj) const
Looks up the RequestorID for a given SimObject returns an invalid RequestorID (invldRequestorId) if n...
Definition: system.cc:557
RequestorID
uint16_t RequestorID
Definition: request.hh:85
QoS::Policy::init
virtual void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: policy.hh:68
QoS::Policy::setMemCtrl
void setMemCtrl(MemCtrl *mem)
Setting a pointer to the Memory Controller implementing the policy.
Definition: policy.hh:74
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:234
Request::invldRequestorId
@ invldRequestorId
Invalid requestor id for assertion checking only.
Definition: request.hh:255
std::pair
STL pair class.
Definition: stl.hh:58
QoS::Policy::pair
std::pair< RequestorID, T > pair(Requestor requestor, T value)
Builds a RequestorID/value pair given a requestor input.
Definition: policy.hh:116
mem_ctrl.hh
panic_if
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition: logging.hh:197
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
QoS::Policy
QoS Policy base class.
Definition: policy.hh:58
QoS::Policy::Params
QoSPolicyParams Params
Definition: policy.hh:61
mem
bool_vector8 mem[]
Definition: reset_stim.h:43
QoS::MemCtrl::system
System * system() const
read the system pointer
Definition: mem_ctrl.hh:350
QoS::Policy::~Policy
virtual ~Policy()
Definition: policy.cc:48
trace.hh
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
QoS::Policy::Policy
Policy(const Params *p)
Definition: policy.cc:44
QoS::Policy::memCtrl
MemCtrl * memCtrl
Pointer to parent memory controller implementing the policy.
Definition: policy.hh:111
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:92

Generated on Wed Sep 30 2020 14:02:13 for gem5 by doxygen 1.8.17