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

Generated on Wed Jul 28 2021 12:10:25 for gem5 by doxygen 1.8.17