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