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

Generated on Sat Jun 18 2022 08:12:23 for gem5 by doxygen 1.8.17