gem5  v22.1.0.0
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 #include "base/compiler.hh"
45 
46 namespace gem5
47 {
48 
49 GEM5_DEPRECATED_NAMESPACE(SCMI, scmi);
50 namespace scmi
51 {
52 
53 class Platform;
54 struct Message;
55 
57 {
58  SUCCESS = 0,
61  DENIED = -3,
62  NOT_FOUND = -4,
64  BUSY = -6,
68  PROTOCOL_ERROR = -10
69 };
70 
71 class Protocol
72 {
73  public:
74  // All agent-platform communications in the SCMI protocol
75  // are using 15 as a maximum string size, considering the
76  // 16th byte is used for the NULL terminator
77  static const uint32_t MAX_STRING_SIZE = 15;
78 
79  Protocol(Platform &_platform)
80  : platform(_platform)
81  {}
82 
83  virtual ~Protocol() {}
84 
85  virtual void handleMessage(Message &msg) = 0;
86 
87  virtual void version(Message &msg) = 0;
88 
89  virtual void attributes(Message &msg) = 0;
90 
91  virtual void messageAttributes(Message &msg) = 0;
92 
93  const std::string name() const;
94 
95  protected:
97 };
98 
111 class BaseProtocol : public Protocol
112 {
113  static const uint32_t PROTOCOL_VERSION = 0x10000;
114 
115  public:
116  explicit BaseProtocol(Platform &_platform);
117 
118  enum class Commands
119  {
120  VERSION = 0x0,
121  ATTRIBUTES = 0x1,
122  MESSAGE_ATTRIBUTES = 0x2,
123  DISCOVER_VENDOR = 0x3,
124  DISCOVER_SUB_VENDOR = 0x4,
127  DISCOVER_AGENT = 0x7,
128  NOTIFY_ERRORS = 0x8,
132  };
133 
134  // Commands
135  void handleMessage(Message &msg) override;
136  void version(Message &msg) override;
137  void attributes(Message &msg) override;
138  void messageAttributes(Message &msg) override;
139  void discoverVendor(Message &msg);
140  void discoverSubVendor(Message &msg);
141  void discoverImplVersion(Message &msg);
142  void discoverListProtocols(Message &msg);
143  void discoverAgent(Message &msg);
144 
145  // Invalid Command
146  void invalidCommand(Message &msg);
147 
148  protected:
149  bool implementedProtocol(Commands message_id) const;
150 
151  const std::string vendor;
152  const std::string subvendor;
153  const uint32_t implementationVersion;
154 
155 };
156 
157 } // namespace scmi
158 } // namespace gem5
159 
160 #endif
This protocol describes the properties of the implementation and provides generic error management.
const std::string vendor
void discoverImplVersion(Message &msg)
void version(Message &msg) override
void discoverVendor(Message &msg)
void messageAttributes(Message &msg) override
bool implementedProtocol(Commands message_id) const
void discoverListProtocols(Message &msg)
static const uint32_t PROTOCOL_VERSION
void discoverSubVendor(Message &msg)
void invalidCommand(Message &msg)
void discoverAgent(Message &msg)
BaseProtocol(Platform &_platform)
void handleMessage(Message &msg) override
const uint32_t implementationVersion
void attributes(Message &msg) override
const std::string subvendor
virtual void attributes(Message &msg)=0
const std::string name() const
static const uint32_t MAX_STRING_SIZE
Protocol(Platform &_platform)
virtual void handleMessage(Message &msg)=0
virtual void messageAttributes(Message &msg)=0
virtual void version(Message &msg)=0
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)

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