TianoCore EDK2 master
Loading...
Searching...
No Matches
Cxl20.h
Go to the documentation of this file.
1
13#ifndef CXL20_H_
14#define CXL20_H_
15
17
18//
19// CXL DVSEC IDs
20// Compute Express Link Specification Revision 2.0 - Chapter 8.1.1
21//
22#define CXL_DVSEC_ID_PCIE_DVSEC_FOR_CXL_DEVICE 0x0
23#define CXL_DVSEC_ID_NON_CXL_FUNCTION_MAP 0x2
24#define CXL_DVSEC_ID_CXL20_EXTENSIONS_DVSEC_FOR_PORTS 0x3
25#define CXL_DVSEC_ID_GPF_DVSEC_FOR_CXL_PORTS 0x4
26#define CXL_DVSEC_ID_GPF_DVSEC_FOR_CXL_DEVICES 0x5
27#define CXL_DVSEC_ID_PCIE_DVSEC_FOR_FLEX_BUS_PORT 0x7
28#define CXL_DVSEC_ID_REGISTER_LOCATOR 0x8
29#define CXL_DVSEC_ID_MLD 0x9
30#define CXL_DVSEC_ID_PCIE_DVSEC_FOR_TEST_CAPABILITY 0xA
31
32//
33// Register Block ID
34// Compute Express Link Specification Revision 2.0 - Chapter 8.1.9.1
35//
36#define CXL_REGISTER_BLOCK_ID_EMPTY 0x0
37#define CXL_REGISTER_BLOCK_ID_COMPONENT 0x1
38#define CXL_REGISTER_BLOCK_ID_BAR_VIRTUALIZATION_ACL 0x2
39#define CXL_REGISTER_BLOCK_ID_DEVICE 0x3
40
41//
42// CXL component register layout
43// Compute Express Link Specification Revision 2.0 - Chapter 8.2.4
44//
45// |------------------------------------|
46// |--------- Range & Type -------------|
47// |------------------------------------| IO Base - 0KB
48// | (0KB - 4KB)IO Regs |
49// |------------------------------------| Cache and Mem Base - 4KB
50// | {4KB - 8KB)Cache & Mem Regs |
51// |------------------------------------| Implementation Spec Regs Base - 8KB
52// | (8KB - 56KB)Implement Spec Regs|
53// |------------------------------------| ARB/Mux Regs Base - 56KB
54// | (56KB - 57KB)ARBMUX Regs |
55// |------------------------------------| Reserved Base - 57KB
56// | (57KB - 63KB)Reserved |
57// |------------------------------------| End 64KB
58//
59// Component Register Block Register Ranges Offset
60//
61#define CXL_COMPONENT_REGISTER_RANGE_OFFSET_IO 0x0
62#define CXL_COMPONENT_REGISTER_RANGE_OFFSET_CACHE_MEM 0x1000
63#define CXL_COMPONENT_REGISTER_RANGE_OFFSET_ARB_MUX 0xE000
64
65//
66// CXL Cache Memory Capability IDs
67// Compute Express Link Specification Revision 2.0 - Chapter 8.2.5
68//
69#define CXL_CACHE_MEM_CAPABILITY_ID_CXL 0x1
70#define CXL_CACHE_MEM_CAPABILITY_ID_RAS 0x2
71#define CXL_CACHE_MEM_CAPABILITY_ID_SECURITY 0x3
72#define CXL_CACHE_MEM_CAPABILITY_ID_LINK 0x4
73#define CXL_CACHE_MEM_CAPABILITY_ID_HDM_DECODER 0x5
74#define CXL_CACHE_MEM_CAPABILITY_ID_EXTENDED_SECURITY 0x6
75#define CXL_CACHE_MEM_CAPABILITY_ID_IDE 0x7
76#define CXL_CACHE_MEM_CAPABILITY_ID_SNOOP_FILTER 0x8
77#define CXL_CACHE_MEM_CAPABILITY_ID_MASK 0xFFFF
78
79//
80// Generic CXL Device Capability IDs 0x0000 ~ 0x3FFF
81// Compute Express Link Specification Revision 2.0 - Chapter 8.2.8.2.1
82//
83#define CXL_DEVICE_CAPABILITY_ID_CAPABILITIES_ARRAY_REGISTER 0x0000
84#define CXL_DEVICE_CAPABILITY_ID_DEVICE_STATUS 0x0001
85#define CXL_DEVICE_CAPABILITY_ID_PRIMARY_MAILBOX 0x0002
86#define CXL_DEVICE_CAPABILITY_ID_SECONDARY_MAILBOX 0x0003
87
88//
89// Specific CXL Device Capability IDs 0x4000 ~ 0x7FFF
90// Compute Express Link Specification Revision 2.0 - Chapter 8.2.8.2.1 and 8.2.8.5
91
92//
93#define CXL_DEVICE_CAPABILITY_ID_MEMORY_DEVICE_STATUS 0x4000
94#define CXL_DEVICE_CAPABILITY_ID_MASK 0xFFFF
95
96//
97// Memory Device Status
98// Compute Express Link Specification Revision 2.0 - Chapter 8.2.8.5.1.1
99//
100#define CXL_MEM_DEVICE_MEDIA_STATUS_NOT_READY 0x0
101#define CXL_MEM_DEVICE_MEDIA_STATUS_READY 0x1
102#define CXL_MEM_DEVICE_MEDIA_STATUS_ERROR 0x2
103#define CXL_MEM_DEVICE_MEDIA_STATUS_DISABLED 0x3
104
105//
106// Ensure proper structure formats
107//
108#pragma pack(1)
109
110//
111// PCIe DVSEC for CXL Device
112// Compute Express Link Specification Revision 2.0 - Chapter 8.1.3
113//
114typedef union {
115 struct {
116 UINT16 CacheCapable : 1; // bit 0
117 UINT16 IoCapable : 1; // bit 1
118 UINT16 MemCapable : 1; // bit 2
119 UINT16 MemHwInitMode : 1; // bit 3
120 UINT16 HdmCount : 2; // bit 4..5
121 UINT16 CacheWriteBackAndInvalidateCapable : 1; // bit 6
122 UINT16 CxlResetCapable : 1; // bit 7
123 UINT16 CxlResetTimeout : 3; // bit 8..10
124 UINT16 CxlResetMemClrCapable : 1; // bit 11
125 UINT16 Reserved : 1; // bit 12
126 UINT16 MultipleLogicalDevice : 1; // bit 13
127 UINT16 ViralCapable : 1; // bit 14
128 UINT16 PmInitCompletionReportingCapable : 1; // bit 15
129 } Bits;
130 UINT16 Uint16;
132
133typedef union {
134 struct {
135 UINT16 CacheEnable : 1; // bit 0
136 UINT16 IoEnable : 1; // bit 1
137 UINT16 MemEnable : 1; // bit 2
138 UINT16 CacheSfCoverage : 5; // bit 3..7
139 UINT16 CacheSfGranularity : 3; // bit 8..10
140 UINT16 CacheCleanEviction : 1; // bit 11
141 UINT16 Reserved1 : 2; // bit 12..13
142 UINT16 ViralEnable : 1; // bit 14
143 UINT16 Reserved2 : 1; // bit 15
144 } Bits;
145 UINT16 Uint16;
147
148typedef union {
149 struct {
150 UINT16 Reserved1 : 14; // bit 0..13
151 UINT16 ViralStatus : 1; // bit 14
152 UINT16 Reserved2 : 1; // bit 15
153 } Bits;
154 UINT16 Uint16;
156
157typedef union {
158 struct {
159 UINT16 DisableCaching : 1; // bit 0
160 UINT16 InitiateCacheWriteBackAndInvalidate : 1; // bit 1
161 UINT16 InitiateCxlReset : 1; // bit 2
162 UINT16 CxlResetMemClrEnable : 1; // bit 3
163 UINT16 Reserved : 12; // bit 4..15
164 } Bits;
165 UINT16 Uint16;
167
168typedef union {
169 struct {
170 UINT16 CacheInvalid : 1; // bit 0
171 UINT16 CxlResetComplete : 1; // bit 1
172 UINT16 Reserved : 13; // bit 2..14
173 UINT16 PowerManagementInitialzationComplete : 1; // bit 15
174 } Bits;
175 UINT16 Uint16;
177
178typedef union {
179 struct {
180 UINT16 ConfigLock : 1; // bit 0
181 UINT16 Reserved : 15; // bit 1..15
182 } Bits;
183 UINT16 Uint16;
185
186typedef union {
187 struct {
188 UINT16 CacheSizeUnit : 4; // bit 0..3
189 UINT16 Reserved : 4; // bit 4..7
190 UINT16 CacheSize : 8; // bit 8..15
191 } Bits;
192 UINT16 Uint16;
194
195typedef union {
196 struct {
197 UINT32 MemorySizeHigh : 32; // bit 0..31
198 } Bits;
199 UINT32 Uint32;
201
202typedef union {
203 struct {
204 UINT32 MemoryInfoValid : 1; // bit 0
205 UINT32 MemoryActive : 1; // bit 1
206 UINT32 MediaType : 3; // bit 2..4
207 UINT32 MemoryClass : 3; // bit 5..7
208 UINT32 DesiredInterleave : 5; // bit 8..12
209 UINT32 MemoryActiveTimeout : 3; // bit 13..15
210 UINT32 Reserved : 12; // bit 16..27
211 UINT32 MemorySizeLow : 4; // bit 28..31
212 } Bits;
213 UINT32 Uint32;
215
216typedef union {
217 struct {
218 UINT32 MemoryBaseHigh : 32; // bit 0..31
219 } Bits;
220 UINT32 Uint32;
222
223typedef union {
224 struct {
225 UINT32 Reserved : 28; // bit 0..27
226 UINT32 MemoryBaseLow : 4; // bit 28..31
227 } Bits;
228 UINT32 Uint32;
230
231typedef struct {
232 PCI_EXPRESS_EXTENDED_CAPABILITIES_HEADER Header; // offset 0x00
233 PCI_EXPRESS_DESIGNATED_VENDOR_SPECIFIC_HEADER_1 DvsecHeader1; // offset 0x04
234 PCI_EXPRESS_DESIGNATED_VENDOR_SPECIFIC_HEADER_2 DvsecHeader2; // offset 0x08
235 CXL_DVSEC_CXL_DEVICE_CAPABILITY DeviceCapability; // offset 0x0A
236 CXL_DVSEC_CXL_DEVICE_CONTROL DeviceControl; // offset 0x0C
237 CXL_DVSEC_CXL_DEVICE_STATUS DeviceStatus; // offset 0x0E
238 CXL_DVSEC_CXL_DEVICE_CONTROL2 DeviceControl2; // offset 0x10
239 CXL_DVSEC_CXL_DEVICE_STATUS2 DeviceStatus2; // offset 0x12
240 CXL_DVSEC_CXL_DEVICE_LOCK DeviceLock; // offset 0x14
241 CXL_DVSEC_CXL_DEVICE_CAPABILITY2 DeviceCapability2; // offset 0x16
242 CXL_DVSEC_CXL_DEVICE_RANGE_SIZE_HIGH DeviceRange1SizeHigh; // offset 0x18
243 CXL_DVSEC_CXL_DEVICE_RANGE_SIZE_LOW DeviceRange1SizeLow; // offset 0x1C
244 CXL_DVSEC_CXL_DEVICE_RANGE_BASE_HIGH DeviceRange1BaseHigh; // offset 0x20
245 CXL_DVSEC_CXL_DEVICE_RANGE_BASE_LOW DeviceRange1BaseLow; // offset 0x24
246 CXL_DVSEC_CXL_DEVICE_RANGE_SIZE_HIGH DeviceRange2SizeHigh; // offset 0x28
247 CXL_DVSEC_CXL_DEVICE_RANGE_SIZE_LOW DeviceRange2SizeLow; // offset 0x2C
248 CXL_DVSEC_CXL_DEVICE_RANGE_BASE_HIGH DeviceRange2BaseHigh; // offset 0x30
249 CXL_DVSEC_CXL_DEVICE_RANGE_BASE_LOW DeviceRange2BaseLow; // offset 0x34
251
252#define CXL_DVSEC_CXL_DEVICE_REVISION_1 0x1
253
254//
255// Register Locator DVSEC
256// Compute Express Link Specification Revision 2.0 - Chapter 8.1.9
257//
258
259typedef union {
260 struct {
261 UINT32 RegisterBir : 3; // bit 0..2
262 UINT32 Reserved : 5; // bit 3..7
263 UINT32 RegisterBlockIdentifier : 8; // bit 8..15
264 UINT32 RegisterBlockOffsetLow : 16; // bit 16..31
265 } Bits;
266 UINT32 Uint32;
268
269typedef union {
270 struct {
271 UINT32 RegisterBlockOffsetHigh : 32; // bit 0..31
272 } Bits;
273 UINT32 Uint32;
275
276typedef struct {
280
281typedef struct {
282 PCI_EXPRESS_EXTENDED_CAPABILITIES_HEADER Header; // offset 0x00
283 PCI_EXPRESS_DESIGNATED_VENDOR_SPECIFIC_HEADER_1 DvsecHeader1; // offset 0x04
284 PCI_EXPRESS_DESIGNATED_VENDOR_SPECIFIC_HEADER_2 DvsecHeader2; // offset 0x08
285 UINT16 Reserved; // offset 0x0A
286 CXL_DVSEC_REGISTER_LOCATOR_REGISTER_BLOCK RegisterBlock[]; // offset 0x0C
288
289#define CXL_DVSEC_REGISTER_LOCATOR_REVISION_0 0x0
290
291//
292// CXL HDM Decoder Capability Header Register
293// Compute Express Link Specification Revision 2.0 - Chapter 8.2.5.5
294//
295typedef union {
296 struct {
297 UINT32 CxlCapabilityId : 16; // bit 0..15
298 UINT32 CxlCapabilityVersion : 4; // bit 16..19
299 UINT32 CxlHdmDecoderCapabilityPointer : 12; // bit 20..31
300 } Bits;
301 UINT32 Uint32;
303
304//
305// CXL HDM Decoder Capability Register
306// Compute Express Link Specification Revision 2.0 - Chapter 8.2.5.12
307//
308typedef union {
309 struct {
310 UINT32 DecoderCount : 4; // bit 0..3
311 UINT32 TargetCount : 4; // bit 4..7
312 UINT32 InterleaveCapableA11to8 : 1; // bit 8
313 UINT32 InterleaveCapableA14to12 : 1; // bit 9
314 UINT32 PoisonOnDecodeErrorCapability : 1; // bit 10
315 UINT32 Reserved : 21; // bit 11..31
316 } Bits;
317 UINT32 Uint32;
319
320typedef union {
321 struct {
322 UINT32 PoisonOnDecodeErrorEnable : 1; // bit 0
323 UINT32 HdmDecoderEnable : 1; // bit 1
324 UINT32 Reserved : 30; // bit 2..31
325 } Bits;
326 UINT32 Uint32;
328
329typedef union {
330 struct {
331 UINT32 Reserved : 28; // bit 0..27
332 UINT32 MemoryBaseLow : 4; // bit 28..31
333 } Bits;
334 UINT32 Uint32;
336
337typedef union {
338 struct {
339 UINT32 MemoryBaseHigh : 32; // bit 0..31
340 } Bits;
341 UINT32 Uint32;
343
344typedef union {
345 struct {
346 UINT32 Reserved : 28; // bit 0..27
347 UINT32 MemorySizeLow : 4; // bit 28..31
348 } Bits;
349 UINT32 Uint32;
351
352typedef union {
353 struct {
354 UINT32 MemorySizeHigh : 32; // bit 0..31
355 } Bits;
356 UINT32 Uint32;
358
359typedef union {
360 struct {
361 UINT32 InterleaveGranularity : 4; // bit 0..3
362 UINT32 InterleaveWays : 4; // bit 4..7
363 UINT32 LockOnCommit : 1; // bit 8
364 UINT32 Commit : 1; // bit 9
365 UINT32 Committed : 1; // bit 10
366 UINT32 ErrorNotCommitted : 1; // bit 11
367 UINT32 TargetDeviceType : 1; // bit 12
368 UINT32 Reserved : 19; // bit 13..31
369 } Bits;
370 UINT32 Uint32;
372
373typedef union {
374 struct {
375 UINT32 TargetPortIdentiferWay0 : 8; // bit 0..7
376 UINT32 TargetPortIdentiferWay1 : 8; // bit 8..15
377 UINT32 TargetPortIdentiferWay2 : 8; // bit 16..23
378 UINT32 TargetPortIdentiferWay3 : 8; // bit 24..31
379 } Bits;
380 UINT32 Uint32;
382
383typedef union {
384 struct {
385 UINT32 Reserved : 28; // bit 0..27
386 UINT32 DpaSkipLow : 4; // bit 28..31
387 } Bits;
388 UINT32 Uint32;
390
391typedef union {
392 struct {
393 UINT32 TargetPortIdentiferWay4 : 8; // bit 0..7
394 UINT32 TargetPortIdentiferWay5 : 8; // bit 8..15
395 UINT32 TargetPortIdentiferWay6 : 8; // bit 16..23
396 UINT32 TargetPortIdentiferWay7 : 8; // bit 24..31
397 } Bits;
398 UINT32 Uint32;
400
401typedef union {
402 struct {
403 UINT32 DpaSkipHigh : 32; // bit 0..31
404 } Bits;
405 UINT32 Uint32;
407
408typedef union {
412
413typedef union {
417
418typedef struct {
419 CXL_HDM_DECODER_BASE_LOW_REGISTER DecoderBaseLow; // 0x10
420 CXL_HDM_DECODER_BASE_HIGH_REGISTER DecoderBaseHigh; // 0x14
421 CXL_HDM_DECODER_SIZE_LOW_REGISTER DecoderSizeLow; // 0x18
422 CXL_HDM_DECODER_SIZE_HIGH_REGISTER DecoderSizeHigh; // 0x1c
423 CXL_HDM_DECODER_CONTROL_REGISTER DecoderControl; // 0x20
424 CXL_HDM_DECODER_TARGET_LIST_OR_DPA_SKIP_LOW DecoderTargetListDpaSkipLow; // 0x24
425 CXL_HDM_DECODER_TARGET_LIST_OR_DPA_SKIP_HIGH DecoderTargetListDpaSkipHigh; // 0x28
426 UINT32 Reserved; // 0x2C
428
429//
430// CXL Device Capabilities Array Register
431// Compute Express Link Specification Revision 2.0 - Chapter 8.2.8.1
432//
433
434typedef union {
435 struct {
436 UINT64 CxlDeviceCapabilityId : 16; // bit 0..15
437 UINT64 CxlDeviceCapabilityVersion : 8; // bit 16..23
438 UINT64 Reserved1 : 8; // bit 24..31
439 UINT64 CxlDeviceCapabilitiesCount : 16; // bit 32..47
440 UINT64 Reserved2 : 16; // bit 48..63
441 } Bits;
442 UINT64 Uint64;
444
445//
446// CXL Memory Status Register
447// Compute Express Link Specification Revision 2.0 - Chapter 8.2.8.5
448//
449typedef union {
450 struct {
451 UINT64 DeviceFatal : 1; // bit 0
452 UINT64 FwHalt : 1; // bit 1
453 UINT64 MediaStatus : 2; // bit 2..3
454 UINT64 MailboxInterfacesReady : 1; // bit 4
455 UINT64 ResetNeeded : 3; // bit 5..7
456 UINT64 Reserved : 56; // bit 8..63
457 } Bits;
458 UINT64 Uint64;
460
461#pragma pack()
462
463#endif