1 | /** @file
|
---|
2 | EFI Storage Security Command Protocol as defined in UEFI 2.3.1 specification.
|
---|
3 | This protocol is used to abstract mass storage devices to allow code running in
|
---|
4 | the EFI boot services environment to send security protocol commands to mass
|
---|
5 | storage devices without specific knowledge of the type of device or controller
|
---|
6 | that manages the device.
|
---|
7 |
|
---|
8 | Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
|
---|
9 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
10 |
|
---|
11 | **/
|
---|
12 |
|
---|
13 | #ifndef __STORAGE_SECURITY_COMMAND_H__
|
---|
14 | #define __STORAGE_SECURITY_COMMAND_H__
|
---|
15 |
|
---|
16 | #define EFI_STORAGE_SECURITY_COMMAND_PROTOCOL_GUID \
|
---|
17 | { \
|
---|
18 | 0xC88B0B6D, 0x0DFC, 0x49A7, {0x9C, 0xB4, 0x49, 0x07, 0x4B, 0x4C, 0x3A, 0x78 } \
|
---|
19 | }
|
---|
20 |
|
---|
21 | typedef struct _EFI_STORAGE_SECURITY_COMMAND_PROTOCOL EFI_STORAGE_SECURITY_COMMAND_PROTOCOL;
|
---|
22 |
|
---|
23 | /**
|
---|
24 | Send a security protocol command to a device that receives data and/or the result
|
---|
25 | of one or more commands sent by SendData.
|
---|
26 |
|
---|
27 | The ReceiveData function sends a security protocol command to the given MediaId.
|
---|
28 | The security protocol command sent is defined by SecurityProtocolId and contains
|
---|
29 | the security protocol specific data SecurityProtocolSpecificData. The function
|
---|
30 | returns the data from the security protocol command in PayloadBuffer.
|
---|
31 |
|
---|
32 | For devices supporting the SCSI command set, the security protocol command is sent
|
---|
33 | using the SECURITY PROTOCOL IN command defined in SPC-4.
|
---|
34 |
|
---|
35 | For devices supporting the ATA command set, the security protocol command is sent
|
---|
36 | using one of the TRUSTED RECEIVE commands defined in ATA8-ACS if PayloadBufferSize
|
---|
37 | is non-zero.
|
---|
38 |
|
---|
39 | If the PayloadBufferSize is zero, the security protocol command is sent using the
|
---|
40 | Trusted Non-Data command defined in ATA8-ACS.
|
---|
41 |
|
---|
42 | If PayloadBufferSize is too small to store the available data from the security
|
---|
43 | protocol command, the function shall copy PayloadBufferSize bytes into the
|
---|
44 | PayloadBuffer and return EFI_WARN_BUFFER_TOO_SMALL.
|
---|
45 |
|
---|
46 | If PayloadBuffer or PayloadTransferSize is NULL and PayloadBufferSize is non-zero,
|
---|
47 | the function shall return EFI_INVALID_PARAMETER.
|
---|
48 |
|
---|
49 | If the given MediaId does not support security protocol commands, the function shall
|
---|
50 | return EFI_UNSUPPORTED. If there is no media in the device, the function returns
|
---|
51 | EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the device,
|
---|
52 | the function returns EFI_MEDIA_CHANGED.
|
---|
53 |
|
---|
54 | If the security protocol fails to complete within the Timeout period, the function
|
---|
55 | shall return EFI_TIMEOUT.
|
---|
56 |
|
---|
57 | If the security protocol command completes without an error, the function shall
|
---|
58 | return EFI_SUCCESS. If the security protocol command completes with an error, the
|
---|
59 | function shall return EFI_DEVICE_ERROR.
|
---|
60 |
|
---|
61 | @param This Indicates a pointer to the calling context.
|
---|
62 | @param MediaId ID of the medium to receive data from. If there is no
|
---|
63 | block IO protocol supported by the physical device, the
|
---|
64 | value of MediaId is undefined.
|
---|
65 | @param Timeout The timeout, in 100ns units, to use for the execution
|
---|
66 | of the security protocol command. A Timeout value of 0
|
---|
67 | means that this function will wait indefinitely for the
|
---|
68 | security protocol command to execute. If Timeout is greater
|
---|
69 | than zero, then this function will return EFI_TIMEOUT if the
|
---|
70 | time required to execute the receive data command is greater than Timeout.
|
---|
71 | @param SecurityProtocolId The value of the "Security Protocol" parameter of
|
---|
72 | the security protocol command to be sent.
|
---|
73 | @param SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter
|
---|
74 | of the security protocol command to be sent.
|
---|
75 | @param PayloadBufferSize Size in bytes of the payload data buffer.
|
---|
76 | @param PayloadBuffer A pointer to a destination buffer to store the security
|
---|
77 | protocol command specific payload data for the security
|
---|
78 | protocol command. The caller is responsible for having
|
---|
79 | either implicit or explicit ownership of the buffer.
|
---|
80 | @param PayloadTransferSize A pointer to a buffer to store the size in bytes of the
|
---|
81 | data written to the payload data buffer.
|
---|
82 |
|
---|
83 | @retval EFI_SUCCESS The security protocol command completed successfully.
|
---|
84 | @retval EFI_WARN_BUFFER_TOO_SMALL The PayloadBufferSize was too small to store the available
|
---|
85 | data from the device. The PayloadBuffer contains the truncated data.
|
---|
86 | @retval EFI_UNSUPPORTED The given MediaId does not support security protocol commands.
|
---|
87 | @retval EFI_DEVICE_ERROR The security protocol command completed with an error.
|
---|
88 | @retval EFI_NO_MEDIA There is no media in the device.
|
---|
89 | @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
|
---|
90 | @retval EFI_INVALID_PARAMETER The PayloadBuffer or PayloadTransferSize is NULL and
|
---|
91 | PayloadBufferSize is non-zero.
|
---|
92 | @retval EFI_TIMEOUT A timeout occurred while waiting for the security
|
---|
93 | protocol command to execute.
|
---|
94 |
|
---|
95 | **/
|
---|
96 | typedef
|
---|
97 | EFI_STATUS
|
---|
98 | (EFIAPI *EFI_STORAGE_SECURITY_RECEIVE_DATA)(
|
---|
99 | IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
|
---|
100 | IN UINT32 MediaId,
|
---|
101 | IN UINT64 Timeout,
|
---|
102 | IN UINT8 SecurityProtocolId,
|
---|
103 | IN UINT16 SecurityProtocolSpecificData,
|
---|
104 | IN UINTN PayloadBufferSize,
|
---|
105 | OUT VOID *PayloadBuffer,
|
---|
106 | OUT UINTN *PayloadTransferSize
|
---|
107 | );
|
---|
108 |
|
---|
109 | /**
|
---|
110 | Send a security protocol command to a device.
|
---|
111 |
|
---|
112 | The SendData function sends a security protocol command containing the payload
|
---|
113 | PayloadBuffer to the given MediaId. The security protocol command sent is
|
---|
114 | defined by SecurityProtocolId and contains the security protocol specific data
|
---|
115 | SecurityProtocolSpecificData. If the underlying protocol command requires a
|
---|
116 | specific padding for the command payload, the SendData function shall add padding
|
---|
117 | bytes to the command payload to satisfy the padding requirements.
|
---|
118 |
|
---|
119 | For devices supporting the SCSI command set, the security protocol command is sent
|
---|
120 | using the SECURITY PROTOCOL OUT command defined in SPC-4.
|
---|
121 |
|
---|
122 | For devices supporting the ATA command set, the security protocol command is sent
|
---|
123 | using one of the TRUSTED SEND commands defined in ATA8-ACS if PayloadBufferSize
|
---|
124 | is non-zero. If the PayloadBufferSize is zero, the security protocol command is
|
---|
125 | sent using the Trusted Non-Data command defined in ATA8-ACS.
|
---|
126 |
|
---|
127 | If PayloadBuffer is NULL and PayloadBufferSize is non-zero, the function shall
|
---|
128 | return EFI_INVALID_PARAMETER.
|
---|
129 |
|
---|
130 | If the given MediaId does not support security protocol commands, the function
|
---|
131 | shall return EFI_UNSUPPORTED. If there is no media in the device, the function
|
---|
132 | returns EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the
|
---|
133 | device, the function returns EFI_MEDIA_CHANGED.
|
---|
134 |
|
---|
135 | If the security protocol fails to complete within the Timeout period, the function
|
---|
136 | shall return EFI_TIMEOUT.
|
---|
137 |
|
---|
138 | If the security protocol command completes without an error, the function shall return
|
---|
139 | EFI_SUCCESS. If the security protocol command completes with an error, the function
|
---|
140 | shall return EFI_DEVICE_ERROR.
|
---|
141 |
|
---|
142 | @param This Indicates a pointer to the calling context.
|
---|
143 | @param MediaId ID of the medium to receive data from. If there is no
|
---|
144 | block IO protocol supported by the physical device, the
|
---|
145 | value of MediaId is undefined.
|
---|
146 | @param Timeout The timeout, in 100ns units, to use for the execution
|
---|
147 | of the security protocol command. A Timeout value of 0
|
---|
148 | means that this function will wait indefinitely for the
|
---|
149 | security protocol command to execute. If Timeout is greater
|
---|
150 | than zero, then this function will return EFI_TIMEOUT if the
|
---|
151 | time required to execute the receive data command is greater than Timeout.
|
---|
152 | @param SecurityProtocolId The value of the "Security Protocol" parameter of
|
---|
153 | the security protocol command to be sent.
|
---|
154 | @param SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter
|
---|
155 | of the security protocol command to be sent.
|
---|
156 | @param PayloadBufferSize Size in bytes of the payload data buffer.
|
---|
157 | @param PayloadBuffer A pointer to a destination buffer to store the security
|
---|
158 | protocol command specific payload data for the security
|
---|
159 | protocol command.
|
---|
160 |
|
---|
161 | @retval EFI_SUCCESS The security protocol command completed successfully.
|
---|
162 | @retval EFI_UNSUPPORTED The given MediaId does not support security protocol commands.
|
---|
163 | @retval EFI_DEVICE_ERROR The security protocol command completed with an error.
|
---|
164 | @retval EFI_NO_MEDIA There is no media in the device.
|
---|
165 | @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
|
---|
166 | @retval EFI_INVALID_PARAMETER The PayloadBuffer is NULL and PayloadBufferSize is non-zero.
|
---|
167 | @retval EFI_TIMEOUT A timeout occurred while waiting for the security
|
---|
168 | protocol command to execute.
|
---|
169 |
|
---|
170 | **/
|
---|
171 | typedef
|
---|
172 | EFI_STATUS
|
---|
173 | (EFIAPI *EFI_STORAGE_SECURITY_SEND_DATA)(
|
---|
174 | IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
|
---|
175 | IN UINT32 MediaId,
|
---|
176 | IN UINT64 Timeout,
|
---|
177 | IN UINT8 SecurityProtocolId,
|
---|
178 | IN UINT16 SecurityProtocolSpecificData,
|
---|
179 | IN UINTN PayloadBufferSize,
|
---|
180 | IN VOID *PayloadBuffer
|
---|
181 | );
|
---|
182 |
|
---|
183 | ///
|
---|
184 | /// The EFI_STORAGE_SECURITY_COMMAND_PROTOCOL is used to send security protocol
|
---|
185 | /// commands to a mass storage device. Two types of security protocol commands
|
---|
186 | /// are supported. SendData sends a command with data to a device. ReceiveData
|
---|
187 | /// sends a command that receives data and/or the result of one or more commands
|
---|
188 | /// sent by SendData.
|
---|
189 | ///
|
---|
190 | /// The security protocol command formats supported shall be based on the definition
|
---|
191 | /// of the SECURITY PROTOCOL IN and SECURITY PROTOCOL OUT commands defined in SPC-4.
|
---|
192 | /// If the device uses the SCSI command set, no translation is needed in the firmware
|
---|
193 | /// and the firmware can package the parameters into a SECURITY PROTOCOL IN or SECURITY
|
---|
194 | /// PROTOCOL OUT command and send the command to the device. If the device uses a
|
---|
195 | /// non-SCSI command set, the firmware shall map the command and data payload to the
|
---|
196 | /// corresponding command and payload format defined in the non-SCSI command set
|
---|
197 | /// (for example, TRUSTED RECEIVE and TRUSTED SEND in ATA8-ACS).
|
---|
198 | ///
|
---|
199 | /// The firmware shall automatically add an EFI_STORAGE_SECURITY_COMMAND_PROTOCOL
|
---|
200 | /// for any storage devices detected during system boot that support SPC-4, ATA8-ACS
|
---|
201 | /// or their successors.
|
---|
202 | ///
|
---|
203 | struct _EFI_STORAGE_SECURITY_COMMAND_PROTOCOL {
|
---|
204 | EFI_STORAGE_SECURITY_RECEIVE_DATA ReceiveData;
|
---|
205 | EFI_STORAGE_SECURITY_SEND_DATA SendData;
|
---|
206 | };
|
---|
207 |
|
---|
208 | extern EFI_GUID gEfiStorageSecurityCommandProtocolGuid;
|
---|
209 |
|
---|
210 | #endif
|
---|