TianoCore EDK2 master
Loading...
Searching...
No Matches
IScsiMisc.c File Reference
#include "IScsiImpl.h"

Go to the source code of this file.

Functions

VOID IScsiStrTrim (IN OUT CHAR16 *Str, IN CHAR16 CharC)
 
UINT8 IScsiGetSubnetMaskPrefixLength (IN EFI_IPv4_ADDRESS *SubnetMask)
 
EFI_STATUS IScsiAsciiStrToLun (IN CHAR8 *Str, OUT UINT8 *Lun)
 
VOID IScsiLunToUnicodeStr (IN UINT8 *Lun, OUT CHAR16 *Str)
 
EFI_STATUS IScsiAsciiStrToIp (IN CHAR8 *Str, IN UINT8 IpMode, OUT EFI_IP_ADDRESS *Ip)
 
VOID IScsiMacAddrToStr (IN EFI_MAC_ADDRESS *Mac, IN UINT32 Len, IN UINT16 VlanId, OUT CHAR16 *Str)
 
EFI_STATUS IScsiBinToHex (IN UINT8 *BinBuffer, IN UINT32 BinLength, IN OUT CHAR8 *HexStr, IN OUT UINT32 *HexLength)
 
EFI_STATUS IScsiHexToBin (IN OUT UINT8 *BinBuffer, IN OUT UINT32 *BinLength, IN CHAR8 *HexStr)
 
UINTN IScsiNetNtoi (IN CHAR8 *Str)
 
EFI_STATUS IScsiGenRandom (IN OUT UINT8 *Rand, IN UINTN RandLength)
 
EFI_STATUS IScsiCheckIpv6Support (IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE Image, OUT BOOLEAN *Ipv6Support)
 
EFI_STATUS IScsiAddNic (IN EFI_HANDLE Controller, IN EFI_HANDLE Image)
 
EFI_STATUS IScsiRemoveNic (IN EFI_HANDLE Controller)
 
EFI_STATUS IScsiCreateAttempts (IN UINTN AttemptNum)
 
EFI_STATUS IScsiCreateKeywords (IN UINTN KeywordNum)
 
VOID IScsiCleanAttemptVariable (IN VOID)
 
ISCSI_NIC_INFOIScsiGetNicInfoByIndex (IN UINT8 NicIndex)
 
UINT16 IScsiGetNICPciLocation (IN EFI_HANDLE Controller, OUT UINTN *Bus, OUT UINTN *Device, OUT UINTN *Function)
 
VOID * IScsiGetVariableAndSize (IN CHAR16 *Name, IN EFI_GUID *VendorGuid, OUT UINTN *VariableSize)
 
ISCSI_DRIVER_DATAIScsiCreateDriverData (IN EFI_HANDLE Image, IN EFI_HANDLE Controller)
 
EFI_STATUS IScsiCleanDriverData (IN ISCSI_DRIVER_DATA *Private)
 
BOOLEAN IScsiDhcpIsConfigured (IN EFI_HANDLE Controller, IN UINT8 IpVersion)
 
BOOLEAN IScsiDnsIsConfigured (IN EFI_HANDLE Controller)
 
EFI_STATUS IScsiGetConfigData (IN ISCSI_DRIVER_DATA *Private)
 
EFI_DEVICE_PATH_PROTOCOLIScsiGetTcpConnDevicePath (IN ISCSI_SESSION *Session)
 
VOID EFIAPI IScsiOnExitBootService (IN EFI_EVENT Event, IN VOID *Context)
 
EFI_STATUS EFIAPI IScsiTestManagedDevice (IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE DriverBindingHandle, IN EFI_GUID *ProtocolGuid)
 

Variables

GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 IScsiHexString [] = "0123456789ABCDEFabcdef"
 

Detailed Description

Miscellaneous routines for iSCSI driver.

Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
Copyright (c) Microsoft Corporation SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file IScsiMisc.c.

Function Documentation

◆ IScsiAddNic()

EFI_STATUS IScsiAddNic ( IN EFI_HANDLE  Controller,
IN EFI_HANDLE  Image 
)

Record the NIC info in global structure.

Parameters
[in]ControllerThe handle of the controller.
[in]ImageHandle of the image.
Return values
EFI_SUCCESSThe operation is completed.
EFI_OUT_OF_RESOURCESDo not have sufficient resources to finish this operation.

Definition at line 607 of file IScsiMisc.c.

◆ IScsiAsciiStrToIp()

EFI_STATUS IScsiAsciiStrToIp ( IN CHAR8 *  Str,
IN UINT8  IpMode,
OUT EFI_IP_ADDRESS Ip 
)

