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