From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: liming.gao@intel.com) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by groups.io with SMTP; Thu, 13 Jun 2019 05:54:15 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jun 2019 05:54:14 -0700 X-ExtLoop1: 1 Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by FMSMGA003.fm.intel.com with ESMTP; 13 Jun 2019 05:54:14 -0700 Received: from fmsmsx155.amr.corp.intel.com (10.18.116.71) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 13 Jun 2019 05:54:13 -0700 Received: from shsmsx154.ccr.corp.intel.com (10.239.6.54) by FMSMSX155.amr.corp.intel.com (10.18.116.71) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 13 Jun 2019 05:54:13 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.185]) by SHSMSX154.ccr.corp.intel.com ([169.254.7.156]) with mapi id 14.03.0439.000; Thu, 13 Jun 2019 20:54:11 +0800 From: "Liming Gao" To: "Zurcher, Christopher J" , "devel@edk2.groups.io" CC: "Yao, Jiewen" , "Wang, Jian J" Subject: Re: [PATCH v4 1/2] MdePkg: Implement SCSI commands for Security Protocol In/Out Thread-Topic: [PATCH v4 1/2] MdePkg: Implement SCSI commands for Security Protocol In/Out Thread-Index: AQHVIYxoZzUWqiRtHUeV4DjwxJ1VpaaZiq5Q Date: Thu, 13 Jun 2019 12:54:10 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E48099C@SHSMSX104.ccr.corp.intel.com> References: <20190613020454.19324-1-christopher.j.zurcher@intel.com> <20190613020454.19324-2-christopher.j.zurcher@intel.com> In-Reply-To: <20190613020454.19324-2-christopher.j.zurcher@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNjdmMDk1NTItYjM0Yy00NGIzLWIxZjAtODdiNGNlYTk0MTNjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoieG9GcTFcL1cyT3pEdUVFblBhTlJDRXlwdHA1aVhBUCsrc3VCYVdNYkdmM3UyZUJ2SWxyN2diU3haWmVpdXFcL0Z5In0= dlp-product: dlpe-windows dlp-version: 11.0.600.7 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: liming.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: Zurcher, Christopher J > Sent: Thursday, June 13, 2019 10:05 AM > To: devel@edk2.groups.io > Cc: Yao, Jiewen ; Wang, Jian J ; Gao, Liming > Subject: [PATCH v4 1/2] MdePkg: Implement SCSI commands for Security Prot= ocol In/Out >=20 > This patch implements the Security Protocol In and Security Protocol Out > commands in UefiScsiLib to prepare support for the Storage Security > Command Protocol. >=20 > Cc: Jiewen Yao > Cc: Jian J Wang > Cc: Liming Gao > Signed-off-by: Christopher J Zurcher > --- > MdePkg/Include/IndustryStandard/Scsi.h | 48 +++-- > MdePkg/Include/Library/UefiScsiLib.h | 126 +++++++++++- > MdePkg/Include/Protocol/ScsiIo.h | 9 +- > MdePkg/Library/UefiScsiLib/UefiScsiLib.c | 205 +++++++++++++++++++- > 4 files changed, 366 insertions(+), 22 deletions(-) >=20 > diff --git a/MdePkg/Include/IndustryStandard/Scsi.h b/MdePkg/Include/Indu= stryStandard/Scsi.h > index cbe5709fe5..10d7b49ba7 100644 > --- a/MdePkg/Include/IndustryStandard/Scsi.h > +++ b/MdePkg/Include/IndustryStandard/Scsi.h > @@ -1,7 +1,7 @@ > /** @file > Support for SCSI-2 standard >=20 > - Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
> + Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > **/ > @@ -163,6 +163,12 @@ > #define EFI_SCSI_OP_SEND_MESSAGE10 0x2a > #define EFI_SCSI_OP_SEND_MESSAGE12 0xaa >=20 > +// > +// Additional commands for Secure Transactions > +// > +#define EFI_SCSI_OP_SECURITY_PROTOCOL_IN 0xa2 > +#define EFI_SCSI_OP_SECURITY_PROTOCOL_OUT 0xb5 > + > // > // SCSI Data Transfer Direction > // > @@ -172,22 +178,30 @@ > // > // Peripheral Device Type Definitions > // > -#define EFI_SCSI_TYPE_DISK 0x00 ///< Direct-access device (e.g= . magnetic disk) > -#define EFI_SCSI_TYPE_TAPE 0x01 ///< Sequential-access device = (e.g. magnetic tape) > -#define EFI_SCSI_TYPE_PRINTER 0x02 ///< Printer device > -#define EFI_SCSI_TYPE_PROCESSOR 0x03 ///< Processor device > -#define EFI_SCSI_TYPE_WORM 0x04 ///< Write-once device (e.g. s= ome optical disks) > -#define EFI_SCSI_TYPE_CDROM 0x05 ///< CD-ROM device > -#define EFI_SCSI_TYPE_SCANNER 0x06 ///< Scanner device > -#define EFI_SCSI_TYPE_OPTICAL 0x07 ///< Optical memory device (e.= g. some optical disks) > -#define EFI_SCSI_TYPE_MEDIUMCHANGER 0x08 ///< Medium changer device (e.= g. jukeboxes) > -#define EFI_SCSI_TYPE_COMMUNICATION 0x09 ///< Communications device > -#define EFI_SCSI_TYPE_ASCIT8_1 0x0A ///< Defined by ASC IT8 (Graph= ic arts pre-press devices) > -#define EFI_SCSI_TYPE_ASCIT8_2 0x0B ///< Defined by ASC IT8 (Graph= ic arts pre-press devices) Why remove ASCIT8_1 & ASCIT8_2? Can we keep them for compatibility? > -// > -// 0Ch - 1Eh are reserved > -// > -#define EFI_SCSI_TYPE_UNKNOWN 0x1F ///< Unknown or no device type > +#define EFI_SCSI_TYPE_DISK 0x00 ///< Direct-access device (e= .g. magnetic disk) > +#define EFI_SCSI_TYPE_TAPE 0x01 ///< Sequential-access devic= e (e.g. magnetic tape) > +#define EFI_SCSI_TYPE_PRINTER 0x02 ///< Printer device > +#define EFI_SCSI_TYPE_PROCESSOR 0x03 ///< Processor device > +#define EFI_SCSI_TYPE_WORM 0x04 ///< Write-once device (e.g.= some optical disks) > +#define EFI_SCSI_TYPE_CDROM 0x05 ///< CD/DVD device > +#define EFI_SCSI_TYPE_SCANNER 0x06 ///< Scanner device (obsolet= e) > +#define EFI_SCSI_TYPE_OPTICAL 0x07 ///< Optical memory device (= e.g. some optical disks) > +#define EFI_SCSI_TYPE_MEDIUMCHANGER 0x08 ///< Medium changer device (= e.g. jukeboxes) > +#define EFI_SCSI_TYPE_COMMUNICATION 0x09 ///< Communications device (= obsolete) > +#define EFI_SCSI_TYPE_A 0x0A ///< Obsolete > +#define EFI_SCSI_TYPE_B 0x0B ///< Obsolete > +#define EFI_SCSI_TYPE_RAID 0x0C ///< Storage array controlle= r device (e.g., RAID) > +#define EFI_SCSI_TYPE_SES 0x0D ///< Enclosure services devi= ce > +#define EFI_SCSI_TYPE_RBC 0x0E ///< Simplified direct-acces= s device (e.g., magnetic disk) > +#define EFI_SCSI_TYPE_OCRW 0x0F ///< Optical card reader/wri= ter device > +#define EFI_SCSI_TYPE_BRIDGE 0x10 ///< Bridge Controller Comma= nds > +#define EFI_SCSI_TYPE_OSD 0x11 ///< Object-based Storage De= vice > +#define EFI_SCSI_TYPE_AUTOMATION 0x12 ///< Automation/Drive Interf= ace > +#define EFI_SCSI_TYPE_SECURITYMANAGER 0x13 ///< Security manager device > +#define EFI_SCSI_TYPE_RESERVED_LOW 0x14 ///< Reserved (low) > +#define EFI_SCSI_TYPE_RESERVED_HIGH 0x1D ///< Reserved (high) > +#define EFI_SCSI_TYPE_WLUN 0x1E ///< Well known logical unit > +#define EFI_SCSI_TYPE_UNKNOWN 0x1F ///< Unknown or no device ty= pe >=20 > // > // Page Codes for INQUIRY command > diff --git a/MdePkg/Include/Library/UefiScsiLib.h b/MdePkg/Include/Librar= y/UefiScsiLib.h > index 10dd81902b..a0d99e703a 100644 > --- a/MdePkg/Include/Library/UefiScsiLib.h > +++ b/MdePkg/Include/Library/UefiScsiLib.h > @@ -5,7 +5,7 @@ > for hard drive, CD and DVD devices that are the most common SCSI boot = targets used by UEFI platforms. > This library class depends on SCSI I/O Protocol defined in UEFI Specif= ication and SCSI-2 industry standard. >=20 > -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
> +Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > **/ > @@ -813,6 +813,130 @@ ScsiWrite16Command ( > ); >=20 >=20 > +/** > + Execute Security Protocol In SCSI command on a specific SCSI target. > + > + Executes the SCSI Security Protocol In command on the SCSI target spec= ified by ScsiIo. > + If Timeout is zero, then this function waits indefinitely for the comm= and to complete. > + If Timeout is greater than zero, then the command is executed and will= timeout after > + Timeout 100 ns units. The StartLba and SectorSize parameters are used= to construct > + the CDB for this SCSI command. > + If ScsiIo is NULL, then ASSERT(). > + If SenseDataLength is NULL, then ASSERT(). > + If HostAdapterStatus is NULL, then ASSERT(). > + If TargetStatus is NULL, then ASSERT(). > + If DataLength is NULL, then ASSERT(). > + > + If SenseDataLength is non-zero and SenseData is not NULL, SenseData mu= st meet buffer > + alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_I= NVALID_PARAMETER > + gets returned. > + > + If DataLength is non-zero and DataBuffer is not NULL, DataBuffer must = meet buffer > + alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_I= NVALID_PARAMETER > + gets returned. > + > + @param[in] ScsiIo SCSI IO Protocol to use. > + @param[in] Timeout The length of timeout period. > + @param[in, out] SenseData A pointer to output sense data. > + @param[in, out] SenseDataLength The length of output sense data. > + @param[out] HostAdapterStatus The status of Host Adapter. > + @param[out] TargetStatus The status of the target. > + @param[in] SecurityProtocol The Security Protocol to use. > + @param[in] SecurityProtocolSpecific The Security Protocol Specif= ic data. > + @param[in] TransferLength The size in bytes of the data all= ocation. > + @param[in, out] DataBuffer A pointer to a data buffer. > + @param[in, out] DataLength The length of data buffer. > + > + @retval EFI_SUCCESS Command is executed successfully. > + @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was execu= ted, but the entire DataBuffer could > + not be transferred. The actual nu= mber of bytes transferred is returned in DataLength. > + @retval EFI_NOT_READY The SCSI Request Packet could not= be sent because there are too many > + SCSI Command Packets already queu= ed. > + @retval EFI_DEVICE_ERROR A device error occurred while att= empting to send SCSI Request Packet. > + @retval EFI_UNSUPPORTED The command described by the SCSI= Request Packet is not supported by > + the SCSI initiator(i.e., SCSI Ho= st Controller) > + @retval EFI_TIMEOUT A timeout occurred while waiting = for the SCSI Request Packet to execute. > + @retval EFI_INVALID_PARAMETER The contents of the SCSI Request = Packet are invalid. > + > +**/ > +EFI_STATUS > +EFIAPI > +ScsiSecurityProtocolInCommand ( > + IN EFI_SCSI_IO_PROTOCOL *ScsiIo, > + IN UINT64 Timeout, > + IN OUT VOID *SenseData, OPTIONAL > + IN OUT UINT8 *SenseDataLength, > + OUT UINT8 *HostAdapterStatus, > + OUT UINT8 *TargetStatus, > + IN UINT8 SecurityProtocol, > + IN UINT16 SecurityProtocolSpecific, > + IN UINT32 TransferLength, > + IN OUT VOID *DataBuffer, OPTIONAL > + IN OUT UINT32 *DataLength > + ); > + > + > +/** > + Execute Security Protocol Out SCSI command on a specific SCSI target. > + > + Executes the SCSI Security Protocol Out command on the SCSI target spe= cified by ScsiIo. > + If Timeout is zero, then this function waits indefinitely for the comm= and to complete. > + If Timeout is greater than zero, then the command is executed and will= timeout after > + Timeout 100 ns units. The StartLba and SectorSize parameters are used= to construct > + the CDB for this SCSI command. > + If ScsiIo is NULL, then ASSERT(). > + If SenseDataLength is NULL, then ASSERT(). > + If HostAdapterStatus is NULL, then ASSERT(). > + If TargetStatus is NULL, then ASSERT(). > + If DataLength is NULL, then ASSERT(). > + > + If SenseDataLength is non-zero and SenseData is not NULL, SenseData mu= st meet buffer > + alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_I= NVALID_PARAMETER > + gets returned. > + > + If DataLength is non-zero and DataBuffer is not NULL, DataBuffer must = meet buffer > + alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_I= NVALID_PARAMETER > + gets returned. > + > + @param[in] ScsiIo SCSI IO Protocol to use. > + @param[in] Timeout The length of timeout period. > + @param[in, out] SenseData A pointer to output sense data. > + @param[in, out] SenseDataLength The length of output sense data. > + @param[out] HostAdapterStatus The status of Host Adapter. > + @param[out] TargetStatus The status of the target. > + @param[in] SecurityProtocol The Security Protocol to use. > + @param[in] SecurityProtocolSpecific The Security Protocol Specif= ic data. > + @param[in] TransferLength The size in bytes of the transfer= data. > + @param[in, out] DataBuffer A pointer to a data buffer. > + > + @retval EFI_SUCCESS Command is executed successfully. > + @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was execu= ted, but the entire DataBuffer could > + not be transferred. The actual nu= mber of bytes transferred is returned in DataLength. > + @retval EFI_NOT_READY The SCSI Request Packet could not= be sent because there are too many > + SCSI Command Packets already queu= ed. > + @retval EFI_DEVICE_ERROR A device error occurred while att= empting to send SCSI Request Packet. > + @retval EFI_UNSUPPORTED The command described by the SCSI= Request Packet is not supported by > + the SCSI initiator(i.e., SCSI Ho= st Controller) > + @retval EFI_TIMEOUT A timeout occurred while waiting = for the SCSI Request Packet to execute. > + @retval EFI_INVALID_PARAMETER The contents of the SCSI Request = Packet are invalid. > + > +**/ > +EFI_STATUS > +EFIAPI > +ScsiSecurityProtocolOutCommand ( > + IN EFI_SCSI_IO_PROTOCOL *ScsiIo, > + IN UINT64 Timeout, > + IN OUT VOID *SenseData, OPTIONAL > + IN OUT UINT8 *SenseDataLength, > + OUT UINT8 *HostAdapterStatus, > + OUT UINT8 *TargetStatus, > + IN UINT8 SecurityProtocol, > + IN UINT16 SecurityProtocolSpecific, > + IN UINT32 TransferLength, > + IN OUT VOID *DataBuffer OPTIONAL > + ); > + > + > /** > Execute blocking/non-blocking Read(10) SCSI command on a specific SCSI > target. > diff --git a/MdePkg/Include/Protocol/ScsiIo.h b/MdePkg/Include/Protocol/S= csiIo.h > index 05e46bda9c..27c31fe7f9 100644 > --- a/MdePkg/Include/Protocol/ScsiIo.h > +++ b/MdePkg/Include/Protocol/ScsiIo.h > @@ -4,7 +4,7 @@ > services environment to access SCSI devices. In particular, functions = for > managing devices on SCSI buses are defined here. >=20 > - Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
> + Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > **/ > @@ -43,8 +43,11 @@ typedef struct _EFI_SCSI_IO_PROTOCOL EFI_SCSI_IO_PROTO= COL; > #define MFI_SCSI_IO_TYPE_OCRW 0x0F /= //< Optical card reader/writer device > #define MFI_SCSI_IO_TYPE_BRIDGE 0x10 /= //< Bridge Controller Commands > #define MFI_SCSI_IO_TYPE_OSD 0x11 /= //< Object-based Storage Device > -#define EFI_SCSI_IO_TYPE_RESERVED_LOW 0x12 /= //< Reserved (low) > -#define EFI_SCSI_IO_TYPE_RESERVED_HIGH 0x1E /= //< Reserved (high) > +#define MFI_SCSI_IO_TYPE_AUTOMATION 0x12 /= //< Automation/Drive Interface > +#define MFI_SCSI_IO_TYPE_SECURITYMANAGER 0x13 /= //< Security manager device > +#define EFI_SCSI_IO_TYPE_RESERVED_LOW 0x14 /= //< Reserved (low) > +#define EFI_SCSI_IO_TYPE_RESERVED_HIGH 0x1D /= //< Reserved (high) > +#define EFI_SCSI_IO_TYPE_WLUN 0x1E /= //< Well known logical unit > #define EFI_SCSI_IO_TYPE_UNKNOWN 0x1F /= //< Unknown no device type >=20 > // > diff --git a/MdePkg/Library/UefiScsiLib/UefiScsiLib.c b/MdePkg/Library/Ue= fiScsiLib/UefiScsiLib.c > index c7491d1436..7584d717ad 100644 > --- a/MdePkg/Library/UefiScsiLib/UefiScsiLib.c > +++ b/MdePkg/Library/UefiScsiLib/UefiScsiLib.c > @@ -1,7 +1,7 @@ > /** @file > UEFI SCSI Library implementation >=20 > - Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
> + Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > **/ > @@ -23,6 +23,7 @@ > // > #define EFI_SCSI_OP_LENGTH_SIX 0x6 > #define EFI_SCSI_OP_LENGTH_TEN 0xa > +#define EFI_SCSI_OP_LENGTH_TWELVE 0xc > #define EFI_SCSI_OP_LENGTH_SIXTEEN 0x10 >=20 > // > @@ -1280,6 +1281,208 @@ ScsiWrite16Command ( > } >=20 >=20 > +/** > + Execute Security Protocol In SCSI command on a specific SCSI target. > + > + Executes the SCSI Security Protocol In command on the SCSI target spec= ified by ScsiIo. > + If Timeout is zero, then this function waits indefinitely for the comm= and to complete. > + If Timeout is greater than zero, then the command is executed and will= timeout after > + Timeout 100 ns units. The StartLba and SectorSize parameters are used= to construct > + the CDB for this SCSI command. > + If ScsiIo is NULL, then ASSERT(). > + If SenseDataLength is NULL, then ASSERT(). > + If HostAdapterStatus is NULL, then ASSERT(). > + If TargetStatus is NULL, then ASSERT(). > + If DataLength is NULL, then ASSERT(). > + > + If SenseDataLength is non-zero and SenseData is not NULL, SenseData mu= st meet buffer > + alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_I= NVALID_PARAMETER > + gets returned. > + > + If DataLength is non-zero and DataBuffer is not NULL, DataBuffer must = meet buffer > + alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_I= NVALID_PARAMETER > + gets returned. > + > + @param[in] ScsiIo SCSI IO Protocol to use. > + @param[in] Timeout The length of timeout period. > + @param[in, out] SenseData A pointer to output sense data. > + @param[in, out] SenseDataLength The length of output sense data. > + @param[out] HostAdapterStatus The status of Host Adapter. > + @param[out] TargetStatus The status of the target. > + @param[in] SecurityProtocol The Security Protocol to use. > + @param[in] SecurityProtocolSpecific The Security Protocol Specif= ic data. > + @param[in] TransferLength The size in bytes of the data all= ocation. > + @param[in, out] DataBuffer A pointer to a data buffer. > + @param[in, out] DataLength The length of data buffer. > + > + @retval EFI_SUCCESS Command is executed successfully. > + @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was execu= ted, but the entire DataBuffer could > + not be transferred. The actual nu= mber of bytes transferred is returned in DataLength. > + @retval EFI_NOT_READY The SCSI Request Packet could not= be sent because there are too many > + SCSI Command Packets already queu= ed. > + @retval EFI_DEVICE_ERROR A device error occurred while att= empting to send SCSI Request Packet. > + @retval EFI_UNSUPPORTED The command described by the SCSI= Request Packet is not supported by > + the SCSI initiator(i.e., SCSI Ho= st Controller) > + @retval EFI_TIMEOUT A timeout occurred while waiting = for the SCSI Request Packet to execute. > + @retval EFI_INVALID_PARAMETER The contents of the SCSI Request = Packet are invalid. > + > +**/ > +EFI_STATUS > +EFIAPI > +ScsiSecurityProtocolInCommand ( > + IN EFI_SCSI_IO_PROTOCOL *ScsiIo, > + IN UINT64 Timeout, > + IN OUT VOID *SenseData, OPTIONAL > + IN OUT UINT8 *SenseDataLength, > + OUT UINT8 *HostAdapterStatus, > + OUT UINT8 *TargetStatus, > + IN UINT8 SecurityProtocol, > + IN UINT16 SecurityProtocolSpecific, > + IN UINT32 TransferLength, > + IN OUT VOID *DataBuffer, OPTIONAL > + IN OUT UINT32 *DataLength > + ) > +{ > + EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket; > + EFI_STATUS Status; > + UINT8 Cdb[EFI_SCSI_OP_LENGTH_TWELVE]; > + > + ASSERT (SenseDataLength !=3D NULL); > + ASSERT (HostAdapterStatus !=3D NULL); > + ASSERT (TargetStatus !=3D NULL); > + ASSERT (DataLength !=3D NULL); > + ASSERT (ScsiIo !=3D NULL); > + > + ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET)); > + ZeroMem (Cdb, EFI_SCSI_OP_LENGTH_TWELVE); > + > + CommandPacket.Timeout =3D Timeout; > + CommandPacket.InDataBuffer =3D DataBuffer; > + CommandPacket.SenseData =3D SenseData; > + CommandPacket.InTransferLength =3D TransferLength; > + CommandPacket.Cdb =3D Cdb; > + // > + // Fill Cdb for Security Protocol In Command > + // > + Cdb[0] =3D EFI_SCSI_OP_SECURITY_PROTOCOL_IN; > + Cdb[1] =3D SecurityProtocol; > + WriteUnaligned16 ((UINT16 *)&Cdb[2], SwapBytes16 (SecurityProtocolSpec= ific)); > + WriteUnaligned32 ((UINT32 *)&Cdb[6], SwapBytes32 (TransferLength)); > + > + CommandPacket.CdbLength =3D EFI_SCSI_OP_LENGTH_TWELVE; > + CommandPacket.DataDirection =3D EFI_SCSI_DATA_IN; > + CommandPacket.SenseDataLength =3D *SenseDataLength; > + > + Status =3D ScsiIo->ExecuteScsiCommand (ScsiIo, = &CommandPacket, NULL); > + > + *HostAdapterStatus =3D CommandPacket.HostAdapterStatus; > + *TargetStatus =3D CommandPacket.TargetStatus; > + *SenseDataLength =3D CommandPacket.SenseDataLength; > + *DataLength =3D CommandPacket.InTransferLength; > + > + return Status; > +} > + > + > +/** > + Execute Security Protocol Out SCSI command on a specific SCSI target. > + > + Executes the SCSI Security Protocol Out command on the SCSI target spe= cified by ScsiIo. > + If Timeout is zero, then this function waits indefinitely for the comm= and to complete. > + If Timeout is greater than zero, then the command is executed and will= timeout after > + Timeout 100 ns units. The StartLba and SectorSize parameters are used= to construct > + the CDB for this SCSI command. > + If ScsiIo is NULL, then ASSERT(). > + If SenseDataLength is NULL, then ASSERT(). > + If HostAdapterStatus is NULL, then ASSERT(). > + If TargetStatus is NULL, then ASSERT(). > + If DataLength is NULL, then ASSERT(). > + > + If SenseDataLength is non-zero and SenseData is not NULL, SenseData mu= st meet buffer > + alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_I= NVALID_PARAMETER > + gets returned. > + > + If DataLength is non-zero and DataBuffer is not NULL, DataBuffer must = meet buffer > + alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_I= NVALID_PARAMETER > + gets returned. > + > + @param[in] ScsiIo SCSI IO Protocol to use. > + @param[in] Timeout The length of timeout period. > + @param[in, out] SenseData A pointer to output sense data. > + @param[in, out] SenseDataLength The length of output sense data. > + @param[out] HostAdapterStatus The status of Host Adapter. > + @param[out] TargetStatus The status of the target. > + @param[in] SecurityProtocol The Security Protocol to use. > + @param[in] SecurityProtocolSpecific The Security Protocol Specif= ic data. > + @param[in] TransferLength The size in bytes of the transfer= data. > + @param[in, out] DataBuffer A pointer to a data buffer. > + > + @retval EFI_SUCCESS Command is executed successfully. > + @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was execu= ted, but the entire DataBuffer could > + not be transferred. The actual nu= mber of bytes transferred is returned in DataLength. > + @retval EFI_NOT_READY The SCSI Request Packet could not= be sent because there are too many > + SCSI Command Packets already queu= ed. > + @retval EFI_DEVICE_ERROR A device error occurred while att= empting to send SCSI Request Packet. > + @retval EFI_UNSUPPORTED The command described by the SCSI= Request Packet is not supported by > + the SCSI initiator(i.e., SCSI Ho= st Controller) > + @retval EFI_TIMEOUT A timeout occurred while waiting = for the SCSI Request Packet to execute. > + @retval EFI_INVALID_PARAMETER The contents of the SCSI Request = Packet are invalid. > + > +**/ > +EFI_STATUS > +EFIAPI > +ScsiSecurityProtocolOutCommand ( > + IN EFI_SCSI_IO_PROTOCOL *ScsiIo, > + IN UINT64 Timeout, > + IN OUT VOID *SenseData, OPTIONAL > + IN OUT UINT8 *SenseDataLength, > + OUT UINT8 *HostAdapterStatus, > + OUT UINT8 *TargetStatus, > + IN UINT8 SecurityProtocol, > + IN UINT16 SecurityProtocolSpecific, > + IN UINT32 TransferLength, > + IN OUT VOID *DataBuffer OPTIONAL > + ) > +{ > + EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket; > + EFI_STATUS Status; > + UINT8 Cdb[EFI_SCSI_OP_LENGTH_TWELVE]; > + > + ASSERT (SenseDataLength !=3D NULL); > + ASSERT (HostAdapterStatus !=3D NULL); > + ASSERT (TargetStatus !=3D NULL); > + ASSERT (ScsiIo !=3D NULL); > + > + ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET)); > + ZeroMem (Cdb, EFI_SCSI_OP_LENGTH_TWELVE); > + > + CommandPacket.Timeout =3D Timeout; > + CommandPacket.OutDataBuffer =3D DataBuffer; > + CommandPacket.SenseData =3D SenseData; > + CommandPacket.OutTransferLength =3D TransferLength; > + CommandPacket.Cdb =3D Cdb; > + // > + // Fill Cdb for Security Protocol Out Command > + // > + Cdb[0] =3D EFI_SCSI_OP_SECURITY_PROTOCOL_OUT; > + Cdb[1] =3D SecurityProtocol; > + WriteUnaligned16 ((UINT16 *)&Cdb[2], SwapBytes16 (SecurityProtocolSpec= ific)); > + WriteUnaligned32 ((UINT32 *)&Cdb[6], SwapBytes32 (TransferLength)); > + > + CommandPacket.CdbLength =3D EFI_SCSI_OP_LENGTH_TWELVE; > + CommandPacket.DataDirection =3D EFI_SCSI_DATA_OUT; > + CommandPacket.SenseDataLength =3D *SenseDataLength; > + > + Status =3D ScsiIo->ExecuteScsiCommand (ScsiIo, = &CommandPacket, NULL); > + > + *HostAdapterStatus =3D CommandPacket.HostAdapterStatus; > + *TargetStatus =3D CommandPacket.TargetStatus; > + *SenseDataLength =3D CommandPacket.SenseDataLength; > + > + return Status; > +} > + > + > /** > Internal helper notify function in which update the result of the > non-blocking SCSI Read/Write commands and signal caller event. > -- > 2.16.2.windows.1