diff --git a/InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.c b/InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.c index 999af355aa..ba625aea78 100644 --- a/InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.c +++ b/InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.c @@ -20,8 +20,10 @@ #include #include -#include +#include +#include #include +#include /** @@ -76,3 +78,106 @@ DevPathToTextVendorLib ( return EFI_NOT_FOUND; } +/** + Converts a text device path node to Hardware Vendor device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Hardware Vendor device path structure. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +DevPathFromTextEmuThunk ( + IN CHAR16 *TextDeviceNode + ) +{ + CHAR16 *Str; + VENDOR_DEVICE_PATH *Vendor; + + Str = GetNextParamStr (&TextDeviceNode); + Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode ( + HARDWARE_DEVICE_PATH, + HW_VENDOR_DP, + (UINT16) sizeof (VENDOR_DEVICE_PATH) + ); + CopyGuid (&Vendor->Guid, &gEmuThunkProtocolGuid); + return (EFI_DEVICE_PATH_PROTOCOL *) Vendor; +} + +/** + Converts a text device path node to Hardware Vendor device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Hardware Vendor device path structure. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +DevPathFromTextEmuThread ( + IN CHAR16 *TextDeviceNode + ) +{ + CHAR16 *Str; + VENDOR_DEVICE_PATH *Vendor; + + Str = GetNextParamStr (&TextDeviceNode); + Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode ( + HARDWARE_DEVICE_PATH, + HW_VENDOR_DP, + (UINT16) sizeof (VENDOR_DEVICE_PATH) + ); + CopyGuid (&Vendor->Guid, &gEmuThreadThunkProtocolGuid); + return (EFI_DEVICE_PATH_PROTOCOL *) Vendor; +} + +/** + Converts a text device path node to Hardware Vendor device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Hardware Vendor device path structure. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +DevPathFromTextEmuFs ( + IN CHAR16 *TextDeviceNode + ) +{ + CHAR16 *Str; + EMU_VENDOR_DEVICE_PATH_NODE *Vendor; + + Str = GetNextParamStr (&TextDeviceNode); + Vendor = (EMU_VENDOR_DEVICE_PATH_NODE *) CreateDeviceNode ( + HARDWARE_DEVICE_PATH, + HW_VENDOR_DP, + (UINT16) sizeof (EMU_VENDOR_DEVICE_PATH_NODE) + ); + CopyGuid (&Vendor->VendorDevicePath.Guid, &gEfiSimpleFileSystemProtocolGuid); + Vendor->Instance = (UINT32) StrDecimalToUintn (Str); + + return (EFI_DEVICE_PATH_PROTOCOL *) Vendor; +} + +/** + Register the Filter function + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor executed correctly. + +**/ +EFI_STATUS +EFIAPI +DevicePathToTextLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) + +{ + DevPathToTextSetVendorDevicePathFilter (DevPathToTextVendorLib); + DevicePathFromTextAddFilter (L"EmuThunk", DevPathFromTextEmuThunk); + DevicePathFromTextAddFilter (L"EmuThread", DevPathFromTextEmuThread); + DevicePathFromTextAddFilter (L"EmuFs", DevPathFromTextEmuFs); + return EFI_SUCCESS; +} \ No newline at end of file diff --git a/InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.inf b/InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.inf index 546cbf1d8b..2895b3963b 100644 --- a/InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.inf +++ b/InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.inf @@ -16,9 +16,10 @@ INF_VERSION = 0x00010005 BASE_NAME = DevicePathTextLib FILE_GUID = DCD1F939-1732-CA4D-81B7-C757AEC84DBC - MODULE_TYPE = BASE + MODULE_TYPE = UEFI_DRIVER VERSION_STRING = 1.0 - LIBRARY_CLASS = DevicePathTextLib + LIBRARY_CLASS = NULL|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE + CONSTRUCTOR = DevicePathToTextLibConstructor # # The following information is for reference only and not required by the build tools. @@ -35,7 +36,9 @@ InOsEmuPkg/InOsEmuPkg.dec [LibraryClasses] - BaseMemoryLib + BaseLib + DebugLib + DevicePathLib [Protocols] gEmuThunkProtocolGuid