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