Convert the formatted IP address into the binary IP address.

Parameters
[in]StrThe UNICODE string.
[in]IpModeIndicates whether the IP address is v4 or v6.
[out]IpThe storage to return the ASCII string.
Return values
EFI_SUCCESSThe binary IP address is returned in Ip.
EFI_INVALID_PARAMETERThe IP string is malformatted or IpMode is invalid.

Definition at line 248 of file IScsiMisc.c.

◆ IScsiAsciiStrToLun()

EFI_STATUS IScsiAsciiStrToLun ( IN CHAR8 *  Str,
OUT UINT8 *  Lun 
)

Convert the hexadecimal encoded LUN string into the 64-bit LUN.

Parameters
[in]StrThe hexadecimal encoded LUN string.
[out]LunStorage to return the 64-bit LUN.
Return values
EFI_SUCCESSThe 64-bit LUN is stored in Lun.
EFI_INVALID_PARAMETERThe string is malformatted.

Definition at line 118 of file IScsiMisc.c.

◆ IScsiBinToHex()

EFI_STATUS IScsiBinToHex ( IN UINT8 *  BinBuffer,
IN UINT32  BinLength,
IN OUT CHAR8 *  HexStr,
IN OUT UINT32 *  HexLength 
)

Convert the binary encoded buffer into a hexadecimal encoded string.

Parameters
[in]BinBufferThe buffer containing the binary data.
[in]BinLengthLength of the binary buffer.
[in,out]HexStrPointer to the string.
[in,out]HexLengthThe length of the string.
Return values
EFI_SUCCESSThe binary data is converted to the hexadecimal string and the length of the string is updated.
EFI_BUFFER_TOO_SMALLThe string is too small.
EFI_BAD_BUFFER_SIZEBinLength is too large for hex encoding.
EFI_INVALID_PARAMETERThe IP string is malformatted.

Definition at line 322 of file IScsiMisc.c.

◆ IScsiCheckIpv6Support()

EFI_STATUS IScsiCheckIpv6Support ( IN EFI_HANDLE  ControllerHandle,
IN EFI_HANDLE  Image,
OUT BOOLEAN *  Ipv6Support 
)

Check whether UNDI protocol supports IPv6.

Parameters
[in]ControllerHandleController handle.
[in]ImageHandle of the image.
[out]Ipv6SupportTRUE if UNDI supports IPv6.
Return values
EFI_SUCCESSGet the result whether UNDI supports IPv6 by NII or AIP protocol successfully.
EFI_NOT_FOUNDDon't know whether UNDI supports IPv6 since NII or AIP is not available.

Definition at line 503 of file IScsiMisc.c.

◆ IScsiCleanAttemptVariable()

VOID IScsiCleanAttemptVariable ( IN  VOID)

Free the attempt configure data variable.

Definition at line 1551 of file IScsiMisc.c.

◆ IScsiCleanDriverData()

EFI_STATUS IScsiCleanDriverData ( IN ISCSI_DRIVER_DATA Private)

Clean the iSCSI driver data.

Parameters
[in]PrivateThe iSCSI driver data.
Return values
EFI_SUCCESSThe clean operation is successful.
OthersOther errors as indicated.

Definition at line 1807 of file IScsiMisc.c.

◆ IScsiCreateAttempts()

EFI_STATUS IScsiCreateAttempts ( IN UINTN  AttemptNum)

Create and initialize the Attempts.

Parameters
[in]AttemptNumThe number of Attempts will be created.
Return values
EFI_SUCCESSThe Attempts have been created successfully.
OthersFailed to create the Attempt.

Definition at line 812 of file IScsiMisc.c.

◆ IScsiCreateDriverData()

ISCSI_DRIVER_DATA * IScsiCreateDriverData ( IN EFI_HANDLE  Image,
IN EFI_HANDLE  Controller 
)

Create the iSCSI driver data.

Parameters
[in]ImageThe handle of the driver image.
[in]ControllerThe handle of the controller.
Returns
The iSCSI driver data created.
Return values
NULLOther errors as indicated.

Definition at line 1748 of file IScsiMisc.c.

◆ IScsiCreateKeywords()

EFI_STATUS IScsiCreateKeywords ( IN UINTN  KeywordNum)

