gem5  v21.0.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
scmi_platform.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 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 
38 #ifndef __DEV_ARM_CSS_SCMI_PLATFORM_H__
39 #define __DEV_ARM_CSS_SCMI_PLATFORM_H__
40 
42 #include "dev/arm/css/scp.hh"
43 #include "dev/dma_device.hh"
44 #include "mem/mem_object.hh"
45 #include "params/ScmiPlatform.hh"
46 
47 class Doorbell;
48 
49 namespace SCMI
50 {
51 
52 class Platform;
53 
54 // Maximum number of protocols defined by the SCMI specification
55 static const uint8_t PROTOCOL_MAX = 6;
56 
57 enum ProtocolID : uint8_t
58 {
59  BASE = 0x10,
60  START = 0x11,
62  SYSTEM_POWER = 0x12,
64  CLOCK = 0x14,
65  SENSOR = 0x15,
67 };
68 
69 enum class MessageType
70 {
71  COMMANDS = 0,
73  NOTIFICATIONS = 3
74 };
75 
76 BitUnion32(MessageHeader)
77  Bitfield<27,18> token;
78  Bitfield<17,10> protocolId;
79  Bitfield<9,8> messageType;
80  Bitfield<7,0> messageId;
81 EndBitUnion(MessageHeader)
82 
83 union Payload
84 {
85  struct
86  {
87  int32_t status;
88  } invalidCommand;
89 
90  struct
91  {
92  int32_t status;
93  uint32_t version;
94  } baseProtocolVersion;
95 
96  struct
97  {
98  int32_t status;
99  uint32_t attributes;
100  } baseProtocolAttributes;
101 
102  struct
103  {
104  union
105  {
106  int32_t status;
107  uint32_t messageId;
108  };
109  uint32_t attributes;
110  } baseProtocolMessageAttributes;
111 
112  struct
113  {
114  int32_t status;
115  uint8_t vendorIdentifier[Protocol::MAX_STRING_SIZE + 1];
116  } baseDiscoverVendor;
117 
118  struct
119  {
120  int32_t status;
121  uint8_t vendorIdentifier[Protocol::MAX_STRING_SIZE + 1];
122  } baseDiscoverSubVendor;
123 
124  struct
125  {
126  int32_t status;
127  uint32_t implementationVersion;
128  } baseDiscoverImplementationVersion;
129 
130  struct
131  {
132  union
133  {
134  uint32_t skip;
135  int32_t status;
136  };
137  uint32_t numProtocols;
138  uint32_t protocols[(PROTOCOL_MAX - 1)/ 4];
139  } baseDiscoverListProtocols;
140 
141  struct
142  {
143  union
144  {
145  uint32_t agentId;
146  int32_t status;
147  };
148  uint8_t name[Protocol::MAX_STRING_SIZE + 1];
149  } baseDiscoverAgent;
150 
151  int32_t status;
152 };
153 
154 struct Message
155 {
156  uint32_t reserved0;
157  uint32_t channelStatus;
158  uint64_t reserved1;
159  uint32_t mailboxFlags;
160  uint32_t length;
161  uint32_t header;
162  Payload payload;
163 };
164 
168 class VirtualChannel : public SimObject
169 {
170  public:
171  VirtualChannel(const ScmiChannelParams &p)
172  : SimObject(p),
173  msgBuffer(), pendingMessage(false), shmem(p.shmem_range),
174  physID(p.phys_id), virtID(p.virt_id),
176  {}
177 
179  void
180  setPlatform(Platform *_platform)
181  {
182  platform = _platform;
183  }
184 
187 
189 
190  const uint32_t physID;
191  const uint32_t virtID;
192 
196 
197  private:
198  static const int dmaSize = 8; // 64 bits
199 };
200 
205 {
206  public:
207  AgentChannel(const ScmiChannelParams &p);
208 
209  void initiateRead();
210 
211  void readStatus();
212  void readLength();
213  void readMessage();
214  void handleMessage();
215 
219 };
220 
225 {
226  public:
227  PlatformChannel(const ScmiChannelParams &p);
228 
229  void writeBackMessage(const Message &msg);
230  void notifyAgent();
231  void clearDoorbell();
232  void complete();
233 
237 
238  protected:
241 };
242 
249 class Communication : public SimObject
250 {
251  public:
252  Communication(const ScmiCommunicationParams &p)
253  : SimObject(p), platformChan(p.platform_channel),
254  agentChan(p.agent_channel)
255  {}
256 
259 };
260 
261 class Platform : public Scp
262 {
263  public:
264  using ProtocolList = std::unordered_map<uint8_t, Protocol *>;
265 
266  PARAMS(ScmiPlatform);
267  Platform(const Params &p);
268  ~Platform();
269 
270  void handleMessage(AgentChannel *ch, Message &msg);
271 
273  uint32_t numAgents() const { return agents.size(); }
274 
276  const char*
277  getAgent(unsigned index) const
278  {
279  return agents[index].c_str();
280  }
281 
286  uint32_t numProtocols() const { return protocols.size() - 1; }
287 
288  Port& getPort(const std::string &if_name, PortID idx) override;
289 
290  void raiseInterrupt(const Doorbell *doorbell) override;
291  void clearInterrupt(const Doorbell *doorbell) override;
292 
293  static uint32_t
294  protocolID(const Message &msg)
295  {
296  return bits(msg.header, 17, 10);
297  }
298 
299  static uint32_t
300  messageID(const Message &msg)
301  {
302  return bits(msg.header, 7, 0);
303  }
304 
305  static uint32_t
306  messageType(const Message &msg)
307  {
308  return bits(msg.header, 9, 8);
309  }
310 
311  const ProtocolList&
312  protocolList() const
313  {
314  return protocols;
315  }
316 
317  AgentChannel* find(PlatformChannel* platform) const;
318  PlatformChannel* find(AgentChannel* agent) const;
319 
320  private:
323 
325 
327 };
328 
329 } // namespace SCMI
330 
331 #endif // __DEV_ARM_CSS_SCMI_PLATFORM_H__
SCMI::START
@ START
Definition: scmi_platform.hh:60
SCMI::PlatformChannel::agentDoorbellVal
uint32_t agentDoorbellVal
Definition: scmi_platform.hh:239
SCMI::Platform::protocols
ProtocolList protocols
Definition: scmi_platform.hh:324
SCMI::Platform::agents
const std::vector< std::string > agents
Definition: scmi_platform.hh:322
ArmISA::status
Bitfield< 5, 0 > status
Definition: miscregs_types.hh:417
SCMI::AgentChannel::readLength
void readLength()
Definition: scmi_platform.cc:82
SCMI::VirtualChannel::doorbell
Doorbell * doorbell
Definition: scmi_platform.hh:194
SCMI::PlatformChannel::PlatformChannel
PlatformChannel(const ScmiChannelParams &p)
Definition: scmi_platform.cc:132
SCMI::PlatformChannel::clearDoorbellEvent
EventFunctionWrapper clearDoorbellEvent
Definition: scmi_platform.hh:234
SCMI::VirtualChannel::msgBuffer
Message msgBuffer
Definition: scmi_platform.hh:185
SCMI::Communication::Communication
Communication(const ScmiCommunicationParams &p)
Definition: scmi_platform.hh:252
MipsISA::index
Bitfield< 30, 0 > index
Definition: pra_constants.hh:44
SCMI::MessageType::NOTIFICATIONS
@ NOTIFICATIONS
SCMI::Communication::agentChan
AgentChannel * agentChan
Definition: scmi_platform.hh:258
SCMI::PERFORMANCE_DOMAIN
@ PERFORMANCE_DOMAIN
Definition: scmi_platform.hh:63
SCMI::Platform::ProtocolList
std::unordered_map< uint8_t, Protocol * > ProtocolList
Definition: scmi_platform.hh:264
SCMI::Message::header
uint32_t header
Definition: scmi_platform.hh:161
Doorbell
Generic doorbell interface.
Definition: doorbell.hh:50
SCMI::VirtualChannel::platform
Platform * platform
Definition: scmi_platform.hh:195
SCMI::AgentChannel
This is a Agent to Platform channel (The agent is the initiator)
Definition: scmi_platform.hh:204
PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:243
SCMI::Message::channelStatus
uint32_t channelStatus
Definition: scmi_platform.hh:157
SCMI::Platform::find
AgentChannel * find(PlatformChannel *platform) const
Definition: scmi_platform.cc:284
SCMI::Message::payload
Payload payload
Definition: scmi_platform.hh:162
SCMI::AgentChannel::readStatus
void readStatus()
Definition: scmi_platform.cc:68
SCMI::Platform::messageType
static uint32_t messageType(const Message &msg)
Definition: scmi_platform.hh:306
std::vector
STL vector class.
Definition: stl.hh:37
SCMI::VirtualChannel::VirtualChannel
VirtualChannel(const ScmiChannelParams &p)
Definition: scmi_platform.hh:171
SCMI::Platform::getAgent
const char * getAgent(unsigned index) const
Returns the name of an agent given an index.
Definition: scmi_platform.hh:277
SCMI::AgentChannel::handleMessageEvent
EventFunctionWrapper handleMessageEvent
Definition: scmi_platform.hh:218
SCMI::Platform::numAgents
uint32_t numAgents() const
Returns the number of agents in the system.
Definition: scmi_platform.hh:273
SCMI::Platform::messageID
static uint32_t messageID(const Message &msg)
Definition: scmi_platform.hh:300
SCMI::Platform::comms
std::vector< Communication * > comms
Definition: scmi_platform.hh:321
SCMI::Platform::numProtocols
uint32_t numProtocols() const
Returns the number of protocols implemented, except for the base protocol.
Definition: scmi_platform.hh:286
SCMI::AgentChannel::handleMessage
void handleMessage()
Definition: scmi_platform.cc:120
SCMI::Platform
Definition: scmi_platform.hh:261
SCMI::PlatformChannel::clearDoorbell
void clearDoorbell()
Definition: scmi_platform.cc:161
SCMI::Platform::PARAMS
PARAMS(ScmiPlatform)
EventFunctionWrapper
Definition: eventq.hh:1112
SCMI::Platform::handleMessage
void handleMessage(AgentChannel *ch, Message &msg)
Definition: scmi_platform.cc:236
SCMI::Communication::platformChan
PlatformChannel * platformChan
Definition: scmi_platform.hh:257
scp.hh
SCMI::messageType
Bitfield< 9, 8 > messageType
Definition: scmi_platform.hh:79
SCMI::Protocol::MAX_STRING_SIZE
static const uint32_t MAX_STRING_SIZE
Definition: scmi_protocols.hh:71
SCMI::Communication
The SCMI Communication class models a bidirectional communication between the SCMI platform and the a...
Definition: scmi_platform.hh:249
SCMI::SENSOR
@ SENSOR
Definition: scmi_platform.hh:65
dma_device.hh
scmi_protocols.hh
SCMI::Message::length
uint32_t length
Definition: scmi_platform.hh:160
ClockedObject::Params
ClockedObjectParams Params
Parameters of ClockedObject.
Definition: clocked_object.hh:237
SCMI::VirtualChannel
Generic communication channel between the Agent and the Platform.
Definition: scmi_platform.hh:168
AddrRange
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:68
SCMI::Message::reserved0
uint32_t reserved0
Definition: scmi_platform.hh:156
SCMI::PlatformChannel::notifyAgentEvent
EventFunctionWrapper notifyAgentEvent
Definition: scmi_platform.hh:235
SCMI::Platform::clearInterrupt
void clearInterrupt(const Doorbell *doorbell) override
Definition: scmi_platform.cc:278
SCMI::protocolId
Bitfield< 17, 10 > protocolId
Definition: scmi_platform.hh:78
SCMI::Platform::dmaPort
DmaPort dmaPort
Definition: scmi_platform.hh:326
SCMI::VirtualChannel::dmaSize
static const int dmaSize
Definition: scmi_platform.hh:198
SCMI::SYSTEM_POWER
@ SYSTEM_POWER
Definition: scmi_platform.hh:62
Port
Ports are used to interface objects to each other.
Definition: port.hh:56
SCMI::MessageType::DELAYED_RESPONSES
@ DELAYED_RESPONSES
SCMI::Message::mailboxFlags
uint32_t mailboxFlags
Definition: scmi_platform.hh:159
SCMI::Platform::Platform
Platform(const Params &p)
SCMI::CLOCK
@ CLOCK
Definition: scmi_platform.hh:64
SCMI::AgentChannel::readMessageEvent
EventFunctionWrapper readMessageEvent
Definition: scmi_platform.hh:217
SCMI::token
token
Definition: scmi_platform.hh:77
SCMI::Platform::~Platform
~Platform()
Definition: scmi_platform.cc:219
SCMI::MessageType::COMMANDS
@ COMMANDS
Scp
Definition: scp.hh:45
SCMI::PlatformChannel::writeBackMessage
void writeBackMessage(const Message &msg)
Definition: scmi_platform.cc:142
SCMI::BASE
@ BASE
Definition: scmi_platform.hh:59
SCMI::VirtualChannel::setPlatform
void setPlatform(Platform *_platform)
Set a pointer to the SCMI platform.
Definition: scmi_platform.hh:180
name
const std::string & name()
Definition: trace.cc:48
SCMI::ProtocolID
ProtocolID
Definition: scmi_platform.hh:57
SCMI::Platform::protocolID
static uint32_t protocolID(const Message &msg)
Definition: scmi_platform.hh:294
SCMI::VirtualChannel::virtID
const uint32_t virtID
Definition: scmi_platform.hh:191
SCMI::PlatformChannel::completeEvent
EventFunctionWrapper completeEvent
Definition: scmi_platform.hh:236
SCMI::PlatformChannel::complete
void complete()
Definition: scmi_platform.cc:193
SCMI::PlatformChannel::notifyAgent
void notifyAgent()
Definition: scmi_platform.cc:179
SCMI::AgentChannel::readLengthEvent
EventFunctionWrapper readLengthEvent
Definition: scmi_platform.hh:216
SCMI::Message::reserved1
uint64_t reserved1
Definition: scmi_platform.hh:158
SCMI::BitUnion32
BitUnion32(MessageHeader) Bitfield< 27
SCMI::VirtualChannel::pendingMessage
bool pendingMessage
Definition: scmi_platform.hh:186
SCMI::Platform::getPort
Port & getPort(const std::string &if_name, PortID idx) override
Get a port with a given name and index.
Definition: scmi_platform.cc:227
SCMI::MessageType
MessageType
Definition: scmi_platform.hh:69
SCMI::PROTOCOL_MAX
static const uint8_t PROTOCOL_MAX
Definition: scmi_platform.hh:55
SCMI::Platform::raiseInterrupt
void raiseInterrupt(const Doorbell *doorbell) override
Definition: scmi_platform.cc:256
SCMI::Platform::protocolList
const ProtocolList & protocolList() const
Definition: scmi_platform.hh:312
SCMI::VirtualChannel::physID
const uint32_t physID
Definition: scmi_platform.hh:190
SCMI::AgentChannel::initiateRead
void initiateRead()
Definition: scmi_platform.cc:56
SCMI::Message
Definition: scmi_platform.hh:154
bits
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition: bitfield.hh:73
SCMI::AgentChannel::readMessage
void readMessage()
Definition: scmi_platform.cc:105
SCMI::END
@ END
Definition: scmi_platform.hh:66
mem_object.hh
SCMI::VirtualChannel::dmaPort
DmaPort * dmaPort
Definition: scmi_platform.hh:193
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
SCMI::EndBitUnion
EndBitUnion(MessageHeader) union Payload
Definition: scmi_platform.hh:81
DmaPort
Definition: dma_device.hh:58
SCMI
Definition: scmi_platform.hh:49
SCMI::VirtualChannel::shmem
const AddrRange shmem
Definition: scmi_platform.hh:188
SCMI::PlatformChannel::platformDoorbellVal
uint32_t platformDoorbellVal
Definition: scmi_platform.hh:240
SCMI::AgentChannel::AgentChannel
AgentChannel(const ScmiChannelParams &p)
Definition: scmi_platform.cc:48
SCMI::messageId
Bitfield< 7, 0 > messageId
Definition: scmi_platform.hh:80
SCMI::POWER_DOMAIN
@ POWER_DOMAIN
Definition: scmi_platform.hh:61
SCMI::PlatformChannel
This is a Platform to Agent channel (The platform is the initiator)
Definition: scmi_platform.hh:224
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:141

Generated on Tue Jun 22 2021 15:28:27 for gem5 by doxygen 1.8.17