]>
Commit | Line | Data |
---|---|---|
fb0b259e | 1 | /** @file\r |
2 | Header file for Console Platfrom DXE Driver.\r | |
95276127 | 3 | \r |
d1102dba | 4 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r |
9d510e61 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
95276127 | 6 | \r |
fb0b259e | 7 | **/\r |
95276127 | 8 | \r |
415df2a3 | 9 | #ifndef _CON_PLATFORM_H_\r |
10 | #define _CON_PLATFORM_H_\r | |
95276127 | 11 | \r |
60c93673 | 12 | #include <Uefi.h>\r |
7b9ff698 | 13 | \r |
859b72fa | 14 | #include <Protocol/SimpleTextOut.h>\r |
7b9ff698 | 15 | #include <Protocol/DevicePath.h>\r |
16 | #include <Protocol/SimpleTextIn.h>\r | |
5b7183ef | 17 | #include <Protocol/PciIo.h>\r |
5c9ac43f | 18 | #include <Protocol/UsbIo.h>\r |
5b7183ef | 19 | #include <Protocol/GraphicsOutput.h>\r |
7b9ff698 | 20 | \r |
859b72fa A |
21 | #include <Guid/GlobalVariable.h>\r |
22 | #include <Guid/ConsoleInDevice.h>\r | |
fb0b259e | 23 | #include <Guid/StandardErrorDevice.h>\r |
24 | #include <Guid/ConsoleOutDevice.h>\r | |
fb0b259e | 25 | \r |
859b72fa A |
26 | #include <Library/DebugLib.h>\r |
27 | #include <Library/UefiDriverEntryPoint.h>\r | |
28 | #include <Library/UefiLib.h>\r | |
29 | #include <Library/BaseMemoryLib.h>\r | |
30 | #include <Library/UefiBootServicesTableLib.h>\r | |
31 | #include <Library/UefiRuntimeServicesTableLib.h>\r | |
32 | #include <Library/DevicePathLib.h>\r | |
33 | #include <Library/MemoryAllocationLib.h>\r | |
56dee83a | 34 | #include <Library/UefiBootManagerLib.h>\r |
859b72fa | 35 | \r |
95276127 | 36 | //\r |
859b72fa | 37 | // Driver Binding Externs\r |
95276127 | 38 | //\r |
1436aea4 MK |
39 | extern EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextInDriverBinding;\r |
40 | extern EFI_COMPONENT_NAME_PROTOCOL gConPlatformComponentName;\r | |
41 | extern EFI_COMPONENT_NAME2_PROTOCOL gConPlatformComponentName2;\r | |
42 | extern EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextOutDriverBinding;\r | |
43 | extern EFI_COMPONENT_NAME_PROTOCOL gConPlatformComponentName;\r | |
44 | extern EFI_COMPONENT_NAME2_PROTOCOL gConPlatformComponentName2;\r | |
95276127 | 45 | \r |
46 | typedef enum {\r | |
1ccdbf2a | 47 | Check,\r |
48 | Append,\r | |
49 | Delete\r | |
95276127 | 50 | } CONPLATFORM_VAR_OPERATION;\r |
51 | \r | |
9359e53f | 52 | /**\r |
d1102dba | 53 | Test to see if specific protocol could be supported on the ControllerHandle.\r |
9359e53f | 54 | \r |
55 | @param This Protocol instance pointer.\r | |
56 | @param ControllerHandle Handle of device to test.\r | |
9359e53f | 57 | @param ProtocolGuid The specfic protocol.\r |
58 | \r | |
59 | @retval EFI_SUCCESS This driver supports this device\r | |
60 | @retval other This driver does not support this device\r | |
61 | \r | |
62 | **/\r | |
95276127 | 63 | EFI_STATUS\r |
64 | ConPlatformDriverBindingSupported (\r | |
65 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
66 | IN EFI_HANDLE ControllerHandle,\r | |
95276127 | 67 | IN EFI_GUID *ProtocolGuid\r |
68 | );\r | |
69 | \r | |
9359e53f | 70 | /**\r |
d1102dba | 71 | Test to see if EFI_SIMPLE_TEXT_INPUT_PROTOCOL is supported on ControllerHandle.\r |
9359e53f | 72 | \r |
73 | @param This Protocol instance pointer.\r | |
74 | @param ControllerHandle Handle of device to test.\r | |
75 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
76 | device to start.\r | |
77 | \r | |
c5ed97f6 | 78 | @retval EFI_SUCCESS This driver supports this device.\r |
79 | @retval other This driver does not support this device.\r | |
9359e53f | 80 | \r |
81 | **/\r | |
95276127 | 82 | EFI_STATUS\r |
83 | EFIAPI\r | |
84 | ConPlatformTextInDriverBindingSupported (\r | |
85 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
86 | IN EFI_HANDLE Handle,\r | |
c5ed97f6 | 87 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r |
95276127 | 88 | );\r |
89 | \r | |
9359e53f | 90 | /**\r |
d1102dba | 91 | Test to see if EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL is supported on ControllerHandle.\r |
9359e53f | 92 | \r |
93 | @param This Protocol instance pointer.\r | |
94 | @param ControllerHandle Handle of device to test.\r | |
95 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
96 | device to start.\r | |
97 | \r | |
c5ed97f6 | 98 | @retval EFI_SUCCESS This driver supports this device.\r |
99 | @retval other This driver does not support this device.\r | |
9359e53f | 100 | \r |
101 | **/\r | |
95276127 | 102 | EFI_STATUS\r |
103 | EFIAPI\r | |
104 | ConPlatformTextOutDriverBindingSupported (\r | |
105 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
106 | IN EFI_HANDLE Handle,\r | |
c5ed97f6 | 107 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r |
95276127 | 108 | );\r |
109 | \r | |
9359e53f | 110 | /**\r |
c5ed97f6 | 111 | Start this driver on the device for console input.\r |
112 | \r | |
113 | Start this driver on ControllerHandle by opening Simple Text Input Protocol,\r | |
24248368 | 114 | reading Device Path, and installing Console In Devcice GUID on ControllerHandle.\r |
9359e53f | 115 | \r |
5c9ac43f | 116 | Append its device path into the console environment variables ConInDev.\r |
d1102dba | 117 | \r |
9359e53f | 118 | @param This Protocol instance pointer.\r |
119 | @param ControllerHandle Handle of device to bind driver to\r | |
120 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
121 | device to start.\r | |
122 | \r | |
123 | @retval EFI_SUCCESS This driver is added to ControllerHandle\r | |
124 | @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle\r | |
c5ed97f6 | 125 | @retval other This driver does not support this device.\r |
9359e53f | 126 | \r |
127 | **/\r | |
95276127 | 128 | EFI_STATUS\r |
129 | EFIAPI\r | |
130 | ConPlatformTextInDriverBindingStart (\r | |
1436aea4 MK |
131 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r |
132 | IN EFI_HANDLE Handle,\r | |
133 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
95276127 | 134 | );\r |
135 | \r | |
9359e53f | 136 | /**\r |
0a18956d | 137 | Start this driver on the device for console output and standard error output.\r |
c5ed97f6 | 138 | \r |
139 | Start this driver on ControllerHandle by opening Simple Text Output Protocol,\r | |
140 | reading Device Path, and installing Console Out Devcic GUID, Standard Error\r | |
9359e53f | 141 | Device GUID on ControllerHandle.\r |
142 | \r | |
5c9ac43f | 143 | Append its device path into the console environment variables ConOutDev, ErrOutDev.\r |
d1102dba | 144 | \r |
9359e53f | 145 | @param This Protocol instance pointer.\r |
146 | @param ControllerHandle Handle of device to bind driver to\r | |
147 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
148 | device to start.\r | |
149 | \r | |
150 | @retval EFI_SUCCESS This driver is added to ControllerHandle\r | |
151 | @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle\r | |
152 | @retval other This driver does not support this device\r | |
153 | \r | |
154 | **/\r | |
95276127 | 155 | EFI_STATUS\r |
156 | EFIAPI\r | |
157 | ConPlatformTextOutDriverBindingStart (\r | |
1436aea4 MK |
158 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r |
159 | IN EFI_HANDLE Handle,\r | |
160 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
95276127 | 161 | );\r |
162 | \r | |
9359e53f | 163 | /**\r |
d1102dba | 164 | Stop this driver on ControllerHandle by removing Console In Devcice GUID\r |
c5ed97f6 | 165 | and closing the Simple Text Input protocol on ControllerHandle.\r |
9359e53f | 166 | \r |
167 | @param This Protocol instance pointer.\r | |
168 | @param ControllerHandle Handle of device to stop driver on\r | |
169 | @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r | |
170 | children is zero stop the entire bus driver.\r | |
171 | @param ChildHandleBuffer List of Child Handles to Stop.\r | |
172 | \r | |
173 | @retval EFI_SUCCESS This driver is removed ControllerHandle\r | |
174 | @retval other This driver was not removed from this device\r | |
175 | \r | |
176 | **/\r | |
95276127 | 177 | EFI_STATUS\r |
178 | EFIAPI\r | |
179 | ConPlatformTextInDriverBindingStop (\r | |
180 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
181 | IN EFI_HANDLE Handle,\r | |
182 | IN UINTN NumberOfChildren,\r | |
183 | IN EFI_HANDLE *ChildHandleBuffer\r | |
184 | );\r | |
185 | \r | |
9359e53f | 186 | /**\r |
d1102dba | 187 | Stop this driver on ControllerHandle by removing Console Out Devcice GUID\r |
c5ed97f6 | 188 | and closing the Simple Text Output protocol on ControllerHandle.\r |
9359e53f | 189 | \r |
190 | @param This Protocol instance pointer.\r | |
191 | @param ControllerHandle Handle of device to stop driver on\r | |
192 | @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r | |
193 | children is zero stop the entire bus driver.\r | |
194 | @param ChildHandleBuffer List of Child Handles to Stop.\r | |
195 | \r | |
196 | @retval EFI_SUCCESS This driver is removed ControllerHandle\r | |
197 | @retval other This driver was not removed from this device\r | |
198 | \r | |
199 | **/\r | |
95276127 | 200 | EFI_STATUS\r |
201 | EFIAPI\r | |
202 | ConPlatformTextOutDriverBindingStop (\r | |
203 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
204 | IN EFI_HANDLE Handle,\r | |
205 | IN UINTN NumberOfChildren,\r | |
206 | IN EFI_HANDLE *ChildHandleBuffer\r | |
207 | );\r | |
208 | \r | |
9359e53f | 209 | /**\r |
7b9ff698 | 210 | Uninstall the specified protocol.\r |
9359e53f | 211 | \r |
212 | @param This Protocol instance pointer.\r | |
7b9ff698 | 213 | @param Handle Handle of device to uninstall protocol on.\r |
214 | @param ProtocolGuid The specified protocol need to be uninstalled.\r | |
9359e53f | 215 | \r |
9359e53f | 216 | **/\r |
95276127 | 217 | VOID\r |
218 | ConPlatformUnInstallProtocol (\r | |
219 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
220 | IN EFI_HANDLE Handle,\r | |
221 | IN EFI_GUID *ProtocolGuid\r | |
222 | );\r | |
223 | \r | |
9359e53f | 224 | /**\r |
225 | Read the EFI variable (Name) and return a dynamically allocated\r | |
226 | buffer, and the size of the buffer. On failure return NULL.\r | |
227 | \r | |
9359e53f | 228 | @param Name String part of EFI variable name\r |
229 | \r | |
230 | @return Dynamically allocated memory that contains a copy of the EFI variable.\r | |
d1102dba | 231 | Caller is repsoncible freeing the buffer. Return NULL means Variable\r |
7b9ff698 | 232 | was not read.\r |
9359e53f | 233 | \r |
234 | **/\r | |
95276127 | 235 | VOID *\r |
236 | ConPlatformGetVariable (\r | |
1436aea4 | 237 | IN CHAR16 *Name\r |
95276127 | 238 | );\r |
239 | \r | |
9359e53f | 240 | /**\r |
241 | Function compares a device path data structure to that of all the nodes of a\r | |
242 | second device path instance.\r | |
243 | \r | |
244 | \r | |
245 | @param Multi A pointer to a multi-instance device path data structure.\r | |
246 | @param Single A pointer to a single-instance device path data structure.\r | |
247 | @param NewDevicePath If Delete is TRUE, this parameter must not be null, and it\r | |
248 | points to the remaining device path data structure.\r | |
249 | (remaining device path = Multi - Single.)\r | |
250 | @param Delete If TRUE, means removing Single from Multi.\r | |
251 | If FALSE, the routine just check whether Single matches\r | |
252 | with any instance in Multi.\r | |
253 | \r | |
c5ed97f6 | 254 | @retval EFI_SUCCESS If the Single is contained within Multi.\r |
255 | @retval EFI_NOT_FOUND If the Single is not contained within Multi.\r | |
256 | @retval EFI_INVALID_PARAMETER Multi is NULL.\r | |
257 | @retval EFI_INVALID_PARAMETER Single is NULL.\r | |
258 | @retval EFI_INVALID_PARAMETER NewDevicePath is NULL when Delete is TRUE.\r | |
9359e53f | 259 | \r |
260 | **/\r | |
95276127 | 261 | EFI_STATUS\r |
262 | ConPlatformMatchDevicePaths (\r | |
9359e53f | 263 | IN EFI_DEVICE_PATH_PROTOCOL *Multi,\r |
264 | IN EFI_DEVICE_PATH_PROTOCOL *Single,\r | |
c5ed97f6 | 265 | OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath OPTIONAL,\r |
95276127 | 266 | IN BOOLEAN Delete\r |
267 | );\r | |
268 | \r | |
9359e53f | 269 | /**\r |
7b9ff698 | 270 | Update console environment variables.\r |
9359e53f | 271 | \r |
272 | @param VariableName Console environment variables, ConOutDev, ConInDev\r | |
273 | StdErrDev, ConIn or ConOut.\r | |
274 | @param DevicePath Console devcie's device path.\r | |
c5ed97f6 | 275 | @param Operation Variable operations, including APPEND, CHECK and DELETE.\r |
9359e53f | 276 | \r |
277 | @retval EFI_SUCCESS Variable operates successfully.\r | |
278 | @retval EFI_OUT_OF_RESOURCES If variable cannot be appended.\r | |
279 | @retval other Variable updating failed.\r | |
280 | \r | |
281 | **/\r | |
95276127 | 282 | EFI_STATUS\r |
283 | ConPlatformUpdateDeviceVariable (\r | |
1436aea4 MK |
284 | IN CHAR16 *VariableName,\r |
285 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r | |
286 | IN CONPLATFORM_VAR_OPERATION Operation\r | |
95276127 | 287 | );\r |
288 | \r | |
859b72fa A |
289 | //\r |
290 | // EFI Component Name Functions\r | |
291 | //\r | |
1436aea4 | 292 | \r |
5bca971e | 293 | /**\r |
294 | Retrieves a Unicode string that is the user readable name of the driver.\r | |
295 | \r | |
296 | This function retrieves the user readable name of a driver in the form of a\r | |
297 | Unicode string. If the driver specified by This has a user readable name in\r | |
298 | the language specified by Language, then a pointer to the driver name is\r | |
299 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r | |
300 | by This does not support the language specified by Language,\r | |
301 | then EFI_UNSUPPORTED is returned.\r | |
302 | \r | |
303 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
304 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
5bca971e | 305 | @param Language[in] A pointer to a Null-terminated ASCII string\r |
306 | array indicating the language. This is the\r | |
307 | language of the driver name that the caller is\r | |
308 | requesting, and it must match one of the\r | |
309 | languages specified in SupportedLanguages. The\r | |
310 | number of languages supported by a driver is up\r | |
311 | to the driver writer. Language is specified\r | |
0254efc0 | 312 | in RFC 4646 or ISO 639-2 language code format.\r |
5bca971e | 313 | @param DriverName[out] A pointer to the Unicode string to return.\r |
314 | This Unicode string is the name of the\r | |
315 | driver specified by This in the language\r | |
316 | specified by Language.\r | |
317 | \r | |
318 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r | |
319 | This and the language specified by Language was\r | |
320 | returned in DriverName.\r | |
5bca971e | 321 | @retval EFI_INVALID_PARAMETER Language is NULL.\r |
5bca971e | 322 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r |
5bca971e | 323 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r |
324 | the language specified by Language.\r | |
325 | \r | |
326 | **/\r | |
859b72fa A |
327 | EFI_STATUS\r |
328 | EFIAPI\r | |
329 | ConPlatformComponentNameGetDriverName (\r | |
330 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
331 | IN CHAR8 *Language,\r | |
332 | OUT CHAR16 **DriverName\r | |
333 | );\r | |
334 | \r | |
5bca971e | 335 | /**\r |
336 | Retrieves a Unicode string that is the user readable name of the controller\r | |
337 | that is being managed by a driver.\r | |
338 | \r | |
339 | This function retrieves the user readable name of the controller specified by\r | |
340 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r | |
341 | driver specified by This has a user readable name in the language specified by\r | |
342 | Language, then a pointer to the controller name is returned in ControllerName,\r | |
343 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r | |
344 | managing the controller specified by ControllerHandle and ChildHandle,\r | |
345 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r | |
346 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r | |
347 | \r | |
348 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
349 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
5bca971e | 350 | @param ControllerHandle[in] The handle of a controller that the driver\r |
351 | specified by This is managing. This handle\r | |
352 | specifies the controller whose name is to be\r | |
353 | returned.\r | |
5bca971e | 354 | @param ChildHandle[in] The handle of the child controller to retrieve\r |
355 | the name of. This is an optional parameter that\r | |
356 | may be NULL. It will be NULL for device\r | |
357 | drivers. It will also be NULL for a bus drivers\r | |
358 | that wish to retrieve the name of the bus\r | |
359 | controller. It will not be NULL for a bus\r | |
360 | driver that wishes to retrieve the name of a\r | |
361 | child controller.\r | |
5bca971e | 362 | @param Language[in] A pointer to a Null-terminated ASCII string\r |
363 | array indicating the language. This is the\r | |
364 | language of the driver name that the caller is\r | |
365 | requesting, and it must match one of the\r | |
366 | languages specified in SupportedLanguages. The\r | |
367 | number of languages supported by a driver is up\r | |
368 | to the driver writer. Language is specified in\r | |
0254efc0 | 369 | RFC 4646 or ISO 639-2 language code format.\r |
5bca971e | 370 | @param ControllerName[out] A pointer to the Unicode string to return.\r |
371 | This Unicode string is the name of the\r | |
372 | controller specified by ControllerHandle and\r | |
373 | ChildHandle in the language specified by\r | |
374 | Language from the point of view of the driver\r | |
375 | specified by This.\r | |
376 | \r | |
377 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r | |
378 | the language specified by Language for the\r | |
379 | driver specified by This was returned in\r | |
380 | DriverName.\r | |
284ee2e8 | 381 | @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r |
5bca971e | 382 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r |
383 | EFI_HANDLE.\r | |
5bca971e | 384 | @retval EFI_INVALID_PARAMETER Language is NULL.\r |
5bca971e | 385 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r |
5bca971e | 386 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r |
387 | managing the controller specified by\r | |
388 | ControllerHandle and ChildHandle.\r | |
5bca971e | 389 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r |
390 | the language specified by Language.\r | |
391 | \r | |
392 | **/\r | |
859b72fa A |
393 | EFI_STATUS\r |
394 | EFIAPI\r | |
395 | ConPlatformComponentNameGetControllerName (\r | |
1436aea4 MK |
396 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r |
397 | IN EFI_HANDLE ControllerHandle,\r | |
398 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
399 | IN CHAR8 *Language,\r | |
400 | OUT CHAR16 **ControllerName\r | |
859b72fa A |
401 | );\r |
402 | \r | |
5b7183ef RN |
403 | /**\r |
404 | Update ConOutDev and ErrOutDev variables to add the device path of\r | |
405 | GOP controller itself and the sibling controllers.\r | |
406 | \r | |
407 | @param DevicePath Pointer to device's device path.\r | |
408 | \r | |
409 | @retval TRUE The devcie is a GOP device.\r | |
410 | @retval FALSE The devcie is not a GOP device.\r | |
411 | \r | |
412 | **/\r | |
413 | BOOLEAN\r | |
414 | ConPlatformUpdateGopCandidate (\r | |
1436aea4 | 415 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r |
5b7183ef | 416 | );\r |
5bca971e | 417 | \r |
95276127 | 418 | #endif\r |