Create the iSCSI configuration Keywords for each attempt. You can find the keywords defined in the "x-UEFI-ns" namespace (http://www.uefi.org/confignamespace).

Parameters
[in]KeywordNumThe number Sets of Keywords will be created.
Return values
EFI_SUCCESSThe operation is completed.
OthersFailed to create the Keywords.

Definition at line 949 of file IScsiMisc.c.

◆ IScsiDhcpIsConfigured()

BOOLEAN IScsiDhcpIsConfigured ( IN EFI_HANDLE  Controller,
IN UINT8  IpVersion 
)

Check wheather the Controller handle is configured to use DHCP protocol.

Parameters
[in]ControllerThe handle of the controller.
[in]IpVersionIP_VERSION_4 or IP_VERSION_6.
Return values
TRUEThe handle of the controller need the Dhcp protocol.
FALSEThe handle of the controller does not need the Dhcp protocol.

Definition at line 1861 of file IScsiMisc.c.

◆ IScsiDnsIsConfigured()

BOOLEAN IScsiDnsIsConfigured ( IN EFI_HANDLE  Controller)

Check whether the Controller handle is configured to use DNS protocol.

Parameters
[in]ControllerThe handle of the controller.
Return values
TRUEThe handle of the controller need the Dns protocol.
FALSEThe handle of the controller does not need the Dns protocol.

Definition at line 1964 of file IScsiMisc.c.

◆ IScsiGenRandom()

EFI_STATUS IScsiGenRandom ( IN OUT UINT8 *  Rand,
IN UINTN  RandLength 
)

Generate random numbers.

Parameters
[in,out]RandThe buffer to contain random numbers.
[in]RandLengthThe length of the Rand buffer.
Return values
EFI_SUCCESSon success
otherson error

Definition at line 483 of file IScsiMisc.c.

◆ IScsiGetConfigData()

EFI_STATUS IScsiGetConfigData ( IN ISCSI_DRIVER_DATA Private)

Get the various configuration data.

Parameters
[in]PrivateThe iSCSI driver data.
Return values
EFI_SUCCESSThe configuration data is retrieved.
EFI_NOT_FOUNDThis iSCSI driver is not configured yet.
EFI_OUT_OF_RESOURCESFailed to allocate memory.

Definition at line 2055 of file IScsiMisc.c.

◆ IScsiGetNicInfoByIndex()

ISCSI_NIC_INFO * IScsiGetNicInfoByIndex ( IN UINT8  NicIndex)

Get the recorded NIC info from global structure by the Index.

Parameters
[in]NicIndexThe index indicates the position of NIC info.
Returns
Pointer to the NIC info, or NULL if not found.

Definition at line 1610 of file IScsiMisc.c.

◆ IScsiGetNICPciLocation()

UINT16 IScsiGetNICPciLocation ( IN EFI_HANDLE  Controller,
OUT UINTN Bus,
OUT UINTN Device,
OUT UINTN Function 
)

Get the NIC's PCI location and return it according to the composited format defined in iSCSI Boot Firmware Table.

Parameters
[in]ControllerThe handle of the controller.
[out]BusThe bus number.
[out]DeviceThe device number.
[out]FunctionThe function number.
Returns
The composited representation of the NIC PCI location.

Definition at line 1640 of file IScsiMisc.c.

◆ IScsiGetSubnetMaskPrefixLength()

UINT8 IScsiGetSubnetMaskPrefixLength ( IN EFI_IPv4_ADDRESS SubnetMask)

Calculate the prefix length of the IPv4 subnet mask.

Parameters
[in]SubnetMaskThe IPv4 subnet mask.
Returns
The prefix length of the subnet mask.
Return values
0Other errors as indicated.

Definition at line 76 of file IScsiMisc.c.

◆ IScsiGetTcpConnDevicePath()

EFI_DEVICE_PATH_PROTOCOL * IScsiGetTcpConnDevicePath ( IN ISCSI_SESSION Session)

Get the device path of the iSCSI tcp connection and update it.

Parameters
SessionThe iSCSI session.
Returns
The updated device path.
Return values
NULLOther errors as indicated.

Definition at line 2408 of file IScsiMisc.c.

◆ IScsiGetVariableAndSize()

VOID * IScsiGetVariableAndSize ( IN CHAR16 *  Name,
IN EFI_GUID VendorGuid,
OUT UINTN VariableSize 
)

Read the EFI variable (VendorGuid/Name) and return a dynamically allocated buffer, and the size of the buffer. If failure, return NULL.

Parameters
[in]NameString part of EFI variable name.
[in]VendorGuidGUID part of EFI variable name.
[out]VariableSizeReturns the size of the EFI variable that was read.
Returns
Dynamically allocated memory that contains a copy of the EFI variable.
Caller is responsible freeing the buffer.
Return values
NULLVariable was not read.

Definition at line 1698 of file IScsiMisc.c.

◆ IScsiHexToBin()

EFI_STATUS IScsiHexToBin ( IN OUT UINT8 *  BinBuffer,
IN OUT UINT32 *  BinLength,
IN CHAR8 *  HexStr 
)

Convert the hexadecimal string into a binary encoded buffer.

Parameters
[in,out]BinBufferThe binary buffer.
[in,out]BinLengthLength of the binary buffer.
[in]HexStrThe hexadecimal string.
Return values
EFI_SUCCESSThe hexadecimal string is converted into a binary encoded buffer.
EFI_INVALID_PARAMETERInvalid hex encoding found in HexStr.
EFI_BAD_BUFFER_SIZEThe length of HexStr is too large for decoding: the decoded size cannot be expressed in BinLength on output.
EFI_BUFFER_TOO_SMALLThe binary buffer is too small to hold the converted data.

Definition at line 385 of file IScsiMisc.c.

◆ IScsiLunToUnicodeStr()

VOID IScsiLunToUnicodeStr ( IN UINT8 *  Lun,
OUT CHAR16 *  Str 
)

Convert the 64-bit LUN into the hexadecimal encoded LUN string.

Parameters
[in]LunThe 64-bit LUN.
[out]StrThe storage to return the hexadecimal encoded LUN string.

Definition at line 193 of file IScsiMisc.c.

◆ IScsiMacAddrToStr()

VOID IScsiMacAddrToStr ( IN EFI_MAC_ADDRESS Mac,
IN UINT32  Len,
IN UINT16  VlanId,
OUT CHAR16 *  Str 
)

Convert the mac address into a hexadecimal encoded "-" separated string.

Parameters
[in]MacThe mac address.
[in]LenLength in bytes of the mac address.
[in]VlanIdVLAN ID of the network device.
[out]StrThe storage to return the mac string.

Definition at line 282 of file IScsiMisc.c.

◆ IScsiNetNtoi()

UINTN IScsiNetNtoi ( IN CHAR8 *  Str)

Convert the decimal-constant string or hex-constant string into a numerical value.

Parameters
[in]StrString in decimal or hex.
Returns
The numerical value.

Definition at line 459 of file IScsiMisc.c.

◆ IScsiOnExitBootService()

VOID EFIAPI IScsiOnExitBootService ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Abort the session when the transition from BS to RT is initiated.

Parameters
[in]EventThe event signaled.
[in]ContextThe iSCSI driver data.

Definition at line 2523 of file IScsiMisc.c.

◆ IScsiRemoveNic()

EFI_STATUS IScsiRemoveNic ( IN EFI_HANDLE  Controller)

Delete the recorded NIC info from global structure. Also delete corresponding attempts.

Parameters
[in]ControllerThe handle of the controller.
Return values
EFI_SUCCESSThe operation is completed.
EFI_NOT_FOUNDThe NIC info to be deleted is not recorded.

Definition at line 717 of file IScsiMisc.c.

◆ IScsiStrTrim()

VOID IScsiStrTrim ( IN OUT CHAR16 *  Str,
IN CHAR16  CharC 
)

Removes (trims) specified leading and trailing characters from a string.

Parameters
[in,out]StrPointer to the null-terminated string to be trimmed. On return, Str will hold the trimmed string.
[in]CharCCharacter will be trimmed from str.

Definition at line 24 of file IScsiMisc.c.

◆ IScsiTestManagedDevice()

EFI_STATUS EFIAPI IScsiTestManagedDevice ( IN EFI_HANDLE  ControllerHandle,
IN EFI_HANDLE  DriverBindingHandle,
IN EFI_GUID ProtocolGuid 
)

Tests whether a controller handle is being managed by IScsi driver.

This function tests whether the driver specified by DriverBindingHandle is currently managing the controller specified by ControllerHandle. This test is performed by evaluating if the protocol specified by ProtocolGuid is present on ControllerHandle and is was opened by DriverBindingHandle and Nic Device handle with an attribute of EFI_OPEN_PROTOCOL_BY_DRIVER. If ProtocolGuid is NULL, then ASSERT().

Parameters
ControllerHandleA handle for a controller to test.
DriverBindingHandleSpecifies the driver binding handle for the driver.
ProtocolGuidSpecifies the protocol that the driver specified by DriverBindingHandle opens in its Start() function.
Return values
EFI_SUCCESSControllerHandle is managed by the driver specified by DriverBindingHandle.
EFI_UNSUPPORTEDControllerHandle is not managed by the driver specified by DriverBindingHandle.

Definition at line 2565 of file IScsiMisc.c.

Variable Documentation

◆ IScsiHexString

GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 IScsiHexString[] = "0123456789ABCDEFabcdef"

Definition at line 12 of file IScsiMisc.c.