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