gem5  v22.1.0.0
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 
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,
70  END = SENSOR
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__
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:82
ClockedObjectParams Params
Parameters of ClockedObject.
Generic doorbell interface.
Definition: doorbell.hh:54
Ports are used to interface objects to each other.
Definition: port.hh:62
Definition: scp.hh:49
Abstract superclass for simulation objects.
Definition: sim_object.hh:148
This is a Agent to Platform channel (The agent is the initiator)
AgentChannel(const ScmiChannelParams &p)
EventFunctionWrapper handleMessageEvent
EventFunctionWrapper readLengthEvent
EventFunctionWrapper readMessageEvent
The SCMI Communication class models a bidirectional communication between the SCMI platform and the a...
Communication(const ScmiCommunicationParams &p)
PlatformChannel * platformChan
This is a Platform to Agent channel (The platform is the initiator)
EventFunctionWrapper completeEvent
PlatformChannel(const ScmiChannelParams &p)
EventFunctionWrapper notifyAgentEvent
EventFunctionWrapper clearDoorbellEvent
void writeBackMessage(const Message &msg)
static uint32_t protocolID(const Message &msg)
ProtocolList protocols
static uint32_t messageID(const Message &msg)
AgentChannel * find(PlatformChannel *platform) const
std::vector< Communication * > comms
Port & getPort(const std::string &if_name, PortID idx) override
Get a port with a given name and index.
const char * getAgent(unsigned index) const
Returns the name of an agent given an index.
void handleMessage(AgentChannel *ch, Message &msg)
void raiseInterrupt(const Doorbell *doorbell) override
const std::vector< std::string > agents
std::unordered_map< uint8_t, Protocol * > ProtocolList
const ProtocolList & protocolList() const
uint32_t numAgents() const
Returns the number of agents in the system.
void clearInterrupt(const Doorbell *doorbell) override
uint32_t numProtocols() const
Returns the number of protocols implemented, except for the base protocol.
PARAMS(ScmiPlatform)
static uint32_t messageType(const Message &msg)
Platform(const Params &p)
Definition: platform.cc:36
static const uint32_t MAX_STRING_SIZE
Generic communication channel between the Agent and the Platform.
void setPlatform(Platform *_platform)
Set a pointer to the SCMI platform.
VirtualChannel(const ScmiChannelParams &p)
STL vector class.
Definition: stl.hh:37
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
Bitfield< 5, 0 > status
Definition: misc_types.hh:429
Bitfield< 30, 0 > index
Bitfield< 54 > p
Definition: pagetable.hh:70
Bitfield< 9, 8 > messageType
Bitfield< 7, 0 > messageId
static const uint8_t PROTOCOL_MAX
Bitfield< 17, 10 > protocolId
EndBitUnion(MessageHeader) union Payload
BitUnion32(MessageHeader) Bitfield< 27
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:245
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
const std::string & name()
Definition: trace.cc:49

Generated on Wed Dec 21 2022 10:22:32 for gem5 by doxygen 1.9.1