]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiStorageSecurity.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / NvmExpressPei / NvmExpressPeiStorageSecurity.h
CommitLineData
2e15b750
HW
1/** @file\r
2 The NvmExpressPei driver is used to manage non-volatile memory subsystem\r
3 which follows NVM Express specification at PEI phase.\r
4\r
5 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r
6\r
9d510e61 7 SPDX-License-Identifier: BSD-2-Clause-Patent\r
2e15b750
HW
8\r
9**/\r
10\r
11#ifndef _NVM_EXPRESS_PEI_STORAGE_SECURITY_H_\r
12#define _NVM_EXPRESS_PEI_STORAGE_SECURITY_H_\r
13\r
14/**\r
15 Gets the count of storage security devices that one specific driver detects.\r
16\r
17 @param[in] This The PPI instance pointer.\r
18 @param[out] NumberofDevices The number of storage security devices discovered.\r
19\r
20 @retval EFI_SUCCESS The operation performed successfully.\r
21 @retval EFI_INVALID_PARAMETER The parameters are invalid.\r
22\r
23**/\r
24EFI_STATUS\r
25EFIAPI\r
26NvmeStorageSecurityGetDeviceNo (\r
27 IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This,\r
28 OUT UINTN *NumberofDevices\r
29 );\r
30\r
31/**\r
32 Gets the device path of a specific storage security device.\r
33\r
34 @param[in] This The PPI instance pointer.\r
35 @param[in] DeviceIndex Specifies the storage security device to which\r
36 the function wants to talk. Because the driver\r
37 that implements Storage Security Command PPIs\r
38 will manage multiple storage devices, the PPIs\r
39 that want to talk to a single device must specify\r
40 the device index that was assigned during the\r
41 enumeration process. This index is a number from\r
42 one to NumberofDevices.\r
43 @param[out] DevicePathLength The length of the device path in bytes specified\r
44 by DevicePath.\r
45 @param[out] DevicePath The device path of storage security device.\r
46 This field re-uses EFI Device Path Protocol as\r
47 defined by Section 10.2 EFI Device Path Protocol\r
48 of UEFI 2.7 Specification.\r
49\r
50 @retval EFI_SUCCESS The operation succeeds.\r
51 @retval EFI_INVALID_PARAMETER DevicePathLength or DevicePath is NULL.\r
52 @retval EFI_NOT_FOUND The specified storage security device not found.\r
53 @retval EFI_OUT_OF_RESOURCES The operation fails due to lack of resources.\r
54\r
55**/\r
56EFI_STATUS\r
57EFIAPI\r
58NvmeStorageSecurityGetDevicePath (\r
59 IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This,\r
60 IN UINTN DeviceIndex,\r
61 OUT UINTN *DevicePathLength,\r
62 OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath\r
63 );\r
64\r
65/**\r
66 Send a security protocol command to a device that receives data and/or the result\r
67 of one or more commands sent by SendData.\r
68\r
69 The ReceiveData function sends a security protocol command to the given DeviceIndex.\r
70 The security protocol command sent is defined by SecurityProtocolId and contains\r
71 the security protocol specific data SecurityProtocolSpecificData. The function\r
72 returns the data from the security protocol command in PayloadBuffer.\r
73\r
74 For devices supporting the SCSI command set, the security protocol command is sent\r
75 using the SECURITY PROTOCOL IN command defined in SPC-4.\r
76\r
77 For devices supporting the ATA command set, the security protocol command is sent\r
78 using one of the TRUSTED RECEIVE commands defined in ATA8-ACS if PayloadBufferSize\r
79 is non-zero.\r
80\r
81 If the PayloadBufferSize is zero, the security protocol command is sent using the\r
82 Trusted Non-Data command defined in ATA8-ACS.\r
83\r
84 If PayloadBufferSize is too small to store the available data from the security\r
85 protocol command, the function shall copy PayloadBufferSize bytes into the\r
86 PayloadBuffer and return EFI_WARN_BUFFER_TOO_SMALL.\r
87\r
88 If PayloadBuffer or PayloadTransferSize is NULL and PayloadBufferSize is non-zero,\r
89 the function shall return EFI_INVALID_PARAMETER.\r
90\r
91 If the given DeviceIndex does not support security protocol commands, the function\r
92 shall return EFI_UNSUPPORTED.\r
93\r
94 If the security protocol fails to complete within the Timeout period, the function\r
95 shall return EFI_TIMEOUT.\r
96\r
97 If the security protocol command completes without an error, the function shall\r
98 return EFI_SUCCESS. If the security protocol command completes with an error, the\r
99 function shall return EFI_DEVICE_ERROR.\r
100\r
101 @param[in] This The PPI instance pointer.\r
102 @param[in] DeviceIndex Specifies the storage security device to which the\r
103 function wants to talk. Because the driver that\r
104 implements Storage Security Command PPIs will manage\r
105 multiple storage devices, the PPIs that want to talk\r
106 to a single device must specify the device index\r
107 that was assigned during the enumeration process.\r
108 This index is a number from one to NumberofDevices.\r
109 @param[in] Timeout The timeout, in 100ns units, to use for the execution\r
110 of the security protocol command. A Timeout value\r
111 of 0 means that this function will wait indefinitely\r
112 for the security protocol command to execute. If\r
113 Timeout is greater than zero, then this function\r
114 will return EFI_TIMEOUT if the time required to\r
115 execute the receive data command is greater than\r
116 Timeout.\r
117 @param[in] SecurityProtocolId\r
118 The value of the "Security Protocol" parameter of\r
119 the security protocol command to be sent.\r
120 @param[in] SecurityProtocolSpecificData\r
121 The value of the "Security Protocol Specific"\r
122 parameter of the security protocol command to be\r
123 sent.\r
124 @param[in] PayloadBufferSize\r
125 Size in bytes of the payload data buffer.\r
126 @param[out] PayloadBuffer A pointer to a destination buffer to store the\r
127 security protocol command specific payload data\r
128 for the security protocol command. The caller is\r
129 responsible for having either implicit or explicit\r
130 ownership of the buffer.\r
131 @param[out] PayloadTransferSize\r
132 A pointer to a buffer to store the size in bytes\r
133 of the data written to the payload data buffer.\r
134\r
135 @retval EFI_SUCCESS The security protocol command completed\r
136 successfully.\r
137 @retval EFI_WARN_BUFFER_TOO_SMALL The PayloadBufferSize was too small to\r
138 store the available data from the device.\r
139 The PayloadBuffer contains the truncated\r
140 data.\r
141 @retval EFI_UNSUPPORTED The given DeviceIndex does not support\r
142 security protocol commands.\r
143 @retval EFI_DEVICE_ERROR The security protocol command completed\r
144 with an error.\r
145 @retval EFI_INVALID_PARAMETER The PayloadBuffer or PayloadTransferSize\r
146 is NULL and PayloadBufferSize is non-zero.\r
147 @retval EFI_TIMEOUT A timeout occurred while waiting for the\r
148 security protocol command to execute.\r
149\r
150**/\r
151EFI_STATUS\r
152EFIAPI\r
153NvmeStorageSecurityReceiveData (\r
154 IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This,\r
155 IN UINTN DeviceIndex,\r
156 IN UINT64 Timeout,\r
157 IN UINT8 SecurityProtocolId,\r
158 IN UINT16 SecurityProtocolSpecificData,\r
159 IN UINTN PayloadBufferSize,\r
160 OUT VOID *PayloadBuffer,\r
161 OUT UINTN *PayloadTransferSize\r
162 );\r
163\r
164/**\r
165 Send a security protocol command to a device.\r
166\r
167 The SendData function sends a security protocol command containing the payload\r
168 PayloadBuffer to the given DeviceIndex. The security protocol command sent is\r
169 defined by SecurityProtocolId and contains the security protocol specific data\r
170 SecurityProtocolSpecificData. If the underlying protocol command requires a\r
171 specific padding for the command payload, the SendData function shall add padding\r
172 bytes to the command payload to satisfy the padding requirements.\r
173\r
174 For devices supporting the SCSI command set, the security protocol command is\r
175 sent using the SECURITY PROTOCOL OUT command defined in SPC-4.\r
176\r
177 For devices supporting the ATA command set, the security protocol command is\r
178 sent using one of the TRUSTED SEND commands defined in ATA8-ACS if PayloadBufferSize\r
179 is non-zero. If the PayloadBufferSize is zero, the security protocol command\r
180 is sent using the Trusted Non-Data command defined in ATA8-ACS.\r
181\r
182 If PayloadBuffer is NULL and PayloadBufferSize is non-zero, the function shall\r
183 return EFI_INVALID_PARAMETER.\r
184\r
185 If the given DeviceIndex does not support security protocol commands, the function\r
186 shall return EFI_UNSUPPORTED.\r
187\r
188 If the security protocol fails to complete within the Timeout period, the function\r
189 shall return EFI_TIMEOUT.\r
190\r
191 If the security protocol command completes without an error, the function shall\r
192 return EFI_SUCCESS. If the security protocol command completes with an error,\r
193 the functio shall return EFI_DEVICE_ERROR.\r
194\r
195 @param[in] This The PPI instance pointer.\r
196 @param[in] DeviceIndex The ID of the device.\r
197 @param[in] Timeout The timeout, in 100ns units, to use for the execution\r
198 of the security protocol command. A Timeout value\r
199 of 0 means that this function will wait indefinitely\r
200 for the security protocol command to execute. If\r
201 Timeout is greater than zero, then this function\r
202 will return EFI_TIMEOUT if the time required to\r
203 execute the receive data command is greater than\r
204 Timeout.\r
205 @param[in] SecurityProtocolId\r
206 The value of the "Security Protocol" parameter of\r
207 the security protocol command to be sent.\r
208 @param[in] SecurityProtocolSpecificData\r
209 The value of the "Security Protocol Specific"\r
210 parameter of the security protocol command to be\r
211 sent.\r
212 @param[in] PayloadBufferSize Size in bytes of the payload data buffer.\r
213 @param[in] PayloadBuffer A pointer to a destination buffer to store the\r
214 security protocol command specific payload data\r
215 for the security protocol command.\r
216\r
217 @retval EFI_SUCCESS The security protocol command completed successfully.\r
218 @retval EFI_UNSUPPORTED The given DeviceIndex does not support security\r
219 protocol commands.\r
220 @retval EFI_DEVICE_ERROR The security protocol command completed with\r
221 an error.\r
222 @retval EFI_INVALID_PARAMETER The PayloadBuffer is NULL and PayloadBufferSize\r
223 is non-zero.\r
224 @retval EFI_TIMEOUT A timeout occurred while waiting for the security\r
225 protocol command to execute.\r
226\r
227**/\r
228EFI_STATUS\r
229EFIAPI\r
230NvmeStorageSecuritySendData (\r
231 IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This,\r
232 IN UINTN DeviceIndex,\r
233 IN UINT64 Timeout,\r
234 IN UINT8 SecurityProtocolId,\r
235 IN UINT16 SecurityProtocolSpecificData,\r
236 IN UINTN PayloadBufferSize,\r
237 IN VOID *PayloadBuffer\r
238 );\r
239\r
240#endif\r