1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
|
/** @file
Null Platform Hook Library instance.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <Base.h>
#include <Protocol/EmuThunk.h>
#include <Protocol/EmuGraphicsWindow.h>
#include <Protocol/EmuBlockIo.h>
#include <Protocol/SimpleFileSystem.h>
#include <Protocol/EmuThread.h>
#include <Library/BaseLib.h>
#include <Library/DevicePathToTextLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DevicePathLib.h>
/**
Converts a Vendor device path structure to its string representative.
@param Str The string representative of input device.
@param DevPath The input device path structure.
@param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
of the display node is used, where applicable. If DisplayOnly
is FALSE, then the longer text representation of the display node
is used.
@param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
representation for a device node can be used, where applicable.
@return EFI_NOT_FOUND if no string representation exists.
@return EFI_SUCCESS a string representation was created.
**/
EFI_STATUS
EFIAPI
DevPathToTextVendorLib (
IN OUT POOL_PRINT *Str,
IN VOID *DevPath,
IN BOOLEAN DisplayOnly,
IN BOOLEAN AllowShortcuts
)
{
EMU_VENDOR_DEVICE_PATH_NODE *Vendor;
CHAR16 *Type;
Vendor = (EMU_VENDOR_DEVICE_PATH_NODE *)DevPath;
if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuThunkProtocolGuid)) {
CatPrint (Str, L"EmuThunk()");
return EFI_SUCCESS;
}
if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuGraphicsWindowProtocolGuid)) {
CatPrint (Str, L"EmuGraphics(%d)", Vendor->Instance);
return EFI_SUCCESS;
}
if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEfiSimpleFileSystemProtocolGuid)) {
CatPrint (Str, L"EmuFs(%d)", Vendor->Instance);
return EFI_SUCCESS;
}
if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuBlockIoProtocolGuid)) {
CatPrint (Str, L"EmuBlk(%d)", Vendor->Instance);
return EFI_SUCCESS;
}
if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuThreadThunkProtocolGuid)) {
CatPrint (Str, L"EmuThread()");
return EFI_SUCCESS;
}
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;
}
|