mirror of https://github.com/acidanthera/audk.git
1 update function header
2 update file header 3 correct some expression: Non-Boolean comparisons must use a compare operator 4 corrent some variable naming git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6960 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
9fd6fde8b2
commit
1055b68d04
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Miscellaneous routines for IScsi driver.
|
Miscellaneous routines for IScsi driver.
|
||||||
|
|
||||||
Copyright (c) 2004 - 2008, Intel Corporation
|
Copyright (c) 2004 - 2008, Intel Corporation.<BR>
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -10,14 +10,6 @@ http://opensource.org/licenses/bsd-license.php
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
Module Name:
|
|
||||||
|
|
||||||
IScsiMisc.c
|
|
||||||
|
|
||||||
Abstract:
|
|
||||||
|
|
||||||
Miscellaneous routines for IScsi driver.
|
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include "IScsiImpl.h"
|
#include "IScsiImpl.h"
|
||||||
|
@ -27,65 +19,62 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 IScsiHexString[] = "0123456789ABCDEFa
|
||||||
/**
|
/**
|
||||||
Removes (trims) specified leading and trailing characters from a string.
|
Removes (trims) specified leading and trailing characters from a string.
|
||||||
|
|
||||||
@param str[in][out] Pointer to the null-terminated string to be trimmed. On return,
|
@param[in, out] Str Pointer to the null-terminated string to be trimmed. On return,
|
||||||
str will hold the trimmed string.
|
str will hold the trimmed string.
|
||||||
|
|
||||||
@param CharC[in] Character will be trimmed from str.
|
|
||||||
|
|
||||||
@retval NONE.
|
|
||||||
|
|
||||||
|
@param[in] CharC Character will be trimmed from str.
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
StrTrim (
|
StrTrim (
|
||||||
IN OUT CHAR16 *str,
|
IN OUT CHAR16 *Str,
|
||||||
IN CHAR16 CharC
|
IN CHAR16 CharC
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CHAR16 *p1;
|
CHAR16 *Pointer1;
|
||||||
CHAR16 *p2;
|
CHAR16 *Pointer2;
|
||||||
|
|
||||||
if (*str == 0) {
|
if (*Str == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Trim off the leading and trailing characters c
|
// Trim off the leading and trailing characters c
|
||||||
//
|
//
|
||||||
for (p1 = str; *p1 && *p1 == CharC; p1++) {
|
for (Pointer1 = Str; (*Pointer1 != 0) && (*Pointer1 == CharC); Pointer1++) {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
p2 = str;
|
Pointer2 = Str;
|
||||||
if (p2 == p1) {
|
if (Pointer2 == Pointer1) {
|
||||||
while (*p1) {
|
while (*Pointer1 != 0) {
|
||||||
p2++;
|
Pointer2++;
|
||||||
p1++;
|
Pointer1++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (*p1) {
|
while (*Pointer1 != 0) {
|
||||||
*p2 = *p1;
|
*Pointer2 = *Pointer1;
|
||||||
p1++;
|
Pointer1++;
|
||||||
p2++;
|
Pointer2++;
|
||||||
}
|
}
|
||||||
*p2 = 0;
|
*Pointer2 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (p1 = str + StrLen(str) - 1; p1 >= str && *p1 == CharC; p1--) {
|
for (Pointer1 = Str + StrLen(Str) - 1; Pointer1 >= Str && *Pointer1 == CharC; Pointer1--) {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
if (p1 != str + StrLen(str) - 1) {
|
if (Pointer1 != Str + StrLen(Str) - 1) {
|
||||||
*(p1 + 1) = 0;
|
*(Pointer1 + 1) = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Calculate the prefix length of the IPv4 subnet mask.
|
Calculate the prefix length of the IPv4 subnet mask.
|
||||||
|
|
||||||
@param SubnetMask[in] The IPv4 subnet mask.
|
@param[in] SubnetMask The IPv4 subnet mask.
|
||||||
|
|
||||||
@retval The prefix length of the subnet mask.
|
|
||||||
|
|
||||||
|
@return The prefix length of the subnet mask.
|
||||||
|
@return 0 Some unexpected error happened.
|
||||||
**/
|
**/
|
||||||
UINT8
|
UINT8
|
||||||
IScsiGetSubnetMaskPrefixLength (
|
IScsiGetSubnetMaskPrefixLength (
|
||||||
|
@ -105,7 +94,7 @@ IScsiGetSubnetMaskPrefixLength (
|
||||||
//
|
//
|
||||||
ReverseMask = ~ReverseMask;
|
ReverseMask = ~ReverseMask;
|
||||||
|
|
||||||
if (ReverseMask & (ReverseMask + 1)) {
|
if ((ReverseMask != 0) & ((ReverseMask + 1) != 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,14 +111,11 @@ IScsiGetSubnetMaskPrefixLength (
|
||||||
/**
|
/**
|
||||||
Convert the hexadecimal encoded LUN string into the 64-bit LUN.
|
Convert the hexadecimal encoded LUN string into the 64-bit LUN.
|
||||||
|
|
||||||
@param Str[in] The hexadecimal encoded LUN string.
|
@param[in] Str The hexadecimal encoded LUN string.
|
||||||
|
@param[out] Lun Storage to return the 64-bit LUN.
|
||||||
@param Lun[out] Storage to return the 64-bit LUN.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The 64-bit LUN is stored in Lun.
|
@retval EFI_SUCCESS The 64-bit LUN is stored in Lun.
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER The string is malformatted.
|
@retval EFI_INVALID_PARAMETER The string is malformatted.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
IScsiAsciiStrToLun (
|
IScsiAsciiStrToLun (
|
||||||
|
@ -192,12 +178,8 @@ IScsiAsciiStrToLun (
|
||||||
/**
|
/**
|
||||||
Convert the 64-bit LUN into the hexadecimal encoded LUN string.
|
Convert the 64-bit LUN into the hexadecimal encoded LUN string.
|
||||||
|
|
||||||
@param Lun[in] The 64-bit LUN.
|
@param[in] Lun The 64-bit LUN.
|
||||||
|
@param[out] Str The storage to return the hexadecimal encoded LUN string.
|
||||||
@param Str[out] The storage to return the hexadecimal encoded LUN string.
|
|
||||||
|
|
||||||
@retval None.
|
|
||||||
|
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
IScsiLunToUnicodeStr (
|
IScsiLunToUnicodeStr (
|
||||||
|
@ -242,12 +224,10 @@ IScsiLunToUnicodeStr (
|
||||||
/**
|
/**
|
||||||
Convert the ASCII string into a UNICODE string.
|
Convert the ASCII string into a UNICODE string.
|
||||||
|
|
||||||
@param Source[out] The ASCII string.
|
@param[in] Source The ASCII string.
|
||||||
|
@param[out] Destination The storage to return the UNICODE string.
|
||||||
@param Destination[out] The storage to return the UNICODE string.
|
|
||||||
|
|
||||||
@retval CHAR16 * Pointer to the UNICODE string.
|
|
||||||
|
|
||||||
|
@return CHAR16 * Pointer to the UNICODE string.
|
||||||
**/
|
**/
|
||||||
CHAR16 *
|
CHAR16 *
|
||||||
IScsiAsciiStrToUnicodeStr (
|
IScsiAsciiStrToUnicodeStr (
|
||||||
|
@ -270,12 +250,11 @@ IScsiAsciiStrToUnicodeStr (
|
||||||
/**
|
/**
|
||||||
Convert the UNICODE string into an ASCII string.
|
Convert the UNICODE string into an ASCII string.
|
||||||
|
|
||||||
@param Source[in] The UNICODE string.
|
@param[in] Source The UNICODE string.
|
||||||
|
@param[out] Destination The storage to return the ASCII string.
|
||||||
@param Destination[out] The storage to return the ASCII string.
|
|
||||||
|
|
||||||
@retval CHAR8 * Pointer to the ASCII string.
|
|
||||||
|
|
||||||
|
@return CHAR8 * Pointer to the ASCII string.
|
||||||
|
**/
|
||||||
**/
|
**/
|
||||||
CHAR8 *
|
CHAR8 *
|
||||||
IScsiUnicodeStrToAsciiStr (
|
IScsiUnicodeStrToAsciiStr (
|
||||||
|
@ -303,14 +282,11 @@ IScsiUnicodeStrToAsciiStr (
|
||||||
/**
|
/**
|
||||||
Convert the decimal dotted IPv4 address into the binary IPv4 address.
|
Convert the decimal dotted IPv4 address into the binary IPv4 address.
|
||||||
|
|
||||||
@param Str[in] The UNICODE string.
|
@param[in] Str The UNICODE string.
|
||||||
|
@param[out] Ip The storage to return the ASCII string.
|
||||||
@param Ip[out] The storage to return the ASCII string.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The binary IP address is returned in Ip.
|
@retval EFI_SUCCESS The binary IP address is returned in Ip.
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER The IP string is malformatted.
|
@retval EFI_INVALID_PARAMETER The IP string is malformatted.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
IScsiAsciiStrToIp (
|
IScsiAsciiStrToIp (
|
||||||
|
@ -369,14 +345,9 @@ IScsiAsciiStrToIp (
|
||||||
/**
|
/**
|
||||||
Convert the mac address into a hexadecimal encoded "-" seperated string.
|
Convert the mac address into a hexadecimal encoded "-" seperated string.
|
||||||
|
|
||||||
@param Mac[in] The mac address.
|
@param[in] Mac The mac address.
|
||||||
|
@param[in] Len Length in bytes of the mac address.
|
||||||
@param Len[in] Length in bytes of the mac address.
|
@param[out] Str The storage to return the mac string.
|
||||||
|
|
||||||
@param Str[out] The storage to return the mac string.
|
|
||||||
|
|
||||||
@retval None.
|
|
||||||
|
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
IScsiMacAddrToStr (
|
IScsiMacAddrToStr (
|
||||||
|
@ -399,19 +370,15 @@ IScsiMacAddrToStr (
|
||||||
/**
|
/**
|
||||||
Convert the binary encoded buffer into a hexadecimal encoded string.
|
Convert the binary encoded buffer into a hexadecimal encoded string.
|
||||||
|
|
||||||
@param BinBuffer[in] The buffer containing the binary data.
|
@param[in] BinBuffer The buffer containing the binary data.
|
||||||
|
@param[in] BinLength Length of the binary buffer.
|
||||||
@param BinLength[in] Length of the binary buffer.
|
@param[in, out] HexStr Pointer to the string.
|
||||||
|
@param[in, out] HexLength The length of the string.
|
||||||
@param HexStr[in][out] Pointer to the string.
|
|
||||||
|
|
||||||
@param HexLength[in][out] The length of the string.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The binary data is converted to the hexadecimal string
|
@retval EFI_SUCCESS The binary data is converted to the hexadecimal string
|
||||||
and the length of the string is updated.
|
and the length of the string is updated.
|
||||||
|
|
||||||
@retval EFI_BUFFER_TOO_SMALL The string is too small.
|
@retval EFI_BUFFER_TOO_SMALL The string is too small.
|
||||||
|
@retval EFI_INVALID_PARAMETER The IP string is malformatted.
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
IScsiBinToHex (
|
IScsiBinToHex (
|
||||||
|
@ -452,17 +419,13 @@ IScsiBinToHex (
|
||||||
/**
|
/**
|
||||||
Convert the hexadecimal string into a binary encoded buffer.
|
Convert the hexadecimal string into a binary encoded buffer.
|
||||||
|
|
||||||
@param BinBuffer[in][out] The binary buffer.
|
@param[in, out] BinBuffer The binary buffer.
|
||||||
|
@param[in, out] BinLength Length of the binary buffer.
|
||||||
@param BinLength[in][out] Length of the binary buffer.
|
@param[in] HexStr The hexadecimal string.
|
||||||
|
|
||||||
@param HexStr[in] The hexadecimal string.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The hexadecimal string is converted into a binary
|
@retval EFI_SUCCESS The hexadecimal string is converted into a binary
|
||||||
encoded buffer.
|
encoded buffer.
|
||||||
|
|
||||||
@retval EFI_BUFFER_TOO_SMALL The binary buffer is too small to hold the converted data.s
|
@retval EFI_BUFFER_TOO_SMALL The binary buffer is too small to hold the converted data.s
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
IScsiHexToBin (
|
IScsiHexToBin (
|
||||||
|
@ -525,12 +488,8 @@ IScsiHexToBin (
|
||||||
/**
|
/**
|
||||||
Generate random numbers.
|
Generate random numbers.
|
||||||
|
|
||||||
@param Rand[in][out] The buffer to contain random numbers.
|
@param[in, out] Rand The buffer to contain random numbers.
|
||||||
|
@param[in] RandLength The length of the Rand buffer.
|
||||||
@param RandLength[in] The length of the Rand buffer.
|
|
||||||
|
|
||||||
@retval None.
|
|
||||||
|
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
IScsiGenRandom (
|
IScsiGenRandom (
|
||||||
|
@ -550,12 +509,11 @@ IScsiGenRandom (
|
||||||
/**
|
/**
|
||||||
Create the iSCSI driver data..
|
Create the iSCSI driver data..
|
||||||
|
|
||||||
@param Image[in] The handle of the driver image.
|
@param[in] Image The handle of the driver image.
|
||||||
|
@param[in] Controller The handle of the controller.
|
||||||
@param Controller[in] The handle of the controller.
|
|
||||||
|
|
||||||
@retval The iSCSI driver data created.
|
|
||||||
|
|
||||||
|
@return The iSCSI driver data created.
|
||||||
|
@return NULL Some unexpected error happened.
|
||||||
**/
|
**/
|
||||||
ISCSI_DRIVER_DATA *
|
ISCSI_DRIVER_DATA *
|
||||||
IScsiCreateDriverData (
|
IScsiCreateDriverData (
|
||||||
|
@ -625,10 +583,7 @@ IScsiCreateDriverData (
|
||||||
/**
|
/**
|
||||||
Clean the iSCSI driver data.
|
Clean the iSCSI driver data.
|
||||||
|
|
||||||
@param Private[in] The iSCSI driver data.
|
@param[in] Private The iSCSI driver data.
|
||||||
|
|
||||||
@retval None.
|
|
||||||
|
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
IScsiCleanDriverData (
|
IScsiCleanDriverData (
|
||||||
|
@ -659,15 +614,13 @@ IScsiCleanDriverData (
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Get the various configuration data of this iSCSI instance.
|
Get the various configuration data of this iSCSI instance.
|
||||||
|
|
||||||
@param Private[in] The iSCSI driver data.
|
@param[in] Private The iSCSI driver data.
|
||||||
|
|
||||||
@retval EFI_SUCCESS The configuration of this instance is got.
|
@retval EFI_SUCCESS The configuration of this instance is got.
|
||||||
|
@retval EFI_ABORTED The operation was aborted.
|
||||||
@retval EFI_NOT_FOUND This iSCSI instance is not configured yet.
|
@retval Others Some unexpected error happened.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
IScsiGetConfigData (
|
IScsiGetConfigData (
|
||||||
|
@ -754,10 +707,10 @@ IScsiGetConfigData (
|
||||||
/**
|
/**
|
||||||
Get the device path of the iSCSI tcp connection and update it.
|
Get the device path of the iSCSI tcp connection and update it.
|
||||||
|
|
||||||
@param Private[in] The iSCSI driver data.
|
@param[in] Private The iSCSI driver data.
|
||||||
|
|
||||||
@retval The updated device path.
|
|
||||||
|
|
||||||
|
@return The updated device path.
|
||||||
|
@return NULL Some unexpected error happened.
|
||||||
**/
|
**/
|
||||||
EFI_DEVICE_PATH_PROTOCOL *
|
EFI_DEVICE_PATH_PROTOCOL *
|
||||||
IScsiGetTcpConnDevicePath (
|
IScsiGetTcpConnDevicePath (
|
||||||
|
@ -818,12 +771,8 @@ IScsiGetTcpConnDevicePath (
|
||||||
/**
|
/**
|
||||||
Abort the session when the transition from BS to RT is initiated.
|
Abort the session when the transition from BS to RT is initiated.
|
||||||
|
|
||||||
@param Event[in] The event signaled.
|
@param[in] Event The event signaled.
|
||||||
|
@param[in] Context The iSCSI driver data.
|
||||||
@param Context[in] The iSCSI driver data.
|
|
||||||
|
|
||||||
@retval None.
|
|
||||||
|
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
|
|
Loading…
Reference in New Issue