gem5  v21.0.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
scmi_protocols.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_PROTOCOLS_H__
39 #define __DEV_ARM_CSS_SCMI_PROTOCOLS_H__
40 
41 #include <cstdint>
42 #include <string>
43 
44 namespace SCMI
45 {
46 
47 class Platform;
48 struct Message;
49 
51 {
52  SUCCESS = 0,
55  DENIED = -3,
56  NOT_FOUND = -4,
58  BUSY = -6,
63 };
64 
65 class Protocol
66 {
67  public:
68  // All agent-platform communications in the SCMI protocol
69  // are using 15 as a maximum string size, considering the
70  // 16th byte is used for the NULL terminator
71  static const uint32_t MAX_STRING_SIZE = 15;
72 
73  Protocol(Platform &_platform)
74  : platform(_platform)
75  {}
76 
77  virtual ~Protocol() {}
78 
79  virtual void handleMessage(Message &msg) = 0;
80 
81  virtual void version(Message &msg) = 0;
82 
83  virtual void attributes(Message &msg) = 0;
84 
85  virtual void messageAttributes(Message &msg) = 0;
86 
87  const std::string name() const;
88 
89  protected:
91 };
92 
105 class BaseProtocol : public Protocol
106 {
107  static const uint32_t PROTOCOL_VERSION = 0x10000;
108 
109  public:
110  explicit BaseProtocol(Platform &_platform);
111 
112  enum class Commands
113  {
114  VERSION = 0x0,
115  ATTRIBUTES = 0x1,
116  MESSAGE_ATTRIBUTES = 0x2,
117  DISCOVER_VENDOR = 0x3,
118  DISCOVER_SUB_VENDOR = 0x4,
121  DISCOVER_AGENT = 0x7,
122  NOTIFY_ERRORS = 0x8,
126  };
127 
128  // Commands
129  void handleMessage(Message &msg) override;
130  void version(Message &msg) override;
131  void attributes(Message &msg) override;
132  void messageAttributes(Message &msg) override;
133  void discoverVendor(Message &msg);
134  void discoverSubVendor(Message &msg);
135  void discoverImplVersion(Message &msg);
136  void discoverListProtocols(Message &msg);
137  void discoverAgent(Message &msg);
138 
139  // Invalid Command
140  void invalidCommand(Message &msg);
141 
142  protected:
143  bool implementedProtocol(Commands message_id) const;
144 
145  const std::string vendor;
146  const std::string subvendor;
147  const uint32_t implementationVersion;
148 
149 };
150 
151 }; // namespace SCMI
152 
153 #endif
SCMI::Protocol
Definition: scmi_protocols.hh:65
SCMI::BaseProtocol::vendor
const std::string vendor
Definition: scmi_protocols.hh:145
SCMI::Protocol::attributes
virtual void attributes(Message &msg)=0
SCMI::BaseProtocol::Commands::DISCOVER_SUB_VENDOR
@ DISCOVER_SUB_VENDOR
SCMI::SUCCESS
@ SUCCESS
Definition: scmi_protocols.hh:52
SCMI::Protocol::~Protocol
virtual ~Protocol()
Definition: scmi_protocols.hh:77
SCMI::INVALID_PARAMETERS
@ INVALID_PARAMETERS
Definition: scmi_protocols.hh:54
SCMI::Protocol::name
const std::string name() const
Definition: scmi_protocols.cc:46
SCMI::BaseProtocol::Commands::DISCOVER_IMPLEMENTATION_VERSION
@ DISCOVER_IMPLEMENTATION_VERSION
SCMI::BaseProtocol::BaseProtocol
BaseProtocol(Platform &_platform)
Definition: scmi_protocols.cc:51
SCMI::BaseProtocol::Commands::SET_DEVICE_PERMISSIONS
@ SET_DEVICE_PERMISSIONS
SCMI::BaseProtocol::Commands::DISCOVER_LIST_PROTOCOLS
@ DISCOVER_LIST_PROTOCOLS
SCMI::BaseProtocol::implementationVersion
const uint32_t implementationVersion
Definition: scmi_protocols.hh:147
SCMI::BaseProtocol::discoverImplVersion
void discoverImplVersion(Message &msg)
Definition: scmi_protocols.cc:199
SCMI::BaseProtocol::Commands::RESET_AGENT_CONFIGURATION
@ RESET_AGENT_CONFIGURATION
SCMI::OUT_OF_RANGE
@ OUT_OF_RANGE
Definition: scmi_protocols.hh:57
SCMI::BaseProtocol::implementedProtocol
bool implementedProtocol(Commands message_id) const
Definition: scmi_protocols.cc:135
SCMI::BaseProtocol::PROTOCOL_VERSION
static const uint32_t PROTOCOL_VERSION
Definition: scmi_protocols.hh:107
SCMI::BaseProtocol::Commands::VERSION
@ VERSION
SCMI::Platform
Definition: scmi_platform.hh:261
SCMI::BaseProtocol::discoverAgent
void discoverAgent(Message &msg)
Definition: scmi_protocols.cc:244
SCMI::BaseProtocol::Commands::SET_PROTOCOL_PERMISSIONS
@ SET_PROTOCOL_PERMISSIONS
SCMI::Protocol::MAX_STRING_SIZE
static const uint32_t MAX_STRING_SIZE
Definition: scmi_protocols.hh:71
SCMI::Protocol::platform
Platform & platform
Definition: scmi_protocols.hh:90
SCMI::BaseProtocol::discoverListProtocols
void discoverListProtocols(Message &msg)
Definition: scmi_protocols.cc:210
SCMI::Protocol::Protocol
Protocol(Platform &_platform)
Definition: scmi_protocols.hh:73
SCMI::BaseProtocol::subvendor
const std::string subvendor
Definition: scmi_protocols.hh:146
SCMI::NOT_FOUND
@ NOT_FOUND
Definition: scmi_protocols.hh:56
SCMI::Protocol::version
virtual void version(Message &msg)=0
SCMI::Protocol::messageAttributes
virtual void messageAttributes(Message &msg)=0
Platform
Definition: platform.hh:49
SCMI::HARDWARE_ERROR
@ HARDWARE_ERROR
Definition: scmi_protocols.hh:61
SCMI::BaseProtocol::Commands::MESSAGE_ATTRIBUTES
@ MESSAGE_ATTRIBUTES
SCMI::StatusCode
StatusCode
Definition: scmi_protocols.hh:50
SCMI::COMMS_ERROR
@ COMMS_ERROR
Definition: scmi_protocols.hh:59
SCMI::BaseProtocol::messageAttributes
void messageAttributes(Message &msg) override
Definition: scmi_protocols.cc:153
SCMI::BaseProtocol::discoverVendor
void discoverVendor(Message &msg)
Definition: scmi_protocols.cc:173
SCMI::BaseProtocol::discoverSubVendor
void discoverSubVendor(Message &msg)
Definition: scmi_protocols.cc:186
SCMI::NOT_SUPPORTED
@ NOT_SUPPORTED
Definition: scmi_protocols.hh:53
SCMI::BaseProtocol::invalidCommand
void invalidCommand(Message &msg)
Definition: scmi_protocols.cc:277
SCMI::BaseProtocol
This protocol describes the properties of the implementation and provides generic error management.
Definition: scmi_protocols.hh:105
SCMI::Protocol::handleMessage
virtual void handleMessage(Message &msg)=0
SCMI::BaseProtocol::Commands::NOTIFY_ERRORS
@ NOTIFY_ERRORS
SCMI::PROTOCOL_ERROR
@ PROTOCOL_ERROR
Definition: scmi_protocols.hh:62
SCMI::DENIED
@ DENIED
Definition: scmi_protocols.hh:55
SCMI::BaseProtocol::Commands::DISCOVER_AGENT
@ DISCOVER_AGENT
SCMI::BUSY
@ BUSY
Definition: scmi_protocols.hh:58
SCMI::BaseProtocol::version
void version(Message &msg) override
Definition: scmi_protocols.cc:108
SCMI::Message
Definition: scmi_platform.hh:154
Message
Definition: Message.hh:56
SCMI::BaseProtocol::Commands
Commands
Definition: scmi_protocols.hh:112
SCMI::BaseProtocol::handleMessage
void handleMessage(Message &msg) override
Definition: scmi_protocols.cc:64
SCMI::BaseProtocol::Commands::ATTRIBUTES
@ ATTRIBUTES
SCMI
Definition: scmi_platform.hh:49
SCMI::BaseProtocol::attributes
void attributes(Message &msg) override
Definition: scmi_protocols.cc:119
SCMI::BaseProtocol::Commands::DISCOVER_VENDOR
@ DISCOVER_VENDOR
SCMI::GENERIC_ERROR
@ GENERIC_ERROR
Definition: scmi_protocols.hh:60

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