Adopt new IPv4/IPv6 device path for network modules.

Signed-off-by: tye
Reviewed-by: niruiyu

Adopt SasEx and new IPv6 device path for DevicePathDxe driver.
Signed-off-by: niruiyu
Reviewed-by: erictian

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12574 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
niruiyu
2011-10-26 09:29:46 +00:00
parent 8f5e3a12a9
commit 501793fad4
13 changed files with 291 additions and 20 deletions

View File

@@ -1684,6 +1684,74 @@ DevPathFromTextSAS (
return (EFI_DEVICE_PATH_PROTOCOL *) Sas;
}
/**
Converts a text device path node to Serial Attached SCSI Ex device path structure.
@param TextDeviceNode The input Text device path node.
@return A pointer to the newly-created Serial Attached SCSI Ex device path structure.
**/
EFI_DEVICE_PATH_PROTOCOL *
DevPathFromTextSasEx (
IN CHAR16 *TextDeviceNode
)
{
CHAR16 *AddressStr;
CHAR16 *LunStr;
CHAR16 *RTPStr;
CHAR16 *SASSATAStr;
CHAR16 *LocationStr;
CHAR16 *ConnectStr;
CHAR16 *DriveBayStr;
UINT16 Info;
SASEX_DEVICE_PATH *SasEx;
AddressStr = GetNextParamStr (&TextDeviceNode);
LunStr = GetNextParamStr (&TextDeviceNode);
RTPStr = GetNextParamStr (&TextDeviceNode);
SASSATAStr = GetNextParamStr (&TextDeviceNode);
LocationStr = GetNextParamStr (&TextDeviceNode);
ConnectStr = GetNextParamStr (&TextDeviceNode);
DriveBayStr = GetNextParamStr (&TextDeviceNode);
Info = 0x0000;
SasEx = (SASEX_DEVICE_PATH *) CreateDeviceNode (
MESSAGING_DEVICE_PATH,
MSG_SASEX_DP,
(UINT16) sizeof (SASEX_DEVICE_PATH)
);
Strtoi64 (AddressStr, (UINT64 *) &SasEx->SasAddress);
Strtoi64 (LunStr, (UINT64 *) &SasEx->Lun);
*(UINT64 *) &SasEx->SasAddress = SwapBytes64 (*(UINT64 *) &SasEx->SasAddress);
*(UINT64 *) &SasEx->Lun = SwapBytes64 (*(UINT64 *) &SasEx->Lun);
SasEx->RelativeTargetPort = (UINT16) Strtoi (RTPStr);
if (StrCmp (SASSATAStr, L"NoTopology") != 0) {
if (StrCmp (DriveBayStr, L"0") == 0) {
Info |= 0x0001;
} else {
Info |= 0x0002;
Info = (UINT16) (Info | (Strtoi (DriveBayStr) << 8));
}
if (StrCmp (SASSATAStr, L"SATA") == 0) {
Info |= 0x0010;
}
if (StrCmp (LocationStr, L"External") == 0) {
Info |= 0x0020;
}
if (StrCmp (ConnectStr, L"Expanded") == 0) {
Info |= 0x0040;
}
}
SasEx->DeviceTopology = Info;
return (EFI_DEVICE_PATH_PROTOCOL *) SasEx;
}
/**
Converts a text device path node to Debug Port device path structure.
@@ -1843,12 +1911,16 @@ DevPathFromTextIPv6 (
CHAR16 *ProtocolStr;
CHAR16 *TypeStr;
CHAR16 *LocalIPStr;
CHAR16 *GatewayIPStr;
CHAR16 *PrefixLengthStr;
IPv6_DEVICE_PATH *IPv6;
RemoteIPStr = GetNextParamStr (&TextDeviceNode);
ProtocolStr = GetNextParamStr (&TextDeviceNode);
TypeStr = GetNextParamStr (&TextDeviceNode);
LocalIPStr = GetNextParamStr (&TextDeviceNode);
PrefixLengthStr = GetNextParamStr (&TextDeviceNode);
GatewayIPStr = GetNextParamStr (&TextDeviceNode);
IPv6 = (IPv6_DEVICE_PATH *) CreateDeviceNode (
MESSAGING_DEVICE_PATH,
MSG_IPv6_DP,
@@ -1858,12 +1930,21 @@ DevPathFromTextIPv6 (
StrToIPv6Addr (&RemoteIPStr, &IPv6->RemoteIpAddress);
IPv6->Protocol = (UINT16) NetworkProtocolFromText (ProtocolStr);
if (StrCmp (TypeStr, L"Static") == 0) {
IPv6->StaticIpAddress = TRUE;
IPv6->IpAddressOrigin = 0;
} else if (StrCmp (TypeStr, L"StatelessAutoConfigure") == 0) {
IPv6->IpAddressOrigin = 1;
} else {
IPv6->StaticIpAddress = FALSE;
IPv6->IpAddressOrigin = 2;
}
StrToIPv6Addr (&LocalIPStr, &IPv6->LocalIpAddress);
if (!IS_NULL (*GatewayIPStr) && !IS_NULL (*PrefixLengthStr)) {
StrToIPv6Addr (&GatewayIPStr, &IPv6->GatewayIpAddress);
IPv6->PrefixLength = (UINT8) Strtoi (PrefixLengthStr);
} else {
ZeroMem (&IPv6->GatewayIpAddress, sizeof (IPv6->GatewayIpAddress));
IPv6->PrefixLength = 0;
}
IPv6->LocalPort = 0;
IPv6->RemotePort = 0;
@@ -2895,6 +2976,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE DevPathFromTextTable[]
{L"VenUtf8", DevPathFromTextVenUtf8},
{L"UartFlowCtrl", DevPathFromTextUartFlowCtrl},
{L"SAS", DevPathFromTextSAS},
{L"SasEx", DevPathFromTextSasEx},
{L"DebugPort", DevPathFromTextDebugPort},
{L"MAC", DevPathFromTextMAC},
{L"IPv4", DevPathFromTextIPv4},