gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
47namespace gem5
48{
49
50class Doorbell;
51
52namespace scmi
53{
54
55class Platform;
56
57// Maximum number of protocols defined by the SCMI specification
58static const uint8_t PROTOCOL_MAX = 6;
59
60enum ProtocolID : uint8_t
61{
62 BASE = 0x10,
63 START = 0x11,
67 CLOCK = 0x14,
68 SENSOR = 0x15,
69 END = SENSOR
70};
71
72enum class MessageType
73{
74 COMMANDS = 0,
77};
78
79BitUnion32(MessageHeader)
80 Bitfield<27,18> token;
81 Bitfield<17,10> protocolId;
82 Bitfield<9,8> messageType;
83 Bitfield<7,0> messageId;
84EndBitUnion(MessageHeader)
85
86union 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
158{
159 uint32_t reserved0;
161 uint64_t reserved1;
162 uint32_t mailboxFlags;
163 uint32_t length;
164 uint32_t header;
165 Payload payload;
166};
167
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
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
253{
254 public:
255 Communication(const ScmiCommunicationParams &p)
256 : SimObject(p), platformChan(p.platform_channel),
257 agentChan(p.agent_channel)
258 {}
259
262};
263
264class 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
310 {
311 return bits(msg.header, 9, 8);
312 }
313
314 const ProtocolList&
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__
#define BitUnion32(name)
Definition bitunion.hh:495
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
Abstract superclass for simulation objects.
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)
static uint32_t messageID(const Message &msg)
AgentChannel * find(PlatformChannel *platform) const
std::vector< Communication * > comms
const char * getAgent(unsigned index) const
Returns the name of an agent given an index.
Port & getPort(const std::string &if_name, PortID idx) override
Get a port with a given name and index.
void handleMessage(AgentChannel *ch, Message &msg)
void raiseInterrupt(const Doorbell *doorbell) override
const std::vector< std::string > agents
const ProtocolList & protocolList() const
std::unordered_map< uint8_t, Protocol * > ProtocolList
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:79
#define EndBitUnion(name)
This closes off the class and union started by the above macro.
Definition bitunion.hh:428
Bitfield< 5, 0 > status
Bitfield< 30, 0 > index
Bitfield< 0 > p
Bitfield< 9, 8 > messageType
Bitfield< 7, 0 > messageId
static const uint8_t PROTOCOL_MAX
Bitfield< 17, 10 > protocolId
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition types.hh:245
const std::string & name()
Definition trace.cc:48

Generated on Tue Jun 18 2024 16:24:02 for gem5 by doxygen 1.11.0