]>
Commit | Line | Data |
---|---|---|
7e284acb | 1 | /** @file\r |
2 | Null Platform Hook Library instance.\r | |
3 | \r | |
4 | Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r | |
5 | This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #include <Base.h>\r | |
16 | \r | |
17 | #include <Protocol/EmuThunk.h>\r | |
18 | #include <Protocol/EmuGraphicsWindow.h>\r | |
19 | #include <Protocol/EmuBlockIo.h>\r | |
20 | #include <Protocol/SimpleFileSystem.h>\r | |
21 | #include <Protocol/EmuThread.h>\r | |
22 | \r | |
a0aab286 | 23 | #include <Library/BaseLib.h>\r |
24 | #include <Library/DevicePathToTextLib.h>\r | |
7e284acb | 25 | #include <Library/BaseMemoryLib.h>\r |
a0aab286 | 26 | #include <Library/DevicePathLib.h>\r |
7e284acb | 27 | \r |
28 | \r | |
29 | /**\r | |
30 | Converts a Vendor device path structure to its string representative.\r | |
31 | \r | |
32 | @param Str The string representative of input device.\r | |
33 | @param DevPath The input device path structure.\r | |
34 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
35 | of the display node is used, where applicable. If DisplayOnly\r | |
36 | is FALSE, then the longer text representation of the display node\r | |
37 | is used.\r | |
38 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
39 | representation for a device node can be used, where applicable.\r | |
40 | \r | |
41 | @return EFI_NOT_FOUND if no string representation exists.\r | |
42 | @return EFI_SUCCESS a string representation was created.\r | |
43 | **/\r | |
44 | EFI_STATUS\r | |
45 | EFIAPI\r | |
46 | DevPathToTextVendorLib (\r | |
47 | IN OUT POOL_PRINT *Str,\r | |
48 | IN VOID *DevPath,\r | |
49 | IN BOOLEAN DisplayOnly,\r | |
50 | IN BOOLEAN AllowShortcuts\r | |
51 | )\r | |
52 | {\r | |
53 | EMU_VENDOR_DEVICE_PATH_NODE *Vendor;\r | |
54 | CHAR16 *Type;\r | |
55 | \r | |
56 | Vendor = (EMU_VENDOR_DEVICE_PATH_NODE *)DevPath;\r | |
57 | if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuThunkProtocolGuid)) {\r | |
58 | CatPrint (Str, L"EmuThunk()");\r | |
59 | return EFI_SUCCESS;\r | |
60 | }\r | |
61 | if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuGraphicsWindowProtocolGuid)) {\r | |
62 | CatPrint (Str, L"EmuGraphics(%d)", Vendor->Instance);\r | |
63 | return EFI_SUCCESS;\r | |
64 | }\r | |
65 | if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEfiSimpleFileSystemProtocolGuid)) {\r | |
66 | CatPrint (Str, L"EmuFs(%d)", Vendor->Instance);\r | |
67 | return EFI_SUCCESS;\r | |
68 | }\r | |
69 | if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuBlockIoProtocolGuid)) {\r | |
70 | CatPrint (Str, L"EmuBlk(%d)", Vendor->Instance);\r | |
71 | return EFI_SUCCESS;\r | |
72 | }\r | |
73 | if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuThreadThunkProtocolGuid)) {\r | |
74 | CatPrint (Str, L"EmuThread()");\r | |
75 | return EFI_SUCCESS;\r | |
76 | }\r | |
d18d8a1d | 77 | \r |
7e284acb | 78 | return EFI_NOT_FOUND;\r |
79 | }\r | |
80 | \r | |
a0aab286 | 81 | /**\r |
82 | Converts a text device path node to Hardware Vendor device path structure.\r | |
83 | \r | |
84 | @param TextDeviceNode The input Text device path node.\r | |
85 | \r | |
86 | @return A pointer to the newly-created Hardware Vendor device path structure.\r | |
87 | \r | |
88 | **/\r | |
89 | EFI_DEVICE_PATH_PROTOCOL *\r | |
90 | DevPathFromTextEmuThunk (\r | |
91 | IN CHAR16 *TextDeviceNode\r | |
92 | )\r | |
93 | {\r | |
94 | CHAR16 *Str;\r | |
95 | VENDOR_DEVICE_PATH *Vendor;\r | |
96 | \r | |
97 | Str = GetNextParamStr (&TextDeviceNode);\r | |
98 | Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r | |
99 | HARDWARE_DEVICE_PATH,\r | |
100 | HW_VENDOR_DP,\r | |
101 | (UINT16) sizeof (VENDOR_DEVICE_PATH)\r | |
102 | );\r | |
103 | CopyGuid (&Vendor->Guid, &gEmuThunkProtocolGuid);\r | |
104 | return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r | |
105 | }\r | |
106 | \r | |
107 | /**\r | |
108 | Converts a text device path node to Hardware Vendor device path structure.\r | |
109 | \r | |
110 | @param TextDeviceNode The input Text device path node.\r | |
111 | \r | |
112 | @return A pointer to the newly-created Hardware Vendor device path structure.\r | |
113 | \r | |
114 | **/\r | |
115 | EFI_DEVICE_PATH_PROTOCOL *\r | |
116 | DevPathFromTextEmuThread (\r | |
117 | IN CHAR16 *TextDeviceNode\r | |
118 | )\r | |
119 | {\r | |
120 | CHAR16 *Str;\r | |
121 | VENDOR_DEVICE_PATH *Vendor;\r | |
122 | \r | |
123 | Str = GetNextParamStr (&TextDeviceNode);\r | |
124 | Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r | |
125 | HARDWARE_DEVICE_PATH,\r | |
126 | HW_VENDOR_DP,\r | |
127 | (UINT16) sizeof (VENDOR_DEVICE_PATH)\r | |
128 | );\r | |
129 | CopyGuid (&Vendor->Guid, &gEmuThreadThunkProtocolGuid);\r | |
130 | return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r | |
131 | }\r | |
132 | \r | |
133 | /**\r | |
134 | Converts a text device path node to Hardware Vendor device path structure.\r | |
135 | \r | |
136 | @param TextDeviceNode The input Text device path node.\r | |
137 | \r | |
138 | @return A pointer to the newly-created Hardware Vendor device path structure.\r | |
139 | \r | |
140 | **/\r | |
141 | EFI_DEVICE_PATH_PROTOCOL *\r | |
142 | DevPathFromTextEmuFs (\r | |
143 | IN CHAR16 *TextDeviceNode\r | |
144 | )\r | |
145 | {\r | |
146 | CHAR16 *Str;\r | |
147 | EMU_VENDOR_DEVICE_PATH_NODE *Vendor;\r | |
148 | \r | |
149 | Str = GetNextParamStr (&TextDeviceNode);\r | |
150 | Vendor = (EMU_VENDOR_DEVICE_PATH_NODE *) CreateDeviceNode (\r | |
151 | HARDWARE_DEVICE_PATH,\r | |
152 | HW_VENDOR_DP,\r | |
153 | (UINT16) sizeof (EMU_VENDOR_DEVICE_PATH_NODE)\r | |
154 | );\r | |
155 | CopyGuid (&Vendor->VendorDevicePath.Guid, &gEfiSimpleFileSystemProtocolGuid);\r | |
156 | Vendor->Instance = (UINT32) StrDecimalToUintn (Str);\r | |
157 | \r | |
158 | return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r | |
159 | }\r | |
160 | \r | |
161 | /**\r | |
162 | Register the Filter function\r | |
d18d8a1d | 163 | \r |
a0aab286 | 164 | @param ImageHandle The firmware allocated handle for the EFI image.\r |
165 | @param SystemTable A pointer to the EFI System Table.\r | |
d18d8a1d | 166 | \r |
a0aab286 | 167 | @retval EFI_SUCCESS The constructor executed correctly.\r |
168 | \r | |
169 | **/\r | |
170 | EFI_STATUS\r | |
171 | EFIAPI\r | |
172 | DevicePathToTextLibConstructor (\r | |
173 | IN EFI_HANDLE ImageHandle,\r | |
174 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
175 | )\r | |
176 | \r | |
177 | {\r | |
178 | DevPathToTextSetVendorDevicePathFilter (DevPathToTextVendorLib);\r | |
179 | DevicePathFromTextAddFilter (L"EmuThunk", DevPathFromTextEmuThunk);\r | |
180 | DevicePathFromTextAddFilter (L"EmuThread", DevPathFromTextEmuThread);\r | |
181 | DevicePathFromTextAddFilter (L"EmuFs", DevPathFromTextEmuFs);\r | |
182 | return EFI_SUCCESS;\r | |
183 | } |