2 Header file for Console Platfrom DXE Driver.
4 Copyright (c) 2006 - 2008, Intel Corporation. <BR>
5 All rights reserved. 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
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.
15 #ifndef _CON_PLATFORM_H_
16 #define _CON_PLATFORM_H_
20 #include <Protocol/SimpleTextOut.h>
21 #include <Protocol/DevicePath.h>
22 #include <Protocol/SimpleTextIn.h>
24 #include <Guid/GlobalVariable.h>
25 #include <Guid/ConsoleInDevice.h>
26 #include <Guid/StandardErrorDevice.h>
27 #include <Guid/ConsoleOutDevice.h>
28 #include <Guid/HotPlugDevice.h>
30 #include <Library/DebugLib.h>
31 #include <Library/UefiDriverEntryPoint.h>
32 #include <Library/UefiLib.h>
33 #include <Library/BaseMemoryLib.h>
34 #include <Library/UefiBootServicesTableLib.h>
35 #include <Library/UefiRuntimeServicesTableLib.h>
36 #include <Library/DevicePathLib.h>
37 #include <Library/MemoryAllocationLib.h>
40 // Driver Binding Externs
42 extern EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextInDriverBinding
;
43 extern EFI_COMPONENT_NAME_PROTOCOL gConPlatformComponentName
;
44 extern EFI_COMPONENT_NAME2_PROTOCOL gConPlatformComponentName2
;
45 extern EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextOutDriverBinding
;
46 extern EFI_COMPONENT_NAME_PROTOCOL gConPlatformComponentName
;
47 extern EFI_COMPONENT_NAME2_PROTOCOL gConPlatformComponentName2
;
54 } CONPLATFORM_VAR_OPERATION
;
57 Test to see if specific Protocol could be supported on the ControllerHandle.
59 @param This Protocol instance pointer.
60 @param ControllerHandle Handle of device to test.
61 @param RemainingDevicePath Optional parameter use to pick a specific child
63 @param ProtocolGuid The specfic protocol.
65 @retval EFI_SUCCESS This driver supports this device
66 @retval other This driver does not support this device
70 ConPlatformDriverBindingSupported (
71 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
72 IN EFI_HANDLE ControllerHandle
,
73 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
,
74 IN EFI_GUID
*ProtocolGuid
78 Test to see if EFI Text In Protocol could be supported on the ControllerHandle.
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
85 @retval EFI_SUCCESS This driver supports this device
86 @retval other This driver does not support this device
91 ConPlatformTextInDriverBindingSupported (
92 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
94 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
98 Test to see if EFI Text Out Protocol could be supported on the ControllerHandle.
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
105 @retval EFI_SUCCESS This driver supports this device
106 @retval other This driver does not support this device
111 ConPlatformTextOutDriverBindingSupported (
112 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
113 IN EFI_HANDLE Handle
,
114 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
118 Start this driver on ControllerHandle by opening Simple Text In protocol,
119 reading Device Path, and installing Console In Devcice GUID on ControllerHandle.
121 If this devcie is not one hot-plug devce, append its device path into the
122 console environment variables ConInDev.
124 @param This Protocol instance pointer.
125 @param ControllerHandle Handle of device to bind driver to
126 @param RemainingDevicePath Optional parameter use to pick a specific child
129 @retval EFI_SUCCESS This driver is added to ControllerHandle
130 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
131 @retval other This driver does not support this device
136 ConPlatformTextInDriverBindingStart (
137 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
138 IN EFI_HANDLE Handle
,
139 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
143 Start this driver on ControllerHandle by opening Simple Text Out protocol,
144 reading Device Path, and installing Console Out Devcice GUID, Standard Error
145 Device GUID on ControllerHandle.
147 If this devcie is not one hot-plug devce, append its device path into the
148 console environment variables ConOutDev, StdErrDev.
150 @param This Protocol instance pointer.
151 @param ControllerHandle Handle of device to bind driver to
152 @param RemainingDevicePath Optional parameter use to pick a specific child
155 @retval EFI_SUCCESS This driver is added to ControllerHandle
156 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
157 @retval other This driver does not support this device
162 ConPlatformTextOutDriverBindingStart (
163 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
164 IN EFI_HANDLE Handle
,
165 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
169 Stop this driver on ControllerHandle by removing Console In Devcice GUID
170 and closing the Simple Text In protocol on ControllerHandle.
172 @param This Protocol instance pointer.
173 @param ControllerHandle Handle of device to stop driver on
174 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
175 children is zero stop the entire bus driver.
176 @param ChildHandleBuffer List of Child Handles to Stop.
178 @retval EFI_SUCCESS This driver is removed ControllerHandle
179 @retval other This driver was not removed from this device
184 ConPlatformTextInDriverBindingStop (
185 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
186 IN EFI_HANDLE Handle
,
187 IN UINTN NumberOfChildren
,
188 IN EFI_HANDLE
*ChildHandleBuffer
192 Stop this driver on ControllerHandle by removing Console Out Devcice GUID
193 and closing the Simple Text Out protocol on ControllerHandle.
195 @param This Protocol instance pointer.
196 @param ControllerHandle Handle of device to stop driver on
197 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
198 children is zero stop the entire bus driver.
199 @param ChildHandleBuffer List of Child Handles to Stop.
201 @retval EFI_SUCCESS This driver is removed ControllerHandle
202 @retval other This driver was not removed from this device
207 ConPlatformTextOutDriverBindingStop (
208 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
209 IN EFI_HANDLE Handle
,
210 IN UINTN NumberOfChildren
,
211 IN EFI_HANDLE
*ChildHandleBuffer
215 Uninstall the specified protocol.
217 @param This Protocol instance pointer.
218 @param Handle Handle of device to uninstall protocol on.
219 @param ProtocolGuid The specified protocol need to be uninstalled.
225 ConPlatformUnInstallProtocol (
226 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
227 IN EFI_HANDLE Handle
,
228 IN EFI_GUID
*ProtocolGuid
232 Read the EFI variable (Name) and return a dynamically allocated
233 buffer, and the size of the buffer. On failure return NULL.
235 @param Name String part of EFI variable name
237 @return Dynamically allocated memory that contains a copy of the EFI variable.
238 Caller is repsoncible freeing the buffer. Return NULL means Variable
243 ConPlatformGetVariable (
248 Function compares a device path data structure to that of all the nodes of a
249 second device path instance.
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.
261 @retval EFI_SUCCESS If the Single is contained within Multi.
262 @retval EFI_NOT_FOUND If the Single is not contained within Multi.
266 ConPlatformMatchDevicePaths (
267 IN EFI_DEVICE_PATH_PROTOCOL
*Multi
,
268 IN EFI_DEVICE_PATH_PROTOCOL
*Single
,
269 IN EFI_DEVICE_PATH_PROTOCOL
**NewDevicePath OPTIONAL
,
274 Update console environment variables.
276 @param VariableName Console environment variables, ConOutDev, ConInDev
277 StdErrDev, ConIn or ConOut.
278 @param DevicePath Console devcie's device path.
279 @param Operation Variable operations, such as APPEND or DELETE.
281 @retval EFI_SUCCESS Variable operates successfully.
282 @retval EFI_OUT_OF_RESOURCES If variable cannot be appended.
283 @retval other Variable updating failed.
287 ConPlatformUpdateDeviceVariable (
288 IN CHAR16
*VariableName
,
289 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
290 IN CONPLATFORM_VAR_OPERATION Operation
294 Check if the device is one hot-plug supported.
296 @param DriverBindingHandle Protocol instance pointer.
297 @param ControllerHandle Handle of device to check.
299 @retval TRUE The devcie is a hot-plug device
300 @retval FALSE The devcie is not a hot-plug device.
305 EFI_HANDLE DriverBindingHandle
,
306 EFI_HANDLE ControllerHandle
310 // EFI Component Name Functions
313 Retrieves a Unicode string that is the user readable name of the driver.
315 This function retrieves the user readable name of a driver in the form of a
316 Unicode string. If the driver specified by This has a user readable name in
317 the language specified by Language, then a pointer to the driver name is
318 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
319 by This does not support the language specified by Language,
320 then EFI_UNSUPPORTED is returned.
322 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
323 EFI_COMPONENT_NAME_PROTOCOL instance.
325 @param Language[in] A pointer to a Null-terminated ASCII string
326 array indicating the language. This is the
327 language of the driver name that the caller is
328 requesting, and it must match one of the
329 languages specified in SupportedLanguages. The
330 number of languages supported by a driver is up
331 to the driver writer. Language is specified
332 in RFC 3066 or ISO 639-2 language code format.
334 @param DriverName[out] A pointer to the Unicode string to return.
335 This Unicode string is the name of the
336 driver specified by This in the language
337 specified by Language.
339 @retval EFI_SUCCESS The Unicode string for the Driver specified by
340 This and the language specified by Language was
341 returned in DriverName.
343 @retval EFI_INVALID_PARAMETER Language is NULL.
345 @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.
353 ConPlatformComponentNameGetDriverName (
354 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
356 OUT CHAR16
**DriverName
361 Retrieves a Unicode string that is the user readable name of the controller
362 that is being managed by a driver.
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.
373 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
374 EFI_COMPONENT_NAME_PROTOCOL instance.
376 @param ControllerHandle[in] The handle of a controller that the driver
377 specified by This is managing. This handle
378 specifies the controller whose name is to be
381 @param ChildHandle[in] The handle of the child controller to retrieve
382 the name of. This is an optional parameter that
383 may be NULL. It will be NULL for device
384 drivers. It will also be NULL for a bus drivers
385 that wish to retrieve the name of the bus
386 controller. It will not be NULL for a bus
387 driver that wishes to retrieve the name of a
390 @param Language[in] A pointer to a Null-terminated ASCII string
391 array indicating the language. This is the
392 language of the driver name that the caller is
393 requesting, and it must match one of the
394 languages specified in SupportedLanguages. The
395 number of languages supported by a driver is up
396 to the driver writer. Language is specified in
397 RFC 3066 or ISO 639-2 language code format.
399 @param ControllerName[out] A pointer to the Unicode string to return.
400 This Unicode string is the name of the
401 controller specified by ControllerHandle and
402 ChildHandle in the language specified by
403 Language from the point of view of the driver
406 @retval EFI_SUCCESS The Unicode string for the user readable name in
407 the language specified by Language for the
408 driver specified by This was returned in
411 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
413 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
416 @retval EFI_INVALID_PARAMETER Language is NULL.
418 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
420 @retval EFI_UNSUPPORTED The driver specified by This is not currently
421 managing the controller specified by
422 ControllerHandle and ChildHandle.
424 @retval EFI_UNSUPPORTED The driver specified by This does not support
425 the language specified by Language.
430 ConPlatformComponentNameGetControllerName (
431 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
432 IN EFI_HANDLE ControllerHandle
,
433 IN EFI_HANDLE ChildHandle OPTIONAL
,
435 OUT CHAR16
**ControllerName