summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Include/Protocol/CxlIo.h
blob: 4137f40554a9afa96b8ae3f144f4d43c358cc5fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/** @file
  EFI CXL I/O Protocol provides the interfaces to interact with the CXL-specific
  subsystems of CXL devices. Other interactions with CXL devices should be
  routed through EFI_PCI_IO_PROTOCOL

  Copyright (c) 2026, Google, LLC. All rights reserved.<BR>
  SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#pragma once

#include <Uefi/UefiBaseType.h>
#include "IndustryStandard/Cxl20.h"
#include "Protocol/PciIo.h"

#include <IndustryStandard/Cxl.h>
#include <IndustryStandard/CxlCdat.h>

///
/// Global ID for the CXL I/O Protocol
///
// 8fac60b2-bbc1-41de-a797-9875cdd3a8f8

#define EDKII_CXL_IO_PROTOCOL_GUID \
  { \
    0x8fac60b2, 0xbbc1, 0x41de, {0xa7, 0x97, 0x98, 0x75, 0xcd, 0xd3, 0xa8, 0xf8 } \
  }

typedef struct _EDKII_CXL_IO_PROTOCOL EDKII_CXL_IO_PROTOCOL;

/**
  Performs a CXL DOE transaction.

  @param  This                  A pointer to the EDKII_CXL_IO_PROTOCOL instance.
  @param  RequestBuffer         Payload of the request. This buffer should contain anything needed
                                for the DOE request beyond the standard 2 DWORD header. If not extra
                                data is required, this may be NULL.
  @param  RequestBufferSize     Size of the request buffer in bytes. If RequestBuffer is NULL,
                                RequestBufferSize must be 0.
  @param  ResponseBuffer        Destination buffer for the response.
  @param  ResponseBufferSize    As an input parameter, the maximum size of the buffer.
                                As an output parameter, the actual size of the response.

  @retval EFI_SUCCESS           The data was read from or written to the CXL controller.
  @retval EFI_UNSUPPORTED       This device does not support DOE.
  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.
  @retval EFI_INVALID_PARAMETER One or more parameters are invalid.

**/
typedef
EFI_STATUS
(EFIAPI *EDKII_CXL_IO_PROTOCOL_IO_DOE_TRANSACT)(
  IN     EDKII_CXL_IO_PROTOCOL          *This,
  IN CONST VOID                       *RequestBuffer,
  IN     UINTN                        RequestBufferSize,
  OUT VOID                            *ResponseBuffer,
  IN OUT UINTN                        *ResponseBufferSize
  );

/**
  Transacts a set of regblock registers.

  @param[in]      This           A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
  @param[in]      RegBlock       The type of regblock regs.
  @param[in]      Offset         Offset from the start of the regblock.
  @param[in, out] Buf            The bufer to write or fill.
  @param[in]      Size           The size of the buffer.

  @retval EFI_SUCCESS All bytes were written or read successfully.
  @retval other       Something went wrong.
*/
typedef
EFI_STATUS
(EFIAPI *EDKII_CXL_IO_PROTOCOL_IO_REGBLOCK)(
  IN EDKII_CXL_IO_PROTOCOL          *This,
  IN UINT32     RegBlock,
  IN UINT64                       Offset,
  IN VOID                         *Buf,
  IN UINTN                        Size
  );

typedef struct {
  ///
  /// Read CXL DVSEC.
  ///
  EDKII_CXL_IO_PROTOCOL_IO_REGBLOCK    Read;
  ///
  /// Write CXL DVSEC.
  ///
  EDKII_CXL_IO_PROTOCOL_IO_REGBLOCK    Write;
} EDKII_CXL_IO_PROTOCOL_REGBLOCK_ACCESS;

/**
  Reads a set of DVSEC registers.

  @param[in]      This           A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
  @param[in]      CxlDvsecId     The DVSEC to read or write. See #defines prefixed with CXL_DVSEC_ID_.
  @param[in]      Offset         Offset from the start of the DVSEC.
  @param[in, out] Buf            The buffer to write or fill.
  @param[in]      Size           The size of the buffer.

  @retval EFI_SUCCESS All bytes were written or read successfully.
  @retval other       Something went wrong.
*/
typedef
EFI_STATUS
(EFIAPI *EDKII_CXL_IO_PROTOCOL_IO_DVSEC)(
  IN EDKII_CXL_IO_PROTOCOL          *This,
  IN UINT32                       CxlDvsecId,
  IN UINT32                       Offset,
  IN VOID                         *Buf,
  IN UINTN                        Size
  );

typedef struct {
  ///
  /// Read CXL DVSEC.
  ///
  EDKII_CXL_IO_PROTOCOL_IO_DVSEC    Read;
  ///
  /// Write CXL DVSEC.
  ///
  EDKII_CXL_IO_PROTOCOL_IO_DVSEC    Write;
} EDKII_CXL_IO_PROTOCOL_DVSEC_ACCESS;

///
///  EFI CXL I/O Protocol provides the interfaces to interact with the CXL-specific
///  subsystems of CXL devices. Other interactions with CXL devices should be
///  routed through EFI_PCI_IO_PROTOCOL.
///
struct _EDKII_CXL_IO_PROTOCOL {
  ///
  /// Access to the associated PciIo protocol for this CXL device.
  ///
  EFI_PCI_IO_PROTOCOL                      *PciIo;
  ///
  /// Data object exchange request-response transaction.
  ///
  EDKII_CXL_IO_PROTOCOL_IO_DOE_TRANSACT    DoeTransact;
  ///
  /// Regblock register getter/setter.
  ///
  EDKII_CXL_IO_PROTOCOL_REGBLOCK_ACCESS    Regblock;
  ///
  /// DVSEC register getter/setter.
  ///
  EDKII_CXL_IO_PROTOCOL_DVSEC_ACCESS       Dvsec;
};

extern EFI_GUID  gEdkiiCxlIoProtocolGuid;