Home | History | Annotate | Download | only in Protocol
      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, Intel Corporation. All rights reserved.<BR>
      9   This program and the accompanying materials
     10   are licensed and made available under the terms and conditions of the BSD License
     11   which accompanies this distribution.  The full text of the license may be found at
     12   http://opensource.org/licenses/bsd-license.php
     13 
     14   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     15   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     16 
     17 **/
     18 
     19 #ifndef __STORAGE_SECURITY_COMMAND_H__
     20 #define __STORAGE_SECURITY_COMMAND_H__
     21 
     22 #define EFI_STORAGE_SECURITY_COMMAND_PROTOCOL_GUID \
     23   { \
     24     0xC88B0B6D, 0x0DFC, 0x49A7, {0x9C, 0xB4, 0x49, 0x07, 0x4B, 0x4C, 0x3A, 0x78 } \
     25   }
     26 
     27 typedef struct _EFI_STORAGE_SECURITY_COMMAND_PROTOCOL  EFI_STORAGE_SECURITY_COMMAND_PROTOCOL;
     28 
     29 /**
     30   Send a security protocol command to a device that receives data and/or the result
     31   of one or more commands sent by SendData.
     32 
     33   The ReceiveData function sends a security protocol command to the given MediaId.
     34   The security protocol command sent is defined by SecurityProtocolId and contains
     35   the security protocol specific data SecurityProtocolSpecificData. The function
     36   returns the data from the security protocol command in PayloadBuffer.
     37 
     38   For devices supporting the SCSI command set, the security protocol command is sent
     39   using the SECURITY PROTOCOL IN command defined in SPC-4.
     40 
     41   For devices supporting the ATA command set, the security protocol command is sent
     42   using one of the TRUSTED RECEIVE commands defined in ATA8-ACS if PayloadBufferSize
     43   is non-zero.
     44 
     45   If the PayloadBufferSize is zero, the security protocol command is sent using the
     46   Trusted Non-Data command defined in ATA8-ACS.
     47 
     48   If PayloadBufferSize is too small to store the available data from the security
     49   protocol command, the function shall copy PayloadBufferSize bytes into the
     50   PayloadBuffer and return EFI_WARN_BUFFER_TOO_SMALL.
     51 
     52   If PayloadBuffer or PayloadTransferSize is NULL and PayloadBufferSize is non-zero,
     53   the function shall return EFI_INVALID_PARAMETER.
     54 
     55   If the given MediaId does not support security protocol commands, the function shall
     56   return EFI_UNSUPPORTED. If there is no media in the device, the function returns
     57   EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the device,
     58   the function returns EFI_MEDIA_CHANGED.
     59 
     60   If the security protocol fails to complete within the Timeout period, the function
     61   shall return EFI_TIMEOUT.
     62 
     63   If the security protocol command completes without an error, the function shall
     64   return EFI_SUCCESS. If the security protocol command completes with an error, the
     65   function shall return EFI_DEVICE_ERROR.
     66 
     67   @param  This                         Indicates a pointer to the calling context.
     68   @param  MediaId                      ID of the medium to receive data from.
     69   @param  Timeout                      The timeout, in 100ns units, to use for the execution
     70                                        of the security protocol command. A Timeout value of 0
     71                                        means that this function will wait indefinitely for the
     72                                        security protocol command to execute. If Timeout is greater
     73                                        than zero, then this function will return EFI_TIMEOUT if the
     74                                        time required to execute the receive data command is greater than Timeout.
     75   @param  SecurityProtocolId           The value of the "Security Protocol" parameter of
     76                                        the security protocol command to be sent.
     77   @param  SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter
     78                                        of the security protocol command to be sent.
     79   @param  PayloadBufferSize            Size in bytes of the payload data buffer.
     80   @param  PayloadBuffer                A pointer to a destination buffer to store the security
     81                                        protocol command specific payload data for the security
     82                                        protocol command. The caller is responsible for having
     83                                        either implicit or explicit ownership of the buffer.
     84   @param  PayloadTransferSize          A pointer to a buffer to store the size in bytes of the
     85                                        data written to the payload data buffer.
     86 
     87   @retval EFI_SUCCESS                  The security protocol command completed successfully.
     88   @retval EFI_WARN_BUFFER_TOO_SMALL    The PayloadBufferSize was too small to store the available
     89                                        data from the device. The PayloadBuffer contains the truncated data.
     90   @retval EFI_UNSUPPORTED              The given MediaId does not support security protocol commands.
     91   @retval EFI_DEVICE_ERROR             The security protocol command completed with an error.
     92   @retval EFI_NO_MEDIA                 There is no media in the device.
     93   @retval EFI_MEDIA_CHANGED            The MediaId is not for the current media.
     94   @retval EFI_INVALID_PARAMETER        The PayloadBuffer or PayloadTransferSize is NULL and
     95                                        PayloadBufferSize is non-zero.
     96   @retval EFI_TIMEOUT                  A timeout occurred while waiting for the security
     97                                        protocol command to execute.
     98 
     99 **/
    100 typedef
    101 EFI_STATUS
    102 (EFIAPI *EFI_STORAGE_SECURITY_RECEIVE_DATA)(
    103   IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL    *This,
    104   IN UINT32                                   MediaId,
    105   IN UINT64                                   Timeout,
    106   IN UINT8                                    SecurityProtocolId,
    107   IN UINT16                                   SecurityProtocolSpecificData,
    108   IN UINTN                                    PayloadBufferSize,
    109   OUT VOID                                    *PayloadBuffer,
    110   OUT UINTN                                   *PayloadTransferSize
    111   );
    112 
    113 /**
    114   Send a security protocol command to a device.
    115 
    116   The SendData function sends a security protocol command containing the payload
    117   PayloadBuffer to the given MediaId. The security protocol command sent is
    118   defined by SecurityProtocolId and contains the security protocol specific data
    119   SecurityProtocolSpecificData. If the underlying protocol command requires a
    120   specific padding for the command payload, the SendData function shall add padding
    121   bytes to the command payload to satisfy the padding requirements.
    122 
    123   For devices supporting the SCSI command set, the security protocol command is sent
    124   using the SECURITY PROTOCOL OUT command defined in SPC-4.
    125 
    126   For devices supporting the ATA command set, the security protocol command is sent
    127   using one of the TRUSTED SEND commands defined in ATA8-ACS if PayloadBufferSize
    128   is non-zero. If the PayloadBufferSize is zero, the security protocol command is
    129   sent using the Trusted Non-Data command defined in ATA8-ACS.
    130 
    131   If PayloadBuffer is NULL and PayloadBufferSize is non-zero, the function shall
    132   return EFI_INVALID_PARAMETER.
    133 
    134   If the given MediaId does not support security protocol commands, the function
    135   shall return EFI_UNSUPPORTED. If there is no media in the device, the function
    136   returns EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the
    137   device, the function returns EFI_MEDIA_CHANGED.
    138 
    139   If the security protocol fails to complete within the Timeout period, the function
    140   shall return EFI_TIMEOUT.
    141 
    142   If the security protocol command completes without an error, the function shall return
    143   EFI_SUCCESS. If the security protocol command completes with an error, the function
    144   shall return EFI_DEVICE_ERROR.
    145 
    146   @param  This                         Indicates a pointer to the calling context.
    147   @param  MediaId                      ID of the medium to receive data from.
    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
    174 EFI_STATUS
    175 (EFIAPI *EFI_STORAGE_SECURITY_SEND_DATA) (
    176   IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL    *This,
    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 ///
    205 struct _EFI_STORAGE_SECURITY_COMMAND_PROTOCOL {
    206   EFI_STORAGE_SECURITY_RECEIVE_DATA ReceiveData;
    207   EFI_STORAGE_SECURITY_SEND_DATA    SendData;
    208 };
    209 
    210 extern EFI_GUID gEfiStorageSecurityCommandProtocolGuid;
    211 
    212 #endif
    213