ngscopeclient 0.1-dev+51fbda87c
ESPIDecoder.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopeprotocols *
4* *
5* Copyright (c) 2012-2022 Andrew D. Zonenberg and contributors *
6* All rights reserved. *
7* *
8* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
9* following conditions are met: *
10* *
11* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
12* following disclaimer. *
13* *
14* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
15* following disclaimer in the documentation and/or other materials provided with the distribution. *
16* *
17* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
18* derived from this software without specific prior written permission. *
19* *
20* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
21* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
22* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
24* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
26* POSSIBILITY OF SUCH DAMAGE. *
27* *
28***********************************************************************************************************************/
29
35#ifndef ESPIDecoder_h
36#define ESPIDecoder_h
37
38#include "../scopehal/PacketDecoder.h"
39
41{
42public:
43
44 enum ESpiType
45 {
46 TYPE_COMMAND_TYPE,
47
48 TYPE_CAPS_ADDR,
49
50 TYPE_COMMAND_DATA_8,
51 TYPE_COMMAND_DATA_32,
52 TYPE_COMMAND_CRC_GOOD,
53 TYPE_COMMAND_CRC_BAD,
54
55 TYPE_RESPONSE_OP,
56 TYPE_RESPONSE_STATUS,
57 TYPE_RESPONSE_DATA_32,
58 TYPE_RESPONSE_CRC_GOOD,
59 TYPE_RESPONSE_CRC_BAD,
60
61 TYPE_VWIRE_COUNT,
62 TYPE_VWIRE_INDEX,
63 TYPE_VWIRE_DATA,
64
65 TYPE_GENERAL_CAPS_RD,
66 TYPE_GENERAL_CAPS_WR,
67 TYPE_CH0_CAPS_RD,
68 TYPE_CH0_CAPS_WR,
69 TYPE_CH1_CAPS_RD,
70 TYPE_CH1_CAPS_WR,
71 TYPE_CH2_CAPS_RD,
72 TYPE_CH2_CAPS_WR,
73
74 TYPE_REQUEST_TAG,
75 TYPE_REQUEST_LEN,
76
77 TYPE_FLASH_REQUEST_TYPE,
78 TYPE_FLASH_REQUEST_ADDR,
79 TYPE_FLASH_REQUEST_DATA,
80
81 TYPE_SMBUS_REQUEST_TYPE,
82 TYPE_SMBUS_REQUEST_ADDR,
83 TYPE_SMBUS_REQUEST_DATA,
84
85 TYPE_IO_ADDR,
86 TYPE_IO_DATA,
87
88 TYPE_WAIT,
89
90 TYPE_COMPLETION_TYPE,
91 TYPE_COMPLETION_DATA,
92
93 TYPE_ERROR
94 } m_type;
95
96 //Table 3
97 enum ESpiCommand
98 {
99 //Table 6
100 COMMAND_PUT_PC = 0x00,
101 COMMAND_GET_PC = 0x01,
102 COMMAND_PUT_NP = 0x02,
103 COMMAND_GET_NP = 0x03,
104 COMMAND_PUT_OOB = 0x06,
105 COMMAND_GET_OOB = 0x07,
106 COMMAND_PUT_FLASH_C = 0x08,
107 COMMAND_GET_FLASH_NP = 0x09,
108
109 //Figure 37
110 COMMAND_PUT_IORD_SHORT_x1 = 0x40,
111 COMMAND_PUT_IORD_SHORT_x2 = 0x41,
112 COMMAND_PUT_IORD_SHORT_x4 = 0x43,
113 COMMAND_PUT_IOWR_SHORT_x1 = 0x44,
114 COMMAND_PUT_IOWR_SHORT_x2 = 0x45,
115 COMMAND_PUT_IOWR_SHORT_x4 = 0x47,
116 COMMAND_PUT_MEMRD32_SHORT_x1 = 0x48,
117 COMMAND_PUT_MEMRD32_SHORT_x2 = 0x49,
118 COMMAND_PUT_MEMRD32_SHORT_x4 = 0x4b,
119 COMMAND_PUT_MEMWR32_SHORT_x1 = 0x4c,
120 COMMAND_PUT_MEMWR32_SHORT_x2 = 0x4d,
121 COMMAND_PUT_MEMWR32_SHORT_x4 = 0x4f,
122
123 //Figure 40
124 COMMAND_PUT_VWIRE = 0x04,
125 COMMAND_GET_VWIRE = 0x05,
126
127 COMMAND_GET_STATUS = 0x25,
128 COMMAND_SET_CONFIGURATION = 0x22,
129 COMMAND_GET_CONFIGURATION = 0x21,
130 COMMAND_RESET = 0xff,
131
132 COMMAND_NONE = 0x100
133 };
134
135 //Table 4
136 enum ESpiResponse
137 {
138 RESPONSE_DEFER = 0x1,
139 RESPONSE_NONFATAL_ERROR = 0x2,
140 RESPONSE_FATAL_ERROR = 0x3,
141 RESPONSE_ACCEPT = 0x8,
142 RESPONSE_NONE = 0xf //also NO_RESPONSE with other bits high
143 };
144
145 enum ESpiCompletion
146 {
147 COMPLETION_NONE = 0,
148 COMPLETION_PERIPHERAL = 1,
149 COMPLETION_VWIRE = 2,
150 COMPLETION_FLASH = 3
151 };
152
153 //Table 6
154 enum ESpiCycleType
155 {
156 CYCLE_READ = 0,
157 CYCLE_WRITE = 1,
158 CYCLE_ERASE = 2,
159
160 CYCLE_SMBUS = 0x21,
161
162 // completion types
163 CYCLE_SUCCESS_NODATA = 0x06,
164 CYCLE_SUCCESS_DATA_MIDDLE = 0x09,
165 CYCLE_SUCCESS_DATA_FIRST = 0x0b,
166 CYCLE_SUCCESS_DATA_LAST = 0x0d,
167 CYCLE_SUCCESS_DATA_ONLY = 0x0f,
168
169 CYCLE_FAIL_LAST = 0x08,
170 CYCLE_FAIL_ONLY = 0x0e
171 };
172
173 uint64_t m_data;
174 ESPISymbol()
175 {}
176
177 ESPISymbol(ESpiType type, uint64_t data = 0)
178 : m_type(type)
179 , m_data(data)
180 {}
181
182 bool operator== (const ESPISymbol& s) const
183 {
184 return (m_type == s.m_type) && (m_data == s.m_data);
185 }
186};
187
188class ESPIWaveform : public SparseWaveform<ESPISymbol>
189{
190public:
192 virtual std::string GetText(size_t) override;
193 virtual std::string GetColor(size_t) override;
194};
195
202{
203public:
204 ESPIDecoder(const std::string& color);
205
206 virtual void Refresh() override;
207
208 std::vector<std::string> GetHeaders() override;
209
210 static std::string GetProtocolName();
211
212 virtual bool ValidateChannel(size_t i, StreamDescriptor stream) override;
213
214 virtual bool CanMerge(Packet* first, Packet* cur, Packet* next) override;
215 virtual Packet* CreateMergedHeader(Packet* pack, size_t i) override;
216
217 PROTOCOL_DECODER_INITPROC(ESPIDecoder)
218
219protected:
220 uint8_t UpdateCRC8(uint8_t crc, uint8_t data);
221
222 enum BusWidth
223 {
224 BUS_WIDTH_AUTO,
225 BUS_WIDTH_X1,
226 BUS_WIDTH_X4
227 };
228
229 std::string m_busWidthName;
230};
231
232#endif
Decoder for Intel Enhanced Serial Peripheral Interface (eSPI)
Definition: ESPIDecoder.h:202
virtual void Refresh() override
Evaluates a filter graph node.
Definition: ESPIDecoder.cpp:97
virtual bool CanMerge(Packet *first, Packet *cur, Packet *next) override
Checks if multiple packets can be merged under a single heading in the protocol analyzer view.
Definition: ESPIDecoder.cpp:2088
virtual Packet * CreateMergedHeader(Packet *pack, size_t i) override
Creates a summary packet for one or more merged packets.
Definition: ESPIDecoder.cpp:2167
Definition: ESPIDecoder.h:41
Definition: ESPIDecoder.h:189
virtual std::string GetColor(size_t) override
Returns the displayed color (in HTML #rrggbb or #rrggbbaa notation) of a given protocol sample.
Definition: ESPIDecoder.cpp:1466
virtual std::string GetText(size_t) override
Returns the text representation of a given protocol sample.
Definition: ESPIDecoder.cpp:1543
Definition: PacketDecoder.h:85
Definition: PacketDecoder.h:40
A waveform sampled at irregular intervals.
Definition: Waveform.h:460
Descriptor for a single stream coming off a channel.
Definition: StreamDescriptor.h:46