]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Include/Ppi/StorageSecurityCommand.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Include / Ppi / StorageSecurityCommand.h
1 /** @file
2
3 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
5
6 **/
7
8 #ifndef _EDKII_STORAGE_SECURITY_COMMAND_PPI_H_
9 #define _EDKII_STORAGE_SECURITY_COMMAND_PPI_H_
10
11 #include <Protocol/DevicePath.h>
12
13 ///
14 /// Global ID for the EDKII_PEI_STORAGE_SECURITY_CMD_PPI.
15 ///
16 #define EDKII_PEI_STORAGE_SECURITY_CMD_PPI_GUID \
17 { \
18 0x35de0b4e, 0x30fb, 0x46c3, { 0xbd, 0x84, 0x1f, 0xdb, 0xa1, 0x58, 0xbb, 0x56 } \
19 }
20
21 //
22 // Forward declaration for the EDKII_PEI_STORAGE_SECURITY_CMD_PPI.
23 //
24 typedef struct _EDKII_PEI_STORAGE_SECURITY_CMD_PPI EDKII_PEI_STORAGE_SECURITY_CMD_PPI;
25
26 //
27 // Revision The revision to which the Storage Security Command interface adheres.
28 // All future revisions must be backwards compatible.
29 // If a future version is not back wards compatible it is not the same GUID.
30 //
31 #define EDKII_STORAGE_SECURITY_PPI_REVISION 0x00010000
32
33
34 /**
35 Gets the count of storage security devices that one specific driver detects.
36
37 @param[in] This The PPI instance pointer.
38 @param[out] NumberofDevices The number of storage security devices discovered.
39
40 @retval EFI_SUCCESS The operation performed successfully.
41 @retval EFI_INVALID_PARAMETER The parameters are invalid.
42
43 **/
44 typedef
45 EFI_STATUS
46 (EFIAPI *EDKII_PEI_STORAGE_SECURITY_GET_NUMBER_DEVICES) (
47 IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This,
48 OUT UINTN *NumberofDevices
49 );
50
51 /**
52 Gets the device path of a specific storage security device.
53
54 @param[in] This The PPI instance pointer.
55 @param[in] DeviceIndex Specifies the storage security device to which
56 the function wants to talk. Because the driver
57 that implements Storage Security Command PPIs
58 will manage multiple storage devices, the PPIs
59 that want to talk to a single device must specify
60 the device index that was assigned during the
61 enumeration process. This index is a number from
62 one to NumberofDevices.
63 @param[out] DevicePathLength The length of the device path in bytes specified
64 by DevicePath.
65 @param[out] DevicePath The device path of storage security device.
66 This field re-uses EFI Device Path Protocol as
67 defined by Section 10.2 EFI Device Path Protocol
68 of UEFI 2.7 Specification.
69
70 @retval EFI_SUCCESS The operation succeeds.
71 @retval EFI_INVALID_PARAMETER DevicePathLength or DevicePath is NULL.
72 @retval EFI_NOT_FOUND The specified storage security device not found.
73 @retval EFI_OUT_OF_RESOURCES The operation fails due to lack of resources.
74
75 **/
76 typedef
77 EFI_STATUS
78 (EFIAPI *EDKII_PEI_STORAGE_SECURITY_GET_DEVICE_PATH) (
79 IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This,
80 IN UINTN DeviceIndex,
81 OUT UINTN *DevicePathLength,
82 OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
83 );
84
85 /**
86 Send a security protocol command to a device that receives data and/or the result
87 of one or more commands sent by SendData.
88
89 The ReceiveData function sends a security protocol command to the given DeviceIndex.
90 The security protocol command sent is defined by SecurityProtocolId and contains
91 the security protocol specific data SecurityProtocolSpecificData. The function
92 returns the data from the security protocol command in PayloadBuffer.
93
94 For devices supporting the SCSI command set, the security protocol command is sent
95 using the SECURITY PROTOCOL IN command defined in SPC-4.
96
97 For devices supporting the ATA command set, the security protocol command is sent
98 using one of the TRUSTED RECEIVE commands defined in ATA8-ACS if PayloadBufferSize
99 is non-zero.
100
101 If the PayloadBufferSize is zero, the security protocol command is sent using the
102 Trusted Non-Data command defined in ATA8-ACS.
103
104 If PayloadBufferSize is too small to store the available data from the security
105 protocol command, the function shall copy PayloadBufferSize bytes into the
106 PayloadBuffer and return EFI_WARN_BUFFER_TOO_SMALL.
107
108 If PayloadBuffer or PayloadTransferSize is NULL and PayloadBufferSize is non-zero,
109 the function shall return EFI_INVALID_PARAMETER.
110
111 If the given DeviceIndex does not support security protocol commands, the function
112 shall return EFI_UNSUPPORTED.
113
114 If the security protocol fails to complete within the Timeout period, the function
115 shall return EFI_TIMEOUT.
116
117 If the security protocol command completes without an error, the function shall
118 return EFI_SUCCESS. If the security protocol command completes with an error, the
119 function shall return EFI_DEVICE_ERROR.
120
121 @param[in] This The PPI instance pointer.
122 @param[in] DeviceIndex Specifies the storage security device to which the
123 function wants to talk. Because the driver that
124 implements Storage Security Command PPIs will manage
125 multiple storage devices, the PPIs that want to talk
126 to a single device must specify the device index
127 that was assigned during the enumeration process.
128 This index is a number from one to NumberofDevices.
129 @param[in] Timeout The timeout, in 100ns units, to use for the execution
130 of the security protocol command. A Timeout value
131 of 0 means that this function will wait indefinitely
132 for the security protocol command to execute. If
133 Timeout is greater than zero, then this function
134 will return EFI_TIMEOUT if the time required to
135 execute the receive data command is greater than
136 Timeout.
137 @param[in] SecurityProtocolId
138 The value of the "Security Protocol" parameter of
139 the security protocol command to be sent.
140 @param[in] SecurityProtocolSpecificData
141 The value of the "Security Protocol Specific"
142 parameter of the security protocol command to be
143 sent.
144 @param[in] PayloadBufferSize
145 Size in bytes of the payload data buffer.
146 @param[out] PayloadBuffer A pointer to a destination buffer to store the
147 security protocol command specific payload data
148 for the security protocol command. The caller is
149 responsible for having either implicit or explicit
150 ownership of the buffer.
151 @param[out] PayloadTransferSize
152 A pointer to a buffer to store the size in bytes
153 of the data written to the payload data buffer.
154
155 @retval EFI_SUCCESS The security protocol command completed
156 successfully.
157 @retval EFI_WARN_BUFFER_TOO_SMALL The PayloadBufferSize was too small to
158 store the available data from the device.
159 The PayloadBuffer contains the truncated
160 data.
161 @retval EFI_UNSUPPORTED The given DeviceIndex does not support
162 security protocol commands.
163 @retval EFI_DEVICE_ERROR The security protocol command completed
164 with an error.
165 @retval EFI_INVALID_PARAMETER The PayloadBuffer or PayloadTransferSize
166 is NULL and PayloadBufferSize is non-zero.
167 @retval EFI_TIMEOUT A timeout occurred while waiting for the
168 security protocol command to execute.
169
170 **/
171 typedef
172 EFI_STATUS
173 (EFIAPI *EDKII_PEI_STORAGE_SECURITY_RECEIVE_DATA) (
174 IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This,
175 IN UINTN DeviceIndex,
176 IN UINT64 Timeout,
177 IN UINT8 SecurityProtocolId,
178 IN UINT16 SecurityProtocolSpecificData,
179 IN UINTN PayloadBufferSize,
180 OUT VOID *PayloadBuffer,
181 OUT UINTN *PayloadTransferSize
182 );
183
184 /**
185 Send a security protocol command to a device.
186
187 The SendData function sends a security protocol command containing the payload
188 PayloadBuffer to the given DeviceIndex. The security protocol command sent is
189 defined by SecurityProtocolId and contains the security protocol specific data
190 SecurityProtocolSpecificData. If the underlying protocol command requires a
191 specific padding for the command payload, the SendData function shall add padding
192 bytes to the command payload to satisfy the padding requirements.
193
194 For devices supporting the SCSI command set, the security protocol command is
195 sent using the SECURITY PROTOCOL OUT command defined in SPC-4.
196
197 For devices supporting the ATA command set, the security protocol command is
198 sent using one of the TRUSTED SEND commands defined in ATA8-ACS if PayloadBufferSize
199 is non-zero. If the PayloadBufferSize is zero, the security protocol command
200 is sent using the Trusted Non-Data command defined in ATA8-ACS.
201
202 If PayloadBuffer is NULL and PayloadBufferSize is non-zero, the function shall
203 return EFI_INVALID_PARAMETER.
204
205 If the given DeviceIndex does not support security protocol commands, the function
206 shall return EFI_UNSUPPORTED.
207
208 If the security protocol fails to complete within the Timeout period, the function
209 shall return EFI_TIMEOUT.
210
211 If the security protocol command completes without an error, the function shall
212 return EFI_SUCCESS. If the security protocol command completes with an error,
213 the functio shall return EFI_DEVICE_ERROR.
214
215 @param[in] This The PPI instance pointer.
216 @param[in] DeviceIndex The ID of the device.
217 @param[in] Timeout The timeout, in 100ns units, to use for the execution
218 of the security protocol command. A Timeout value
219 of 0 means that this function will wait indefinitely
220 for the security protocol command to execute. If
221 Timeout is greater than zero, then this function
222 will return EFI_TIMEOUT if the time required to
223 execute the receive data command is greater than
224 Timeout.
225 @param[in] SecurityProtocolId
226 The value of the "Security Protocol" parameter of
227 the security protocol command to be sent.
228 @param[in] SecurityProtocolSpecificData
229 The value of the "Security Protocol Specific"
230 parameter of the security protocol command to be
231 sent.
232 @param[in] PayloadBufferSize Size in bytes of the payload data buffer.
233 @param[in] PayloadBuffer A pointer to a destination buffer to store the
234 security protocol command specific payload data
235 for the security protocol command.
236
237 @retval EFI_SUCCESS The security protocol command completed successfully.
238 @retval EFI_UNSUPPORTED The given DeviceIndex does not support security
239 protocol commands.
240 @retval EFI_DEVICE_ERROR The security protocol command completed with
241 an error.
242 @retval EFI_INVALID_PARAMETER The PayloadBuffer is NULL and PayloadBufferSize
243 is non-zero.
244 @retval EFI_TIMEOUT A timeout occurred while waiting for the security
245 protocol command to execute.
246
247 **/
248 typedef
249 EFI_STATUS
250 (EFIAPI *EDKII_PEI_STORAGE_SECURITY_SEND_DATA) (
251 IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This,
252 IN UINTN DeviceIndex,
253 IN UINT64 Timeout,
254 IN UINT8 SecurityProtocolId,
255 IN UINT16 SecurityProtocolSpecificData,
256 IN UINTN PayloadBufferSize,
257 IN VOID *PayloadBuffer
258 );
259
260 //
261 // EDKII_PEI_STORAGE_SECURITY_CMD_PPI contains a set of services to send security
262 // protocol commands to a mass storage device. Two types of security protocol
263 // commands are supported. SendData sends a command with data to a device.
264 // ReceiveData sends a command that receives data and/or the result of one or
265 // more commands sent by SendData.
266 //
267 struct _EDKII_PEI_STORAGE_SECURITY_CMD_PPI {
268 UINT64 Revision;
269 EDKII_PEI_STORAGE_SECURITY_GET_NUMBER_DEVICES GetNumberofDevices;
270 EDKII_PEI_STORAGE_SECURITY_GET_DEVICE_PATH GetDevicePath;
271 EDKII_PEI_STORAGE_SECURITY_RECEIVE_DATA ReceiveData;
272 EDKII_PEI_STORAGE_SECURITY_SEND_DATA SendData;
273 };
274
275 extern EFI_GUID gEdkiiPeiStorageSecurityCommandPpiGuid;
276
277 #endif