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