/** @file\r
The implementation of EFI_EXT_SCSI_PASS_THRU_PROTOCOL.\r
\r
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
#include "IScsiImpl.h"\r
\r
-EFI_EXT_SCSI_PASS_THRU_PROTOCOL gIScsiExtScsiPassThruProtocolTemplate = {\r
+EFI_EXT_SCSI_PASS_THRU_PROTOCOL gIScsiExtScsiPassThruProtocolTemplate = {\r
NULL,\r
IScsiExtScsiPassThruFunction,\r
IScsiExtScsiPassThruGetNextTargetLun,\r
IScsiExtScsiPassThruGetNextTarget\r
};\r
\r
-\r
/**\r
Sends a SCSI Request Packet to a SCSI device that is attached to the SCSI channel.\r
This function supports both blocking I/O and nonblocking I/O. The blocking I/O\r
- functionality is required, and the nonblocking I/O functionality is optional. \r
+ functionality is required, and the nonblocking I/O functionality is optional.\r
\r
@param[in] This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r
@param[in] Target The Target is an array of size TARGET_MAX_BYTES and it\r
represents the id of the SCSI device to send the SCSI\r
Request Packet. Each transport driver may choose to\r
utilize a subset of this size to suit the needs\r
- of transport target representation. For example, a \r
+ of transport target representation. For example, a\r
Fibre Channel driver may use only 8 bytes (WWN)\r
to represent an FC target.\r
@param[in] Lun The LUN of the SCSI device to send the SCSI Request Packet.\r
@param[in, out] Packet A pointer to the SCSI Request Packet to send to the\r
- SCSI device specified by Target and Lun. \r
+ SCSI device specified by Target and Lun.\r
@param[in] Event If nonblocking I/O is not supported then Event is ignored,\r
and blocking I/O is performed. If Event is NULL, then\r
blocking I/O is performed. If Event is not NULL and non\r
completes.\r
\r
@retval EFI_SUCCESS The SCSI Request Packet was sent by the host. For\r
- bi-directional commands, InTransferLength bytes \r
+ bi-directional commands, InTransferLength bytes\r
were transferred from InDataBuffer.\r
For write and bi-directional commands, OutTransferLength\r
bytes were transferred by OutDataBuffer.\r
there are too many SCSI Request Packets already\r
queued. The caller may retry later.\r
@retval EFI_DEVICE_ERROR A device error occurred while attempting to send\r
- the SCSI Request Packet. \r
+ the SCSI Request Packet.\r
@retval EFI_INVALID_PARAMETER Target, Lun, or the contents of ScsiRequestPacket,\r
are invalid.\r
@retval EFI_UNSUPPORTED The command described by the SCSI Request Packet\r
EFI_STATUS\r
EFIAPI\r
IScsiExtScsiPassThruFunction (\r
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,\r
- IN UINT8 *Target,\r
- IN UINT64 Lun,\r
- IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,\r
- IN EFI_EVENT Event OPTIONAL\r
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,\r
+ IN UINT8 *Target,\r
+ IN UINT64 Lun,\r
+ IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,\r
+ IN EFI_EVENT Event OPTIONAL\r
)\r
{\r
EFI_STATUS Status;\r
ISCSI_DRIVER_DATA *Private;\r
- \r
+\r
if (Target[0] != 0) {\r
return EFI_INVALID_PARAMETER;\r
}\r
return Status;\r
}\r
\r
-\r
/**\r
Used to retrieve the list of legal Target IDs and LUNs for SCSI devices on\r
a SCSI channel. These can either be the list SCSI devices that are actually\r
present on the SCSI channel, or the list of legal Target Ids and LUNs for the\r
- SCSI channel. Regardless, the caller of this function must probe the Target ID \r
- and LUN returned to see if a SCSI device is actually present at that location \r
- on the SCSI channel. \r
+ SCSI channel. Regardless, the caller of this function must probe the Target ID\r
+ and LUN returned to see if a SCSI device is actually present at that location\r
+ on the SCSI channel.\r
\r
@param[in] This The EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r
@param[in, out] Target On input, a pointer to the Target ID of a SCSI\r
IN OUT UINT64 *Lun\r
)\r
{\r
- ISCSI_DRIVER_DATA *Private;\r
- ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData;\r
- UINT8 TargetId[TARGET_MAX_BYTES];\r
+ ISCSI_DRIVER_DATA *Private;\r
+ ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData;\r
+ UINT8 TargetId[TARGET_MAX_BYTES];\r
\r
- Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);\r
- ConfigNvData = &Private->Session->ConfigData->SessionConfigData;\r
+ Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);\r
+ ConfigNvData = &Private->Session->ConfigData->SessionConfigData;\r
\r
- if ((*Target)[0] == 0 && (CompareMem (Lun, ConfigNvData->BootLun, sizeof (UINT64)) == 0)) {\r
+ if (((*Target)[0] == 0) && (CompareMem (Lun, ConfigNvData->BootLun, sizeof (UINT64)) == 0)) {\r
//\r
// Only one <Target, Lun> pair per iSCSI Driver instance.\r
//\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
-\r
/**\r
Allocate and build a device path node for a SCSI device on a SCSI channel.\r
\r
IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath\r
)\r
{\r
- ISCSI_DRIVER_DATA *Private;\r
- ISCSI_SESSION *Session;\r
- ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData;\r
- ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfig;\r
- EFI_DEV_PATH *Node;\r
- UINTN DevPathNodeLen;\r
-\r
- if ((DevicePath == NULL)) {\r
+ ISCSI_DRIVER_DATA *Private;\r
+ ISCSI_SESSION *Session;\r
+ ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData;\r
+ ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfig;\r
+ EFI_DEV_PATH *Node;\r
+ UINTN DevPathNodeLen;\r
+\r
+ if (DevicePath == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
return EFI_NOT_FOUND;\r
}\r
\r
- Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);\r
- Session = Private->Session;\r
- ConfigNvData = &Session->ConfigData->SessionConfigData;\r
- AuthConfig = Session->AuthData.CHAP.AuthConfig;\r
+ Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);\r
+ Session = Private->Session;\r
+ ConfigNvData = &Session->ConfigData->SessionConfigData;\r
+ AuthConfig = Session->AuthData.CHAP.AuthConfig;\r
\r
if (CompareMem (&Lun, ConfigNvData->BootLun, sizeof (UINT64)) != 0) {\r
return EFI_NOT_FOUND;\r
}\r
\r
- DevPathNodeLen = sizeof (ISCSI_DEVICE_PATH) + AsciiStrLen (ConfigNvData->TargetName) + 1;\r
- Node = AllocateZeroPool (DevPathNodeLen);\r
+ DevPathNodeLen = sizeof (ISCSI_DEVICE_PATH) + AsciiStrLen (ConfigNvData->TargetName) + 1;\r
+ Node = AllocateZeroPool (DevPathNodeLen);\r
if (Node == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
//\r
Node->Iscsi.NetworkProtocol = 0;\r
\r
- Node->Iscsi.LoginOption = 0;\r
+ Node->Iscsi.LoginOption = 0;\r
\r
switch (Session->AuthType) {\r
- case ISCSI_AUTH_TYPE_NONE:\r
- Node->Iscsi.LoginOption |= 0x0800;\r
- break;\r
-\r
- case ISCSI_AUTH_TYPE_CHAP:\r
- //\r
- // Bit12: 0=CHAP_BI, 1=CHAP_UNI\r
- //\r
- if (AuthConfig->CHAPType == ISCSI_CHAP_UNI) {\r
- Node->Iscsi.LoginOption |= 0x1000;\r
- }\r
- break;\r
-\r
- default:\r
- break;\r
+ case ISCSI_AUTH_TYPE_NONE:\r
+ Node->Iscsi.LoginOption |= 0x0800;\r
+ break;\r
+\r
+ case ISCSI_AUTH_TYPE_CHAP:\r
+ //\r
+ // Bit12: 0=CHAP_BI, 1=CHAP_UNI\r
+ //\r
+ if (AuthConfig->CHAPType == ISCSI_CHAP_UNI) {\r
+ Node->Iscsi.LoginOption |= 0x1000;\r
+ }\r
+\r
+ break;\r
+\r
+ default:\r
+ break;\r
}\r
\r
CopyMem (&Node->Iscsi.Lun, ConfigNvData->BootLun, sizeof (UINT64));\r
Node->Iscsi.TargetPortalGroupTag = Session->TargetPortalGroupTag;\r
- AsciiStrCpy ((CHAR8 *) Node + sizeof (ISCSI_DEVICE_PATH), ConfigNvData->TargetName);\r
+ AsciiStrCpyS ((CHAR8 *)Node + sizeof (ISCSI_DEVICE_PATH), AsciiStrLen (ConfigNvData->TargetName) + 1, ConfigNvData->TargetName);\r
\r
- *DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Node;\r
+ *DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)Node;\r
\r
return EFI_SUCCESS;\r
}\r
\r
-\r
/**\r
Translate a device path node to a Target ID and LUN.\r
\r
@retval EFI_INVALID_PARAMETER DevicePath/Target/Lun is NULL.\r
@retval EFI_UNSUPPORTED This driver does not support the device path node\r
type in DevicePath.\r
- @retval EFI_NOT_FOUND A valid translation does not exist from DevicePath \r
+ @retval EFI_NOT_FOUND A valid translation does not exist from DevicePath\r
to a TargetID and LUN.\r
\r
**/\r
OUT UINT64 *Lun\r
)\r
{\r
- ISCSI_DRIVER_DATA *Private;\r
- ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData;\r
+ ISCSI_DRIVER_DATA *Private;\r
+ ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData;\r
\r
if ((DevicePath == NULL) || (Target == NULL) || (Lun == NULL)) {\r
return EFI_INVALID_PARAMETER;\r
if ((DevicePath->Type != MESSAGING_DEVICE_PATH) ||\r
(DevicePath->SubType != MSG_ISCSI_DP) ||\r
(DevicePathNodeLength (DevicePath) <= sizeof (ISCSI_DEVICE_PATH))\r
- ) {\r
+ )\r
+ {\r
return EFI_UNSUPPORTED;\r
}\r
\r
- Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);\r
- ConfigNvData = &Private->Session->ConfigData->SessionConfigData;\r
+ Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);\r
+ ConfigNvData = &Private->Session->ConfigData->SessionConfigData;\r
\r
SetMem (*Target, TARGET_MAX_BYTES, 0xFF);\r
(*Target)[0] = 0;\r
\r
- if (AsciiStrCmp (ConfigNvData->TargetName, (CHAR8 *) DevicePath + sizeof (ISCSI_DEVICE_PATH)) != 0) {\r
+ if (AsciiStrCmp (ConfigNvData->TargetName, (CHAR8 *)DevicePath + sizeof (ISCSI_DEVICE_PATH)) != 0) {\r
return EFI_UNSUPPORTED;\r
}\r
\r
return EFI_SUCCESS;\r
}\r
\r
-\r
/**\r
Resets a SCSI channel. This operation resets all the SCSI devices connected to\r
the SCSI channel.\r
return EFI_UNSUPPORTED;\r
}\r
\r
-\r
/**\r
Resets a SCSI device that is connected to a SCSI channel.\r
\r
}\r
\r
/**\r
- Retrieve the list of legal Target IDs for SCSI devices on a SCSI channel. \r
+ Retrieve the list of legal Target IDs for SCSI devices on a SCSI channel.\r
\r
@param[in] This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL\r
instance.\r
next SCSI device present on a SCSI channel.\r
An input value of 0xF(all bytes in the array are 0xF)\r
in the Target array retrieves the Target ID of the\r
- first SCSI device present on a SCSI channel. \r
+ first SCSI device present on a SCSI channel.\r
\r
@retval EFI_SUCCESS The Target ID of the next SCSI device on the SCSI\r
channel was returned in Target.\r
IN OUT UINT8 **Target\r
)\r
{\r
- UINT8 TargetId[TARGET_MAX_BYTES];\r
+ UINT8 TargetId[TARGET_MAX_BYTES];\r
\r
SetMem (TargetId, TARGET_MAX_BYTES, 0xFF);\r
\r
return EFI_INVALID_PARAMETER;\r
}\r
}\r
-\r