summaryrefslogtreecommitdiff
path: root/EdkModulePkg
diff options
context:
space:
mode:
authorcwu11 <cwu11@6f19259b-4bc3-4df7-8a09-765794883524>2006-11-03 02:47:43 +0000
committercwu11 <cwu11@6f19259b-4bc3-4df7-8a09-765794883524>2006-11-03 02:47:43 +0000
commit511710d68f477e0210ae1830769e5d0cde4ea36a (patch)
tree98a972482719ce74286d602ca242153a0a5c9964 /EdkModulePkg
parentcb44bbdb8e15fc40362e6b0542be196c15c04615 (diff)
downloadedk2-platforms-511710d68f477e0210ae1830769e5d0cde4ea36a.tar.xz
1. Add the fix for the following Bugs:
i) BMM_FAKE_NV_DATA definition inconsistent in bm.vfr and BootMain.h (EdkNt32Pkg\Dxe\PlatformBdsDxe\Generic\BootMaint\BootMain.h) ii) Change some files’ EOL(end of line) format to DOS. Some file use even mixed style EOL. (EdkModulePkg\Universal\DevicePath\Dxe\DevicePath.c, DevicepathFromText.c, DevicePathUtilities.c; EdkModulePkg\Universal\Disk\DiskIo\Dxe\diskIo.c; MdePkg\Library\UefiLib\UefiNotTiano.c) iii) Change some illegal characters in many files, the problem is mainly connected with people using Chinese Input method to input symbols such as ' " - ?, etc. Multiple files are influenced. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1890 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkModulePkg')
-rw-r--r--EdkModulePkg/Core/Dxe/DxeMain.h10
-rw-r--r--EdkModulePkg/Core/Dxe/Hand/handle.c2
-rw-r--r--EdkModulePkg/Core/Dxe/Image/Image.c6
-rw-r--r--EdkModulePkg/Core/Pei/Memory/MemoryServices.c2
-rw-r--r--EdkModulePkg/Include/Library/OemHookStatusCodeLib.h4
-rw-r--r--EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/DebugLib.c2
-rw-r--r--EdkModulePkg/Library/EdkOemHookStatusCodeLibNull/OemHookStatusCodeLibNull.c4
-rw-r--r--EdkModulePkg/Library/EdkUefiDebugLibConOut/DebugLib.c2
-rw-r--r--EdkModulePkg/Library/EdkUefiDebugLibStdErr/DebugLib.c2
-rw-r--r--EdkModulePkg/Library/EdkUefiRuntimeLib/Common/RuntimeService.c8
-rw-r--r--EdkModulePkg/Library/EdkUefiRuntimeLib/Ipf/RuntimeService.c8
-rw-r--r--EdkModulePkg/Universal/DevicePath/Dxe/DevicePath.c178
-rw-r--r--EdkModulePkg/Universal/DevicePath/Dxe/DevicePathFromText.c4754
-rw-r--r--EdkModulePkg/Universal/DevicePath/Dxe/DevicePathUtilities.c422
-rw-r--r--EdkModulePkg/Universal/Disk/DiskIo/Dxe/diskio.c1562
-rw-r--r--EdkModulePkg/Universal/StatusCode/Dxe/Common/DxeStatusCodeCommon.c6
-rw-r--r--EdkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c4
-rw-r--r--EdkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.h12
-rw-r--r--EdkModulePkg/Universal/StatusCode/Dxe/Ipf/DxeStatusCodeIpf.c2
-rw-r--r--EdkModulePkg/Universal/StatusCode/Dxe/RtMemoryStatusCodeWorker.c4
-rw-r--r--EdkModulePkg/Universal/StatusCode/Dxe/SerialStatusCodeWorker.c4
-rw-r--r--EdkModulePkg/Universal/StatusCode/Pei/MemoryStausCodeWorker.c4
-rw-r--r--EdkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.c4
-rw-r--r--EdkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.h8
-rw-r--r--EdkModulePkg/Universal/StatusCode/Pei/SerialStatusCodeWorker.c4
-rw-r--r--EdkModulePkg/Universal/UserInterface/HiiDataBase/Dxe/Forms.c4
26 files changed, 3511 insertions, 3511 deletions
diff --git a/EdkModulePkg/Core/Dxe/DxeMain.h b/EdkModulePkg/Core/Dxe/DxeMain.h
index 9a9ba683e7..4ff23f3b0b 100644
--- a/EdkModulePkg/Core/Dxe/DxeMain.h
+++ b/EdkModulePkg/Core/Dxe/DxeMain.h
@@ -1669,7 +1669,7 @@ Arguments:
ExitData - Pointer to a pointer to a data buffer that includes a Null-terminated
Unicode string, optionally followed by additional binary data. The string
is a description that the caller may use to further indicate the reason for
- the image¡¯s exit.
+ the image's exit.
Returns:
@@ -1701,13 +1701,13 @@ Arguments:
ImageHandle - Handle that identifies the image. This parameter is passed to the image
on entry.
- Status - The image¡¯s exit code.
+ Status - The image's exit code.
ExitDataSize - The size, in bytes, of ExitData. Ignored if ExitStatus is
EFI_SUCCESS.
ExitData - Pointer to a data buffer that includes a Null-terminated Unicode string,
optionally followed by additional binary data. The string is a
description that the caller may use to further indicate the reason for
- the image¡¯s exit.
+ the image's exit.
Returns:
@@ -1740,8 +1740,8 @@ Arguments:
Type - The type of event to create and its mode and attributes
NotifyTpl - The task priority level of event notifications
- NotifyFunction - Pointer to the event’s notification function
- NotifyContext - Pointer to the notification function’s context; corresponds to
+ NotifyFunction - Pointer to the event's notification function
+ NotifyContext - Pointer to the notification function's context; corresponds to
parameter "Context" in the notification function
pEvent - Pointer to the newly created event if the call succeeds; undefined otherwise
diff --git a/EdkModulePkg/Core/Dxe/Hand/handle.c b/EdkModulePkg/Core/Dxe/Hand/handle.c
index 2edfdeb78b..f958bff63f 100644
--- a/EdkModulePkg/Core/Dxe/Hand/handle.c
+++ b/EdkModulePkg/Core/Dxe/Hand/handle.c
@@ -1325,7 +1325,7 @@ Arguments:
UserHandle - The handle for the protocol interface that was previously opened
with OpenProtocol(), and is now being closed.
- Protocol - The published unique identifier of the protocol. It is the caller¡¯s
+ Protocol - The published unique identifier of the protocol. It is the caller's
responsibility to pass in a valid GUID.
AgentHandle - The handle of the agent that is closing the protocol interface.
ControllerHandle - If the agent that opened a protocol is a driver that follows the
diff --git a/EdkModulePkg/Core/Dxe/Image/Image.c b/EdkModulePkg/Core/Dxe/Image/Image.c
index d77f4c4fca..9b9720d897 100644
--- a/EdkModulePkg/Core/Dxe/Image/Image.c
+++ b/EdkModulePkg/Core/Dxe/Image/Image.c
@@ -905,7 +905,7 @@ Arguments:
ExitData - Pointer to a pointer to a data buffer that includes a Null-terminated
Unicode string, optionally followed by additional binary data. The string
is a description that the caller may use to further indicate the reason for
- the image¡¯s exit.
+ the image's exit.
Returns:
@@ -1209,13 +1209,13 @@ Arguments:
ImageHandle - Handle that identifies the image. This parameter is passed to the image
on entry.
- Status - The image¡¯s exit code.
+ Status - The image's exit code.
ExitDataSize - The size, in bytes, of ExitData. Ignored if ExitStatus is
EFI_SUCCESS.
ExitData - Pointer to a data buffer that includes a Null-terminated Unicode string,
optionally followed by additional binary data. The string is a
description that the caller may use to further indicate the reason for
- the image¡¯s exit.
+ the image's exit.
Returns:
diff --git a/EdkModulePkg/Core/Pei/Memory/MemoryServices.c b/EdkModulePkg/Core/Pei/Memory/MemoryServices.c
index d49b7427b4..62cd59edf0 100644
--- a/EdkModulePkg/Core/Pei/Memory/MemoryServices.c
+++ b/EdkModulePkg/Core/Pei/Memory/MemoryServices.c
@@ -302,7 +302,7 @@ Returns:
EFI_HOB_MEMORY_POOL *Hob;
//
- // If some ¡°post-memory¡± PEIM wishes to allocate larger pool,
+ // If some "post-memory" PEIM wishes to allocate larger pool,
// it should use AllocatePages service instead.
//
ASSERT (Size < 0x10000 - sizeof (EFI_HOB_MEMORY_POOL));
diff --git a/EdkModulePkg/Include/Library/OemHookStatusCodeLib.h b/EdkModulePkg/Include/Library/OemHookStatusCodeLib.h
index 3de7551ceb..533df317ff 100644
--- a/EdkModulePkg/Include/Library/OemHookStatusCodeLib.h
+++ b/EdkModulePkg/Include/Library/OemHookStatusCodeLib.h
@@ -35,13 +35,13 @@ OemHookStatusCodeInitialize (
/**
Report status code to OEM device.
- @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions¡± below.
+ @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
@param Value Describes the current status of a hardware or software entity.
This included information about the class and subclass that is used to classify the entity
as well as an operation. For progress codes, the operation is the current activity.
For error codes, it is the exception. For debug codes, it is not defined at this time.
- Type EFI_STATUS_CODE_VALUE is defined in ¡°Related Definitions¡± below.
+ Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
@param Instance The enumeration of a hardware or software entity within the system.
diff --git a/EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/DebugLib.c b/EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/DebugLib.c
index fed9ba4d66..482e12e79e 100644
--- a/EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/DebugLib.c
+++ b/EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/DebugLib.c
@@ -225,7 +225,7 @@ DebugAssert (
If Buffer is NULL, then ASSERT().
- If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT().
+ If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
@param Buffer Pointer to the target buffer to fill with PcdDebugClearMemoryValue.
@param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue.
diff --git a/EdkModulePkg/Library/EdkOemHookStatusCodeLibNull/OemHookStatusCodeLibNull.c b/EdkModulePkg/Library/EdkOemHookStatusCodeLibNull/OemHookStatusCodeLibNull.c
index 98c98cc9d0..7816931e96 100644
--- a/EdkModulePkg/Library/EdkOemHookStatusCodeLibNull/OemHookStatusCodeLibNull.c
+++ b/EdkModulePkg/Library/EdkOemHookStatusCodeLibNull/OemHookStatusCodeLibNull.c
@@ -33,13 +33,13 @@ OemHookStatusCodeInitialize (
/**
Report status code to OEM device.
- @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions¡± below.
+ @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
@param Value Describes the current status of a hardware or software entity.
This included information about the class and subclass that is used to classify the entity
as well as an operation. For progress codes, the operation is the current activity.
For error codes, it is the exception. For debug codes, it is not defined at this time.
- Type EFI_STATUS_CODE_VALUE is defined in ¡°Related Definitions¡± below.
+ Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
@param Instance The enumeration of a hardware or software entity within the system.
diff --git a/EdkModulePkg/Library/EdkUefiDebugLibConOut/DebugLib.c b/EdkModulePkg/Library/EdkUefiDebugLibConOut/DebugLib.c
index 5f5f2c56ca..43d904a677 100644
--- a/EdkModulePkg/Library/EdkUefiDebugLibConOut/DebugLib.c
+++ b/EdkModulePkg/Library/EdkUefiDebugLibConOut/DebugLib.c
@@ -189,7 +189,7 @@ DebugAssert (
If Buffer is NULL, then ASSERT().
- If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT().
+ If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
@param Buffer Pointer to the target buffer to fill with PcdDebugClearMemoryValue.
@param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue.
diff --git a/EdkModulePkg/Library/EdkUefiDebugLibStdErr/DebugLib.c b/EdkModulePkg/Library/EdkUefiDebugLibStdErr/DebugLib.c
index 2016701284..9ba70df0d6 100644
--- a/EdkModulePkg/Library/EdkUefiDebugLibStdErr/DebugLib.c
+++ b/EdkModulePkg/Library/EdkUefiDebugLibStdErr/DebugLib.c
@@ -189,7 +189,7 @@ DebugAssert (
If Buffer is NULL, then ASSERT().
- If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT().
+ If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
@param Buffer Pointer to the target buffer to fill with PcdDebugClearMemoryValue.
@param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue.
diff --git a/EdkModulePkg/Library/EdkUefiRuntimeLib/Common/RuntimeService.c b/EdkModulePkg/Library/EdkUefiRuntimeLib/Common/RuntimeService.c
index 42a872cd5a..013c3f159f 100644
--- a/EdkModulePkg/Library/EdkUefiRuntimeLib/Common/RuntimeService.c
+++ b/EdkModulePkg/Library/EdkUefiRuntimeLib/Common/RuntimeService.c
@@ -68,7 +68,7 @@ Routine Description:
Arguments:
Time - A pointer to storage to receive a snapshot of the current time.
- Capabilities - An optional pointer to a buffer to receive the real time clock device¡¯s
+ Capabilities - An optional pointer to a buffer to receive the real time clock device's
capabilities.
Returns:
@@ -180,7 +180,7 @@ Routine Description:
Arguments:
VariableName - A Null-terminated Unicode string that is the name of the
- vendor¡¯s variable.
+ vendor's variable.
VendorGuid - A unique identifier for the vendor.
Attributes - If not NULL, a pointer to the memory location to return the
attributes bitmask for the variable.
@@ -248,7 +248,7 @@ Routine Description:
Arguments:
VariableName - A Null-terminated Unicode string that is the name of the
- vendor¡¯s variable.
+ vendor's variable.
VendorGuid - A unique identifier for the vendor.
Attributes - Attributes bitmask to set for the variable.
DataSize - The size in bytes of the Data buffer.
@@ -272,7 +272,7 @@ EfiGetNextHighMonotonicCount (
Routine Description:
- Returns the next high 32 bits of the platform¡¯s monotonic counter.
+ Returns the next high 32 bits of the platform's monotonic counter.
Arguments:
diff --git a/EdkModulePkg/Library/EdkUefiRuntimeLib/Ipf/RuntimeService.c b/EdkModulePkg/Library/EdkUefiRuntimeLib/Ipf/RuntimeService.c
index 13fa9d7e0a..159a53fc0e 100644
--- a/EdkModulePkg/Library/EdkUefiRuntimeLib/Ipf/RuntimeService.c
+++ b/EdkModulePkg/Library/EdkUefiRuntimeLib/Ipf/RuntimeService.c
@@ -81,7 +81,7 @@ Routine Description:
Arguments:
Time - A pointer to storage to receive a snapshot of the current time.
- Capabilities - An optional pointer to a buffer to receive the real time clock device¡¯s
+ Capabilities - An optional pointer to a buffer to receive the real time clock device's
capabilities.
Returns:
@@ -209,7 +209,7 @@ Routine Description:
Arguments:
VariableName - A Null-terminated Unicode string that is the name of the
- vendor¡¯s variable.
+ vendor's variable.
VendorGuid - A unique identifier for the vendor.
Attributes - If not NULL, a pointer to the memory location to return the
attributes bitmask for the variable.
@@ -305,7 +305,7 @@ Routine Description:
Arguments:
VariableName - A Null-terminated Unicode string that is the name of the
- vendor¡¯s variable.
+ vendor's variable.
VendorGuid - A unique identifier for the vendor.
Attributes - Attributes bitmask to set for the variable.
DataSize - The size in bytes of the Data buffer.
@@ -343,7 +343,7 @@ EfiGetNextHighMonotonicCount (
Routine Description:
- Returns the next high 32 bits of the platform¡¯s monotonic counter.
+ Returns the next high 32 bits of the platform's monotonic counter.
Arguments:
diff --git a/EdkModulePkg/Universal/DevicePath/Dxe/DevicePath.c b/EdkModulePkg/Universal/DevicePath/Dxe/DevicePath.c
index 6117a3245e..8aff74d64e 100644
--- a/EdkModulePkg/Universal/DevicePath/Dxe/DevicePath.c
+++ b/EdkModulePkg/Universal/DevicePath/Dxe/DevicePath.c
@@ -1,43 +1,43 @@
-/*++
-
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-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
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-Module Name:
-
- DevicePathDriver.c
-
-Abstract:
-
- Device Path Driver to produce DevPathUtilities Protocol, DevPathFromText Protocol
- and DevPathToText Protocol.
-
---*/
-
-#include "DevicePath.h"
-
-EFI_HANDLE mDevicePathHandle = NULL;
-
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+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
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DevicePathDriver.c
+
+Abstract:
+
+ Device Path Driver to produce DevPathUtilities Protocol, DevPathFromText Protocol
+ and DevPathToText Protocol.
+
+--*/
+
+#include "DevicePath.h"
+
+EFI_HANDLE mDevicePathHandle = NULL;
+
GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DEVICE_PATH_UTILITIES_PROTOCOL mDevicePathUtilities = {
- GetDevicePathSizeProtocolInterface,
- DuplicateDevicePathProtocolInterface,
- AppendDevicePathProtocolInterface,
- AppendDeviceNodeProtocolInterface,
- AppendDevicePathInstanceProtocolInterface,
- GetNextDevicePathInstanceProtocolInterface,
- IsDevicePathMultiInstanceProtocolInterface,
- CreateDeviceNodeProtocolInterface
+ GetDevicePathSizeProtocolInterface,
+ DuplicateDevicePathProtocolInterface,
+ AppendDevicePathProtocolInterface,
+ AppendDeviceNodeProtocolInterface,
+ AppendDevicePathInstanceProtocolInterface,
+ GetNextDevicePathInstanceProtocolInterface,
+ IsDevicePathMultiInstanceProtocolInterface,
+ CreateDeviceNodeProtocolInterface
};
GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DEVICE_PATH_TO_TEXT_PROTOCOL mDevicePathToText = {
- ConvertDeviceNodeToText,
- ConvertDevicePathToText
+ ConvertDeviceNodeToText,
+ ConvertDevicePathToText
};
GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL mDevicePathFromText = {
@@ -45,65 +45,65 @@ GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL mDevicePa
ConvertTextToDevicePath
};
-GLOBAL_REMOVE_IF_UNREFERENCED const EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid = DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL;
-GLOBAL_REMOVE_IF_UNREFERENCED const EFI_GUID mEfiDevicePathMessagingSASGuid = DEVICE_PATH_MESSAGING_SAS;
-
-EFI_STATUS
-EFIAPI
-DevicePathEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-/*++
-
- Routine Description:
- Entry point for EFI drivers.
-
- Arguments:
- ImageHandle - EFI_HANDLE
- SystemTable - EFI_SYSTEM_TABLE
-
- Returns:
- EFI_SUCCESS
- others
-
---*/
-{
- EFI_STATUS Status;
-
- Status = EFI_UNSUPPORTED;
+GLOBAL_REMOVE_IF_UNREFERENCED const EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid = DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL;
+GLOBAL_REMOVE_IF_UNREFERENCED const EFI_GUID mEfiDevicePathMessagingSASGuid = DEVICE_PATH_MESSAGING_SAS;
+
+EFI_STATUS
+EFIAPI
+DevicePathEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+ Routine Description:
+ Entry point for EFI drivers.
+
+ Arguments:
+ ImageHandle - EFI_HANDLE
+ SystemTable - EFI_SYSTEM_TABLE
+
+ Returns:
+ EFI_SUCCESS
+ others
+
+--*/
+{
+ EFI_STATUS Status;
+
+ Status = EFI_UNSUPPORTED;
if (FeaturePcdGet (PcdDevicePathSupportDevicePathToText)) {
if (FeaturePcdGet (PcdDevicePathSupportDevicePathFromText)) {
- Status = gBS->InstallMultipleProtocolInterfaces (
- &mDevicePathHandle,
- &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities,
- &gEfiDevicePathToTextProtocolGuid, &mDevicePathToText,
- &gEfiDevicePathFromTextProtocolGuid, &mDevicePathFromText,
- NULL
- );
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &mDevicePathHandle,
+ &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities,
+ &gEfiDevicePathToTextProtocolGuid, &mDevicePathToText,
+ &gEfiDevicePathFromTextProtocolGuid, &mDevicePathFromText,
+ NULL
+ );
} else {
- Status = gBS->InstallMultipleProtocolInterfaces (
- &mDevicePathHandle,
- &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities,
- &gEfiDevicePathToTextProtocolGuid, &mDevicePathToText,
- NULL
- );
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &mDevicePathHandle,
+ &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities,
+ &gEfiDevicePathToTextProtocolGuid, &mDevicePathToText,
+ NULL
+ );
}
} else {
if (FeaturePcdGet (PcdDevicePathSupportDevicePathFromText)) {
- Status = gBS->InstallMultipleProtocolInterfaces (
- &mDevicePathHandle,
- &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities,
- &gEfiDevicePathFromTextProtocolGuid, &mDevicePathFromText,
- NULL
- );
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &mDevicePathHandle,
+ &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities,
+ &gEfiDevicePathFromTextProtocolGuid, &mDevicePathFromText,
+ NULL
+ );
} else {
- Status = gBS->InstallMultipleProtocolInterfaces (
- &mDevicePathHandle,
- &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities,
- NULL
- );
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &mDevicePathHandle,
+ &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities,
+ NULL
+ );
}
}
- return Status;
-}
+ return Status;
+}
diff --git a/EdkModulePkg/Universal/DevicePath/Dxe/DevicePathFromText.c b/EdkModulePkg/Universal/DevicePath/Dxe/DevicePathFromText.c
index cd49359c76..d9dcd44352 100644
--- a/EdkModulePkg/Universal/DevicePath/Dxe/DevicePathFromText.c
+++ b/EdkModulePkg/Universal/DevicePath/Dxe/DevicePathFromText.c
@@ -1,2377 +1,2377 @@
-/*++
-
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-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
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-Module Name:
-
- DevicePathFromText.c
-
-Abstract:
-
- DevicePathFromText protocol as defined in the UEFI 2.0 specification.
-
---*/
-
-#include "DevicePath.h"
-
-CHAR16 *
-StrDuplicate (
- IN CONST CHAR16 *Src
- )
-/*++
-
- Routine Description:
- Duplicate a string
-
- Arguments:
- Src - Source string
-
- Returns:
- Duplicated string
-
---*/
-{
- UINTN Length;
- CHAR16 *ReturnStr;
-
- Length = StrLen ((CHAR16 *) Src);
-
- ReturnStr = AllocateCopyPool ((Length + 1) * sizeof (CHAR16), (VOID *) Src);
-
- return ReturnStr;
-}
-
-CHAR16 *
-GetParamByNodeName (
- IN CHAR16 *Str,
- IN CHAR16 *NodeName
- )
-/*++
-
- Routine Description:
- Get parameter in a pair of parentheses follow the given node name.
- For example, given the "Pci(0,1)" and NodeName "Pci", it returns "0,1".
-
- Arguments:
- Str - Device Path Text
- NodeName - Name of the node
-
- Returns:
- Parameter text for the node
-
---*/
-{
- CHAR16 *ParamStr;
- CHAR16 *StrPointer;
- UINTN NodeNameLength;
- UINTN ParameterLength;
-
- //
- // Check whether the node name matchs
- //
- NodeNameLength = StrLen (NodeName);
- if (CompareMem (Str, NodeName, NodeNameLength * sizeof (CHAR16)) != 0) {
- return NULL;
- }
-
- ParamStr = Str + NodeNameLength;
- if (!IS_LEFT_PARENTH (*ParamStr)) {
- return NULL;
- }
-
- //
- // Skip the found '(' and find first occurrence of ')'
- //
- ParamStr++;
- ParameterLength = 0;
- StrPointer = ParamStr;
- while (!IS_NULL (*StrPointer)) {
- if (IS_RIGHT_PARENTH (*StrPointer)) {
- break;
- }
- StrPointer++;
- ParameterLength++;
- }
- if (IS_NULL (*StrPointer)) {
- //
- // ')' not found
- //
- return NULL;
- }
-
- ParamStr = AllocateCopyPool ((ParameterLength + 1) * sizeof (CHAR16), ParamStr);
- if (ParamStr == NULL) {
- return NULL;
- }
- //
- // Terminate the parameter string
- //
- ParamStr[ParameterLength] = L'\0';
-
- return ParamStr;
-}
-
-CHAR16 *
-SplitStr (
- IN OUT CHAR16 **List,
- IN CHAR16 Separator
- )
-/*++
-
- Routine Description:
- Get current sub-string from a string list, before return
- the list header is moved to next sub-string. The sub-string is separated
- by the specified character. For example, the separator is ',', the string
- list is "2,0,3", it returns "2", the remain list move to "2,3"
-
- Arguments:
- List - A string list separated by the specified separator
- Separator - The separator character
-
- Returns:
- pointer - The current sub-string
-
---*/
-{
- CHAR16 *Str;
- CHAR16 *ReturnStr;
-
- Str = *List;
- ReturnStr = Str;
-
- if (IS_NULL (*Str)) {
- return ReturnStr;
- }
-
- //
- // Find first occurrence of the separator
- //
- while (!IS_NULL (*Str)) {
- if (*Str == Separator) {
- break;
- }
- Str++;
- }
-
- if (*Str == Separator) {
- //
- // Find a sub-string, terminate it
- //
- *Str = L'\0';
- Str++;
- }
-
- //
- // Move to next sub-string
- //
- *List = Str;
-
- return ReturnStr;
-}
-
-CHAR16 *
-GetNextParamStr (
- IN OUT CHAR16 **List
- )
-{
- //
- // The separator is comma
- //
- return SplitStr (List, L',');
-}
-
-CHAR16 *
-GetNextDeviceNodeStr (
- IN OUT CHAR16 **DevicePath,
- OUT BOOLEAN *IsInstanceEnd
- )
-/*++
-
- Routine Description:
- Get one device node from entire device path text.
-
- Arguments:
- Str - The entire device path text string
- IsInstanceEnd - This node is the end of a device path instance
-
- Returns:
- a pointer - A device node text
- NULL - No more device node available
-
---*/
-{
- CHAR16 *Str;
- CHAR16 *ReturnStr;
- UINTN ParenthesesStack;
-
- Str = *DevicePath;
- if (IS_NULL (*Str)) {
- return NULL;
- }
-
- //
- // Skip the leading '/', '(', ')' and ','
- //
- while (!IS_NULL (*Str)) {
- if (!IS_SLASH (*Str) &&
- !IS_COMMA (*Str) &&
- !IS_LEFT_PARENTH (*Str) &&
- !IS_RIGHT_PARENTH (*Str)) {
- break;
- }
- Str++;
- }
-
- ReturnStr = Str;
-
- //
- // Scan for the separator of this device node, '/' or ','
- //
- ParenthesesStack = 0;
- while (!IS_NULL (*Str)) {
- if ((IS_COMMA (*Str) || IS_SLASH (*Str)) && (ParenthesesStack == 0)) {
- break;
- }
-
- if (IS_LEFT_PARENTH (*Str)) {
- ParenthesesStack++;
- } else if (IS_RIGHT_PARENTH (*Str)) {
- ParenthesesStack--;
- }
-
- Str++;
- }
-
- if (ParenthesesStack != 0) {
- //
- // The '(' doesn't pair with ')', invalid device path text
- //
- return NULL;
- }
-
- if (IS_COMMA (*Str)) {
- *IsInstanceEnd = TRUE;
- *Str = L'\0';
- Str++;
- } else {
- *IsInstanceEnd = FALSE;
- if (!IS_NULL (*Str)) {
- *Str = L'\0';
- Str++;
- }
- }
-
- *DevicePath = Str;
-
- return ReturnStr;
-}
-
-BOOLEAN
-IsHexDigit (
- OUT UINT8 *Digit,
- IN CHAR16 Char
- )
-/*++
-
- Routine Description:
- Determines if a Unicode character is a hexadecimal digit.
- The test is case insensitive.
-
- Arguments:
- Digit - Pointer to byte that receives the value of the hex character.
- Char - Unicode character to test.
-
- Returns:
- TRUE - If the character is a hexadecimal digit.
- FALSE - Otherwise.
-
---*/
-{
- if ((Char >= L'0') && (Char <= L'9')) {
- *Digit = (UINT8) (Char - L'0');
- return TRUE;
- }
-
- if ((Char >= L'A') && (Char <= L'F')) {
- *Digit = (UINT8) (Char - L'A' + 0x0A);
- return TRUE;
- }
-
- if ((Char >= L'a') && (Char <= L'f')) {
- *Digit = (UINT8) (Char - L'a' + 0x0A);
- return TRUE;
- }
-
- return FALSE;
-}
-
-CHAR16
-NibbleToHexChar (
- IN UINT8 Nibble
- )
-/*++
-
- Routine Description:
- Converts the low nibble of a byte to hex unicode character.
-
- Arguments:
- Nibble - lower nibble of a byte.
-
- Returns:
- Hex unicode character.
-
---*/
-{
- Nibble &= 0x0F;
- if (Nibble <= 0x9) {
- return (CHAR16)(Nibble + L'0');
- }
-
- return (CHAR16)(Nibble - 0xA + L'A');
-}
-
-EFI_STATUS
-HexStringToBuf (
- IN OUT UINT8 *Buf,
- IN OUT UINTN *Len,
- IN CHAR16 *Str,
- OUT UINTN *ConvertedStrLen OPTIONAL
- )
-/*++
-
- Routine Description:
- Converts Unicode string to binary buffer.
- The conversion may be partial.
- The first character in the string that is not hex digit stops the conversion.
- At a minimum, any blob of data could be represented as a hex string.
-
- Arguments:
- Buf - Pointer to buffer that receives the data.
- Len - Length in bytes of the buffer to hold converted data.
- If routine return with EFI_SUCCESS, containing length of converted data.
- If routine return with EFI_BUFFER_TOO_SMALL, containg length of buffer desired.
- Str - String to be converted from.
- ConvertedStrLen - Length of the Hex String consumed.
-
- Returns:
- EFI_SUCCESS: Routine Success.
- EFI_BUFFER_TOO_SMALL: The buffer is too small to hold converted data.
- EFI_
-
---*/
-{
- UINTN HexCnt;
- UINTN Idx;
- UINTN BufferLength;
- UINT8 Digit;
- UINT8 Byte;
-
- //
- // Find out how many hex characters the string has.
- //
- for (Idx = 0, HexCnt = 0; IsHexDigit (&Digit, Str[Idx]); Idx++, HexCnt++);
-
- if (HexCnt == 0) {
- *Len = 0;
- return EFI_SUCCESS;
- }
- //
- // Two Unicode characters make up 1 buffer byte. Round up.
- //
- BufferLength = (HexCnt + 1) / 2;
-
- //
- // Test if buffer is passed enough.
- //
- if (BufferLength > (*Len)) {
- *Len = BufferLength;
- return EFI_BUFFER_TOO_SMALL;
- }
-
- *Len = BufferLength;
-
- for (Idx = 0; Idx < HexCnt; Idx++) {
-
- IsHexDigit (&Digit, Str[HexCnt - 1 - Idx]);
-
- //
- // For odd charaters, write the lower nibble for each buffer byte,
- // and for even characters, the upper nibble.
- //
- if ((Idx & 1) == 0) {
- Byte = Digit;
- } else {
- Byte = Buf[Idx / 2];
- Byte &= 0x0F;
- Byte |= Digit << 4;
- }
-
- Buf[Idx / 2] = Byte;
- }
-
- if (ConvertedStrLen != NULL) {
- *ConvertedStrLen = HexCnt;
- }
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-BufToHexString (
- IN OUT CHAR16 *Str,
- IN OUT UINTN *HexStringBufferLength,
- IN UINT8 *Buf,
- IN UINTN Len
- )
-/*++
-
- Routine Description:
- Converts binary buffer to Unicode string.
- At a minimum, any blob of data could be represented as a hex string.
-
- Arguments:
- Str - Pointer to the string.
- HexStringBufferLength - Length in bytes of buffer to hold the hex string. Includes tailing '\0' character.
- If routine return with EFI_SUCCESS, containing length of hex string buffer.
- If routine return with EFI_BUFFER_TOO_SMALL, containg length of hex string buffer desired.
- Buf - Buffer to be converted from.
- Len - Length in bytes of the buffer to be converted.
-
- Returns:
- EFI_SUCCESS: Routine success.
- EFI_BUFFER_TOO_SMALL: The hex string buffer is too small.
-
---*/
-{
- UINTN Idx;
- UINT8 Byte;
- UINTN StrLen;
-
- //
- // Make sure string is either passed or allocate enough.
- // It takes 2 Unicode characters (4 bytes) to represent 1 byte of the binary buffer.
- // Plus the Unicode termination character.
- //
- StrLen = Len * 2;
- if (StrLen > ((*HexStringBufferLength) - 1)) {
- *HexStringBufferLength = StrLen + 1;
- return EFI_BUFFER_TOO_SMALL;
- }
-
- *HexStringBufferLength = StrLen + 1;
- //
- // Ends the string.
- //
- Str[StrLen] = L'\0';
-
- for (Idx = 0; Idx < Len; Idx++) {
-
- Byte = Buf[Idx];
- Str[StrLen - 1 - Idx * 2] = NibbleToHexChar (Byte);
- Str[StrLen - 2 - Idx * 2] = NibbleToHexChar ((UINT8)(Byte >> 4));
- }
-
- return EFI_SUCCESS;
-}
-
-CHAR16 *
-TrimHexStr (
- IN CHAR16 *Str
- )
-/*++
-
- Routine Description:
- Skip the leading white space and '0x' or '0X' of a hex string
-
- Arguments:
- Str - The hex string
-
- Returns:
-
---*/
-{
- //
- // skip preceeding white space
- //
- while (*Str && *Str == ' ') {
- Str += 1;
- }
- //
- // skip preceeding zeros
- //
- while (*Str && *Str == '0') {
- Str += 1;
- }
- //
- // skip preceeding white space
- //
- if (*Str && (*Str == 'x' || *Str == 'X')) {
- Str += 1;
- }
-
- return Str;
-}
-
-UINTN
-Xtoi (
- IN CHAR16 *Str
- )
-/*++
-
-Routine Description:
-
- Convert hex string to uint
-
-Arguments:
-
- Str - The string
-
-Returns:
-
---*/
-{
- UINTN Rvalue;
- UINTN Length;
-
- ASSERT (Str != NULL);
-
- //
- // convert hex digits
- //
- Rvalue = 0;
- Length = sizeof (UINTN);
- HexStringToBuf ((UINT8 *) &Rvalue, &Length, TrimHexStr (Str), NULL);
-
- return Rvalue;
-}
-
-VOID
-Xtoi64 (
- IN CHAR16 *Str,
- IN UINT64 *Data
- )
-/*++
-
-Routine Description:
-
- Convert hex string to 64 bit data.
-
-Arguments:
-
- Str - The string
-
-Returns:
-
---*/
-{
- UINTN Length;
-
- *Data = 0;
- Length = sizeof (UINT64);
- HexStringToBuf ((UINT8 *) Data, &Length, TrimHexStr (Str), NULL);
-}
-
-UINTN
-Atoi (
- IN CHAR16 *str
- )
-/*++
-
-Routine Description:
-
- Convert decimal string to uint
-
-Arguments:
-
- Str - The string
-
-Returns:
-
---*/
-{
- UINTN Rvalue;
- CHAR16 Char;
- UINTN High;
- UINTN Low;
-
- ASSERT (str != NULL);
-
- High = (UINTN) -1 / 10;
- Low = (UINTN) -1 % 10;
- //
- // skip preceeding white space
- //
- while (*str && *str == ' ') {
- str += 1;
- }
- //
- // convert digits
- //
- Rvalue = 0;
- Char = *(str++);
- while (Char) {
- if (Char >= '0' && Char <= '9') {
- if ((Rvalue > High || Rvalue == High) && (Char - '0' > (INTN) Low)) {
- return (UINTN) -1;
- }
-
- Rvalue = (Rvalue * 10) + Char - '0';
- } else {
- break;
- }
-
- Char = *(str++);
- }
-
- return Rvalue;
-}
-
-EFI_STATUS
-StrToBuf (
- OUT UINT8 *Buf,
- IN UINTN BufferLength,
- IN CHAR16 *Str
- )
-{
- UINTN Index;
- UINTN StrLength;
- UINT8 Digit;
- UINT8 Byte;
-
- //
- // Two hex char make up one byte
- //
- StrLength = BufferLength * sizeof (CHAR16);
-
- for(Index = 0; Index < StrLength; Index++, Str++) {
-
- IsHexDigit (&Digit, *Str);
-
- //
- // For odd charaters, write the upper nibble for each buffer byte,
- // and for even characters, the lower nibble.
- //
- if ((Index & 1) == 0) {
- Byte = Digit << 4;
- } else {
- Byte = Buf[Index / 2];
- Byte &= 0xF0;
- Byte |= Digit;
- }
-
- Buf[Index / 2] = Byte;
- }
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-StrToGuid (
- IN CHAR16 *Str,
- OUT EFI_GUID *Guid
- )
-{
- UINTN BufferLength;
- UINTN ConvertedStrLen;
- EFI_STATUS Status;
-
- BufferLength = sizeof (Guid->Data1);
- Status = HexStringToBuf ((UINT8 *) &Guid->Data1, &BufferLength, Str, &ConvertedStrLen);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- Str += ConvertedStrLen;
- if (IS_HYPHEN (*Str)) {
- Str++;
- } else {
- return EFI_UNSUPPORTED;
- }
-
- BufferLength = sizeof (Guid->Data2);
- Status = HexStringToBuf ((UINT8 *) &Guid->Data2, &BufferLength, Str, &ConvertedStrLen);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- Str += ConvertedStrLen;
- if (IS_HYPHEN (*Str)) {
- Str++;
- } else {
- return EFI_UNSUPPORTED;
- }
-
- BufferLength = sizeof (Guid->Data3);
- Status = HexStringToBuf ((UINT8 *) &Guid->Data3, &BufferLength, Str, &ConvertedStrLen);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- Str += ConvertedStrLen;
- if (IS_HYPHEN (*Str)) {
- Str++;
- } else {
- return EFI_UNSUPPORTED;
- }
-
- StrToBuf (&Guid->Data4[0], 2, Str);
- //
- // Skip 2 byte hex chars
- //
- Str += 2 * 2;
-
- if (IS_HYPHEN (*Str)) {
- Str++;
- } else {
- return EFI_UNSUPPORTED;
- }
- StrToBuf (&Guid->Data4[2], 6, Str);
-
- return EFI_SUCCESS;
-}
-
-VOID
-StrToIPv4Addr (
- IN OUT CHAR16 **Str,
- OUT EFI_IPv4_ADDRESS *IPv4Addr
- )
-{
- UINTN Index;
-
- for (Index = 0; Index < 4; Index++) {
- IPv4Addr->Addr[Index] = (UINT8) Atoi (SplitStr (Str, L'.'));
- }
-}
-
-VOID
-StrToIPv6Addr (
- IN OUT CHAR16 **Str,
- OUT EFI_IPv6_ADDRESS *IPv6Addr
- )
-{
- UINTN Index;
- UINT16 Data;
-
- for (Index = 0; Index < 8; Index++) {
- Data = (UINT16) Xtoi (SplitStr (Str, L':'));
- IPv6Addr->Addr[Index * 2] = (UINT8) (Data >> 8);
- IPv6Addr->Addr[Index * 2 + 1] = (UINT8) (Data & 0xff);
- }
-}
-
-VOID
-StrToAscii (
- IN CHAR16 *Str,
- IN OUT CHAR8 **AsciiStr
- )
-{
- CHAR8 *Dest;
-
- Dest = *AsciiStr;
- while (!IS_NULL (*Str)) {
- *(Dest++) = (CHAR8) *(Str++);
- }
- *Dest = 0;
-
- //
- // Return the string next to it
- //
- *AsciiStr = Dest + 1;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextPci (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *FunctionStr;
- CHAR16 *DeviceStr;
- PCI_DEVICE_PATH *Pci;
-
- FunctionStr = GetNextParamStr (&TextDeviceNode);
- DeviceStr = GetNextParamStr (&TextDeviceNode);
- Pci = (PCI_DEVICE_PATH *) CreateDeviceNode (
- HARDWARE_DEVICE_PATH,
- HW_PCI_DP,
- sizeof (PCI_DEVICE_PATH)
- );
-
- Pci->Function = (UINT8) Xtoi (FunctionStr);
- Pci->Device = (UINT8) Xtoi (DeviceStr);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) Pci;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextPcCard (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *FunctionNumberStr;
- PCCARD_DEVICE_PATH *Pccard;
-
- FunctionNumberStr = GetNextParamStr (&TextDeviceNode);
- Pccard = (PCCARD_DEVICE_PATH *) CreateDeviceNode (
- HARDWARE_DEVICE_PATH,
- HW_PCCARD_DP,
- sizeof (PCCARD_DEVICE_PATH)
- );
-
- Pccard->FunctionNumber = (UINT8) Xtoi (FunctionNumberStr);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) Pccard;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextMemoryMapped (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *StartingAddressStr;
- CHAR16 *EndingAddressStr;
- MEMMAP_DEVICE_PATH *MemMap;
-
- StartingAddressStr = GetNextParamStr (&TextDeviceNode);
- EndingAddressStr = GetNextParamStr (&TextDeviceNode);
- MemMap = (MEMMAP_DEVICE_PATH *) CreateDeviceNode (
- HARDWARE_DEVICE_PATH,
- HW_MEMMAP_DP,
- sizeof (MEMMAP_DEVICE_PATH)
- );
-
- MemMap->MemoryType = 0;
-
- Xtoi64 (StartingAddressStr, &MemMap->StartingAddress);
- Xtoi64 (EndingAddressStr, &MemMap->EndingAddress);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) MemMap;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-ConvertFromTextVendor (
- IN CHAR16 *TextDeviceNode,
- IN UINT8 Type,
- IN UINT8 SubType
- )
-{
- CHAR16 *GuidStr;
- CHAR16 *DataStr;
- UINTN Length;
- VENDOR_DEVICE_PATH *Vendor;
-
- GuidStr = GetNextParamStr (&TextDeviceNode);
-
- DataStr = GetNextParamStr (&TextDeviceNode);
- Length = StrLen (DataStr);
- //
- // Two hex characters make up 1 buffer byte
- //
- Length = (Length + 1) / 2;
-
- Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
- Type,
- SubType,
- sizeof (VENDOR_DEVICE_PATH) + (UINT16) Length
- );
-
- StrToGuid (GuidStr, &Vendor->Guid);
- StrToBuf (((UINT8 *) Vendor) + sizeof (VENDOR_DEVICE_PATH), Length, DataStr);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextVenHw (
- IN CHAR16 *TextDeviceNode
- )
-{
- return ConvertFromTextVendor (
- TextDeviceNode,
- HARDWARE_DEVICE_PATH,
- HW_VENDOR_DP
- );
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextCtrl (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *ControllerStr;
- CONTROLLER_DEVICE_PATH *Controller;
-
- ControllerStr = GetNextParamStr (&TextDeviceNode);
- Controller = (CONTROLLER_DEVICE_PATH *) CreateDeviceNode (
- HARDWARE_DEVICE_PATH,
- HW_CONTROLLER_DP,
- sizeof (CONTROLLER_DEVICE_PATH)
- );
- Controller->ControllerNumber = (UINT32) Xtoi (ControllerStr);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) Controller;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextAcpi (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *HIDStr;
- CHAR16 *UIDStr;
- ACPI_HID_DEVICE_PATH *Acpi;
-
- HIDStr = GetNextParamStr (&TextDeviceNode);
- UIDStr = GetNextParamStr (&TextDeviceNode);
- Acpi = (ACPI_HID_DEVICE_PATH *) CreateDeviceNode (
- ACPI_DEVICE_PATH,
- ACPI_DP,
- sizeof (ACPI_HID_DEVICE_PATH)
- );
-
- if ((HIDStr[0] == L'P') && (HIDStr[1] == L'N') && (HIDStr[2] == L'P')) {
- HIDStr += 3;
- }
-
- Acpi->HID = EISA_PNP_ID (Xtoi (HIDStr));
- Acpi->UID = (UINT32) Xtoi (UIDStr);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) Acpi;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-ConvertFromTextAcpi (
- IN CHAR16 *TextDeviceNode,
- IN UINT32 Hid
- )
-{
- CHAR16 *UIDStr;
- ACPI_HID_DEVICE_PATH *Acpi;
-
- UIDStr = GetNextParamStr (&TextDeviceNode);
- Acpi = (ACPI_HID_DEVICE_PATH *) CreateDeviceNode (
- ACPI_DEVICE_PATH,
- ACPI_DP,
- sizeof (ACPI_HID_DEVICE_PATH)
- );
-
- Acpi->HID = Hid;
- Acpi->UID = (UINT32) Xtoi (UIDStr);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) Acpi;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextPciRoot (
- IN CHAR16 *TextDeviceNode
- )
-{
- return ConvertFromTextAcpi (TextDeviceNode, 0x0a0341d0);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextFloppy (
- IN CHAR16 *TextDeviceNode
- )
-{
- return ConvertFromTextAcpi (TextDeviceNode, 0x060441d0);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextKeyboard (
- IN CHAR16 *TextDeviceNode
- )
-{
- return ConvertFromTextAcpi (TextDeviceNode, 0x030141d0);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextSerial (
- IN CHAR16 *TextDeviceNode
- )
-{
- return ConvertFromTextAcpi (TextDeviceNode, 0x050141d0);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextParallelPort (
- IN CHAR16 *TextDeviceNode
- )
-{
- return ConvertFromTextAcpi (TextDeviceNode, 0x040141d0);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextAcpiEx (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *HIDStr;
- CHAR16 *CIDStr;
- CHAR16 *UIDStr;
- CHAR16 *HIDSTRStr;
- CHAR16 *CIDSTRStr;
- CHAR16 *UIDSTRStr;
- CHAR8 *AsciiStr;
- UINT16 Length;
- ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR *AcpiExt;
-
- HIDStr = GetNextParamStr (&TextDeviceNode);
- CIDStr = GetNextParamStr (&TextDeviceNode);
- UIDStr = GetNextParamStr (&TextDeviceNode);
- HIDSTRStr = GetNextParamStr (&TextDeviceNode);
- CIDSTRStr = GetNextParamStr (&TextDeviceNode);
- UIDSTRStr = GetNextParamStr (&TextDeviceNode);
- Length = sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) +
- (UINT16) StrLen (HIDSTRStr) + 1 +
- (UINT16) StrLen (UIDSTRStr) + 1 +
- (UINT16) StrLen (CIDSTRStr) + 1;
- AcpiExt = (ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR *) CreateDeviceNode (
- ACPI_DEVICE_PATH,
- ACPI_EXTENDED_DP,
- Length
- );
-
- if ((HIDStr[0] == L'P') && (HIDStr[1] == L'N') && (HIDStr[2] == L'P')) {
- HIDStr += 3;
- AcpiExt->HID = EISA_PNP_ID (Xtoi (HIDStr));
- } else {
- AcpiExt->HID = (UINT32) Xtoi (HIDStr);
- }
-
- AcpiExt->UID = (UINT32) Xtoi (UIDStr);
- AcpiExt->CID = (UINT32) Xtoi (CIDStr);
-
- AsciiStr = AcpiExt->HidUidCidStr;
- StrToAscii (HIDSTRStr, &AsciiStr);
- StrToAscii (UIDSTRStr, &AsciiStr);
- StrToAscii (CIDSTRStr, &AsciiStr);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) AcpiExt;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextAcpiExp (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *HIDStr;
- CHAR16 *CIDStr;
- CHAR16 *UIDSTRStr;
- CHAR8 *AsciiStr;
- UINT16 Length;
- ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR *AcpiExt;
-
- HIDStr = GetNextParamStr (&TextDeviceNode);
- CIDStr = GetNextParamStr (&TextDeviceNode);
- UIDSTRStr = GetNextParamStr (&TextDeviceNode);
- Length = sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + (UINT16) StrLen (UIDSTRStr) + 3;
- AcpiExt = (ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR *) CreateDeviceNode (
- ACPI_DEVICE_PATH,
- ACPI_EXTENDED_DP,
- Length
- );
-
- if ((HIDStr[0] == L'P') && (HIDStr[1] == L'N') && (HIDStr[2] == L'P')) {
- HIDStr += 3;
- AcpiExt->HID = EISA_PNP_ID (Xtoi (HIDStr));
- } else {
- AcpiExt->HID = (UINT32) Xtoi (HIDStr);
- }
-
- AcpiExt->UID = 0;
- AcpiExt->CID = (UINT32) Xtoi (CIDStr);
-
- AsciiStr = AcpiExt->HidUidCidStr;
- //
- // HID string is NULL
- //
- *AsciiStr = 0;
- //
- // Convert UID string
- //
- AsciiStr++;
- StrToAscii (UIDSTRStr, &AsciiStr);
- //
- // CID string is NULL
- //
- *AsciiStr = 0;
-
- return (EFI_DEVICE_PATH_PROTOCOL *) AcpiExt;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextAta (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *PrimarySecondaryStr;
- CHAR16 *SlaveMasterStr;
- CHAR16 *LunStr;
- ATAPI_DEVICE_PATH *Atapi;
-
- Atapi = (ATAPI_DEVICE_PATH *) CreateDeviceNode (
- MESSAGING_DEVICE_PATH,
- MSG_ATAPI_DP,
- sizeof (ATAPI_DEVICE_PATH)
- );
-
- PrimarySecondaryStr = GetNextParamStr (&TextDeviceNode);
- SlaveMasterStr = GetNextParamStr (&TextDeviceNode);
- LunStr = GetNextParamStr (&TextDeviceNode);
-
- Atapi->PrimarySecondary = (StrCmp (PrimarySecondaryStr, L"Primary") == 0) ? (UINT8) 0 : (UINT8) 1;
- Atapi->SlaveMaster = (StrCmp (SlaveMasterStr, L"Master") == 0) ? (UINT8) 0 : (UINT8) 1;
- Atapi->Lun = (UINT16) Xtoi (LunStr);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) Atapi;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextScsi (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *PunStr;
- CHAR16 *LunStr;
- SCSI_DEVICE_PATH *Scsi;
-
- PunStr = GetNextParamStr (&TextDeviceNode);
- LunStr = GetNextParamStr (&TextDeviceNode);
- Scsi = (SCSI_DEVICE_PATH *) CreateDeviceNode (
- MESSAGING_DEVICE_PATH,
- MSG_SCSI_DP,
- sizeof (SCSI_DEVICE_PATH)
- );
-
- Scsi->Pun = (UINT16) Xtoi (PunStr);
- Scsi->Lun = (UINT16) Xtoi (LunStr);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) Scsi;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextFibre (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *WWNStr;
- CHAR16 *LunStr;
- FIBRECHANNEL_DEVICE_PATH *Fibre;
-
- WWNStr = GetNextParamStr (&TextDeviceNode);
- LunStr = GetNextParamStr (&TextDeviceNode);
- Fibre = (FIBRECHANNEL_DEVICE_PATH *) CreateDeviceNode (
- MESSAGING_DEVICE_PATH,
- MSG_FIBRECHANNEL_DP,
- sizeof (FIBRECHANNEL_DEVICE_PATH)
- );
-
- Fibre->Reserved = 0;
- Xtoi64 (WWNStr, &Fibre->WWN);
- Xtoi64 (LunStr, &Fibre->Lun);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) Fibre;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromText1394 (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *GuidStr;
- F1394_DEVICE_PATH *F1394;
-
- GuidStr = GetNextParamStr (&TextDeviceNode);
- F1394 = (F1394_DEVICE_PATH *) CreateDeviceNode (
- MESSAGING_DEVICE_PATH,
- MSG_1394_DP,
- sizeof (F1394_DEVICE_PATH)
- );
-
- F1394->Reserved = 0;
- Xtoi64 (GuidStr, &F1394->Guid);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) F1394;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextUsb (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *PortStr;
- CHAR16 *InterfaceStr;
- USB_DEVICE_PATH *Usb;
-
- PortStr = GetNextParamStr (&TextDeviceNode);
- InterfaceStr = GetNextParamStr (&TextDeviceNode);
- Usb = (USB_DEVICE_PATH *) CreateDeviceNode (
- MESSAGING_DEVICE_PATH,
- MSG_USB_DP,
- sizeof (USB_DEVICE_PATH)
- );
-
- Usb->ParentPortNumber = (UINT8) Xtoi (PortStr);
- Usb->InterfaceNumber = (UINT8) Xtoi (InterfaceStr);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) Usb;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextI2O (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *TIDStr;
- I2O_DEVICE_PATH *I2O;
-
- TIDStr = GetNextParamStr (&TextDeviceNode);
- I2O = (I2O_DEVICE_PATH *) CreateDeviceNode (
- MESSAGING_DEVICE_PATH,
- MSG_I2O_DP,
- sizeof (I2O_DEVICE_PATH)
- );
-
- I2O->Tid = (UINT32) Xtoi (TIDStr);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) I2O;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextInfiniband (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *FlagsStr;
- CHAR16 *GuidStr;
- CHAR16 *SidStr;
- CHAR16 *TidStr;
- CHAR16 *DidStr;
- EFI_GUID PortGid;
- INFINIBAND_DEVICE_PATH *InfiniBand;
-
- FlagsStr = GetNextParamStr (&TextDeviceNode);
- GuidStr = GetNextParamStr (&TextDeviceNode);
- SidStr = GetNextParamStr (&TextDeviceNode);
- TidStr = GetNextParamStr (&TextDeviceNode);
- DidStr = GetNextParamStr (&TextDeviceNode);
- InfiniBand = (INFINIBAND_DEVICE_PATH *) CreateDeviceNode (
- MESSAGING_DEVICE_PATH,
- MSG_INFINIBAND_DP,
- sizeof (INFINIBAND_DEVICE_PATH)
- );
-
- InfiniBand->ResourceFlags = (UINT32) Xtoi (FlagsStr);
- StrToGuid (GuidStr, &PortGid);
- CopyMem (InfiniBand->PortGid, &PortGid, sizeof (EFI_GUID));
- Xtoi64 (SidStr, &InfiniBand->ServiceId);
- Xtoi64 (TidStr, &InfiniBand->TargetPortId);
- Xtoi64 (DidStr, &InfiniBand->DeviceId);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) InfiniBand;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextVenMsg (
- IN CHAR16 *TextDeviceNode
- )
-{
- return ConvertFromTextVendor (
- TextDeviceNode,
- MESSAGING_DEVICE_PATH,
- MSG_VENDOR_DP
- );
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextVenPcAnsi (
- IN CHAR16 *TextDeviceNode
- )
-{
- VENDOR_DEVICE_PATH *Vendor;
-
- Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
- MESSAGING_DEVICE_PATH,
- MSG_VENDOR_DP,
- sizeof (VENDOR_DEVICE_PATH));
- CopyGuid (&Vendor->Guid, &gEfiPcAnsiGuid);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextVenVt100 (
- IN CHAR16 *TextDeviceNode
- )
-{
- VENDOR_DEVICE_PATH *Vendor;
-
- Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
- MESSAGING_DEVICE_PATH,
- MSG_VENDOR_DP,
- sizeof (VENDOR_DEVICE_PATH));
- CopyGuid (&Vendor->Guid, &gEfiVT100Guid);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextVenVt100Plus (
- IN CHAR16 *TextDeviceNode
- )
-{
- VENDOR_DEVICE_PATH *Vendor;
-
- Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
- MESSAGING_DEVICE_PATH,
- MSG_VENDOR_DP,
- sizeof (VENDOR_DEVICE_PATH));
- CopyGuid (&Vendor->Guid, &gEfiVT100PlusGuid);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextVenUtf8 (
- IN CHAR16 *TextDeviceNode
- )
-{
- VENDOR_DEVICE_PATH *Vendor;
-
- Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
- MESSAGING_DEVICE_PATH,
- MSG_VENDOR_DP,
- sizeof (VENDOR_DEVICE_PATH));
- CopyGuid (&Vendor->Guid, &gEfiVTUTF8Guid);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextUartFlowCtrl (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *ValueStr;
- UART_FLOW_CONTROL_DEVICE_PATH *UartFlowControl;
-
- ValueStr = GetNextParamStr (&TextDeviceNode);
- UartFlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) CreateDeviceNode (
- MESSAGING_DEVICE_PATH,
- MSG_VENDOR_DP,
- sizeof (UART_FLOW_CONTROL_DEVICE_PATH)
- );
-
- CopyGuid (&UartFlowControl->Guid, &mEfiDevicePathMessagingUartFlowControlGuid);
- if (StrCmp (ValueStr, L"XonXoff") == 0) {
- UartFlowControl->FlowControlMap = 2;
- } else if (StrCmp (ValueStr, L"Hardware") == 0) {
- UartFlowControl->FlowControlMap = 1;
- } else {
- UartFlowControl->FlowControlMap = 0;
- }
-
- return (EFI_DEVICE_PATH_PROTOCOL *) UartFlowControl;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextSAS (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *AddressStr;
- CHAR16 *LunStr;
- CHAR16 *RTPStr;
- CHAR16 *SASSATAStr;
- CHAR16 *LocationStr;
- CHAR16 *ConnectStr;
- CHAR16 *DriveBayStr;
- CHAR16 *ReservedStr;
- UINT16 Info;
- SAS_DEVICE_PATH *Sas;
-
- AddressStr = GetNextParamStr (&TextDeviceNode);
- LunStr = GetNextParamStr (&TextDeviceNode);
- RTPStr = GetNextParamStr (&TextDeviceNode);
- SASSATAStr = GetNextParamStr (&TextDeviceNode);
- LocationStr = GetNextParamStr (&TextDeviceNode);
- ConnectStr = GetNextParamStr (&TextDeviceNode);
- DriveBayStr = GetNextParamStr (&TextDeviceNode);
- ReservedStr = GetNextParamStr (&TextDeviceNode);
- Info = 0x0000;
- Sas = (SAS_DEVICE_PATH *) CreateDeviceNode (
- MESSAGING_DEVICE_PATH,
- MSG_VENDOR_DP,
- sizeof (SAS_DEVICE_PATH)
- );
-
- CopyGuid (&Sas->Guid, &mEfiDevicePathMessagingSASGuid);
- Xtoi64 (AddressStr, &Sas->SasAddress);
- Xtoi64 (LunStr, &Sas->Lun);
- Sas->RelativeTargetPort = (UINT16) Xtoi (RTPStr);
- if (StrCmp (SASSATAStr, L"NoTopology") == 0)
- ;
- else {
- if (StrCmp (DriveBayStr, L"0") == 0) {
- Info |= 0x0001;
- } else {
- Info |= 0x0002;
- Info |= (Xtoi (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;
- }
- }
-
- Sas->DeviceTopology = Info;
- Sas->Reserved = (UINT32) Xtoi (ReservedStr);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) Sas;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextDebugPort (
- IN CHAR16 *TextDeviceNode
- )
-{
- VENDOR_DEFINED_MESSAGING_DEVICE_PATH *Vend;
-
- Vend = (VENDOR_DEFINED_MESSAGING_DEVICE_PATH *) CreateDeviceNode (
- MESSAGING_DEVICE_PATH,
- MSG_VENDOR_DP,
- sizeof (VENDOR_DEFINED_MESSAGING_DEVICE_PATH)
- );
-
- CopyGuid (&Vend->Guid, &gEfiDebugPortProtocolGuid);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) Vend;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextMAC (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *AddressStr;
- CHAR16 *IfTypeStr;
- UINTN Length;
- MAC_ADDR_DEVICE_PATH *MAC;
-
- AddressStr = GetNextParamStr (&TextDeviceNode);
- IfTypeStr = GetNextParamStr (&TextDeviceNode);
- MAC = (MAC_ADDR_DEVICE_PATH *) CreateDeviceNode (
- MESSAGING_DEVICE_PATH,
- MSG_MAC_ADDR_DP,
- sizeof (MAC_ADDR_DEVICE_PATH)
- );
-
- MAC->IfType = (UINT8) Xtoi (IfTypeStr);
-
- Length = sizeof (EFI_MAC_ADDRESS);
- StrToBuf (&MAC->MacAddress.Addr[0], Length, AddressStr);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) MAC;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextIPv4 (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *RemoteIPStr;
- CHAR16 *ProtocolStr;
- CHAR16 *TypeStr;
- CHAR16 *LocalIPStr;
- IPv4_DEVICE_PATH *IPv4;
-
- RemoteIPStr = GetNextParamStr (&TextDeviceNode);
- ProtocolStr = GetNextParamStr (&TextDeviceNode);
- TypeStr = GetNextParamStr (&TextDeviceNode);
- LocalIPStr = GetNextParamStr (&TextDeviceNode);
- IPv4 = (IPv4_DEVICE_PATH *) CreateDeviceNode (
- MESSAGING_DEVICE_PATH,
- MSG_IPv4_DP,
- sizeof (IPv4_DEVICE_PATH)
- );
-
- StrToIPv4Addr (&RemoteIPStr, &IPv4->RemoteIpAddress);
- IPv4->Protocol = (StrCmp (ProtocolStr, L"UDP") == 0) ? (UINT16) 0 : (UINT16) 1;
- if (StrCmp (TypeStr, L"Static") == 0) {
- IPv4->StaticIpAddress = TRUE;
- } else {
- IPv4->StaticIpAddress = FALSE;
- }
-
- StrToIPv4Addr (&LocalIPStr, &IPv4->LocalIpAddress);
-
- IPv4->LocalPort = 0;
- IPv4->RemotePort = 0;
-
- return (EFI_DEVICE_PATH_PROTOCOL *) IPv4;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextIPv6 (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *RemoteIPStr;
- CHAR16 *ProtocolStr;
- CHAR16 *TypeStr;
- CHAR16 *LocalIPStr;
- IPv6_DEVICE_PATH *IPv6;
-
- RemoteIPStr = GetNextParamStr (&TextDeviceNode);
- ProtocolStr = GetNextParamStr (&TextDeviceNode);
- TypeStr = GetNextParamStr (&TextDeviceNode);
- LocalIPStr = GetNextParamStr (&TextDeviceNode);
- IPv6 = (IPv6_DEVICE_PATH *) CreateDeviceNode (
- MESSAGING_DEVICE_PATH,
- MSG_IPv6_DP,
- sizeof (IPv6_DEVICE_PATH)
- );
-
- StrToIPv6Addr (&RemoteIPStr, &IPv6->RemoteIpAddress);
- IPv6->Protocol = (StrCmp (ProtocolStr, L"UDP") == 0) ? (UINT16) 0 : (UINT16) 1;
- if (StrCmp (TypeStr, L"Static") == 0) {
- IPv6->StaticIpAddress = TRUE;
- } else {
- IPv6->StaticIpAddress = FALSE;
- }
-
- StrToIPv6Addr (&LocalIPStr, &IPv6->LocalIpAddress);
-
- IPv6->LocalPort = 0;
- IPv6->RemotePort = 0;
-
- return (EFI_DEVICE_PATH_PROTOCOL *) IPv6;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextUart (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *BaudStr;
- CHAR16 *DataBitsStr;
- CHAR16 *ParityStr;
- CHAR16 *StopBitsStr;
- UART_DEVICE_PATH *Uart;
-
- BaudStr = GetNextParamStr (&TextDeviceNode);
- DataBitsStr = GetNextParamStr (&TextDeviceNode);
- ParityStr = GetNextParamStr (&TextDeviceNode);
- StopBitsStr = GetNextParamStr (&TextDeviceNode);
- Uart = (UART_DEVICE_PATH *) CreateDeviceNode (
- MESSAGING_DEVICE_PATH,
- MSG_UART_DP,
- sizeof (UART_DEVICE_PATH)
- );
-
- Uart->BaudRate = (StrCmp (BaudStr, L"DEFAULT") == 0) ? 115200 : Atoi (BaudStr);
- Uart->DataBits = (StrCmp (DataBitsStr, L"DEFAULT") == 0) ? (UINT8) 8 : (UINT8) Atoi (DataBitsStr);
- switch (*ParityStr) {
- case L'D':
- Uart->Parity = 0;
- break;
-
- case L'N':
- Uart->Parity = 1;
- break;
-
- case L'E':
- Uart->Parity = 2;
- break;
-
- case L'O':
- Uart->Parity = 3;
- break;
-
- case L'M':
- Uart->Parity = 4;
- break;
-
- case L'S':
- Uart->Parity = 5;
-
- default:
- Uart->Parity = 0xff;
- }
-
- if (StrCmp (StopBitsStr, L"D") == 0) {
- Uart->StopBits = (UINT8) 0;
- } else if (StrCmp (StopBitsStr, L"1") == 0) {
- Uart->StopBits = (UINT8) 1;
- } else if (StrCmp (StopBitsStr, L"1.5") == 0) {
- Uart->StopBits = (UINT8) 2;
- } else if (StrCmp (StopBitsStr, L"2") == 0) {
- Uart->StopBits = (UINT8) 3;
- } else {
- Uart->StopBits = 0xff;
- }
-
- return (EFI_DEVICE_PATH_PROTOCOL *) Uart;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-ConvertFromTextUsbClass (
- IN CHAR16 *TextDeviceNode,
- IN USB_CLASS_TEXT *UsbClassText
- )
-{
- CHAR16 *VIDStr;
- CHAR16 *PIDStr;
- CHAR16 *ClassStr;
- CHAR16 *SubClassStr;
- CHAR16 *ProtocolStr;
- USB_CLASS_DEVICE_PATH *UsbClass;
-
- UsbClass = (USB_CLASS_DEVICE_PATH *) CreateDeviceNode (
- MESSAGING_DEVICE_PATH,
- MSG_USB_CLASS_DP,
- sizeof (USB_CLASS_DEVICE_PATH)
- );
-
- VIDStr = GetNextParamStr (&TextDeviceNode);
- PIDStr = GetNextParamStr (&TextDeviceNode);
- if (UsbClassText->ClassExist) {
- ClassStr = GetNextParamStr (&TextDeviceNode);
- UsbClass->DeviceClass = (UINT8) Xtoi (ClassStr);
- } else {
- UsbClass->DeviceClass = UsbClassText->Class;
- }
- if (UsbClassText->SubClassExist) {
- SubClassStr = GetNextParamStr (&TextDeviceNode);
- UsbClass->DeviceSubClass = (UINT8) Xtoi (SubClassStr);
- } else {
- UsbClass->DeviceSubClass = UsbClassText->SubClass;
- }
-
- ProtocolStr = GetNextParamStr (&TextDeviceNode);
-
- UsbClass->VendorId = (UINT16) Xtoi (VIDStr);
- UsbClass->ProductId = (UINT16) Xtoi (PIDStr);
- UsbClass->DeviceProtocol = (UINT8) Xtoi (ProtocolStr);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) UsbClass;
-}
-
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextUsbClass (
- IN CHAR16 *TextDeviceNode
- )
-{
- USB_CLASS_TEXT UsbClassText;
-
- UsbClassText.ClassExist = TRUE;
- UsbClassText.SubClassExist = TRUE;
-
- return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextUsbAudio (
- IN CHAR16 *TextDeviceNode
- )
-{
- USB_CLASS_TEXT UsbClassText;
-
- UsbClassText.ClassExist = FALSE;
- UsbClassText.Class = USB_CLASS_AUDIO;
- UsbClassText.SubClassExist = TRUE;
-
- return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextUsbCDCControl (
- IN CHAR16 *TextDeviceNode
- )
-{
- USB_CLASS_TEXT UsbClassText;
-
- UsbClassText.ClassExist = FALSE;
- UsbClassText.Class = USB_CLASS_CDCCONTROL;
- UsbClassText.SubClassExist = TRUE;
-
- return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextUsbHID (
- IN CHAR16 *TextDeviceNode
- )
-{
- USB_CLASS_TEXT UsbClassText;
-
- UsbClassText.ClassExist = FALSE;
- UsbClassText.Class = USB_CLASS_HID;
- UsbClassText.SubClassExist = TRUE;
-
- return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextUsbImage (
- IN CHAR16 *TextDeviceNode
- )
-{
- USB_CLASS_TEXT UsbClassText;
-
- UsbClassText.ClassExist = FALSE;
- UsbClassText.Class = USB_CLASS_IMAGE;
- UsbClassText.SubClassExist = TRUE;
-
- return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextUsbPrinter (
- IN CHAR16 *TextDeviceNode
- )
-{
- USB_CLASS_TEXT UsbClassText;
-
- UsbClassText.ClassExist = FALSE;
- UsbClassText.Class = USB_CLASS_PRINTER;
- UsbClassText.SubClassExist = TRUE;
-
- return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextUsbMassStorage (
- IN CHAR16 *TextDeviceNode
- )
-{
- USB_CLASS_TEXT UsbClassText;
-
- UsbClassText.ClassExist = FALSE;
- UsbClassText.Class = USB_CLASS_MASS_STORAGE;
- UsbClassText.SubClassExist = TRUE;
-
- return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextUsbHub (
- IN CHAR16 *TextDeviceNode
- )
-{
- USB_CLASS_TEXT UsbClassText;
-
- UsbClassText.ClassExist = FALSE;
- UsbClassText.Class = USB_CLASS_HUB;
- UsbClassText.SubClassExist = TRUE;
-
- return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextUsbCDCData (
- IN CHAR16 *TextDeviceNode
- )
-{
- USB_CLASS_TEXT UsbClassText;
-
- UsbClassText.ClassExist = FALSE;
- UsbClassText.Class = USB_CLASS_CDCDATA;
- UsbClassText.SubClassExist = TRUE;
-
- return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextUsbSmartCard (
- IN CHAR16 *TextDeviceNode
- )
-{
- USB_CLASS_TEXT UsbClassText;
-
- UsbClassText.ClassExist = FALSE;
- UsbClassText.Class = USB_CLASS_SMART_CARD;
- UsbClassText.SubClassExist = TRUE;
-
- return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextUsbVideo (
- IN CHAR16 *TextDeviceNode
- )
-{
- USB_CLASS_TEXT UsbClassText;
-
- UsbClassText.ClassExist = FALSE;
- UsbClassText.Class = USB_CLASS_VIDEO;
- UsbClassText.SubClassExist = TRUE;
-
- return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextUsbDiagnostic (
- IN CHAR16 *TextDeviceNode
- )
-{
- USB_CLASS_TEXT UsbClassText;
-
- UsbClassText.ClassExist = FALSE;
- UsbClassText.Class = USB_CLASS_DIAGNOSTIC;
- UsbClassText.SubClassExist = TRUE;
-
- return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextUsbWireless (
- IN CHAR16 *TextDeviceNode
- )
-{
- USB_CLASS_TEXT UsbClassText;
-
- UsbClassText.ClassExist = FALSE;
- UsbClassText.Class = USB_CLASS_WIRELESS;
- UsbClassText.SubClassExist = TRUE;
-
- return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextUsbDeviceFirmwareUpdate (
- IN CHAR16 *TextDeviceNode
- )
-{
- USB_CLASS_TEXT UsbClassText;
-
- UsbClassText.ClassExist = FALSE;
- UsbClassText.Class = USB_CLASS_RESERVE;
- UsbClassText.SubClassExist = FALSE;
- UsbClassText.SubClass = USB_SUBCLASS_FW_UPDATE;
-
- return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextUsbIrdaBridge (
- IN CHAR16 *TextDeviceNode
- )
-{
- USB_CLASS_TEXT UsbClassText;
-
- UsbClassText.ClassExist = FALSE;
- UsbClassText.Class = USB_CLASS_RESERVE;
- UsbClassText.SubClassExist = FALSE;
- UsbClassText.SubClass = USB_SUBCLASS_IRDA_BRIDGE;
-
- return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextUsbTestAndMeasurement (
- IN CHAR16 *TextDeviceNode
- )
-{
- USB_CLASS_TEXT UsbClassText;
-
- UsbClassText.ClassExist = FALSE;
- UsbClassText.Class = USB_CLASS_RESERVE;
- UsbClassText.SubClassExist = FALSE;
- UsbClassText.SubClass = USB_SUBCLASS_TEST;
-
- return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextUsbWwid (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *VIDStr;
- CHAR16 *PIDStr;
- CHAR16 *InterfaceNumStr;
- USB_WWID_DEVICE_PATH *UsbWwid;
-
- VIDStr = GetNextParamStr (&TextDeviceNode);
- PIDStr = GetNextParamStr (&TextDeviceNode);
- InterfaceNumStr = GetNextParamStr (&TextDeviceNode);
- UsbWwid = (USB_WWID_DEVICE_PATH *) CreateDeviceNode (
- MESSAGING_DEVICE_PATH,
- MSG_USB_WWID_DP,
- sizeof (USB_WWID_DEVICE_PATH)
- );
-
- UsbWwid->VendorId = (UINT16) Xtoi (VIDStr);
- UsbWwid->ProductId = (UINT16) Xtoi (PIDStr);
- UsbWwid->InterfaceNumber = (UINT16) Xtoi (InterfaceNumStr);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) UsbWwid;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextUnit (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *LunStr;
- DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;
-
- LunStr = GetNextParamStr (&TextDeviceNode);
- LogicalUnit = (DEVICE_LOGICAL_UNIT_DEVICE_PATH *) CreateDeviceNode (
- MESSAGING_DEVICE_PATH,
- MSG_DEVICE_LOGICAL_UNIT_DP,
- sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH)
- );
-
- LogicalUnit->Lun = (UINT8) Xtoi (LunStr);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) LogicalUnit;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextiSCSI (
- IN CHAR16 *TextDeviceNode
- )
-{
- UINT16 Options;
- CHAR16 *NameStr;
- CHAR16 *PortalGroupStr;
- CHAR16 *LunStr;
- CHAR16 *HeaderDigestStr;
- CHAR16 *DataDigestStr;
- CHAR16 *AuthenticationStr;
- CHAR16 *ProtocolStr;
- ISCSI_DEVICE_PATH_WITH_NAME *iSCSI;
-
- NameStr = GetNextParamStr (&TextDeviceNode);
- PortalGroupStr = GetNextParamStr (&TextDeviceNode);
- LunStr = GetNextParamStr (&TextDeviceNode);
- HeaderDigestStr = GetNextParamStr (&TextDeviceNode);
- DataDigestStr = GetNextParamStr (&TextDeviceNode);
- AuthenticationStr = GetNextParamStr (&TextDeviceNode);
- ProtocolStr = GetNextParamStr (&TextDeviceNode);
- iSCSI = (ISCSI_DEVICE_PATH_WITH_NAME *) CreateDeviceNode (
- MESSAGING_DEVICE_PATH,
- MSG_ISCSI_DP,
- sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + (UINT16) (StrLen (NameStr) * 2)
- );
-
- StrCpy (iSCSI->iSCSITargetName, NameStr);
- iSCSI->TargetPortalGroupTag = (UINT16) Xtoi (PortalGroupStr);
- Xtoi64 (LunStr, &iSCSI->Lun);
-
- Options = 0x0000;
- if (StrCmp (HeaderDigestStr, L"CRC32C") == 0) {
- Options |= 0x0002;
- }
-
- if (StrCmp (DataDigestStr, L"CRC32C") == 0) {
- Options |= 0x0008;
- }
-
- if (StrCmp (AuthenticationStr, L"None") == 0) {
- Options |= 0x0800;
- }
-
- if (StrCmp (AuthenticationStr, L"CHAP_UNI") == 0) {
- Options |= 0x1000;
- }
-
- iSCSI->LoginOption = (UINT16) Options;
-
- iSCSI->NetworkProtocol = (UINT16) StrCmp (ProtocolStr, L"TCP");
- iSCSI->Reserved = (UINT16) 0;
-
- return (EFI_DEVICE_PATH_PROTOCOL *) iSCSI;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextHD (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *PartitionStr;
- CHAR16 *TypeStr;
- CHAR16 *SignatureStr;
- CHAR16 *StartStr;
- CHAR16 *SizeStr;
- UINT32 Signature32;
- EFI_GUID SignatureGuid;
- HARDDRIVE_DEVICE_PATH *Hd;
-
- PartitionStr = GetNextParamStr (&TextDeviceNode);
- TypeStr = GetNextParamStr (&TextDeviceNode);
- SignatureStr = GetNextParamStr (&TextDeviceNode);
- StartStr = GetNextParamStr (&TextDeviceNode);
- SizeStr = GetNextParamStr (&TextDeviceNode);
- Hd = (HARDDRIVE_DEVICE_PATH *) CreateDeviceNode (
- MEDIA_DEVICE_PATH,
- MEDIA_HARDDRIVE_DP,
- sizeof (HARDDRIVE_DEVICE_PATH)
- );
-
- Hd->PartitionNumber = (UINT32) Atoi (PartitionStr);
-
- ZeroMem (Hd->Signature, 16);
- Hd->MBRType = (UINT8) 0;
-
- if (StrCmp (TypeStr, L"None") == 0) {
- Hd->SignatureType = (UINT8) 0;
- } else if (StrCmp (TypeStr, L"MBR") == 0) {
- Hd->SignatureType = SIGNATURE_TYPE_MBR;
- Hd->MBRType = 0x01;
-
- Signature32 = (UINT32) Xtoi (SignatureStr);
- CopyMem (Hd->Signature, &Signature32, sizeof (UINT32));
- } else if (StrCmp (TypeStr, L"GUID") == 0) {
- Hd->SignatureType = SIGNATURE_TYPE_GUID;
- Hd->MBRType = 0x02;
-
- StrToGuid (SignatureStr, &SignatureGuid);
- CopyMem (Hd->Signature, &SignatureGuid, sizeof (EFI_GUID));
- } else {
- Hd->SignatureType = 0xff;
-
- }
-
- Xtoi64 (StartStr, &Hd->PartitionStart);
- Xtoi64 (SizeStr, &Hd->PartitionSize);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) Hd;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextCDROM (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *EntryStr;
- CHAR16 *StartStr;
- CHAR16 *SizeStr;
- CDROM_DEVICE_PATH *CDROM;
-
- EntryStr = GetNextParamStr (&TextDeviceNode);
- StartStr = GetNextParamStr (&TextDeviceNode);
- SizeStr = GetNextParamStr (&TextDeviceNode);
- CDROM = (CDROM_DEVICE_PATH *) CreateDeviceNode (
- MEDIA_DEVICE_PATH,
- MEDIA_CDROM_DP,
- sizeof (CDROM_DEVICE_PATH)
- );
-
- CDROM->BootEntry = (UINT32) Xtoi (EntryStr);
- Xtoi64 (StartStr, &CDROM->PartitionStart);
- Xtoi64 (SizeStr, &CDROM->PartitionSize);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) CDROM;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextVenMEDIA (
- IN CHAR16 *TextDeviceNode
- )
-{
- return ConvertFromTextVendor (
- TextDeviceNode,
- MEDIA_DEVICE_PATH,
- MEDIA_VENDOR_DP
- );
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextFilePath (
- IN CHAR16 *TextDeviceNode
- )
-{
- FILEPATH_DEVICE_PATH *File;
-
- File = (FILEPATH_DEVICE_PATH *) CreateDeviceNode (
- MEDIA_DEVICE_PATH,
- MEDIA_FILEPATH_DP,
- sizeof (FILEPATH_DEVICE_PATH) + (UINT16) (StrLen (TextDeviceNode) * 2)
- );
-
- StrCpy (File->PathName, TextDeviceNode);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) File;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextMedia (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *GuidStr;
- MEDIA_PROTOCOL_DEVICE_PATH *Media;
-
- GuidStr = GetNextParamStr (&TextDeviceNode);
- Media = (MEDIA_PROTOCOL_DEVICE_PATH *) CreateDeviceNode (
- MEDIA_DEVICE_PATH,
- MEDIA_PROTOCOL_DP,
- sizeof (MEDIA_PROTOCOL_DEVICE_PATH)
- );
-
- StrToGuid (GuidStr, &Media->Protocol);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) Media;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DevPathFromTextBBS (
- IN CHAR16 *TextDeviceNode
- )
-{
- CHAR16 *TypeStr;
- CHAR16 *IdStr;
- CHAR16 *FlagsStr;
- UINT8 *AsciiStr;
- BBS_BBS_DEVICE_PATH *Bbs;
-
- TypeStr = GetNextParamStr (&TextDeviceNode);
- IdStr = GetNextParamStr (&TextDeviceNode);
- FlagsStr = GetNextParamStr (&TextDeviceNode);
- Bbs = (BBS_BBS_DEVICE_PATH *) CreateDeviceNode (
- BBS_DEVICE_PATH,
- BBS_BBS_DP,
- sizeof (BBS_BBS_DEVICE_PATH) + (UINT16) (StrLen (IdStr))
- );
-
- if (StrCmp (TypeStr, L"Floppy") == 0) {
- Bbs->DeviceType = BBS_TYPE_FLOPPY;
- } else if (StrCmp (TypeStr, L"HD") == 0) {
- Bbs->DeviceType = BBS_TYPE_HARDDRIVE;
- } else if (StrCmp (TypeStr, L"CDROM") == 0) {
- Bbs->DeviceType = BBS_TYPE_CDROM;
- } else if (StrCmp (TypeStr, L"PCMCIA") == 0) {
- Bbs->DeviceType = BBS_TYPE_PCMCIA;
- } else if (StrCmp (TypeStr, L"USB") == 0) {
- Bbs->DeviceType = BBS_TYPE_USB;
- } else if (StrCmp (TypeStr, L"Network") == 0) {
- Bbs->DeviceType = BBS_TYPE_EMBEDDED_NETWORK;
- } else {
- Bbs->DeviceType = BBS_TYPE_UNKNOWN;
- }
-
- AsciiStr = (UINT8 *) Bbs->String;
- StrToAscii (IdStr, (CHAR8 **) &AsciiStr);
-
- Bbs->StatusFlag = (UINT16) Xtoi (FlagsStr);
-
- return (EFI_DEVICE_PATH_PROTOCOL *) Bbs;
-}
-
-GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE DevPathFromTextTable[] = {
- {L"Pci", DevPathFromTextPci},
- {L"PcCard", DevPathFromTextPcCard},
- {L"MemoryMapped", DevPathFromTextMemoryMapped},
- {L"VenHw", DevPathFromTextVenHw},
- {L"Ctrl", DevPathFromTextCtrl},
- {L"Acpi", DevPathFromTextAcpi},
- {L"PciRoot", DevPathFromTextPciRoot},
- {L"Floppy", DevPathFromTextFloppy},
- {L"Keyboard", DevPathFromTextKeyboard},
- {L"Serial", DevPathFromTextSerial},
- {L"ParallelPort", DevPathFromTextParallelPort},
- {L"AcpiEx", DevPathFromTextAcpiEx},
- {L"AcpiExp", DevPathFromTextAcpiExp},
- {L"Ata", DevPathFromTextAta},
- {L"Scsi", DevPathFromTextScsi},
- {L"Fibre", DevPathFromTextFibre},
- {L"I1394", DevPathFromText1394},
- {L"USB", DevPathFromTextUsb},
- {L"I2O", DevPathFromTextI2O},
- {L"Infiniband", DevPathFromTextInfiniband},
- {L"VenMsg", DevPathFromTextVenMsg},
- {L"VenPcAnsi", DevPathFromTextVenPcAnsi},
- {L"VenVt100", DevPathFromTextVenVt100},
- {L"VenVt100Plus", DevPathFromTextVenVt100Plus},
- {L"VenUtf8", DevPathFromTextVenUtf8},
- {L"UartFlowCtrl", DevPathFromTextUartFlowCtrl},
- {L"SAS", DevPathFromTextSAS},
- {L"DebugPort", DevPathFromTextDebugPort},
- {L"MAC", DevPathFromTextMAC},
- {L"IPv4", DevPathFromTextIPv4},
- {L"IPv6", DevPathFromTextIPv6},
- {L"Uart", DevPathFromTextUart},
- {L"UsbClass", DevPathFromTextUsbClass},
- {L"UsbAudio", DevPathFromTextUsbAudio},
- {L"UsbCDCControl", DevPathFromTextUsbCDCControl},
- {L"UsbHID", DevPathFromTextUsbHID},
- {L"UsbImage", DevPathFromTextUsbImage},
- {L"UsbPrinter", DevPathFromTextUsbPrinter},
- {L"UsbMassStorage", DevPathFromTextUsbMassStorage},
- {L"UsbHub", DevPathFromTextUsbHub},
- {L"UsbCDCData", DevPathFromTextUsbCDCData},
- {L"UsbSmartCard", DevPathFromTextUsbSmartCard},
- {L"UsbVideo", DevPathFromTextUsbVideo},
- {L"UsbDiagnostic", DevPathFromTextUsbDiagnostic},
- {L"UsbWireless", DevPathFromTextUsbWireless},
- {L"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate},
- {L"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge},
- {L"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement},
- {L"UsbWwid", DevPathFromTextUsbWwid},
- {L"Unit", DevPathFromTextUnit},
- {L"iSCSI", DevPathFromTextiSCSI},
- {L"HD", DevPathFromTextHD},
- {L"CDROM", DevPathFromTextCDROM},
- {L"VenMEDIA", DevPathFromTextVenMEDIA},
- {L"Media", DevPathFromTextMedia},
- {L"BBS", DevPathFromTextBBS},
- {NULL, NULL}
-};
-
-EFI_DEVICE_PATH_PROTOCOL *
-ConvertTextToDeviceNode (
- IN CONST CHAR16 *TextDeviceNode
- )
-/*++
-
- Routine Description:
- Convert text to the binary representation of a device node.
-
- Arguments:
- TextDeviceNode - TextDeviceNode points to the text representation of a device
- node. Conversion starts with the first character and continues
- until the first non-device node character.
-
- Returns:
- A pointer - Pointer to the EFI device node.
- NULL - If TextDeviceNode is NULL or there was insufficient memory or text unsupported.
-
---*/
-{
- EFI_DEVICE_PATH_PROTOCOL * (*DumpNode) (CHAR16 *);
- CHAR16 *ParamStr;
- EFI_DEVICE_PATH_PROTOCOL *DeviceNode;
- CHAR16 *DeviceNodeStr;
- UINTN Index;
-
- if ((TextDeviceNode == NULL) || (IS_NULL (*TextDeviceNode))) {
- return NULL;
- }
-
- ParamStr = NULL;
- DumpNode = NULL;
- DeviceNodeStr = StrDuplicate (TextDeviceNode);
-
- for (Index = 0; DevPathFromTextTable[Index].Function; Index++) {
- ParamStr = GetParamByNodeName (DeviceNodeStr, DevPathFromTextTable[Index].DevicePathNodeText);
- if (ParamStr != NULL) {
- DumpNode = DevPathFromTextTable[Index].Function;
- break;
- }
- }
-
- if (DumpNode == NULL) {
- //
- // A file path
- //
- DumpNode = DevPathFromTextFilePath;
- DeviceNode = DumpNode (DeviceNodeStr);
- } else {
- DeviceNode = DumpNode (ParamStr);
- gBS->FreePool (ParamStr);
- }
-
- gBS->FreePool (DeviceNodeStr);
-
- return DeviceNode;
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-ConvertTextToDevicePath (
- IN CONST CHAR16 *TextDevicePath
- )
-/*++
-
- Routine Description:
- Convert text to the binary representation of a device path.
-
- Arguments:
- TextDevicePath - TextDevicePath points to the text representation of a device
- path. Conversion starts with the first character and continues
- until the first non-device node character.
-
- Returns:
- A pointer - Pointer to the allocated device path.
- NULL - If TextDeviceNode is NULL or there was insufficient memory.
-
---*/
-{
- EFI_DEVICE_PATH_PROTOCOL * (*DumpNode) (CHAR16 *);
- CHAR16 *ParamStr;
- EFI_DEVICE_PATH_PROTOCOL *DeviceNode;
- UINTN Index;
- EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
- CHAR16 *DevicePathStr;
- CHAR16 *Str;
- CHAR16 *DeviceNodeStr;
- UINT8 IsInstanceEnd;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
-
- if ((TextDevicePath == NULL) || (IS_NULL (*TextDevicePath))) {
- return NULL;
- }
-
- DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);
- SetDevicePathEndNode (DevicePath);
-
- ParamStr = NULL;
- DeviceNodeStr = NULL;
- DevicePathStr = StrDuplicate (TextDevicePath);
-
- Str = DevicePathStr;
- while ((DeviceNodeStr = GetNextDeviceNodeStr (&Str, &IsInstanceEnd)) != NULL) {
- DumpNode = NULL;
- for (Index = 0; DevPathFromTextTable[Index].Function; Index++) {
- ParamStr = GetParamByNodeName (DeviceNodeStr, DevPathFromTextTable[Index].DevicePathNodeText);
- if (ParamStr != NULL) {
- DumpNode = DevPathFromTextTable[Index].Function;
- break;
- }
- }
-
- if (DumpNode == NULL) {
- //
- // A file path
- //
- DumpNode = DevPathFromTextFilePath;
- DeviceNode = DumpNode (DeviceNodeStr);
- } else {
- DeviceNode = DumpNode (ParamStr);
- gBS->FreePool (ParamStr);
- }
-
- NewDevicePath = AppendDeviceNodeProtocolInterface (DevicePath, DeviceNode);
- gBS->FreePool (DevicePath);
- gBS->FreePool (DeviceNode);
- DevicePath = NewDevicePath;
-
- if (IsInstanceEnd) {
- DeviceNode = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);
- SetDevicePathInstanceEndNode (DeviceNode);
-
- NewDevicePath = AppendDeviceNodeProtocolInterface (DevicePath, DeviceNode);
- gBS->FreePool (DevicePath);
- gBS->FreePool (DeviceNode);
- DevicePath = NewDevicePath;
- }
- }
-
- gBS->FreePool (DevicePathStr);
- return DevicePath;
-}
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+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
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DevicePathFromText.c
+
+Abstract:
+
+ DevicePathFromText protocol as defined in the UEFI 2.0 specification.
+
+--*/
+
+#include "DevicePath.h"
+
+CHAR16 *
+StrDuplicate (
+ IN CONST CHAR16 *Src
+ )
+/*++
+
+ Routine Description:
+ Duplicate a string
+
+ Arguments:
+ Src - Source string
+
+ Returns:
+ Duplicated string
+
+--*/
+{
+ UINTN Length;
+ CHAR16 *ReturnStr;
+
+ Length = StrLen ((CHAR16 *) Src);
+
+ ReturnStr = AllocateCopyPool ((Length + 1) * sizeof (CHAR16), (VOID *) Src);
+
+ return ReturnStr;
+}
+
+CHAR16 *
+GetParamByNodeName (
+ IN CHAR16 *Str,
+ IN CHAR16 *NodeName
+ )
+/*++
+
+ Routine Description:
+ Get parameter in a pair of parentheses follow the given node name.
+ For example, given the "Pci(0,1)" and NodeName "Pci", it returns "0,1".
+
+ Arguments:
+ Str - Device Path Text
+ NodeName - Name of the node
+
+ Returns:
+ Parameter text for the node
+
+--*/
+{
+ CHAR16 *ParamStr;
+ CHAR16 *StrPointer;
+ UINTN NodeNameLength;
+ UINTN ParameterLength;
+
+ //
+ // Check whether the node name matchs
+ //
+ NodeNameLength = StrLen (NodeName);
+ if (CompareMem (Str, NodeName, NodeNameLength * sizeof (CHAR16)) != 0) {
+ return NULL;
+ }
+
+ ParamStr = Str + NodeNameLength;
+ if (!IS_LEFT_PARENTH (*ParamStr)) {
+ return NULL;
+ }
+
+ //
+ // Skip the found '(' and find first occurrence of ')'
+ //
+ ParamStr++;
+ ParameterLength = 0;
+ StrPointer = ParamStr;
+ while (!IS_NULL (*StrPointer)) {
+ if (IS_RIGHT_PARENTH (*StrPointer)) {
+ break;
+ }
+ StrPointer++;
+ ParameterLength++;
+ }
+ if (IS_NULL (*StrPointer)) {
+ //
+ // ')' not found
+ //
+ return NULL;
+ }
+
+ ParamStr = AllocateCopyPool ((ParameterLength + 1) * sizeof (CHAR16), ParamStr);
+ if (ParamStr == NULL) {
+ return NULL;
+ }
+ //
+ // Terminate the parameter string
+ //
+ ParamStr[ParameterLength] = L'\0';
+
+ return ParamStr;
+}
+
+CHAR16 *
+SplitStr (
+ IN OUT CHAR16 **List,
+ IN CHAR16 Separator
+ )
+/*++
+
+ Routine Description:
+ Get current sub-string from a string list, before return
+ the list header is moved to next sub-string. The sub-string is separated
+ by the specified character. For example, the separator is ',', the string
+ list is "2,0,3", it returns "2", the remain list move to "2,3"
+
+ Arguments:
+ List - A string list separated by the specified separator
+ Separator - The separator character
+
+ Returns:
+ pointer - The current sub-string
+
+--*/
+{
+ CHAR16 *Str;
+ CHAR16 *ReturnStr;
+
+ Str = *List;
+ ReturnStr = Str;
+
+ if (IS_NULL (*Str)) {
+ return ReturnStr;
+ }
+
+ //
+ // Find first occurrence of the separator
+ //
+ while (!IS_NULL (*Str)) {
+ if (*Str == Separator) {
+ break;
+ }
+ Str++;
+ }
+
+ if (*Str == Separator) {
+ //
+ // Find a sub-string, terminate it
+ //
+ *Str = L'\0';
+ Str++;
+ }
+
+ //
+ // Move to next sub-string
+ //
+ *List = Str;
+
+ return ReturnStr;
+}
+
+CHAR16 *
+GetNextParamStr (
+ IN OUT CHAR16 **List
+ )
+{
+ //
+ // The separator is comma
+ //
+ return SplitStr (List, L',');
+}
+
+CHAR16 *
+GetNextDeviceNodeStr (
+ IN OUT CHAR16 **DevicePath,
+ OUT BOOLEAN *IsInstanceEnd
+ )
+/*++
+
+ Routine Description:
+ Get one device node from entire device path text.
+
+ Arguments:
+ Str - The entire device path text string
+ IsInstanceEnd - This node is the end of a device path instance
+
+ Returns:
+ a pointer - A device node text
+ NULL - No more device node available
+
+--*/
+{
+ CHAR16 *Str;
+ CHAR16 *ReturnStr;
+ UINTN ParenthesesStack;
+
+ Str = *DevicePath;
+ if (IS_NULL (*Str)) {
+ return NULL;
+ }
+
+ //
+ // Skip the leading '/', '(', ')' and ','
+ //
+ while (!IS_NULL (*Str)) {
+ if (!IS_SLASH (*Str) &&
+ !IS_COMMA (*Str) &&
+ !IS_LEFT_PARENTH (*Str) &&
+ !IS_RIGHT_PARENTH (*Str)) {
+ break;
+ }
+ Str++;
+ }
+
+ ReturnStr = Str;
+
+ //
+ // Scan for the separator of this device node, '/' or ','
+ //
+ ParenthesesStack = 0;
+ while (!IS_NULL (*Str)) {
+ if ((IS_COMMA (*Str) || IS_SLASH (*Str)) && (ParenthesesStack == 0)) {
+ break;
+ }
+
+ if (IS_LEFT_PARENTH (*Str)) {
+ ParenthesesStack++;
+ } else if (IS_RIGHT_PARENTH (*Str)) {
+ ParenthesesStack--;
+ }
+
+ Str++;
+ }
+
+ if (ParenthesesStack != 0) {
+ //
+ // The '(' doesn't pair with ')', invalid device path text
+ //
+ return NULL;
+ }
+
+ if (IS_COMMA (*Str)) {
+ *IsInstanceEnd = TRUE;
+ *Str = L'\0';
+ Str++;
+ } else {
+ *IsInstanceEnd = FALSE;
+ if (!IS_NULL (*Str)) {
+ *Str = L'\0';
+ Str++;
+ }
+ }
+
+ *DevicePath = Str;
+
+ return ReturnStr;
+}
+
+BOOLEAN
+IsHexDigit (
+ OUT UINT8 *Digit,
+ IN CHAR16 Char
+ )
+/*++
+
+ Routine Description:
+ Determines if a Unicode character is a hexadecimal digit.
+ The test is case insensitive.
+
+ Arguments:
+ Digit - Pointer to byte that receives the value of the hex character.
+ Char - Unicode character to test.
+
+ Returns:
+ TRUE - If the character is a hexadecimal digit.
+ FALSE - Otherwise.
+
+--*/
+{
+ if ((Char >= L'0') && (Char <= L'9')) {
+ *Digit = (UINT8) (Char - L'0');
+ return TRUE;
+ }
+
+ if ((Char >= L'A') && (Char <= L'F')) {
+ *Digit = (UINT8) (Char - L'A' + 0x0A);
+ return TRUE;
+ }
+
+ if ((Char >= L'a') && (Char <= L'f')) {
+ *Digit = (UINT8) (Char - L'a' + 0x0A);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+CHAR16
+NibbleToHexChar (
+ IN UINT8 Nibble
+ )
+/*++
+
+ Routine Description:
+ Converts the low nibble of a byte to hex unicode character.
+
+ Arguments:
+ Nibble - lower nibble of a byte.
+
+ Returns:
+ Hex unicode character.
+
+--*/
+{
+ Nibble &= 0x0F;
+ if (Nibble <= 0x9) {
+ return (CHAR16)(Nibble + L'0');
+ }
+
+ return (CHAR16)(Nibble - 0xA + L'A');
+}
+
+EFI_STATUS
+HexStringToBuf (
+ IN OUT UINT8 *Buf,
+ IN OUT UINTN *Len,
+ IN CHAR16 *Str,
+ OUT UINTN *ConvertedStrLen OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Converts Unicode string to binary buffer.
+ The conversion may be partial.
+ The first character in the string that is not hex digit stops the conversion.
+ At a minimum, any blob of data could be represented as a hex string.
+
+ Arguments:
+ Buf - Pointer to buffer that receives the data.
+ Len - Length in bytes of the buffer to hold converted data.
+ If routine return with EFI_SUCCESS, containing length of converted data.
+ If routine return with EFI_BUFFER_TOO_SMALL, containg length of buffer desired.
+ Str - String to be converted from.
+ ConvertedStrLen - Length of the Hex String consumed.
+
+ Returns:
+ EFI_SUCCESS: Routine Success.
+ EFI_BUFFER_TOO_SMALL: The buffer is too small to hold converted data.
+ EFI_
+
+--*/
+{
+ UINTN HexCnt;
+ UINTN Idx;
+ UINTN BufferLength;
+ UINT8 Digit;
+ UINT8 Byte;
+
+ //
+ // Find out how many hex characters the string has.
+ //
+ for (Idx = 0, HexCnt = 0; IsHexDigit (&Digit, Str[Idx]); Idx++, HexCnt++);
+
+ if (HexCnt == 0) {
+ *Len = 0;
+ return EFI_SUCCESS;
+ }
+ //
+ // Two Unicode characters make up 1 buffer byte. Round up.
+ //
+ BufferLength = (HexCnt + 1) / 2;
+
+ //
+ // Test if buffer is passed enough.
+ //
+ if (BufferLength > (*Len)) {
+ *Len = BufferLength;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ *Len = BufferLength;
+
+ for (Idx = 0; Idx < HexCnt; Idx++) {
+
+ IsHexDigit (&Digit, Str[HexCnt - 1 - Idx]);
+
+ //
+ // For odd charaters, write the lower nibble for each buffer byte,
+ // and for even characters, the upper nibble.
+ //
+ if ((Idx & 1) == 0) {
+ Byte = Digit;
+ } else {
+ Byte = Buf[Idx / 2];
+ Byte &= 0x0F;
+ Byte |= Digit << 4;
+ }
+
+ Buf[Idx / 2] = Byte;
+ }
+
+ if (ConvertedStrLen != NULL) {
+ *ConvertedStrLen = HexCnt;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BufToHexString (
+ IN OUT CHAR16 *Str,
+ IN OUT UINTN *HexStringBufferLength,
+ IN UINT8 *Buf,
+ IN UINTN Len
+ )
+/*++
+
+ Routine Description:
+ Converts binary buffer to Unicode string.
+ At a minimum, any blob of data could be represented as a hex string.
+
+ Arguments:
+ Str - Pointer to the string.
+ HexStringBufferLength - Length in bytes of buffer to hold the hex string. Includes tailing '\0' character.
+ If routine return with EFI_SUCCESS, containing length of hex string buffer.
+ If routine return with EFI_BUFFER_TOO_SMALL, containg length of hex string buffer desired.
+ Buf - Buffer to be converted from.
+ Len - Length in bytes of the buffer to be converted.
+
+ Returns:
+ EFI_SUCCESS: Routine success.
+ EFI_BUFFER_TOO_SMALL: The hex string buffer is too small.
+
+--*/
+{
+ UINTN Idx;
+ UINT8 Byte;
+ UINTN StrLen;
+
+ //
+ // Make sure string is either passed or allocate enough.
+ // It takes 2 Unicode characters (4 bytes) to represent 1 byte of the binary buffer.
+ // Plus the Unicode termination character.
+ //
+ StrLen = Len * 2;
+ if (StrLen > ((*HexStringBufferLength) - 1)) {
+ *HexStringBufferLength = StrLen + 1;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ *HexStringBufferLength = StrLen + 1;
+ //
+ // Ends the string.
+ //
+ Str[StrLen] = L'\0';
+
+ for (Idx = 0; Idx < Len; Idx++) {
+
+ Byte = Buf[Idx];
+ Str[StrLen - 1 - Idx * 2] = NibbleToHexChar (Byte);
+ Str[StrLen - 2 - Idx * 2] = NibbleToHexChar ((UINT8)(Byte >> 4));
+ }
+
+ return EFI_SUCCESS;
+}
+
+CHAR16 *
+TrimHexStr (
+ IN CHAR16 *Str
+ )
+/*++
+
+ Routine Description:
+ Skip the leading white space and '0x' or '0X' of a hex string
+
+ Arguments:
+ Str - The hex string
+
+ Returns:
+
+--*/
+{
+ //
+ // skip preceeding white space
+ //
+ while (*Str && *Str == ' ') {
+ Str += 1;
+ }
+ //
+ // skip preceeding zeros
+ //
+ while (*Str && *Str == '0') {
+ Str += 1;
+ }
+ //
+ // skip preceeding white space
+ //
+ if (*Str && (*Str == 'x' || *Str == 'X')) {
+ Str += 1;
+ }
+
+ return Str;
+}
+
+UINTN
+Xtoi (
+ IN CHAR16 *Str
+ )
+/*++
+
+Routine Description:
+
+ Convert hex string to uint
+
+Arguments:
+
+ Str - The string
+
+Returns:
+
+--*/
+{
+ UINTN Rvalue;
+ UINTN Length;
+
+ ASSERT (Str != NULL);
+
+ //
+ // convert hex digits
+ //
+ Rvalue = 0;
+ Length = sizeof (UINTN);
+ HexStringToBuf ((UINT8 *) &Rvalue, &Length, TrimHexStr (Str), NULL);
+
+ return Rvalue;
+}
+
+VOID
+Xtoi64 (
+ IN CHAR16 *Str,
+ IN UINT64 *Data
+ )
+/*++
+
+Routine Description:
+
+ Convert hex string to 64 bit data.
+
+Arguments:
+
+ Str - The string
+
+Returns:
+
+--*/
+{
+ UINTN Length;
+
+ *Data = 0;
+ Length = sizeof (UINT64);
+ HexStringToBuf ((UINT8 *) Data, &Length, TrimHexStr (Str), NULL);
+}
+
+UINTN
+Atoi (
+ IN CHAR16 *str
+ )
+/*++
+
+Routine Description:
+
+ Convert decimal string to uint
+
+Arguments:
+
+ Str - The string
+
+Returns:
+
+--*/
+{
+ UINTN Rvalue;
+ CHAR16 Char;
+ UINTN High;
+ UINTN Low;
+
+ ASSERT (str != NULL);
+
+ High = (UINTN) -1 / 10;
+ Low = (UINTN) -1 % 10;
+ //
+ // skip preceeding white space
+ //
+ while (*str && *str == ' ') {
+ str += 1;
+ }
+ //
+ // convert digits
+ //
+ Rvalue = 0;
+ Char = *(str++);
+ while (Char) {
+ if (Char >= '0' && Char <= '9') {
+ if ((Rvalue > High || Rvalue == High) && (Char - '0' > (INTN) Low)) {
+ return (UINTN) -1;
+ }
+
+ Rvalue = (Rvalue * 10) + Char - '0';
+ } else {
+ break;
+ }
+
+ Char = *(str++);
+ }
+
+ return Rvalue;
+}
+
+EFI_STATUS
+StrToBuf (
+ OUT UINT8 *Buf,
+ IN UINTN BufferLength,
+ IN CHAR16 *Str
+ )
+{
+ UINTN Index;
+ UINTN StrLength;
+ UINT8 Digit;
+ UINT8 Byte;
+
+ //
+ // Two hex char make up one byte
+ //
+ StrLength = BufferLength * sizeof (CHAR16);
+
+ for(Index = 0; Index < StrLength; Index++, Str++) {
+
+ IsHexDigit (&Digit, *Str);
+
+ //
+ // For odd charaters, write the upper nibble for each buffer byte,
+ // and for even characters, the lower nibble.
+ //
+ if ((Index & 1) == 0) {
+ Byte = Digit << 4;
+ } else {
+ Byte = Buf[Index / 2];
+ Byte &= 0xF0;
+ Byte |= Digit;
+ }
+
+ Buf[Index / 2] = Byte;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+StrToGuid (
+ IN CHAR16 *Str,
+ OUT EFI_GUID *Guid
+ )
+{
+ UINTN BufferLength;
+ UINTN ConvertedStrLen;
+ EFI_STATUS Status;
+
+ BufferLength = sizeof (Guid->Data1);
+ Status = HexStringToBuf ((UINT8 *) &Guid->Data1, &BufferLength, Str, &ConvertedStrLen);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ Str += ConvertedStrLen;
+ if (IS_HYPHEN (*Str)) {
+ Str++;
+ } else {
+ return EFI_UNSUPPORTED;
+ }
+
+ BufferLength = sizeof (Guid->Data2);
+ Status = HexStringToBuf ((UINT8 *) &Guid->Data2, &BufferLength, Str, &ConvertedStrLen);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ Str += ConvertedStrLen;
+ if (IS_HYPHEN (*Str)) {
+ Str++;
+ } else {
+ return EFI_UNSUPPORTED;
+ }
+
+ BufferLength = sizeof (Guid->Data3);
+ Status = HexStringToBuf ((UINT8 *) &Guid->Data3, &BufferLength, Str, &ConvertedStrLen);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ Str += ConvertedStrLen;
+ if (IS_HYPHEN (*Str)) {
+ Str++;
+ } else {
+ return EFI_UNSUPPORTED;
+ }
+
+ StrToBuf (&Guid->Data4[0], 2, Str);
+ //
+ // Skip 2 byte hex chars
+ //
+ Str += 2 * 2;
+
+ if (IS_HYPHEN (*Str)) {
+ Str++;
+ } else {
+ return EFI_UNSUPPORTED;
+ }
+ StrToBuf (&Guid->Data4[2], 6, Str);
+
+ return EFI_SUCCESS;
+}
+
+VOID
+StrToIPv4Addr (
+ IN OUT CHAR16 **Str,
+ OUT EFI_IPv4_ADDRESS *IPv4Addr
+ )
+{
+ UINTN Index;
+
+ for (Index = 0; Index < 4; Index++) {
+ IPv4Addr->Addr[Index] = (UINT8) Atoi (SplitStr (Str, L'.'));
+ }
+}
+
+VOID
+StrToIPv6Addr (
+ IN OUT CHAR16 **Str,
+ OUT EFI_IPv6_ADDRESS *IPv6Addr
+ )
+{
+ UINTN Index;
+ UINT16 Data;
+
+ for (Index = 0; Index < 8; Index++) {
+ Data = (UINT16) Xtoi (SplitStr (Str, L':'));
+ IPv6Addr->Addr[Index * 2] = (UINT8) (Data >> 8);
+ IPv6Addr->Addr[Index * 2 + 1] = (UINT8) (Data & 0xff);
+ }
+}
+
+VOID
+StrToAscii (
+ IN CHAR16 *Str,
+ IN OUT CHAR8 **AsciiStr
+ )
+{
+ CHAR8 *Dest;
+
+ Dest = *AsciiStr;
+ while (!IS_NULL (*Str)) {
+ *(Dest++) = (CHAR8) *(Str++);
+ }
+ *Dest = 0;
+
+ //
+ // Return the string next to it
+ //
+ *AsciiStr = Dest + 1;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextPci (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *FunctionStr;
+ CHAR16 *DeviceStr;
+ PCI_DEVICE_PATH *Pci;
+
+ FunctionStr = GetNextParamStr (&TextDeviceNode);
+ DeviceStr = GetNextParamStr (&TextDeviceNode);
+ Pci = (PCI_DEVICE_PATH *) CreateDeviceNode (
+ HARDWARE_DEVICE_PATH,
+ HW_PCI_DP,
+ sizeof (PCI_DEVICE_PATH)
+ );
+
+ Pci->Function = (UINT8) Xtoi (FunctionStr);
+ Pci->Device = (UINT8) Xtoi (DeviceStr);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) Pci;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextPcCard (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *FunctionNumberStr;
+ PCCARD_DEVICE_PATH *Pccard;
+
+ FunctionNumberStr = GetNextParamStr (&TextDeviceNode);
+ Pccard = (PCCARD_DEVICE_PATH *) CreateDeviceNode (
+ HARDWARE_DEVICE_PATH,
+ HW_PCCARD_DP,
+ sizeof (PCCARD_DEVICE_PATH)
+ );
+
+ Pccard->FunctionNumber = (UINT8) Xtoi (FunctionNumberStr);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) Pccard;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextMemoryMapped (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *StartingAddressStr;
+ CHAR16 *EndingAddressStr;
+ MEMMAP_DEVICE_PATH *MemMap;
+
+ StartingAddressStr = GetNextParamStr (&TextDeviceNode);
+ EndingAddressStr = GetNextParamStr (&TextDeviceNode);
+ MemMap = (MEMMAP_DEVICE_PATH *) CreateDeviceNode (
+ HARDWARE_DEVICE_PATH,
+ HW_MEMMAP_DP,
+ sizeof (MEMMAP_DEVICE_PATH)
+ );
+
+ MemMap->MemoryType = 0;
+
+ Xtoi64 (StartingAddressStr, &MemMap->StartingAddress);
+ Xtoi64 (EndingAddressStr, &MemMap->EndingAddress);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) MemMap;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+ConvertFromTextVendor (
+ IN CHAR16 *TextDeviceNode,
+ IN UINT8 Type,
+ IN UINT8 SubType
+ )
+{
+ CHAR16 *GuidStr;
+ CHAR16 *DataStr;
+ UINTN Length;
+ VENDOR_DEVICE_PATH *Vendor;
+
+ GuidStr = GetNextParamStr (&TextDeviceNode);
+
+ DataStr = GetNextParamStr (&TextDeviceNode);
+ Length = StrLen (DataStr);
+ //
+ // Two hex characters make up 1 buffer byte
+ //
+ Length = (Length + 1) / 2;
+
+ Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
+ Type,
+ SubType,
+ sizeof (VENDOR_DEVICE_PATH) + (UINT16) Length
+ );
+
+ StrToGuid (GuidStr, &Vendor->Guid);
+ StrToBuf (((UINT8 *) Vendor) + sizeof (VENDOR_DEVICE_PATH), Length, DataStr);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextVenHw (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ return ConvertFromTextVendor (
+ TextDeviceNode,
+ HARDWARE_DEVICE_PATH,
+ HW_VENDOR_DP
+ );
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextCtrl (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *ControllerStr;
+ CONTROLLER_DEVICE_PATH *Controller;
+
+ ControllerStr = GetNextParamStr (&TextDeviceNode);
+ Controller = (CONTROLLER_DEVICE_PATH *) CreateDeviceNode (
+ HARDWARE_DEVICE_PATH,
+ HW_CONTROLLER_DP,
+ sizeof (CONTROLLER_DEVICE_PATH)
+ );
+ Controller->ControllerNumber = (UINT32) Xtoi (ControllerStr);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) Controller;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextAcpi (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *HIDStr;
+ CHAR16 *UIDStr;
+ ACPI_HID_DEVICE_PATH *Acpi;
+
+ HIDStr = GetNextParamStr (&TextDeviceNode);
+ UIDStr = GetNextParamStr (&TextDeviceNode);
+ Acpi = (ACPI_HID_DEVICE_PATH *) CreateDeviceNode (
+ ACPI_DEVICE_PATH,
+ ACPI_DP,
+ sizeof (ACPI_HID_DEVICE_PATH)
+ );
+
+ if ((HIDStr[0] == L'P') && (HIDStr[1] == L'N') && (HIDStr[2] == L'P')) {
+ HIDStr += 3;
+ }
+
+ Acpi->HID = EISA_PNP_ID (Xtoi (HIDStr));
+ Acpi->UID = (UINT32) Xtoi (UIDStr);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) Acpi;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+ConvertFromTextAcpi (
+ IN CHAR16 *TextDeviceNode,
+ IN UINT32 Hid
+ )
+{
+ CHAR16 *UIDStr;
+ ACPI_HID_DEVICE_PATH *Acpi;
+
+ UIDStr = GetNextParamStr (&TextDeviceNode);
+ Acpi = (ACPI_HID_DEVICE_PATH *) CreateDeviceNode (
+ ACPI_DEVICE_PATH,
+ ACPI_DP,
+ sizeof (ACPI_HID_DEVICE_PATH)
+ );
+
+ Acpi->HID = Hid;
+ Acpi->UID = (UINT32) Xtoi (UIDStr);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) Acpi;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextPciRoot (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ return ConvertFromTextAcpi (TextDeviceNode, 0x0a0341d0);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextFloppy (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ return ConvertFromTextAcpi (TextDeviceNode, 0x060441d0);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextKeyboard (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ return ConvertFromTextAcpi (TextDeviceNode, 0x030141d0);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextSerial (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ return ConvertFromTextAcpi (TextDeviceNode, 0x050141d0);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextParallelPort (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ return ConvertFromTextAcpi (TextDeviceNode, 0x040141d0);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextAcpiEx (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *HIDStr;
+ CHAR16 *CIDStr;
+ CHAR16 *UIDStr;
+ CHAR16 *HIDSTRStr;
+ CHAR16 *CIDSTRStr;
+ CHAR16 *UIDSTRStr;
+ CHAR8 *AsciiStr;
+ UINT16 Length;
+ ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR *AcpiExt;
+
+ HIDStr = GetNextParamStr (&TextDeviceNode);
+ CIDStr = GetNextParamStr (&TextDeviceNode);
+ UIDStr = GetNextParamStr (&TextDeviceNode);
+ HIDSTRStr = GetNextParamStr (&TextDeviceNode);
+ CIDSTRStr = GetNextParamStr (&TextDeviceNode);
+ UIDSTRStr = GetNextParamStr (&TextDeviceNode);
+ Length = sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) +
+ (UINT16) StrLen (HIDSTRStr) + 1 +
+ (UINT16) StrLen (UIDSTRStr) + 1 +
+ (UINT16) StrLen (CIDSTRStr) + 1;
+ AcpiExt = (ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR *) CreateDeviceNode (
+ ACPI_DEVICE_PATH,
+ ACPI_EXTENDED_DP,
+ Length
+ );
+
+ if ((HIDStr[0] == L'P') && (HIDStr[1] == L'N') && (HIDStr[2] == L'P')) {
+ HIDStr += 3;
+ AcpiExt->HID = EISA_PNP_ID (Xtoi (HIDStr));
+ } else {
+ AcpiExt->HID = (UINT32) Xtoi (HIDStr);
+ }
+
+ AcpiExt->UID = (UINT32) Xtoi (UIDStr);
+ AcpiExt->CID = (UINT32) Xtoi (CIDStr);
+
+ AsciiStr = AcpiExt->HidUidCidStr;
+ StrToAscii (HIDSTRStr, &AsciiStr);
+ StrToAscii (UIDSTRStr, &AsciiStr);
+ StrToAscii (CIDSTRStr, &AsciiStr);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) AcpiExt;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextAcpiExp (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *HIDStr;
+ CHAR16 *CIDStr;
+ CHAR16 *UIDSTRStr;
+ CHAR8 *AsciiStr;
+ UINT16 Length;
+ ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR *AcpiExt;
+
+ HIDStr = GetNextParamStr (&TextDeviceNode);
+ CIDStr = GetNextParamStr (&TextDeviceNode);
+ UIDSTRStr = GetNextParamStr (&TextDeviceNode);
+ Length = sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + (UINT16) StrLen (UIDSTRStr) + 3;
+ AcpiExt = (ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR *) CreateDeviceNode (
+ ACPI_DEVICE_PATH,
+ ACPI_EXTENDED_DP,
+ Length
+ );
+
+ if ((HIDStr[0] == L'P') && (HIDStr[1] == L'N') && (HIDStr[2] == L'P')) {
+ HIDStr += 3;
+ AcpiExt->HID = EISA_PNP_ID (Xtoi (HIDStr));
+ } else {
+ AcpiExt->HID = (UINT32) Xtoi (HIDStr);
+ }
+
+ AcpiExt->UID = 0;
+ AcpiExt->CID = (UINT32) Xtoi (CIDStr);
+
+ AsciiStr = AcpiExt->HidUidCidStr;
+ //
+ // HID string is NULL
+ //
+ *AsciiStr = 0;
+ //
+ // Convert UID string
+ //
+ AsciiStr++;
+ StrToAscii (UIDSTRStr, &AsciiStr);
+ //
+ // CID string is NULL
+ //
+ *AsciiStr = 0;
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) AcpiExt;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextAta (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *PrimarySecondaryStr;
+ CHAR16 *SlaveMasterStr;
+ CHAR16 *LunStr;
+ ATAPI_DEVICE_PATH *Atapi;
+
+ Atapi = (ATAPI_DEVICE_PATH *) CreateDeviceNode (
+ MESSAGING_DEVICE_PATH,
+ MSG_ATAPI_DP,
+ sizeof (ATAPI_DEVICE_PATH)
+ );
+
+ PrimarySecondaryStr = GetNextParamStr (&TextDeviceNode);
+ SlaveMasterStr = GetNextParamStr (&TextDeviceNode);
+ LunStr = GetNextParamStr (&TextDeviceNode);
+
+ Atapi->PrimarySecondary = (StrCmp (PrimarySecondaryStr, L"Primary") == 0) ? (UINT8) 0 : (UINT8) 1;
+ Atapi->SlaveMaster = (StrCmp (SlaveMasterStr, L"Master") == 0) ? (UINT8) 0 : (UINT8) 1;
+ Atapi->Lun = (UINT16) Xtoi (LunStr);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) Atapi;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextScsi (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *PunStr;
+ CHAR16 *LunStr;
+ SCSI_DEVICE_PATH *Scsi;
+
+ PunStr = GetNextParamStr (&TextDeviceNode);
+ LunStr = GetNextParamStr (&TextDeviceNode);
+ Scsi = (SCSI_DEVICE_PATH *) CreateDeviceNode (
+ MESSAGING_DEVICE_PATH,
+ MSG_SCSI_DP,
+ sizeof (SCSI_DEVICE_PATH)
+ );
+
+ Scsi->Pun = (UINT16) Xtoi (PunStr);
+ Scsi->Lun = (UINT16) Xtoi (LunStr);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) Scsi;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextFibre (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *WWNStr;
+ CHAR16 *LunStr;
+ FIBRECHANNEL_DEVICE_PATH *Fibre;
+
+ WWNStr = GetNextParamStr (&TextDeviceNode);
+ LunStr = GetNextParamStr (&TextDeviceNode);
+ Fibre = (FIBRECHANNEL_DEVICE_PATH *) CreateDeviceNode (
+ MESSAGING_DEVICE_PATH,
+ MSG_FIBRECHANNEL_DP,
+ sizeof (FIBRECHANNEL_DEVICE_PATH)
+ );
+
+ Fibre->Reserved = 0;
+ Xtoi64 (WWNStr, &Fibre->WWN);
+ Xtoi64 (LunStr, &Fibre->Lun);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) Fibre;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromText1394 (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *GuidStr;
+ F1394_DEVICE_PATH *F1394;
+
+ GuidStr = GetNextParamStr (&TextDeviceNode);
+ F1394 = (F1394_DEVICE_PATH *) CreateDeviceNode (
+ MESSAGING_DEVICE_PATH,
+ MSG_1394_DP,
+ sizeof (F1394_DEVICE_PATH)
+ );
+
+ F1394->Reserved = 0;
+ Xtoi64 (GuidStr, &F1394->Guid);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) F1394;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextUsb (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *PortStr;
+ CHAR16 *InterfaceStr;
+ USB_DEVICE_PATH *Usb;
+
+ PortStr = GetNextParamStr (&TextDeviceNode);
+ InterfaceStr = GetNextParamStr (&TextDeviceNode);
+ Usb = (USB_DEVICE_PATH *) CreateDeviceNode (
+ MESSAGING_DEVICE_PATH,
+ MSG_USB_DP,
+ sizeof (USB_DEVICE_PATH)
+ );
+
+ Usb->ParentPortNumber = (UINT8) Xtoi (PortStr);
+ Usb->InterfaceNumber = (UINT8) Xtoi (InterfaceStr);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) Usb;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextI2O (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *TIDStr;
+ I2O_DEVICE_PATH *I2O;
+
+ TIDStr = GetNextParamStr (&TextDeviceNode);
+ I2O = (I2O_DEVICE_PATH *) CreateDeviceNode (
+ MESSAGING_DEVICE_PATH,
+ MSG_I2O_DP,
+ sizeof (I2O_DEVICE_PATH)
+ );
+
+ I2O->Tid = (UINT32) Xtoi (TIDStr);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) I2O;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextInfiniband (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *FlagsStr;
+ CHAR16 *GuidStr;
+ CHAR16 *SidStr;
+ CHAR16 *TidStr;
+ CHAR16 *DidStr;
+ EFI_GUID PortGid;
+ INFINIBAND_DEVICE_PATH *InfiniBand;
+
+ FlagsStr = GetNextParamStr (&TextDeviceNode);
+ GuidStr = GetNextParamStr (&TextDeviceNode);
+ SidStr = GetNextParamStr (&TextDeviceNode);
+ TidStr = GetNextParamStr (&TextDeviceNode);
+ DidStr = GetNextParamStr (&TextDeviceNode);
+ InfiniBand = (INFINIBAND_DEVICE_PATH *) CreateDeviceNode (
+ MESSAGING_DEVICE_PATH,
+ MSG_INFINIBAND_DP,
+ sizeof (INFINIBAND_DEVICE_PATH)
+ );
+
+ InfiniBand->ResourceFlags = (UINT32) Xtoi (FlagsStr);
+ StrToGuid (GuidStr, &PortGid);
+ CopyMem (InfiniBand->PortGid, &PortGid, sizeof (EFI_GUID));
+ Xtoi64 (SidStr, &InfiniBand->ServiceId);
+ Xtoi64 (TidStr, &InfiniBand->TargetPortId);
+ Xtoi64 (DidStr, &InfiniBand->DeviceId);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) InfiniBand;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextVenMsg (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ return ConvertFromTextVendor (
+ TextDeviceNode,
+ MESSAGING_DEVICE_PATH,
+ MSG_VENDOR_DP
+ );
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextVenPcAnsi (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ VENDOR_DEVICE_PATH *Vendor;
+
+ Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
+ MESSAGING_DEVICE_PATH,
+ MSG_VENDOR_DP,
+ sizeof (VENDOR_DEVICE_PATH));
+ CopyGuid (&Vendor->Guid, &gEfiPcAnsiGuid);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextVenVt100 (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ VENDOR_DEVICE_PATH *Vendor;
+
+ Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
+ MESSAGING_DEVICE_PATH,
+ MSG_VENDOR_DP,
+ sizeof (VENDOR_DEVICE_PATH));
+ CopyGuid (&Vendor->Guid, &gEfiVT100Guid);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextVenVt100Plus (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ VENDOR_DEVICE_PATH *Vendor;
+
+ Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
+ MESSAGING_DEVICE_PATH,
+ MSG_VENDOR_DP,
+ sizeof (VENDOR_DEVICE_PATH));
+ CopyGuid (&Vendor->Guid, &gEfiVT100PlusGuid);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextVenUtf8 (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ VENDOR_DEVICE_PATH *Vendor;
+
+ Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
+ MESSAGING_DEVICE_PATH,
+ MSG_VENDOR_DP,
+ sizeof (VENDOR_DEVICE_PATH));
+ CopyGuid (&Vendor->Guid, &gEfiVTUTF8Guid);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextUartFlowCtrl (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *ValueStr;
+ UART_FLOW_CONTROL_DEVICE_PATH *UartFlowControl;
+
+ ValueStr = GetNextParamStr (&TextDeviceNode);
+ UartFlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) CreateDeviceNode (
+ MESSAGING_DEVICE_PATH,
+ MSG_VENDOR_DP,
+ sizeof (UART_FLOW_CONTROL_DEVICE_PATH)
+ );
+
+ CopyGuid (&UartFlowControl->Guid, &mEfiDevicePathMessagingUartFlowControlGuid);
+ if (StrCmp (ValueStr, L"XonXoff") == 0) {
+ UartFlowControl->FlowControlMap = 2;
+ } else if (StrCmp (ValueStr, L"Hardware") == 0) {
+ UartFlowControl->FlowControlMap = 1;
+ } else {
+ UartFlowControl->FlowControlMap = 0;
+ }
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) UartFlowControl;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextSAS (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *AddressStr;
+ CHAR16 *LunStr;
+ CHAR16 *RTPStr;
+ CHAR16 *SASSATAStr;
+ CHAR16 *LocationStr;
+ CHAR16 *ConnectStr;
+ CHAR16 *DriveBayStr;
+ CHAR16 *ReservedStr;
+ UINT16 Info;
+ SAS_DEVICE_PATH *Sas;
+
+ AddressStr = GetNextParamStr (&TextDeviceNode);
+ LunStr = GetNextParamStr (&TextDeviceNode);
+ RTPStr = GetNextParamStr (&TextDeviceNode);
+ SASSATAStr = GetNextParamStr (&TextDeviceNode);
+ LocationStr = GetNextParamStr (&TextDeviceNode);
+ ConnectStr = GetNextParamStr (&TextDeviceNode);
+ DriveBayStr = GetNextParamStr (&TextDeviceNode);
+ ReservedStr = GetNextParamStr (&TextDeviceNode);
+ Info = 0x0000;
+ Sas = (SAS_DEVICE_PATH *) CreateDeviceNode (
+ MESSAGING_DEVICE_PATH,
+ MSG_VENDOR_DP,
+ sizeof (SAS_DEVICE_PATH)
+ );
+
+ CopyGuid (&Sas->Guid, &mEfiDevicePathMessagingSASGuid);
+ Xtoi64 (AddressStr, &Sas->SasAddress);
+ Xtoi64 (LunStr, &Sas->Lun);
+ Sas->RelativeTargetPort = (UINT16) Xtoi (RTPStr);
+ if (StrCmp (SASSATAStr, L"NoTopology") == 0)
+ ;
+ else {
+ if (StrCmp (DriveBayStr, L"0") == 0) {
+ Info |= 0x0001;
+ } else {
+ Info |= 0x0002;
+ Info |= (Xtoi (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;
+ }
+ }
+
+ Sas->DeviceTopology = Info;
+ Sas->Reserved = (UINT32) Xtoi (ReservedStr);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) Sas;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextDebugPort (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ VENDOR_DEFINED_MESSAGING_DEVICE_PATH *Vend;
+
+ Vend = (VENDOR_DEFINED_MESSAGING_DEVICE_PATH *) CreateDeviceNode (
+ MESSAGING_DEVICE_PATH,
+ MSG_VENDOR_DP,
+ sizeof (VENDOR_DEFINED_MESSAGING_DEVICE_PATH)
+ );
+
+ CopyGuid (&Vend->Guid, &gEfiDebugPortProtocolGuid);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) Vend;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextMAC (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *AddressStr;
+ CHAR16 *IfTypeStr;
+ UINTN Length;
+ MAC_ADDR_DEVICE_PATH *MAC;
+
+ AddressStr = GetNextParamStr (&TextDeviceNode);
+ IfTypeStr = GetNextParamStr (&TextDeviceNode);
+ MAC = (MAC_ADDR_DEVICE_PATH *) CreateDeviceNode (
+ MESSAGING_DEVICE_PATH,
+ MSG_MAC_ADDR_DP,
+ sizeof (MAC_ADDR_DEVICE_PATH)
+ );
+
+ MAC->IfType = (UINT8) Xtoi (IfTypeStr);
+
+ Length = sizeof (EFI_MAC_ADDRESS);
+ StrToBuf (&MAC->MacAddress.Addr[0], Length, AddressStr);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) MAC;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextIPv4 (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *RemoteIPStr;
+ CHAR16 *ProtocolStr;
+ CHAR16 *TypeStr;
+ CHAR16 *LocalIPStr;
+ IPv4_DEVICE_PATH *IPv4;
+
+ RemoteIPStr = GetNextParamStr (&TextDeviceNode);
+ ProtocolStr = GetNextParamStr (&TextDeviceNode);
+ TypeStr = GetNextParamStr (&TextDeviceNode);
+ LocalIPStr = GetNextParamStr (&TextDeviceNode);
+ IPv4 = (IPv4_DEVICE_PATH *) CreateDeviceNode (
+ MESSAGING_DEVICE_PATH,
+ MSG_IPv4_DP,
+ sizeof (IPv4_DEVICE_PATH)
+ );
+
+ StrToIPv4Addr (&RemoteIPStr, &IPv4->RemoteIpAddress);
+ IPv4->Protocol = (StrCmp (ProtocolStr, L"UDP") == 0) ? (UINT16) 0 : (UINT16) 1;
+ if (StrCmp (TypeStr, L"Static") == 0) {
+ IPv4->StaticIpAddress = TRUE;
+ } else {
+ IPv4->StaticIpAddress = FALSE;
+ }
+
+ StrToIPv4Addr (&LocalIPStr, &IPv4->LocalIpAddress);
+
+ IPv4->LocalPort = 0;
+ IPv4->RemotePort = 0;
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) IPv4;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextIPv6 (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *RemoteIPStr;
+ CHAR16 *ProtocolStr;
+ CHAR16 *TypeStr;
+ CHAR16 *LocalIPStr;
+ IPv6_DEVICE_PATH *IPv6;
+
+ RemoteIPStr = GetNextParamStr (&TextDeviceNode);
+ ProtocolStr = GetNextParamStr (&TextDeviceNode);
+ TypeStr = GetNextParamStr (&TextDeviceNode);
+ LocalIPStr = GetNextParamStr (&TextDeviceNode);
+ IPv6 = (IPv6_DEVICE_PATH *) CreateDeviceNode (
+ MESSAGING_DEVICE_PATH,
+ MSG_IPv6_DP,
+ sizeof (IPv6_DEVICE_PATH)
+ );
+
+ StrToIPv6Addr (&RemoteIPStr, &IPv6->RemoteIpAddress);
+ IPv6->Protocol = (StrCmp (ProtocolStr, L"UDP") == 0) ? (UINT16) 0 : (UINT16) 1;
+ if (StrCmp (TypeStr, L"Static") == 0) {
+ IPv6->StaticIpAddress = TRUE;
+ } else {
+ IPv6->StaticIpAddress = FALSE;
+ }
+
+ StrToIPv6Addr (&LocalIPStr, &IPv6->LocalIpAddress);
+
+ IPv6->LocalPort = 0;
+ IPv6->RemotePort = 0;
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) IPv6;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextUart (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *BaudStr;
+ CHAR16 *DataBitsStr;
+ CHAR16 *ParityStr;
+ CHAR16 *StopBitsStr;
+ UART_DEVICE_PATH *Uart;
+
+ BaudStr = GetNextParamStr (&TextDeviceNode);
+ DataBitsStr = GetNextParamStr (&TextDeviceNode);
+ ParityStr = GetNextParamStr (&TextDeviceNode);
+ StopBitsStr = GetNextParamStr (&TextDeviceNode);
+ Uart = (UART_DEVICE_PATH *) CreateDeviceNode (
+ MESSAGING_DEVICE_PATH,
+ MSG_UART_DP,
+ sizeof (UART_DEVICE_PATH)
+ );
+
+ Uart->BaudRate = (StrCmp (BaudStr, L"DEFAULT") == 0) ? 115200 : Atoi (BaudStr);
+ Uart->DataBits = (StrCmp (DataBitsStr, L"DEFAULT") == 0) ? (UINT8) 8 : (UINT8) Atoi (DataBitsStr);
+ switch (*ParityStr) {
+ case L'D':
+ Uart->Parity = 0;
+ break;
+
+ case L'N':
+ Uart->Parity = 1;
+ break;
+
+ case L'E':
+ Uart->Parity = 2;
+ break;
+
+ case L'O':
+ Uart->Parity = 3;
+ break;
+
+ case L'M':
+ Uart->Parity = 4;
+ break;
+
+ case L'S':
+ Uart->Parity = 5;
+
+ default:
+ Uart->Parity = 0xff;
+ }
+
+ if (StrCmp (StopBitsStr, L"D") == 0) {
+ Uart->StopBits = (UINT8) 0;
+ } else if (StrCmp (StopBitsStr, L"1") == 0) {
+ Uart->StopBits = (UINT8) 1;
+ } else if (StrCmp (StopBitsStr, L"1.5") == 0) {
+ Uart->StopBits = (UINT8) 2;
+ } else if (StrCmp (StopBitsStr, L"2") == 0) {
+ Uart->StopBits = (UINT8) 3;
+ } else {
+ Uart->StopBits = 0xff;
+ }
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) Uart;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+ConvertFromTextUsbClass (
+ IN CHAR16 *TextDeviceNode,
+ IN USB_CLASS_TEXT *UsbClassText
+ )
+{
+ CHAR16 *VIDStr;
+ CHAR16 *PIDStr;
+ CHAR16 *ClassStr;
+ CHAR16 *SubClassStr;
+ CHAR16 *ProtocolStr;
+ USB_CLASS_DEVICE_PATH *UsbClass;
+
+ UsbClass = (USB_CLASS_DEVICE_PATH *) CreateDeviceNode (
+ MESSAGING_DEVICE_PATH,
+ MSG_USB_CLASS_DP,
+ sizeof (USB_CLASS_DEVICE_PATH)
+ );
+
+ VIDStr = GetNextParamStr (&TextDeviceNode);
+ PIDStr = GetNextParamStr (&TextDeviceNode);
+ if (UsbClassText->ClassExist) {
+ ClassStr = GetNextParamStr (&TextDeviceNode);
+ UsbClass->DeviceClass = (UINT8) Xtoi (ClassStr);
+ } else {
+ UsbClass->DeviceClass = UsbClassText->Class;
+ }
+ if (UsbClassText->SubClassExist) {
+ SubClassStr = GetNextParamStr (&TextDeviceNode);
+ UsbClass->DeviceSubClass = (UINT8) Xtoi (SubClassStr);
+ } else {
+ UsbClass->DeviceSubClass = UsbClassText->SubClass;
+ }
+
+ ProtocolStr = GetNextParamStr (&TextDeviceNode);
+
+ UsbClass->VendorId = (UINT16) Xtoi (VIDStr);
+ UsbClass->ProductId = (UINT16) Xtoi (PIDStr);
+ UsbClass->DeviceProtocol = (UINT8) Xtoi (ProtocolStr);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) UsbClass;
+}
+
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextUsbClass (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ USB_CLASS_TEXT UsbClassText;
+
+ UsbClassText.ClassExist = TRUE;
+ UsbClassText.SubClassExist = TRUE;
+
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextUsbAudio (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ USB_CLASS_TEXT UsbClassText;
+
+ UsbClassText.ClassExist = FALSE;
+ UsbClassText.Class = USB_CLASS_AUDIO;
+ UsbClassText.SubClassExist = TRUE;
+
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextUsbCDCControl (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ USB_CLASS_TEXT UsbClassText;
+
+ UsbClassText.ClassExist = FALSE;
+ UsbClassText.Class = USB_CLASS_CDCCONTROL;
+ UsbClassText.SubClassExist = TRUE;
+
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextUsbHID (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ USB_CLASS_TEXT UsbClassText;
+
+ UsbClassText.ClassExist = FALSE;
+ UsbClassText.Class = USB_CLASS_HID;
+ UsbClassText.SubClassExist = TRUE;
+
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextUsbImage (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ USB_CLASS_TEXT UsbClassText;
+
+ UsbClassText.ClassExist = FALSE;
+ UsbClassText.Class = USB_CLASS_IMAGE;
+ UsbClassText.SubClassExist = TRUE;
+
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextUsbPrinter (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ USB_CLASS_TEXT UsbClassText;
+
+ UsbClassText.ClassExist = FALSE;
+ UsbClassText.Class = USB_CLASS_PRINTER;
+ UsbClassText.SubClassExist = TRUE;
+
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextUsbMassStorage (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ USB_CLASS_TEXT UsbClassText;
+
+ UsbClassText.ClassExist = FALSE;
+ UsbClassText.Class = USB_CLASS_MASS_STORAGE;
+ UsbClassText.SubClassExist = TRUE;
+
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextUsbHub (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ USB_CLASS_TEXT UsbClassText;
+
+ UsbClassText.ClassExist = FALSE;
+ UsbClassText.Class = USB_CLASS_HUB;
+ UsbClassText.SubClassExist = TRUE;
+
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextUsbCDCData (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ USB_CLASS_TEXT UsbClassText;
+
+ UsbClassText.ClassExist = FALSE;
+ UsbClassText.Class = USB_CLASS_CDCDATA;
+ UsbClassText.SubClassExist = TRUE;
+
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextUsbSmartCard (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ USB_CLASS_TEXT UsbClassText;
+
+ UsbClassText.ClassExist = FALSE;
+ UsbClassText.Class = USB_CLASS_SMART_CARD;
+ UsbClassText.SubClassExist = TRUE;
+
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextUsbVideo (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ USB_CLASS_TEXT UsbClassText;
+
+ UsbClassText.ClassExist = FALSE;
+ UsbClassText.Class = USB_CLASS_VIDEO;
+ UsbClassText.SubClassExist = TRUE;
+
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextUsbDiagnostic (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ USB_CLASS_TEXT UsbClassText;
+
+ UsbClassText.ClassExist = FALSE;
+ UsbClassText.Class = USB_CLASS_DIAGNOSTIC;
+ UsbClassText.SubClassExist = TRUE;
+
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextUsbWireless (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ USB_CLASS_TEXT UsbClassText;
+
+ UsbClassText.ClassExist = FALSE;
+ UsbClassText.Class = USB_CLASS_WIRELESS;
+ UsbClassText.SubClassExist = TRUE;
+
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextUsbDeviceFirmwareUpdate (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ USB_CLASS_TEXT UsbClassText;
+
+ UsbClassText.ClassExist = FALSE;
+ UsbClassText.Class = USB_CLASS_RESERVE;
+ UsbClassText.SubClassExist = FALSE;
+ UsbClassText.SubClass = USB_SUBCLASS_FW_UPDATE;
+
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextUsbIrdaBridge (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ USB_CLASS_TEXT UsbClassText;
+
+ UsbClassText.ClassExist = FALSE;
+ UsbClassText.Class = USB_CLASS_RESERVE;
+ UsbClassText.SubClassExist = FALSE;
+ UsbClassText.SubClass = USB_SUBCLASS_IRDA_BRIDGE;
+
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextUsbTestAndMeasurement (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ USB_CLASS_TEXT UsbClassText;
+
+ UsbClassText.ClassExist = FALSE;
+ UsbClassText.Class = USB_CLASS_RESERVE;
+ UsbClassText.SubClassExist = FALSE;
+ UsbClassText.SubClass = USB_SUBCLASS_TEST;
+
+ return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextUsbWwid (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *VIDStr;
+ CHAR16 *PIDStr;
+ CHAR16 *InterfaceNumStr;
+ USB_WWID_DEVICE_PATH *UsbWwid;
+
+ VIDStr = GetNextParamStr (&TextDeviceNode);
+ PIDStr = GetNextParamStr (&TextDeviceNode);
+ InterfaceNumStr = GetNextParamStr (&TextDeviceNode);
+ UsbWwid = (USB_WWID_DEVICE_PATH *) CreateDeviceNode (
+ MESSAGING_DEVICE_PATH,
+ MSG_USB_WWID_DP,
+ sizeof (USB_WWID_DEVICE_PATH)
+ );
+
+ UsbWwid->VendorId = (UINT16) Xtoi (VIDStr);
+ UsbWwid->ProductId = (UINT16) Xtoi (PIDStr);
+ UsbWwid->InterfaceNumber = (UINT16) Xtoi (InterfaceNumStr);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) UsbWwid;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextUnit (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *LunStr;
+ DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;
+
+ LunStr = GetNextParamStr (&TextDeviceNode);
+ LogicalUnit = (DEVICE_LOGICAL_UNIT_DEVICE_PATH *) CreateDeviceNode (
+ MESSAGING_DEVICE_PATH,
+ MSG_DEVICE_LOGICAL_UNIT_DP,
+ sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH)
+ );
+
+ LogicalUnit->Lun = (UINT8) Xtoi (LunStr);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) LogicalUnit;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextiSCSI (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ UINT16 Options;
+ CHAR16 *NameStr;
+ CHAR16 *PortalGroupStr;
+ CHAR16 *LunStr;
+ CHAR16 *HeaderDigestStr;
+ CHAR16 *DataDigestStr;
+ CHAR16 *AuthenticationStr;
+ CHAR16 *ProtocolStr;
+ ISCSI_DEVICE_PATH_WITH_NAME *iSCSI;
+
+ NameStr = GetNextParamStr (&TextDeviceNode);
+ PortalGroupStr = GetNextParamStr (&TextDeviceNode);
+ LunStr = GetNextParamStr (&TextDeviceNode);
+ HeaderDigestStr = GetNextParamStr (&TextDeviceNode);
+ DataDigestStr = GetNextParamStr (&TextDeviceNode);
+ AuthenticationStr = GetNextParamStr (&TextDeviceNode);
+ ProtocolStr = GetNextParamStr (&TextDeviceNode);
+ iSCSI = (ISCSI_DEVICE_PATH_WITH_NAME *) CreateDeviceNode (
+ MESSAGING_DEVICE_PATH,
+ MSG_ISCSI_DP,
+ sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + (UINT16) (StrLen (NameStr) * 2)
+ );
+
+ StrCpy (iSCSI->iSCSITargetName, NameStr);
+ iSCSI->TargetPortalGroupTag = (UINT16) Xtoi (PortalGroupStr);
+ Xtoi64 (LunStr, &iSCSI->Lun);
+
+ Options = 0x0000;
+ if (StrCmp (HeaderDigestStr, L"CRC32C") == 0) {
+ Options |= 0x0002;
+ }
+
+ if (StrCmp (DataDigestStr, L"CRC32C") == 0) {
+ Options |= 0x0008;
+ }
+
+ if (StrCmp (AuthenticationStr, L"None") == 0) {
+ Options |= 0x0800;
+ }
+
+ if (StrCmp (AuthenticationStr, L"CHAP_UNI") == 0) {
+ Options |= 0x1000;
+ }
+
+ iSCSI->LoginOption = (UINT16) Options;
+
+ iSCSI->NetworkProtocol = (UINT16) StrCmp (ProtocolStr, L"TCP");
+ iSCSI->Reserved = (UINT16) 0;
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) iSCSI;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextHD (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *PartitionStr;
+ CHAR16 *TypeStr;
+ CHAR16 *SignatureStr;
+ CHAR16 *StartStr;
+ CHAR16 *SizeStr;
+ UINT32 Signature32;
+ EFI_GUID SignatureGuid;
+ HARDDRIVE_DEVICE_PATH *Hd;
+
+ PartitionStr = GetNextParamStr (&TextDeviceNode);
+ TypeStr = GetNextParamStr (&TextDeviceNode);
+ SignatureStr = GetNextParamStr (&TextDeviceNode);
+ StartStr = GetNextParamStr (&TextDeviceNode);
+ SizeStr = GetNextParamStr (&TextDeviceNode);
+ Hd = (HARDDRIVE_DEVICE_PATH *) CreateDeviceNode (
+ MEDIA_DEVICE_PATH,
+ MEDIA_HARDDRIVE_DP,
+ sizeof (HARDDRIVE_DEVICE_PATH)
+ );
+
+ Hd->PartitionNumber = (UINT32) Atoi (PartitionStr);
+
+ ZeroMem (Hd->Signature, 16);
+ Hd->MBRType = (UINT8) 0;
+
+ if (StrCmp (TypeStr, L"None") == 0) {
+ Hd->SignatureType = (UINT8) 0;
+ } else if (StrCmp (TypeStr, L"MBR") == 0) {
+ Hd->SignatureType = SIGNATURE_TYPE_MBR;
+ Hd->MBRType = 0x01;
+
+ Signature32 = (UINT32) Xtoi (SignatureStr);
+ CopyMem (Hd->Signature, &Signature32, sizeof (UINT32));
+ } else if (StrCmp (TypeStr, L"GUID") == 0) {
+ Hd->SignatureType = SIGNATURE_TYPE_GUID;
+ Hd->MBRType = 0x02;
+
+ StrToGuid (SignatureStr, &SignatureGuid);
+ CopyMem (Hd->Signature, &SignatureGuid, sizeof (EFI_GUID));
+ } else {
+ Hd->SignatureType = 0xff;
+
+ }
+
+ Xtoi64 (StartStr, &Hd->PartitionStart);
+ Xtoi64 (SizeStr, &Hd->PartitionSize);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) Hd;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextCDROM (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *EntryStr;
+ CHAR16 *StartStr;
+ CHAR16 *SizeStr;
+ CDROM_DEVICE_PATH *CDROM;
+
+ EntryStr = GetNextParamStr (&TextDeviceNode);
+ StartStr = GetNextParamStr (&TextDeviceNode);
+ SizeStr = GetNextParamStr (&TextDeviceNode);
+ CDROM = (CDROM_DEVICE_PATH *) CreateDeviceNode (
+ MEDIA_DEVICE_PATH,
+ MEDIA_CDROM_DP,
+ sizeof (CDROM_DEVICE_PATH)
+ );
+
+ CDROM->BootEntry = (UINT32) Xtoi (EntryStr);
+ Xtoi64 (StartStr, &CDROM->PartitionStart);
+ Xtoi64 (SizeStr, &CDROM->PartitionSize);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) CDROM;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextVenMEDIA (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ return ConvertFromTextVendor (
+ TextDeviceNode,
+ MEDIA_DEVICE_PATH,
+ MEDIA_VENDOR_DP
+ );
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextFilePath (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ FILEPATH_DEVICE_PATH *File;
+
+ File = (FILEPATH_DEVICE_PATH *) CreateDeviceNode (
+ MEDIA_DEVICE_PATH,
+ MEDIA_FILEPATH_DP,
+ sizeof (FILEPATH_DEVICE_PATH) + (UINT16) (StrLen (TextDeviceNode) * 2)
+ );
+
+ StrCpy (File->PathName, TextDeviceNode);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) File;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextMedia (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *GuidStr;
+ MEDIA_PROTOCOL_DEVICE_PATH *Media;
+
+ GuidStr = GetNextParamStr (&TextDeviceNode);
+ Media = (MEDIA_PROTOCOL_DEVICE_PATH *) CreateDeviceNode (
+ MEDIA_DEVICE_PATH,
+ MEDIA_PROTOCOL_DP,
+ sizeof (MEDIA_PROTOCOL_DEVICE_PATH)
+ );
+
+ StrToGuid (GuidStr, &Media->Protocol);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) Media;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextBBS (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *TypeStr;
+ CHAR16 *IdStr;
+ CHAR16 *FlagsStr;
+ UINT8 *AsciiStr;
+ BBS_BBS_DEVICE_PATH *Bbs;
+
+ TypeStr = GetNextParamStr (&TextDeviceNode);
+ IdStr = GetNextParamStr (&TextDeviceNode);
+ FlagsStr = GetNextParamStr (&TextDeviceNode);
+ Bbs = (BBS_BBS_DEVICE_PATH *) CreateDeviceNode (
+ BBS_DEVICE_PATH,
+ BBS_BBS_DP,
+ sizeof (BBS_BBS_DEVICE_PATH) + (UINT16) (StrLen (IdStr))
+ );
+
+ if (StrCmp (TypeStr, L"Floppy") == 0) {
+ Bbs->DeviceType = BBS_TYPE_FLOPPY;
+ } else if (StrCmp (TypeStr, L"HD") == 0) {
+ Bbs->DeviceType = BBS_TYPE_HARDDRIVE;
+ } else if (StrCmp (TypeStr, L"CDROM") == 0) {
+ Bbs->DeviceType = BBS_TYPE_CDROM;
+ } else if (StrCmp (TypeStr, L"PCMCIA") == 0) {
+ Bbs->DeviceType = BBS_TYPE_PCMCIA;
+ } else if (StrCmp (TypeStr, L"USB") == 0) {
+ Bbs->DeviceType = BBS_TYPE_USB;
+ } else if (StrCmp (TypeStr, L"Network") == 0) {
+ Bbs->DeviceType = BBS_TYPE_EMBEDDED_NETWORK;
+ } else {
+ Bbs->DeviceType = BBS_TYPE_UNKNOWN;
+ }
+
+ AsciiStr = (UINT8 *) Bbs->String;
+ StrToAscii (IdStr, (CHAR8 **) &AsciiStr);
+
+ Bbs->StatusFlag = (UINT16) Xtoi (FlagsStr);
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) Bbs;
+}
+
+GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE DevPathFromTextTable[] = {
+ {L"Pci", DevPathFromTextPci},
+ {L"PcCard", DevPathFromTextPcCard},
+ {L"MemoryMapped", DevPathFromTextMemoryMapped},
+ {L"VenHw", DevPathFromTextVenHw},
+ {L"Ctrl", DevPathFromTextCtrl},
+ {L"Acpi", DevPathFromTextAcpi},
+ {L"PciRoot", DevPathFromTextPciRoot},
+ {L"Floppy", DevPathFromTextFloppy},
+ {L"Keyboard", DevPathFromTextKeyboard},
+ {L"Serial", DevPathFromTextSerial},
+ {L"ParallelPort", DevPathFromTextParallelPort},
+ {L"AcpiEx", DevPathFromTextAcpiEx},
+ {L"AcpiExp", DevPathFromTextAcpiExp},
+ {L"Ata", DevPathFromTextAta},
+ {L"Scsi", DevPathFromTextScsi},
+ {L"Fibre", DevPathFromTextFibre},
+ {L"I1394", DevPathFromText1394},
+ {L"USB", DevPathFromTextUsb},
+ {L"I2O", DevPathFromTextI2O},
+ {L"Infiniband", DevPathFromTextInfiniband},
+ {L"VenMsg", DevPathFromTextVenMsg},
+ {L"VenPcAnsi", DevPathFromTextVenPcAnsi},
+ {L"VenVt100", DevPathFromTextVenVt100},
+ {L"VenVt100Plus", DevPathFromTextVenVt100Plus},
+ {L"VenUtf8", DevPathFromTextVenUtf8},
+ {L"UartFlowCtrl", DevPathFromTextUartFlowCtrl},
+ {L"SAS", DevPathFromTextSAS},
+ {L"DebugPort", DevPathFromTextDebugPort},
+ {L"MAC", DevPathFromTextMAC},
+ {L"IPv4", DevPathFromTextIPv4},
+ {L"IPv6", DevPathFromTextIPv6},
+ {L"Uart", DevPathFromTextUart},
+ {L"UsbClass", DevPathFromTextUsbClass},
+ {L"UsbAudio", DevPathFromTextUsbAudio},
+ {L"UsbCDCControl", DevPathFromTextUsbCDCControl},
+ {L"UsbHID", DevPathFromTextUsbHID},
+ {L"UsbImage", DevPathFromTextUsbImage},
+ {L"UsbPrinter", DevPathFromTextUsbPrinter},
+ {L"UsbMassStorage", DevPathFromTextUsbMassStorage},
+ {L"UsbHub", DevPathFromTextUsbHub},
+ {L"UsbCDCData", DevPathFromTextUsbCDCData},
+ {L"UsbSmartCard", DevPathFromTextUsbSmartCard},
+ {L"UsbVideo", DevPathFromTextUsbVideo},
+ {L"UsbDiagnostic", DevPathFromTextUsbDiagnostic},
+ {L"UsbWireless", DevPathFromTextUsbWireless},
+ {L"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate},
+ {L"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge},
+ {L"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement},
+ {L"UsbWwid", DevPathFromTextUsbWwid},
+ {L"Unit", DevPathFromTextUnit},
+ {L"iSCSI", DevPathFromTextiSCSI},
+ {L"HD", DevPathFromTextHD},
+ {L"CDROM", DevPathFromTextCDROM},
+ {L"VenMEDIA", DevPathFromTextVenMEDIA},
+ {L"Media", DevPathFromTextMedia},
+ {L"BBS", DevPathFromTextBBS},
+ {NULL, NULL}
+};
+
+EFI_DEVICE_PATH_PROTOCOL *
+ConvertTextToDeviceNode (
+ IN CONST CHAR16 *TextDeviceNode
+ )
+/*++
+
+ Routine Description:
+ Convert text to the binary representation of a device node.
+
+ Arguments:
+ TextDeviceNode - TextDeviceNode points to the text representation of a device
+ node. Conversion starts with the first character and continues
+ until the first non-device node character.
+
+ Returns:
+ A pointer - Pointer to the EFI device node.
+ NULL - If TextDeviceNode is NULL or there was insufficient memory or text unsupported.
+
+--*/
+{
+ EFI_DEVICE_PATH_PROTOCOL * (*DumpNode) (CHAR16 *);
+ CHAR16 *ParamStr;
+ EFI_DEVICE_PATH_PROTOCOL *DeviceNode;
+ CHAR16 *DeviceNodeStr;
+ UINTN Index;
+
+ if ((TextDeviceNode == NULL) || (IS_NULL (*TextDeviceNode))) {
+ return NULL;
+ }
+
+ ParamStr = NULL;
+ DumpNode = NULL;
+ DeviceNodeStr = StrDuplicate (TextDeviceNode);
+
+ for (Index = 0; DevPathFromTextTable[Index].Function; Index++) {
+ ParamStr = GetParamByNodeName (DeviceNodeStr, DevPathFromTextTable[Index].DevicePathNodeText);
+ if (ParamStr != NULL) {
+ DumpNode = DevPathFromTextTable[Index].Function;
+ break;
+ }
+ }
+
+ if (DumpNode == NULL) {
+ //
+ // A file path
+ //
+ DumpNode = DevPathFromTextFilePath;
+ DeviceNode = DumpNode (DeviceNodeStr);
+ } else {
+ DeviceNode = DumpNode (ParamStr);
+ gBS->FreePool (ParamStr);
+ }
+
+ gBS->FreePool (DeviceNodeStr);
+
+ return DeviceNode;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+ConvertTextToDevicePath (
+ IN CONST CHAR16 *TextDevicePath
+ )
+/*++
+
+ Routine Description:
+ Convert text to the binary representation of a device path.
+
+ Arguments:
+ TextDevicePath - TextDevicePath points to the text representation of a device
+ path. Conversion starts with the first character and continues
+ until the first non-device node character.
+
+ Returns:
+ A pointer - Pointer to the allocated device path.
+ NULL - If TextDeviceNode is NULL or there was insufficient memory.
+
+--*/
+{
+ EFI_DEVICE_PATH_PROTOCOL * (*DumpNode) (CHAR16 *);
+ CHAR16 *ParamStr;
+ EFI_DEVICE_PATH_PROTOCOL *DeviceNode;
+ UINTN Index;
+ EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
+ CHAR16 *DevicePathStr;
+ CHAR16 *Str;
+ CHAR16 *DeviceNodeStr;
+ UINT8 IsInstanceEnd;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+
+ if ((TextDevicePath == NULL) || (IS_NULL (*TextDevicePath))) {
+ return NULL;
+ }
+
+ DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);
+ SetDevicePathEndNode (DevicePath);
+
+ ParamStr = NULL;
+ DeviceNodeStr = NULL;
+ DevicePathStr = StrDuplicate (TextDevicePath);
+
+ Str = DevicePathStr;
+ while ((DeviceNodeStr = GetNextDeviceNodeStr (&Str, &IsInstanceEnd)) != NULL) {
+ DumpNode = NULL;
+ for (Index = 0; DevPathFromTextTable[Index].Function; Index++) {
+ ParamStr = GetParamByNodeName (DeviceNodeStr, DevPathFromTextTable[Index].DevicePathNodeText);
+ if (ParamStr != NULL) {
+ DumpNode = DevPathFromTextTable[Index].Function;
+ break;
+ }
+ }
+
+ if (DumpNode == NULL) {
+ //
+ // A file path
+ //
+ DumpNode = DevPathFromTextFilePath;
+ DeviceNode = DumpNode (DeviceNodeStr);
+ } else {
+ DeviceNode = DumpNode (ParamStr);
+ gBS->FreePool (ParamStr);
+ }
+
+ NewDevicePath = AppendDeviceNodeProtocolInterface (DevicePath, DeviceNode);
+ gBS->FreePool (DevicePath);
+ gBS->FreePool (DeviceNode);
+ DevicePath = NewDevicePath;
+
+ if (IsInstanceEnd) {
+ DeviceNode = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);
+ SetDevicePathInstanceEndNode (DeviceNode);
+
+ NewDevicePath = AppendDeviceNodeProtocolInterface (DevicePath, DeviceNode);
+ gBS->FreePool (DevicePath);
+ gBS->FreePool (DeviceNode);
+ DevicePath = NewDevicePath;
+ }
+ }
+
+ gBS->FreePool (DevicePathStr);
+ return DevicePath;
+}
diff --git a/EdkModulePkg/Universal/DevicePath/Dxe/DevicePathUtilities.c b/EdkModulePkg/Universal/DevicePath/Dxe/DevicePathUtilities.c
index a702595225..548a5349a8 100644
--- a/EdkModulePkg/Universal/DevicePath/Dxe/DevicePathUtilities.c
+++ b/EdkModulePkg/Universal/DevicePath/Dxe/DevicePathUtilities.c
@@ -1,211 +1,211 @@
-/*++
-
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-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
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-Module Name:
-
- DevicePathUtilities.c
-
-Abstract:
-
- Implementation file for Device Path Utilities Protocol
-
---*/
-
-#include "DevicePath.h"
-
-UINTN
-GetDevicePathSizeProtocolInterface (
- IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-/*++
-
- Routine Description:
- Returns the size of the device path, in bytes.
-
- Arguments:
- DevicePath - Points to the start of the EFI device path.
-
- Returns:
- Size - Size of the specified device path, in bytes, including the end-of-path tag.
-
---*/
-{
- return GetDevicePathSize (DevicePath);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-DuplicateDevicePathProtocolInterface (
- IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-/*++
-
- Routine Description:
- Create a duplicate of the specified path.
-
- Arguments:
- DevicePath - Points to the source EFI device path.
-
- Returns:
- Pointer - A pointer to the duplicate device path.
- NULL - Insufficient memory.
-
---*/
-{
- return DuplicateDevicePath (DevicePath);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-AppendDevicePathProtocolInterface (
- IN CONST EFI_DEVICE_PATH_PROTOCOL *Src1,
- IN CONST EFI_DEVICE_PATH_PROTOCOL *Src2
- )
-/*++
-
- Routine Description:
- Create a new path by appending the second device path to the first.
-
- Arguments:
- Src1 - Points to the first device path. If NULL, then it is ignored.
- Src2 - Points to the second device path. If NULL, then it is ignored.
-
- Returns:
- Pointer - A pointer to the newly created device path.
- NULL - Memory could not be allocated
- or either DevicePath or DeviceNode is NULL.
-
---*/
-{
- return AppendDevicePath (Src1, Src2);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-AppendDeviceNodeProtocolInterface (
- IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode
- )
-/*++
-
- Routine Description:
- Creates a new path by appending the device node to the device path.
-
- Arguments:
- DevicePath - Points to the device path.
- DeviceNode - Points to the device node.
-
- Returns:
- Pointer - A pointer to the allocated device node.
- NULL - Memory could not be allocated
- or either DevicePath or DeviceNode is NULL.
-
---*/
-{
- return AppendDevicePathNode (DevicePath, DeviceNode);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-AppendDevicePathInstanceProtocolInterface (
- IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance
- )
-/*++
-
- Routine Description:
- Creates a new path by appending the specified device path instance to the specified device path.
-
- Arguments:
- DevicePath - Points to the device path. If NULL, then ignored.
- DevicePathInstance - Points to the device path instance.
-
- Returns:
- Pointer - A pointer to the newly created device path
- NULL - Memory could not be allocated or DevicePathInstance is NULL.
-
---*/
-{
- return AppendDevicePathInstance (DevicePath, DevicePathInstance);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-GetNextDevicePathInstanceProtocolInterface (
- IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathInstance,
- OUT UINTN *DevicePathInstanceSize
- )
-/*++
-
- Routine Description:
- Creates a copy of the current device path instance and returns a pointer to the next device path instance.
-
- Arguments:
- DevicePathInstance - On input, this holds the pointer to the current device path
- instance. On output, this holds the pointer to the next
- device path instance or NULL if there are no more device
- path instances in the device path.
- DevicePathInstanceSize - On output, this holds the size of the device path instance,
- in bytes or zero, if DevicePathInstance is zero.
-
- Returns:
- Pointer - A pointer to the copy of the current device path instance.
- NULL - DevicePathInstace was NULL on entry or there was insufficient memory.
-
---*/
-{
- return GetNextDevicePathInstance (DevicePathInstance, DevicePathInstanceSize);
-}
-
-BOOLEAN
-IsDevicePathMultiInstanceProtocolInterface (
- IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-/*++
-
- Routine Description:
- Returns whether a device path is multi-instance.
-
- Arguments:
- DevicePath - Points to the device path. If NULL, then ignored.
-
- Returns:
- TRUE - The device path has more than one instance
- FALSE - The device path is empty or contains only a single instance.
-
---*/
-{
- return IsDevicePathMultiInstance (DevicePath);
-}
-
-EFI_DEVICE_PATH_PROTOCOL *
-CreateDeviceNodeProtocolInterface (
- IN UINT8 NodeType,
- IN UINT8 NodeSubType,
- IN UINT16 NodeLength
- )
-/*++
-
- Routine Description:
- Creates a device node
-
- Arguments:
- NodeType - NodeType is the device node type (EFI_DEVICE_PATH.Type) for
- the new device node.
- NodeSubType - NodeSubType is the device node sub-type
- EFI_DEVICE_PATH.SubType) for the new device node.
- NodeLength - NodeLength is the length of the device node
- (EFI_DEVICE_PATH.Length) for the new device node.
-
- Returns:
- Pointer - A pointer to the newly created device node.
- NULL - NodeLength is less than
- the size of the header or there was insufficient memory.
-
---*/
-{
- return CreateDeviceNode (NodeType, NodeSubType, NodeLength);
-}
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+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
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DevicePathUtilities.c
+
+Abstract:
+
+ Implementation file for Device Path Utilities Protocol
+
+--*/
+
+#include "DevicePath.h"
+
+UINTN
+GetDevicePathSizeProtocolInterface (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+/*++
+
+ Routine Description:
+ Returns the size of the device path, in bytes.
+
+ Arguments:
+ DevicePath - Points to the start of the EFI device path.
+
+ Returns:
+ Size - Size of the specified device path, in bytes, including the end-of-path tag.
+
+--*/
+{
+ return GetDevicePathSize (DevicePath);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+DuplicateDevicePathProtocolInterface (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+/*++
+
+ Routine Description:
+ Create a duplicate of the specified path.
+
+ Arguments:
+ DevicePath - Points to the source EFI device path.
+
+ Returns:
+ Pointer - A pointer to the duplicate device path.
+ NULL - Insufficient memory.
+
+--*/
+{
+ return DuplicateDevicePath (DevicePath);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+AppendDevicePathProtocolInterface (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *Src1,
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *Src2
+ )
+/*++
+
+ Routine Description:
+ Create a new path by appending the second device path to the first.
+
+ Arguments:
+ Src1 - Points to the first device path. If NULL, then it is ignored.
+ Src2 - Points to the second device path. If NULL, then it is ignored.
+
+ Returns:
+ Pointer - A pointer to the newly created device path.
+ NULL - Memory could not be allocated
+ or either DevicePath or DeviceNode is NULL.
+
+--*/
+{
+ return AppendDevicePath (Src1, Src2);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+AppendDeviceNodeProtocolInterface (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode
+ )
+/*++
+
+ Routine Description:
+ Creates a new path by appending the device node to the device path.
+
+ Arguments:
+ DevicePath - Points to the device path.
+ DeviceNode - Points to the device node.
+
+ Returns:
+ Pointer - A pointer to the allocated device node.
+ NULL - Memory could not be allocated
+ or either DevicePath or DeviceNode is NULL.
+
+--*/
+{
+ return AppendDevicePathNode (DevicePath, DeviceNode);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+AppendDevicePathInstanceProtocolInterface (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance
+ )
+/*++
+
+ Routine Description:
+ Creates a new path by appending the specified device path instance to the specified device path.
+
+ Arguments:
+ DevicePath - Points to the device path. If NULL, then ignored.
+ DevicePathInstance - Points to the device path instance.
+
+ Returns:
+ Pointer - A pointer to the newly created device path
+ NULL - Memory could not be allocated or DevicePathInstance is NULL.
+
+--*/
+{
+ return AppendDevicePathInstance (DevicePath, DevicePathInstance);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+GetNextDevicePathInstanceProtocolInterface (
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathInstance,
+ OUT UINTN *DevicePathInstanceSize
+ )
+/*++
+
+ Routine Description:
+ Creates a copy of the current device path instance and returns a pointer to the next device path instance.
+
+ Arguments:
+ DevicePathInstance - On input, this holds the pointer to the current device path
+ instance. On output, this holds the pointer to the next
+ device path instance or NULL if there are no more device
+ path instances in the device path.
+ DevicePathInstanceSize - On output, this holds the size of the device path instance,
+ in bytes or zero, if DevicePathInstance is zero.
+
+ Returns:
+ Pointer - A pointer to the copy of the current device path instance.
+ NULL - DevicePathInstace was NULL on entry or there was insufficient memory.
+
+--*/
+{
+ return GetNextDevicePathInstance (DevicePathInstance, DevicePathInstanceSize);
+}
+
+BOOLEAN
+IsDevicePathMultiInstanceProtocolInterface (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+/*++
+
+ Routine Description:
+ Returns whether a device path is multi-instance.
+
+ Arguments:
+ DevicePath - Points to the device path. If NULL, then ignored.
+
+ Returns:
+ TRUE - The device path has more than one instance
+ FALSE - The device path is empty or contains only a single instance.
+
+--*/
+{
+ return IsDevicePathMultiInstance (DevicePath);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+CreateDeviceNodeProtocolInterface (
+ IN UINT8 NodeType,
+ IN UINT8 NodeSubType,
+ IN UINT16 NodeLength
+ )
+/*++
+
+ Routine Description:
+ Creates a device node
+
+ Arguments:
+ NodeType - NodeType is the device node type (EFI_DEVICE_PATH.Type) for
+ the new device node.
+ NodeSubType - NodeSubType is the device node sub-type
+ EFI_DEVICE_PATH.SubType) for the new device node.
+ NodeLength - NodeLength is the length of the device node
+ (EFI_DEVICE_PATH.Length) for the new device node.
+
+ Returns:
+ Pointer - A pointer to the newly created device node.
+ NULL - NodeLength is less than
+ the size of the header or there was insufficient memory.
+
+--*/
+{
+ return CreateDeviceNode (NodeType, NodeSubType, NodeLength);
+}
diff --git a/EdkModulePkg/Universal/Disk/DiskIo/Dxe/diskio.c b/EdkModulePkg/Universal/Disk/DiskIo/Dxe/diskio.c
index 35d2a19be2..1cb26fe976 100644
--- a/EdkModulePkg/Universal/Disk/DiskIo/Dxe/diskio.c
+++ b/EdkModulePkg/Universal/Disk/DiskIo/Dxe/diskio.c
@@ -1,781 +1,781 @@
-/*++
-
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-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
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-Module Name:
-
- DiskIo.c
-
-Abstract:
-
- DiskIo driver that layers it's self on every Block IO protocol in the system.
- DiskIo converts a block oriented device to a byte oriented device.
-
- ReadDisk may have to do reads that are not aligned on sector boundaries.
- There are three cases:
-
- UnderRun - The first byte is not on a sector boundary or the read request is
- less than a sector in length.
-
- Aligned - A read of N contiguous sectors.
-
- OverRun - The last byte is not on a sector boundary.
-
---*/
-
-#include "DiskIo.h"
-
-//
-// Prototypes
-// Driver model protocol interface
-//
-EFI_STATUS
-EFIAPI
-DiskIoDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-EFI_STATUS
-EFIAPI
-DiskIoDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-EFI_STATUS
-EFIAPI
-DiskIoDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- );
-
-//
-// Disk I/O Protocol Interface
-//
-EFI_STATUS
-EFIAPI
-DiskIoReadDisk (
- IN EFI_DISK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN UINT64 Offset,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- );
-
-EFI_STATUS
-EFIAPI
-DiskIoWriteDisk (
- IN EFI_DISK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN UINT64 Offset,
- IN UINTN BufferSize,
- IN VOID *Buffer
- );
-
-EFI_DRIVER_BINDING_PROTOCOL gDiskIoDriverBinding = {
- DiskIoDriverBindingSupported,
- DiskIoDriverBindingStart,
- DiskIoDriverBindingStop,
- 0x10,
- NULL,
- NULL
-};
-
-DISK_IO_PRIVATE_DATA gDiskIoPrivateDataTemplate = {
- DISK_IO_PRIVATE_DATA_SIGNATURE,
- {
- EFI_DISK_IO_PROTOCOL_REVISION,
- DiskIoReadDisk,
- DiskIoWriteDisk
- },
- NULL
-};
-
-EFI_STATUS
-EFIAPI
-DiskIoDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
- )
-/*++
-
- Routine Description:
- Test to see if this driver supports ControllerHandle. Any ControllerHandle
- than contains a BlockIo protocol can be supported.
-
- Arguments:
- This - Protocol instance pointer.
- ControllerHandle - Handle of device to test.
- RemainingDevicePath - Not used.
-
- Returns:
- EFI_SUCCESS - This driver supports this device.
- EFI_ALREADY_STARTED - This driver is already running on this device.
- other - This driver does not support this device.
-
---*/
-{
- EFI_STATUS Status;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
-
- //
- // Open the IO Abstraction(s) needed to perform the supported test.
- //
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiBlockIoProtocolGuid,
- (VOID **) &BlockIo,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Close the I/O Abstraction(s) used to perform the supported test.
- //
- gBS->CloseProtocol (
- ControllerHandle,
- &gEfiBlockIoProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-EFIAPI
-DiskIoDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
- )
-/*++
-
- Routine Description:
- Start this driver on ControllerHandle by opening a Block IO protocol and
- installing a Disk IO protocol on ControllerHandle.
-
- Arguments:
- This - Protocol instance pointer.
- ControllerHandle - Handle of device to bind driver to.
- RemainingDevicePath - Not used, always produce all possible children.
-
- Returns:
- EFI_SUCCESS - This driver is added to ControllerHandle.
- EFI_ALREADY_STARTED - This driver is already running on ControllerHandle.
- other - This driver does not support this device.
-
---*/
-{
- EFI_STATUS Status;
- DISK_IO_PRIVATE_DATA *Private;
-
- Private = NULL;
-
- //
- // Connect to the Block IO interface on ControllerHandle.
- //
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiBlockIoProtocolGuid,
- (VOID **) &gDiskIoPrivateDataTemplate.BlockIo,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Initialize the Disk IO device instance.
- //
- Private = AllocateCopyPool (sizeof (DISK_IO_PRIVATE_DATA), &gDiskIoPrivateDataTemplate);
- if (Private == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ErrorExit;
- }
- //
- // Install protocol interfaces for the Disk IO device.
- //
- Status = gBS->InstallProtocolInterface (
- &ControllerHandle,
- &gEfiDiskIoProtocolGuid,
- EFI_NATIVE_INTERFACE,
- &Private->DiskIo
- );
-
-ErrorExit:
- if (EFI_ERROR (Status)) {
-
- if (Private != NULL) {
- gBS->FreePool (Private);
- }
-
- gBS->CloseProtocol (
- ControllerHandle,
- &gEfiBlockIoProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
- }
-
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-DiskIoDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- )
-/*++
-
- Routine Description:
- Stop this driver on ControllerHandle by removing Disk IO protocol and closing
- the Block IO protocol on ControllerHandle.
-
- Arguments:
- This - Protocol instance pointer.
- ControllerHandle - Handle of device to stop driver on.
- NumberOfChildren - Not used.
- ChildHandleBuffer - Not used.
-
- Returns:
- EFI_SUCCESS - This driver is removed ControllerHandle.
- other - This driver was not removed from this device.
- EFI_UNSUPPORTED
-
---*/
-{
- EFI_STATUS Status;
- EFI_DISK_IO_PROTOCOL *DiskIo;
- DISK_IO_PRIVATE_DATA *Private;
-
- //
- // Get our context back.
- //
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiDiskIoProtocolGuid,
- (VOID **) &DiskIo,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return EFI_UNSUPPORTED;
- }
-
- Private = DISK_IO_PRIVATE_DATA_FROM_THIS (DiskIo);
-
- Status = gBS->UninstallProtocolInterface (
- ControllerHandle,
- &gEfiDiskIoProtocolGuid,
- &Private->DiskIo
- );
- if (!EFI_ERROR (Status)) {
-
- Status = gBS->CloseProtocol (
- ControllerHandle,
- &gEfiBlockIoProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
- }
-
- if (!EFI_ERROR (Status)) {
- gBS->FreePool (Private);
- }
-
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-DiskIoReadDisk (
- IN EFI_DISK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN UINT64 Offset,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- )
-/*++
-
- Routine Description:
- Read BufferSize bytes from Offset into Buffer.
-
- Reads may support reads that are not aligned on
- sector boundaries. There are three cases:
-
- UnderRun - The first byte is not on a sector boundary or the read request is
- less than a sector in length.
-
- Aligned - A read of N contiguous sectors.
-
- OverRun - The last byte is not on a sector boundary.
-
-
- Arguments:
- This - Protocol instance pointer.
- MediaId - Id of the media, changes every time the media is replaced.
- Offset - The starting byte offset to read from.
- BufferSize - Size of Buffer.
- Buffer - Buffer containing read data.
-
- Returns:
- EFI_SUCCESS - The data was read correctly from the device.
- EFI_DEVICE_ERROR - The device reported an error while performing the read.
- EFI_NO_MEDIA - There is no media in the device.
- EFI_MEDIA_CHNAGED - The MediaId does not matched the current device.
- EFI_INVALID_PARAMETER - The read request contains device addresses that are not
- valid for the device.
- EFI_OUT_OF_RESOURCES
-
---*/
-{
- EFI_STATUS Status;
- DISK_IO_PRIVATE_DATA *Private;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
- EFI_BLOCK_IO_MEDIA *Media;
- UINT32 BlockSize;
- UINT64 Lba;
- UINT64 OverRunLba;
- UINT32 UnderRun;
- UINT32 OverRun;
- BOOLEAN TransactionComplete;
- UINTN WorkingBufferSize;
- UINT8 *WorkingBuffer;
- UINTN Length;
- UINT8 *Data;
- UINT8 *PreData;
- UINTN IsBufferAligned;
- UINTN DataBufferSize;
- BOOLEAN LastRead;
-
- Private = DISK_IO_PRIVATE_DATA_FROM_THIS (This);
-
- BlockIo = Private->BlockIo;
- Media = BlockIo->Media;
- BlockSize = Media->BlockSize;
-
- if (Media->MediaId != MediaId) {
- return EFI_MEDIA_CHANGED;
- }
-
- WorkingBuffer = Buffer;
- WorkingBufferSize = BufferSize;
-
- //
- // Allocate a temporary buffer for operation
- //
- DataBufferSize = BlockSize * DATA_BUFFER_BLOCK_NUM;
-
- if (Media->IoAlign > 1) {
- PreData = AllocatePool (DataBufferSize + Media->IoAlign);
- Data = PreData - ((UINTN) PreData & (Media->IoAlign - 1)) + Media->IoAlign;
- } else {
- PreData = AllocatePool (DataBufferSize);
- Data = PreData;
- }
-
- if (PreData == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- Lba = DivU64x32Remainder (Offset, BlockSize, &UnderRun);
-
- Length = BlockSize - UnderRun;
- TransactionComplete = FALSE;
-
- Status = EFI_SUCCESS;
- if (UnderRun != 0) {
- //
- // Offset starts in the middle of an Lba, so read the entire block.
- //
- Status = BlockIo->ReadBlocks (
- BlockIo,
- MediaId,
- Lba,
- BlockSize,
- Data
- );
-
- if (EFI_ERROR (Status)) {
- goto Done;
- }
-
- if (Length > BufferSize) {
- Length = BufferSize;
- TransactionComplete = TRUE;
- }
-
- CopyMem (WorkingBuffer, Data + UnderRun, Length);
-
- WorkingBuffer += Length;
-
- WorkingBufferSize -= Length;
- if (WorkingBufferSize == 0) {
- goto Done;
- }
-
- Lba += 1;
- }
-
- OverRunLba = Lba + DivU64x32Remainder (WorkingBufferSize, BlockSize, &OverRun);
-
- if (!TransactionComplete && WorkingBufferSize >= BlockSize) {
- //
- // If the DiskIo maps directly to a BlockIo device do the read.
- //
- if (OverRun != 0) {
- WorkingBufferSize -= OverRun;
- }
- //
- // Check buffer alignment
- //
- IsBufferAligned = (UINTN) WorkingBuffer & (UINTN) (Media->IoAlign - 1);
-
- if (Media->IoAlign <= 1 || IsBufferAligned == 0) {
- //
- // Alignment is satisfied, so read them together
- //
- Status = BlockIo->ReadBlocks (
- BlockIo,
- MediaId,
- Lba,
- WorkingBufferSize,
- WorkingBuffer
- );
-
- if (EFI_ERROR (Status)) {
- goto Done;
- }
-
- WorkingBuffer += WorkingBufferSize;
-
- } else {
- //
- // Use the allocated buffer instead of the original buffer
- // to avoid alignment issue.
- // Here, the allocated buffer (8-byte align) can satisfy the alignment
- //
- LastRead = FALSE;
- do {
- if (WorkingBufferSize <= DataBufferSize) {
- //
- // It is the last calling to readblocks in this loop
- //
- DataBufferSize = WorkingBufferSize;
- LastRead = TRUE;
- }
-
- Status = BlockIo->ReadBlocks (
- BlockIo,
- MediaId,
- Lba,
- DataBufferSize,
- Data
- );
- if (EFI_ERROR (Status)) {
- goto Done;
- }
-
- CopyMem (WorkingBuffer, Data, DataBufferSize);
- WorkingBufferSize -= DataBufferSize;
- WorkingBuffer += DataBufferSize;
- Lba += DATA_BUFFER_BLOCK_NUM;
- } while (!LastRead);
- }
- }
-
- if (!TransactionComplete && OverRun != 0) {
- //
- // Last read is not a complete block.
- //
- Status = BlockIo->ReadBlocks (
- BlockIo,
- MediaId,
- OverRunLba,
- BlockSize,
- Data
- );
-
- if (EFI_ERROR (Status)) {
- goto Done;
- }
-
- CopyMem (WorkingBuffer, Data, OverRun);
- }
-
-Done:
- if (PreData != NULL) {
- gBS->FreePool (PreData);
- }
-
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-DiskIoWriteDisk (
- IN EFI_DISK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN UINT64 Offset,
- IN UINTN BufferSize,
- IN VOID *Buffer
- )
-/*++
-
- Routine Description:
- Read BufferSize bytes from Offset into Buffer.
-
- Writes may require a read modify write to support writes that are not
- aligned on sector boundaries. There are three cases:
-
- UnderRun - The first byte is not on a sector boundary or the write request
- is less than a sector in length. Read modify write is required.
-
- Aligned - A write of N contiguous sectors.
-
- OverRun - The last byte is not on a sector boundary. Read modified write
- required.
-
- Arguments:
- This - Protocol instance pointer.
- MediaId - Id of the media, changes every time the media is replaced.
- Offset - The starting byte offset to read from.
- BufferSize - Size of Buffer.
- Buffer - Buffer containing read data.
-
- Returns:
- EFI_SUCCESS - The data was written correctly to the device.
- EFI_WRITE_PROTECTED - The device can not be written to.
- EFI_DEVICE_ERROR - The device reported an error while performing the write.
- EFI_NO_MEDIA - There is no media in the device.
- EFI_MEDIA_CHNAGED - The MediaId does not matched the current device.
- EFI_INVALID_PARAMETER - The write request contains device addresses that are not
- valid for the device.
- EFI_OUT_OF_RESOURCES
-
---*/
-{
- EFI_STATUS Status;
- DISK_IO_PRIVATE_DATA *Private;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
- EFI_BLOCK_IO_MEDIA *Media;
- UINT32 BlockSize;
- UINT64 Lba;
- UINT64 OverRunLba;
- UINT32 UnderRun;
- UINT32 OverRun;
- BOOLEAN TransactionComplete;
- UINTN WorkingBufferSize;
- UINT8 *WorkingBuffer;
- UINTN Length;
- UINT8 *Data;
- UINT8 *PreData;
- UINTN IsBufferAligned;
- UINTN DataBufferSize;
- BOOLEAN LastWrite;
-
- Private = DISK_IO_PRIVATE_DATA_FROM_THIS (This);
-
- BlockIo = Private->BlockIo;
- Media = BlockIo->Media;
- BlockSize = Media->BlockSize;
-
- if (Media->ReadOnly) {
- return EFI_WRITE_PROTECTED;
- }
-
- if (Media->MediaId != MediaId) {
- return EFI_MEDIA_CHANGED;
- }
-
- DataBufferSize = BlockSize * DATA_BUFFER_BLOCK_NUM;
-
- if (Media->IoAlign > 1) {
- PreData = AllocatePool (DataBufferSize + Media->IoAlign);
- Data = PreData - ((UINTN) PreData & (Media->IoAlign - 1)) + Media->IoAlign;
- } else {
- PreData = AllocatePool (DataBufferSize);
- Data = PreData;
- }
-
- if (PreData == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- WorkingBuffer = Buffer;
- WorkingBufferSize = BufferSize;
-
- Lba = DivU64x32Remainder (Offset, BlockSize, &UnderRun);
-
- Length = BlockSize - UnderRun;
- TransactionComplete = FALSE;
-
- Status = EFI_SUCCESS;
- if (UnderRun != 0) {
- //
- // Offset starts in the middle of an Lba, so do read modify write.
- //
- Status = BlockIo->ReadBlocks (
- BlockIo,
- MediaId,
- Lba,
- BlockSize,
- Data
- );
-
- if (EFI_ERROR (Status)) {
- goto Done;
- }
-
- if (Length > BufferSize) {
- Length = BufferSize;
- TransactionComplete = TRUE;
- }
-
- CopyMem (Data + UnderRun, WorkingBuffer, Length);
-
- Status = BlockIo->WriteBlocks (
- BlockIo,
- MediaId,
- Lba,
- BlockSize,
- Data
- );
- if (EFI_ERROR (Status)) {
- goto Done;
- }
-
- WorkingBuffer += Length;
- WorkingBufferSize -= Length;
- if (WorkingBufferSize == 0) {
- goto Done;
- }
-
- Lba += 1;
- }
-
- OverRunLba = Lba + DivU64x32Remainder (WorkingBufferSize, BlockSize, &OverRun);
-
- if (!TransactionComplete && WorkingBufferSize >= BlockSize) {
- //
- // If the DiskIo maps directly to a BlockIo device do the write.
- //
- if (OverRun != 0) {
- WorkingBufferSize -= OverRun;
- }
- //
- // Check buffer alignment
- //
- IsBufferAligned = (UINTN) WorkingBuffer & (UINTN) (Media->IoAlign - 1);
-
- if (Media->IoAlign <= 1 || IsBufferAligned == 0) {
- //
- // Alignment is satisfied, so write them together
- //
- Status = BlockIo->WriteBlocks (
- BlockIo,
- MediaId,
- Lba,
- WorkingBufferSize,
- WorkingBuffer
- );
-
- if (EFI_ERROR (Status)) {
- goto Done;
- }
-
- WorkingBuffer += WorkingBufferSize;
-
- } else {
- //
- // The buffer parameter is not aligned with the request
- // So use the allocated instead.
- // It can fit almost all the cases.
- //
- LastWrite = FALSE;
- do {
- if (WorkingBufferSize <= DataBufferSize) {
- //
- // It is the last calling to writeblocks in this loop
- //
- DataBufferSize = WorkingBufferSize;
- LastWrite = TRUE;
- }
-
- CopyMem (Data, WorkingBuffer, DataBufferSize);
- Status = BlockIo->WriteBlocks (
- BlockIo,
- MediaId,
- Lba,
- DataBufferSize,
- Data
- );
- if (EFI_ERROR (Status)) {
- goto Done;
- }
-
- WorkingBufferSize -= DataBufferSize;
- WorkingBuffer += DataBufferSize;
- Lba += DATA_BUFFER_BLOCK_NUM;
- } while (!LastWrite);
- }
- }
-
- if (!TransactionComplete && OverRun != 0) {
- //
- // Last bit is not a complete block, so do a read modify write.
- //
- Status = BlockIo->ReadBlocks (
- BlockIo,
- MediaId,
- OverRunLba,
- BlockSize,
- Data
- );
-
- if (EFI_ERROR (Status)) {
- goto Done;
- }
-
- CopyMem (Data, WorkingBuffer, OverRun);
-
- Status = BlockIo->WriteBlocks (
- BlockIo,
- MediaId,
- OverRunLba,
- BlockSize,
- Data
- );
- if (EFI_ERROR (Status)) {
- goto Done;
- }
- }
-
-Done:
- if (PreData != NULL) {
- gBS->FreePool (PreData);
- }
-
- return Status;
-}
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+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
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DiskIo.c
+
+Abstract:
+
+ DiskIo driver that layers it's self on every Block IO protocol in the system.
+ DiskIo converts a block oriented device to a byte oriented device.
+
+ ReadDisk may have to do reads that are not aligned on sector boundaries.
+ There are three cases:
+
+ UnderRun - The first byte is not on a sector boundary or the read request is
+ less than a sector in length.
+
+ Aligned - A read of N contiguous sectors.
+
+ OverRun - The last byte is not on a sector boundary.
+
+--*/
+
+#include "DiskIo.h"
+
+//
+// Prototypes
+// Driver model protocol interface
+//
+EFI_STATUS
+EFIAPI
+DiskIoDriverBindingSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ );
+
+EFI_STATUS
+EFIAPI
+DiskIoDriverBindingStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ );
+
+EFI_STATUS
+EFIAPI
+DiskIoDriverBindingStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
+ );
+
+//
+// Disk I/O Protocol Interface
+//
+EFI_STATUS
+EFIAPI
+DiskIoReadDisk (
+ IN EFI_DISK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN UINT64 Offset,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
+ );
+
+EFI_STATUS
+EFIAPI
+DiskIoWriteDisk (
+ IN EFI_DISK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN UINT64 Offset,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
+ );
+
+EFI_DRIVER_BINDING_PROTOCOL gDiskIoDriverBinding = {
+ DiskIoDriverBindingSupported,
+ DiskIoDriverBindingStart,
+ DiskIoDriverBindingStop,
+ 0x10,
+ NULL,
+ NULL
+};
+
+DISK_IO_PRIVATE_DATA gDiskIoPrivateDataTemplate = {
+ DISK_IO_PRIVATE_DATA_SIGNATURE,
+ {
+ EFI_DISK_IO_PROTOCOL_REVISION,
+ DiskIoReadDisk,
+ DiskIoWriteDisk
+ },
+ NULL
+};
+
+EFI_STATUS
+EFIAPI
+DiskIoDriverBindingSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Test to see if this driver supports ControllerHandle. Any ControllerHandle
+ than contains a BlockIo protocol can be supported.
+
+ Arguments:
+ This - Protocol instance pointer.
+ ControllerHandle - Handle of device to test.
+ RemainingDevicePath - Not used.
+
+ Returns:
+ EFI_SUCCESS - This driver supports this device.
+ EFI_ALREADY_STARTED - This driver is already running on this device.
+ other - This driver does not support this device.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
+
+ //
+ // Open the IO Abstraction(s) needed to perform the supported test.
+ //
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gEfiBlockIoProtocolGuid,
+ (VOID **) &BlockIo,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Close the I/O Abstraction(s) used to perform the supported test.
+ //
+ gBS->CloseProtocol (
+ ControllerHandle,
+ &gEfiBlockIoProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+DiskIoDriverBindingStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Start this driver on ControllerHandle by opening a Block IO protocol and
+ installing a Disk IO protocol on ControllerHandle.
+
+ Arguments:
+ This - Protocol instance pointer.
+ ControllerHandle - Handle of device to bind driver to.
+ RemainingDevicePath - Not used, always produce all possible children.
+
+ Returns:
+ EFI_SUCCESS - This driver is added to ControllerHandle.
+ EFI_ALREADY_STARTED - This driver is already running on ControllerHandle.
+ other - This driver does not support this device.
+
+--*/
+{
+ EFI_STATUS Status;
+ DISK_IO_PRIVATE_DATA *Private;
+
+ Private = NULL;
+
+ //
+ // Connect to the Block IO interface on ControllerHandle.
+ //
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gEfiBlockIoProtocolGuid,
+ (VOID **) &gDiskIoPrivateDataTemplate.BlockIo,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Initialize the Disk IO device instance.
+ //
+ Private = AllocateCopyPool (sizeof (DISK_IO_PRIVATE_DATA), &gDiskIoPrivateDataTemplate);
+ if (Private == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto ErrorExit;
+ }
+ //
+ // Install protocol interfaces for the Disk IO device.
+ //
+ Status = gBS->InstallProtocolInterface (
+ &ControllerHandle,
+ &gEfiDiskIoProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &Private->DiskIo
+ );
+
+ErrorExit:
+ if (EFI_ERROR (Status)) {
+
+ if (Private != NULL) {
+ gBS->FreePool (Private);
+ }
+
+ gBS->CloseProtocol (
+ ControllerHandle,
+ &gEfiBlockIoProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
+ }
+
+ return Status;
+}
+
+EFI_STATUS
+EFIAPI
+DiskIoDriverBindingStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
+ )
+/*++
+
+ Routine Description:
+ Stop this driver on ControllerHandle by removing Disk IO protocol and closing
+ the Block IO protocol on ControllerHandle.
+
+ Arguments:
+ This - Protocol instance pointer.
+ ControllerHandle - Handle of device to stop driver on.
+ NumberOfChildren - Not used.
+ ChildHandleBuffer - Not used.
+
+ Returns:
+ EFI_SUCCESS - This driver is removed ControllerHandle.
+ other - This driver was not removed from this device.
+ EFI_UNSUPPORTED
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_DISK_IO_PROTOCOL *DiskIo;
+ DISK_IO_PRIVATE_DATA *Private;
+
+ //
+ // Get our context back.
+ //
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gEfiDiskIoProtocolGuid,
+ (VOID **) &DiskIo,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ Private = DISK_IO_PRIVATE_DATA_FROM_THIS (DiskIo);
+
+ Status = gBS->UninstallProtocolInterface (
+ ControllerHandle,
+ &gEfiDiskIoProtocolGuid,
+ &Private->DiskIo
+ );
+ if (!EFI_ERROR (Status)) {
+
+ Status = gBS->CloseProtocol (
+ ControllerHandle,
+ &gEfiBlockIoProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
+ }
+
+ if (!EFI_ERROR (Status)) {
+ gBS->FreePool (Private);
+ }
+
+ return Status;
+}
+
+EFI_STATUS
+EFIAPI
+DiskIoReadDisk (
+ IN EFI_DISK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN UINT64 Offset,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
+ )
+/*++
+
+ Routine Description:
+ Read BufferSize bytes from Offset into Buffer.
+
+ Reads may support reads that are not aligned on
+ sector boundaries. There are three cases:
+
+ UnderRun - The first byte is not on a sector boundary or the read request is
+ less than a sector in length.
+
+ Aligned - A read of N contiguous sectors.
+
+ OverRun - The last byte is not on a sector boundary.
+
+
+ Arguments:
+ This - Protocol instance pointer.
+ MediaId - Id of the media, changes every time the media is replaced.
+ Offset - The starting byte offset to read from.
+ BufferSize - Size of Buffer.
+ Buffer - Buffer containing read data.
+
+ Returns:
+ EFI_SUCCESS - The data was read correctly from the device.
+ EFI_DEVICE_ERROR - The device reported an error while performing the read.
+ EFI_NO_MEDIA - There is no media in the device.
+ EFI_MEDIA_CHNAGED - The MediaId does not matched the current device.
+ EFI_INVALID_PARAMETER - The read request contains device addresses that are not
+ valid for the device.
+ EFI_OUT_OF_RESOURCES
+
+--*/
+{
+ EFI_STATUS Status;
+ DISK_IO_PRIVATE_DATA *Private;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ EFI_BLOCK_IO_MEDIA *Media;
+ UINT32 BlockSize;
+ UINT64 Lba;
+ UINT64 OverRunLba;
+ UINT32 UnderRun;
+ UINT32 OverRun;
+ BOOLEAN TransactionComplete;
+ UINTN WorkingBufferSize;
+ UINT8 *WorkingBuffer;
+ UINTN Length;
+ UINT8 *Data;
+ UINT8 *PreData;
+ UINTN IsBufferAligned;
+ UINTN DataBufferSize;
+ BOOLEAN LastRead;
+
+ Private = DISK_IO_PRIVATE_DATA_FROM_THIS (This);
+
+ BlockIo = Private->BlockIo;
+ Media = BlockIo->Media;
+ BlockSize = Media->BlockSize;
+
+ if (Media->MediaId != MediaId) {
+ return EFI_MEDIA_CHANGED;
+ }
+
+ WorkingBuffer = Buffer;
+ WorkingBufferSize = BufferSize;
+
+ //
+ // Allocate a temporary buffer for operation
+ //
+ DataBufferSize = BlockSize * DATA_BUFFER_BLOCK_NUM;
+
+ if (Media->IoAlign > 1) {
+ PreData = AllocatePool (DataBufferSize + Media->IoAlign);
+ Data = PreData - ((UINTN) PreData & (Media->IoAlign - 1)) + Media->IoAlign;
+ } else {
+ PreData = AllocatePool (DataBufferSize);
+ Data = PreData;
+ }
+
+ if (PreData == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Lba = DivU64x32Remainder (Offset, BlockSize, &UnderRun);
+
+ Length = BlockSize - UnderRun;
+ TransactionComplete = FALSE;
+
+ Status = EFI_SUCCESS;
+ if (UnderRun != 0) {
+ //
+ // Offset starts in the middle of an Lba, so read the entire block.
+ //
+ Status = BlockIo->ReadBlocks (
+ BlockIo,
+ MediaId,
+ Lba,
+ BlockSize,
+ Data
+ );
+
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ if (Length > BufferSize) {
+ Length = BufferSize;
+ TransactionComplete = TRUE;
+ }
+
+ CopyMem (WorkingBuffer, Data + UnderRun, Length);
+
+ WorkingBuffer += Length;
+
+ WorkingBufferSize -= Length;
+ if (WorkingBufferSize == 0) {
+ goto Done;
+ }
+
+ Lba += 1;
+ }
+
+ OverRunLba = Lba + DivU64x32Remainder (WorkingBufferSize, BlockSize, &OverRun);
+
+ if (!TransactionComplete && WorkingBufferSize >= BlockSize) {
+ //
+ // If the DiskIo maps directly to a BlockIo device do the read.
+ //
+ if (OverRun != 0) {
+ WorkingBufferSize -= OverRun;
+ }
+ //
+ // Check buffer alignment
+ //
+ IsBufferAligned = (UINTN) WorkingBuffer & (UINTN) (Media->IoAlign - 1);
+
+ if (Media->IoAlign <= 1 || IsBufferAligned == 0) {
+ //
+ // Alignment is satisfied, so read them together
+ //
+ Status = BlockIo->ReadBlocks (
+ BlockIo,
+ MediaId,
+ Lba,
+ WorkingBufferSize,
+ WorkingBuffer
+ );
+
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ WorkingBuffer += WorkingBufferSize;
+
+ } else {
+ //
+ // Use the allocated buffer instead of the original buffer
+ // to avoid alignment issue.
+ // Here, the allocated buffer (8-byte align) can satisfy the alignment
+ //
+ LastRead = FALSE;
+ do {
+ if (WorkingBufferSize <= DataBufferSize) {
+ //
+ // It is the last calling to readblocks in this loop
+ //
+ DataBufferSize = WorkingBufferSize;
+ LastRead = TRUE;
+ }
+
+ Status = BlockIo->ReadBlocks (
+ BlockIo,
+ MediaId,
+ Lba,
+ DataBufferSize,
+ Data
+ );
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ CopyMem (WorkingBuffer, Data, DataBufferSize);
+ WorkingBufferSize -= DataBufferSize;
+ WorkingBuffer += DataBufferSize;
+ Lba += DATA_BUFFER_BLOCK_NUM;
+ } while (!LastRead);
+ }
+ }
+
+ if (!TransactionComplete && OverRun != 0) {
+ //
+ // Last read is not a complete block.
+ //
+ Status = BlockIo->ReadBlocks (
+ BlockIo,
+ MediaId,
+ OverRunLba,
+ BlockSize,
+ Data
+ );
+
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ CopyMem (WorkingBuffer, Data, OverRun);
+ }
+
+Done:
+ if (PreData != NULL) {
+ gBS->FreePool (PreData);
+ }
+
+ return Status;
+}
+
+EFI_STATUS
+EFIAPI
+DiskIoWriteDisk (
+ IN EFI_DISK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN UINT64 Offset,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
+ )
+/*++
+
+ Routine Description:
+ Read BufferSize bytes from Offset into Buffer.
+
+ Writes may require a read modify write to support writes that are not
+ aligned on sector boundaries. There are three cases:
+
+ UnderRun - The first byte is not on a sector boundary or the write request
+ is less than a sector in length. Read modify write is required.
+
+ Aligned - A write of N contiguous sectors.
+
+ OverRun - The last byte is not on a sector boundary. Read modified write
+ required.
+
+ Arguments:
+ This - Protocol instance pointer.
+ MediaId - Id of the media, changes every time the media is replaced.
+ Offset - The starting byte offset to read from.
+ BufferSize - Size of Buffer.
+ Buffer - Buffer containing read data.
+
+ Returns:
+ EFI_SUCCESS - The data was written correctly to the device.
+ EFI_WRITE_PROTECTED - The device can not be written to.
+ EFI_DEVICE_ERROR - The device reported an error while performing the write.
+ EFI_NO_MEDIA - There is no media in the device.
+ EFI_MEDIA_CHNAGED - The MediaId does not matched the current device.
+ EFI_INVALID_PARAMETER - The write request contains device addresses that are not
+ valid for the device.
+ EFI_OUT_OF_RESOURCES
+
+--*/
+{
+ EFI_STATUS Status;
+ DISK_IO_PRIVATE_DATA *Private;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ EFI_BLOCK_IO_MEDIA *Media;
+ UINT32 BlockSize;
+ UINT64 Lba;
+ UINT64 OverRunLba;
+ UINT32 UnderRun;
+ UINT32 OverRun;
+ BOOLEAN TransactionComplete;
+ UINTN WorkingBufferSize;
+ UINT8 *WorkingBuffer;
+ UINTN Length;
+ UINT8 *Data;
+ UINT8 *PreData;
+ UINTN IsBufferAligned;
+ UINTN DataBufferSize;
+ BOOLEAN LastWrite;
+
+ Private = DISK_IO_PRIVATE_DATA_FROM_THIS (This);
+
+ BlockIo = Private->BlockIo;
+ Media = BlockIo->Media;
+ BlockSize = Media->BlockSize;
+
+ if (Media->ReadOnly) {
+ return EFI_WRITE_PROTECTED;
+ }
+
+ if (Media->MediaId != MediaId) {
+ return EFI_MEDIA_CHANGED;
+ }
+
+ DataBufferSize = BlockSize * DATA_BUFFER_BLOCK_NUM;
+
+ if (Media->IoAlign > 1) {
+ PreData = AllocatePool (DataBufferSize + Media->IoAlign);
+ Data = PreData - ((UINTN) PreData & (Media->IoAlign - 1)) + Media->IoAlign;
+ } else {
+ PreData = AllocatePool (DataBufferSize);
+ Data = PreData;
+ }
+
+ if (PreData == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ WorkingBuffer = Buffer;
+ WorkingBufferSize = BufferSize;
+
+ Lba = DivU64x32Remainder (Offset, BlockSize, &UnderRun);
+
+ Length = BlockSize - UnderRun;
+ TransactionComplete = FALSE;
+
+ Status = EFI_SUCCESS;
+ if (UnderRun != 0) {
+ //
+ // Offset starts in the middle of an Lba, so do read modify write.
+ //
+ Status = BlockIo->ReadBlocks (
+ BlockIo,
+ MediaId,
+ Lba,
+ BlockSize,
+ Data
+ );
+
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ if (Length > BufferSize) {
+ Length = BufferSize;
+ TransactionComplete = TRUE;
+ }
+
+ CopyMem (Data + UnderRun, WorkingBuffer, Length);
+
+ Status = BlockIo->WriteBlocks (
+ BlockIo,
+ MediaId,
+ Lba,
+ BlockSize,
+ Data
+ );
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ WorkingBuffer += Length;
+ WorkingBufferSize -= Length;
+ if (WorkingBufferSize == 0) {
+ goto Done;
+ }
+
+ Lba += 1;
+ }
+
+ OverRunLba = Lba + DivU64x32Remainder (WorkingBufferSize, BlockSize, &OverRun);
+
+ if (!TransactionComplete && WorkingBufferSize >= BlockSize) {
+ //
+ // If the DiskIo maps directly to a BlockIo device do the write.
+ //
+ if (OverRun != 0) {
+ WorkingBufferSize -= OverRun;
+ }
+ //
+ // Check buffer alignment
+ //
+ IsBufferAligned = (UINTN) WorkingBuffer & (UINTN) (Media->IoAlign - 1);
+
+ if (Media->IoAlign <= 1 || IsBufferAligned == 0) {
+ //
+ // Alignment is satisfied, so write them together
+ //
+ Status = BlockIo->WriteBlocks (
+ BlockIo,
+ MediaId,
+ Lba,
+ WorkingBufferSize,
+ WorkingBuffer
+ );
+
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ WorkingBuffer += WorkingBufferSize;
+
+ } else {
+ //
+ // The buffer parameter is not aligned with the request
+ // So use the allocated instead.
+ // It can fit almost all the cases.
+ //
+ LastWrite = FALSE;
+ do {
+ if (WorkingBufferSize <= DataBufferSize) {
+ //
+ // It is the last calling to writeblocks in this loop
+ //
+ DataBufferSize = WorkingBufferSize;
+ LastWrite = TRUE;
+ }
+
+ CopyMem (Data, WorkingBuffer, DataBufferSize);
+ Status = BlockIo->WriteBlocks (
+ BlockIo,
+ MediaId,
+ Lba,
+ DataBufferSize,
+ Data
+ );
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ WorkingBufferSize -= DataBufferSize;
+ WorkingBuffer += DataBufferSize;
+ Lba += DATA_BUFFER_BLOCK_NUM;
+ } while (!LastWrite);
+ }
+ }
+
+ if (!TransactionComplete && OverRun != 0) {
+ //
+ // Last bit is not a complete block, so do a read modify write.
+ //
+ Status = BlockIo->ReadBlocks (
+ BlockIo,
+ MediaId,
+ OverRunLba,
+ BlockSize,
+ Data
+ );
+
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ CopyMem (Data, WorkingBuffer, OverRun);
+
+ Status = BlockIo->WriteBlocks (
+ BlockIo,
+ MediaId,
+ OverRunLba,
+ BlockSize,
+ Data
+ );
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+ }
+
+Done:
+ if (PreData != NULL) {
+ gBS->FreePool (PreData);
+ }
+
+ return Status;
+}
diff --git a/EdkModulePkg/Universal/StatusCode/Dxe/Common/DxeStatusCodeCommon.c b/EdkModulePkg/Universal/StatusCode/Dxe/Common/DxeStatusCodeCommon.c
index 5bb54a201e..43fe3fdfda 100644
--- a/EdkModulePkg/Universal/StatusCode/Dxe/Common/DxeStatusCodeCommon.c
+++ b/EdkModulePkg/Universal/StatusCode/Dxe/Common/DxeStatusCodeCommon.c
@@ -27,7 +27,7 @@
This includes information about the class and subclass that is used to classify the entity
as well as an operation. For progress codes, the operation is the current activity.
For error codes, it is the exception. For debug codes, it is not defined at this time.
- Type EFI_STATUS_CODE_VALUE is defined in ¡°Related Definitions¡± below.
+ Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
@param Instance The enumeration of a hardware or software entity within the system.
A system may contain multiple entities that match a class/subclass pairing.
@@ -122,7 +122,7 @@ DxeStatusCodeDriverEntry (
This includes information about the class and subclass that is used to classify the entity
as well as an operation. For progress codes, the operation is the current activity.
For error codes, it is the exception. For debug codes, it is not defined at this time.
- Type EFI_STATUS_CODE_VALUE is defined in ¡°Related Definitions¡± below.
+ Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
@param Instance The enumeration of a hardware or software entity within the system.
A system may contain multiple entities that match a class/subclass pairing.
@@ -206,7 +206,7 @@ ReportDispatcher (
to virtual address.
@param Event Event whose notification function is being invoked.
- @param Context Pointer to the notification function¡¯s context, which is
+ @param Context Pointer to the notification function's context, which is
always zero in current implementation.
**/
diff --git a/EdkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c b/EdkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c
index 1598397209..c5da3220ce 100644
--- a/EdkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c
+++ b/EdkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c
@@ -88,13 +88,13 @@ FreeRecordBuffer (
/**
Report status code into DataHub.
- @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions¡± below.
+ @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
@param Value Describes the current status of a hardware or software entity.
This included information about the class and subclass that is used to classify the entity
as well as an operation. For progress codes, the operation is the current activity.
For error codes, it is the exception. For debug codes, it is not defined at this time.
- Type EFI_STATUS_CODE_VALUE is defined in ¡°Related Definitions¡± below.
+ Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
@param Instance The enumeration of a hardware or software entity within the system.
diff --git a/EdkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.h b/EdkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.h
index 16fa3e8097..e03dc37241 100644
--- a/EdkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.h
+++ b/EdkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.h
@@ -102,13 +102,13 @@ EfiSerialStatusCodeInitializeWorker (
/**
Convert status code value and extended data to readable ASCII string, send string to serial I/O device.
- @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions¡± below.
+ @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
@param Value Describes the current status of a hardware or software entity.
This included information about the class and subclass that is used to classify the entity
as well as an operation. For progress codes, the operation is the current activity.
For error codes, it is the exception. For debug codes, it is not defined at this time.
- Type EFI_STATUS_CODE_VALUE is defined in ¡°Related Definitions¡± below.
+ Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
@param Instance The enumeration of a hardware or software entity within the system.
@@ -155,13 +155,13 @@ RtMemoryStatusCodeInitializeWorker (
@param RtMemoryStatusCodeTable
Point to Runtime memory table header.
- @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions¡± below.
+ @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
@param Value Describes the current status of a hardware or software entity.
This included information about the class and subclass that is used to classify the entity
as well as an operation. For progress codes, the operation is the current activity.
For error codes, it is the exception. For debug codes, it is not defined at this time.
- Type EFI_STATUS_CODE_VALUE is defined in ¡°Related Definitions¡± below.
+ Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
@param Instance The enumeration of a hardware or software entity within the system.
@@ -196,13 +196,13 @@ DataHubStatusCodeInitializeWorker (
/**
Report status code into DataHub.
- @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions¡± below.
+ @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
@param Value Describes the current status of a hardware or software entity.
This included information about the class and subclass that is used to classify the entity
as well as an operation. For progress codes, the operation is the current activity.
For error codes, it is the exception. For debug codes, it is not defined at this time.
- Type EFI_STATUS_CODE_VALUE is defined in ¡°Related Definitions¡± below.
+ Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
@param Instance The enumeration of a hardware or software entity within the system.
diff --git a/EdkModulePkg/Universal/StatusCode/Dxe/Ipf/DxeStatusCodeIpf.c b/EdkModulePkg/Universal/StatusCode/Dxe/Ipf/DxeStatusCodeIpf.c
index 3838069bb5..614ad5094e 100644
--- a/EdkModulePkg/Universal/StatusCode/Dxe/Ipf/DxeStatusCodeIpf.c
+++ b/EdkModulePkg/Universal/StatusCode/Dxe/Ipf/DxeStatusCodeIpf.c
@@ -178,7 +178,7 @@ DxeStatusCodeDriverEntry (
virtual mode.
@param Event Event whose notification function is being invoked.
- @param Context Pointer to the notification function¡¯s context, which is
+ @param Context Pointer to the notification function's context, which is
always zero in current implementation.
**/
diff --git a/EdkModulePkg/Universal/StatusCode/Dxe/RtMemoryStatusCodeWorker.c b/EdkModulePkg/Universal/StatusCode/Dxe/RtMemoryStatusCodeWorker.c
index c0c9edd939..532ea819ec 100644
--- a/EdkModulePkg/Universal/StatusCode/Dxe/RtMemoryStatusCodeWorker.c
+++ b/EdkModulePkg/Universal/StatusCode/Dxe/RtMemoryStatusCodeWorker.c
@@ -58,13 +58,13 @@ RtMemoryStatusCodeInitializeWorker (
@param RtMemoryStatusCodeTable
Point to Runtime memory table header.
- @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions¡± below.
+ @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
@param Value Describes the current status of a hardware or software entity.
This included information about the class and subclass that is used to classify the entity
as well as an operation. For progress codes, the operation is the current activity.
For error codes, it is the exception. For debug codes, it is not defined at this time.
- Type EFI_STATUS_CODE_VALUE is defined in ¡°Related Definitions¡± below.
+ Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
@param Instance The enumeration of a hardware or software entity within the system.
diff --git a/EdkModulePkg/Universal/StatusCode/Dxe/SerialStatusCodeWorker.c b/EdkModulePkg/Universal/StatusCode/Dxe/SerialStatusCodeWorker.c
index 69e3e10757..d4912836bc 100644
--- a/EdkModulePkg/Universal/StatusCode/Dxe/SerialStatusCodeWorker.c
+++ b/EdkModulePkg/Universal/StatusCode/Dxe/SerialStatusCodeWorker.c
@@ -46,13 +46,13 @@ EfiSerialStatusCodeInitializeWorker (
/**
Convert status code value and extended data to readable ASCII string, send string to serial I/O device.
- @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions¡± below.
+ @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
@param Value Describes the current status of a hardware or software entity.
This included information about the class and subclass that is used to classify the entity
as well as an operation. For progress codes, the operation is the current activity.
For error codes, it is the exception. For debug codes, it is not defined at this time.
- Type EFI_STATUS_CODE_VALUE is defined in ¡°Related Definitions¡± below.
+ Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
@param Instance The enumeration of a hardware or software entity within the system.
diff --git a/EdkModulePkg/Universal/StatusCode/Pei/MemoryStausCodeWorker.c b/EdkModulePkg/Universal/StatusCode/Pei/MemoryStausCodeWorker.c
index 5614d80c6a..9b703878fd 100644
--- a/EdkModulePkg/Universal/StatusCode/Pei/MemoryStausCodeWorker.c
+++ b/EdkModulePkg/Universal/StatusCode/Pei/MemoryStausCodeWorker.c
@@ -76,13 +76,13 @@ MemoryStatusCodeInitializeWorker (
/**
Report status code into GUID'ed HOB..
- @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions¡± below.
+ @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
@param Value Describes the current status of a hardware or software entity.
This included information about the class and subclass that is used to classify the entity
as well as an operation. For progress codes, the operation is the current activity.
For error codes, it is the exception. For debug codes, it is not defined at this time.
- Type EFI_STATUS_CODE_VALUE is defined in ¡°Related Definitions¡± below.
+ Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
@param Instance The enumeration of a hardware or software entity within the system.
diff --git a/EdkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.c b/EdkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.c
index 29db86d4d3..0671201233 100644
--- a/EdkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.c
+++ b/EdkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.c
@@ -29,7 +29,7 @@
This includes information about the class and subclass that is used to classify the entity
as well as an operation. For progress codes, the operation is the current activity.
For error codes, it is the exception. For debug codes, it is not defined at this time.
- Type EFI_STATUS_CODE_VALUE is defined in ¡°Related Definitions¡± below.
+ Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
@param Instance The enumeration of a hardware or software entity within the system.
A system may contain multiple entities that match a class/subclass pairing.
@@ -80,7 +80,7 @@ EFI_PEI_PPI_DESCRIPTOR mStatusCodePpiDescriptor = {
This includes information about the class and subclass that is used to classify the entity
as well as an operation. For progress codes, the operation is the current activity.
For error codes, it is the exception. For debug codes, it is not defined at this time.
- Type EFI_STATUS_CODE_VALUE is defined in ¡°Related Definitions¡± below.
+ Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
@param Instance The enumeration of a hardware or software entity within the system.
A system may contain multiple entities that match a class/subclass pairing.
diff --git a/EdkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.h b/EdkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.h
index f27ae88fcf..88ea9ce260 100644
--- a/EdkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.h
+++ b/EdkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.h
@@ -22,13 +22,13 @@
/**
Convert status code value and extended data to readable ASCII string, send string to serial I/O device.
- @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions¡± below.
+ @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
@param Value Describes the current status of a hardware or software entity.
This included information about the class and subclass that is used to classify the entity
as well as an operation. For progress codes, the operation is the current activity.
For error codes, it is the exception. For debug codes, it is not defined at this time.
- Type EFI_STATUS_CODE_VALUE is defined in ¡°Related Definitions¡± below.
+ Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
@param Instance The enumeration of a hardware or software entity within the system.
@@ -73,13 +73,13 @@ MemoryStatusCodeInitializeWorker (
/**
Report status code into GUID'ed HOB.
- @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions¡± below.
+ @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
@param Value Describes the current status of a hardware or software entity.
This included information about the class and subclass that is used to classify the entity
as well as an operation. For progress codes, the operation is the current activity.
For error codes, it is the exception. For debug codes, it is not defined at this time.
- Type EFI_STATUS_CODE_VALUE is defined in ¡°Related Definitions¡± below.
+ Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
@param Instance The enumeration of a hardware or software entity within the system.
diff --git a/EdkModulePkg/Universal/StatusCode/Pei/SerialStatusCodeWorker.c b/EdkModulePkg/Universal/StatusCode/Pei/SerialStatusCodeWorker.c
index b63692a68d..3cd072ca2c 100644
--- a/EdkModulePkg/Universal/StatusCode/Pei/SerialStatusCodeWorker.c
+++ b/EdkModulePkg/Universal/StatusCode/Pei/SerialStatusCodeWorker.c
@@ -18,13 +18,13 @@
/**
Convert status code value and extended data to readable ASCII string, send string to serial I/O device.
- @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions¡± below.
+ @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
@param Value Describes the current status of a hardware or software entity.
This included information about the class and subclass that is used to classify the entity
as well as an operation. For progress codes, the operation is the current activity.
For error codes, it is the exception. For debug codes, it is not defined at this time.
- Type EFI_STATUS_CODE_VALUE is defined in ¡°Related Definitions¡± below.
+ Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
@param Instance The enumeration of a hardware or software entity within the system.
diff --git a/EdkModulePkg/Universal/UserInterface/HiiDataBase/Dxe/Forms.c b/EdkModulePkg/Universal/UserInterface/HiiDataBase/Dxe/Forms.c
index a0a9619197..2c625fe86e 100644
--- a/EdkModulePkg/Universal/UserInterface/HiiDataBase/Dxe/Forms.c
+++ b/EdkModulePkg/Universal/UserInterface/HiiDataBase/Dxe/Forms.c
@@ -144,11 +144,11 @@ Routine Description:
Arguments:
- DataTable ¨C On input, this parameter point to the EFI_HII_DATA_TABLE structure
+ DataTable - On input, this parameter point to the EFI_HII_DATA_TABLE structure
of the final data buffer for the EFI_HII_EXPORT interface. This function
update the NumberOfVariableData attribute.
IfrData - It points to a staring address of a EFI_HII_IFR_PACK structure.
- ExportBufferPtr ¨C On input, it points the starting address of the data buffer to
+ ExportBufferPtr - On input, it points the starting address of the data buffer to
host the variable pack. On output, it is the starting address
of data buffer for the next extraction operation.
Returns: