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_MANAGE_H_
16 #define _CON_MANAGE_H_
19 #include <Protocol/SimpleTextOut.h>
20 #include <Guid/GlobalVariable.h>
21 #include <Guid/ConsoleInDevice.h>
22 #include <Guid/StandardErrorDevice.h>
23 #include <Guid/ConsoleOutDevice.h>
24 #include <Protocol/DevicePath.h>
25 #include <Protocol/SimpleTextIn.h>
26 #include <Guid/HotPlugDevice.h>
28 #include <Library/DebugLib.h>
29 #include <Library/UefiDriverEntryPoint.h>
30 #include <Library/UefiLib.h>
31 #include <Library/BaseMemoryLib.h>
32 #include <Library/UefiBootServicesTableLib.h>
33 #include <Library/UefiRuntimeServicesTableLib.h>
34 #include <Library/DevicePathLib.h>
35 #include <Library/MemoryAllocationLib.h>
38 // Driver Binding Externs
40 extern EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextInDriverBinding
;
41 extern EFI_COMPONENT_NAME_PROTOCOL gConPlatformComponentName
;
42 extern EFI_COMPONENT_NAME2_PROTOCOL gConPlatformComponentName2
;
43 extern EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextOutDriverBinding
;
44 extern EFI_COMPONENT_NAME_PROTOCOL gConPlatformComponentName
;
45 extern EFI_COMPONENT_NAME2_PROTOCOL gConPlatformComponentName2
;
52 } CONPLATFORM_VAR_OPERATION
;
55 Test to see if specific Protocol could be supported on the ControllerHandle.
57 @param This Protocol instance pointer.
58 @param ControllerHandle Handle of device to test.
59 @param RemainingDevicePath Optional parameter use to pick a specific child
61 @param ProtocolGuid The specfic protocol.
63 @retval EFI_SUCCESS This driver supports this device
64 @retval other This driver does not support this device
68 ConPlatformDriverBindingSupported (
69 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
70 IN EFI_HANDLE ControllerHandle
,
71 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
,
72 IN EFI_GUID
*ProtocolGuid
76 Test to see if EFI Text In Protocol could be supported on the ControllerHandle.
78 @param This Protocol instance pointer.
79 @param ControllerHandle Handle of device to test.
80 @param RemainingDevicePath Optional parameter use to pick a specific child
83 @retval EFI_SUCCESS This driver supports this device
84 @retval other This driver does not support this device
89 ConPlatformTextInDriverBindingSupported (
90 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
92 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
96 Test to see if EFI Text Out Protocol could be supported on the ControllerHandle.
98 @param This Protocol instance pointer.
99 @param ControllerHandle Handle of device to test.
100 @param RemainingDevicePath Optional parameter use to pick a specific child
103 @retval EFI_SUCCESS This driver supports this device
104 @retval other This driver does not support this device
109 ConPlatformTextOutDriverBindingSupported (
110 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
111 IN EFI_HANDLE Handle
,
112 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
116 Start this driver on ControllerHandle by opening Simple Text In protocol,
117 reading Device Path, and installing Console In Devcice GUID on ControllerHandle.
119 If this devcie is not one hot-plug devce, append its device path into the
120 console environment variables ConInDev.
122 @param This Protocol instance pointer.
123 @param ControllerHandle Handle of device to bind driver to
124 @param RemainingDevicePath Optional parameter use to pick a specific child
127 @retval EFI_SUCCESS This driver is added to ControllerHandle
128 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
129 @retval other This driver does not support this device
134 ConPlatformTextInDriverBindingStart (
135 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
136 IN EFI_HANDLE Handle
,
137 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
141 Start this driver on ControllerHandle by opening Simple Text Out protocol,
142 reading Device Path, and installing Console Out Devcice GUID, Standard Error
143 Device GUID on ControllerHandle.
145 If this devcie is not one hot-plug devce, append its device path into the
146 console environment variables ConOutDev, StdErrDev.
148 @param This Protocol instance pointer.
149 @param ControllerHandle Handle of device to bind driver to
150 @param RemainingDevicePath Optional parameter use to pick a specific child
153 @retval EFI_SUCCESS This driver is added to ControllerHandle
154 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
155 @retval other This driver does not support this device
160 ConPlatformTextOutDriverBindingStart (
161 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
162 IN EFI_HANDLE Handle
,
163 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
167 Stop this driver on ControllerHandle by removing Console In Devcice GUID
168 and closing the Simple Text In protocol on ControllerHandle.
170 @param This Protocol instance pointer.
171 @param ControllerHandle Handle of device to stop driver on
172 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
173 children is zero stop the entire bus driver.
174 @param ChildHandleBuffer List of Child Handles to Stop.
176 @retval EFI_SUCCESS This driver is removed ControllerHandle
177 @retval other This driver was not removed from this device
182 ConPlatformTextInDriverBindingStop (
183 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
184 IN EFI_HANDLE Handle
,
185 IN UINTN NumberOfChildren
,
186 IN EFI_HANDLE
*ChildHandleBuffer
190 Stop this driver on ControllerHandle by removing Console Out Devcice GUID
191 and closing the Simple Text Out protocol on ControllerHandle.
193 @param This Protocol instance pointer.
194 @param ControllerHandle Handle of device to stop driver on
195 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
196 children is zero stop the entire bus driver.
197 @param ChildHandleBuffer List of Child Handles to Stop.
199 @retval EFI_SUCCESS This driver is removed ControllerHandle
200 @retval other This driver was not removed from this device
205 ConPlatformTextOutDriverBindingStop (
206 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
207 IN EFI_HANDLE Handle
,
208 IN UINTN NumberOfChildren
,
209 IN EFI_HANDLE
*ChildHandleBuffer
213 Unstall the specific protocol.
215 @param This Protocol instance pointer.
216 @param Handle Handle of device to unstall protocol on.
217 @param ProtocolGuid The specific protocol need to be uninstalled.
223 ConPlatformUnInstallProtocol (
224 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
225 IN EFI_HANDLE Handle
,
226 IN EFI_GUID
*ProtocolGuid
230 Read the EFI variable (Name) and return a dynamically allocated
231 buffer, and the size of the buffer. On failure return NULL.
234 @param Name String part of EFI variable name
236 @return Dynamically allocated memory that contains a copy of the EFI variable.
237 Caller is repsoncible freeing the buffer.
238 NULL - Variable was not read
242 ConPlatformGetVariable (
247 Function compares a device path data structure to that of all the nodes of a
248 second device path instance.
251 @param Multi A pointer to a multi-instance device path data structure.
252 @param Single A pointer to a single-instance device path data structure.
253 @param NewDevicePath If Delete is TRUE, this parameter must not be null, and it
254 points to the remaining device path data structure.
255 (remaining device path = Multi - Single.)
256 @param Delete If TRUE, means removing Single from Multi.
257 If FALSE, the routine just check whether Single matches
258 with any instance in Multi.
260 @return The function returns EFI_SUCCESS if the Single is contained within Multi.
261 Otherwise, EFI_NOT_FOUND is returned.
265 ConPlatformMatchDevicePaths (
266 IN EFI_DEVICE_PATH_PROTOCOL
*Multi
,
267 IN EFI_DEVICE_PATH_PROTOCOL
*Single
,
268 IN EFI_DEVICE_PATH_PROTOCOL
**NewDevicePath OPTIONAL
,
273 Update console devicein console environment variables.
275 @param VariableName Console environment variables, ConOutDev, ConInDev
276 StdErrDev, ConIn or ConOut.
277 @param DevicePath Console devcie's device path.
278 @param Operation Variable operations, such as APPEND or DELETE.
280 @retval EFI_SUCCESS Variable operates successfully.
281 @retval EFI_OUT_OF_RESOURCES If variable cannot be appended.
282 @retval other Variable updating failed.
286 ConPlatformUpdateDeviceVariable (
287 IN CHAR16
*VariableName
,
288 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
289 IN CONPLATFORM_VAR_OPERATION Operation
293 Check if the device is one hot-plug supported.
295 @param DriverBindingHandle Protocol instance pointer.
296 @param ControllerHandle Handle of device to check.
298 @retval TRUE The devcie is a hot-plug device
299 @retval FALSE The devcie is not a hot-plug device.
304 EFI_HANDLE DriverBindingHandle
,
305 EFI_HANDLE ControllerHandle
309 // EFI Component Name Functions
312 Retrieves a Unicode string that is the user readable name of the driver.
314 This function retrieves the user readable name of a driver in the form of a
315 Unicode string. If the driver specified by This has a user readable name in
316 the language specified by Language, then a pointer to the driver name is
317 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
318 by This does not support the language specified by Language,
319 then EFI_UNSUPPORTED is returned.
321 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
322 EFI_COMPONENT_NAME_PROTOCOL instance.
324 @param Language[in] A pointer to a Null-terminated ASCII string
325 array indicating the language. This is the
326 language of the driver name that the caller is
327 requesting, and it must match one of the
328 languages specified in SupportedLanguages. The
329 number of languages supported by a driver is up
330 to the driver writer. Language is specified
331 in RFC 3066 or ISO 639-2 language code format.
333 @param DriverName[out] A pointer to the Unicode string to return.
334 This Unicode string is the name of the
335 driver specified by This in the language
336 specified by Language.
338 @retval EFI_SUCCESS The Unicode string for the Driver specified by
339 This and the language specified by Language was
340 returned in DriverName.
342 @retval EFI_INVALID_PARAMETER Language is NULL.
344 @retval EFI_INVALID_PARAMETER DriverName is NULL.
346 @retval EFI_UNSUPPORTED The driver specified by This does not support
347 the language specified by Language.
352 ConPlatformComponentNameGetDriverName (
353 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
355 OUT CHAR16
**DriverName
360 Retrieves a Unicode string that is the user readable name of the controller
361 that is being managed by a driver.
363 This function retrieves the user readable name of the controller specified by
364 ControllerHandle and ChildHandle in the form of a Unicode string. If the
365 driver specified by This has a user readable name in the language specified by
366 Language, then a pointer to the controller name is returned in ControllerName,
367 and EFI_SUCCESS is returned. If the driver specified by This is not currently
368 managing the controller specified by ControllerHandle and ChildHandle,
369 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
370 support the language specified by Language, then EFI_UNSUPPORTED is returned.
372 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
373 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
380 @param ChildHandle[in] The handle of the child controller to retrieve
381 the name of. This is an optional parameter that
382 may be NULL. It will be NULL for device
383 drivers. It will also be NULL for a bus drivers
384 that wish to retrieve the name of the bus
385 controller. It will not be NULL for a bus
386 driver that wishes to retrieve the name of a
389 @param Language[in] A pointer to a Null-terminated ASCII string
390 array indicating the language. This is the
391 language of the driver name that the caller is
392 requesting, and it must match one of the
393 languages specified in SupportedLanguages. The
394 number of languages supported by a driver is up
395 to the driver writer. Language is specified in
396 RFC 3066 or ISO 639-2 language code format.
398 @param ControllerName[out] A pointer to the Unicode string to return.
399 This Unicode string is the name of the
400 controller specified by ControllerHandle and
401 ChildHandle in the language specified by
402 Language from the point of view of the driver
405 @retval EFI_SUCCESS The Unicode string for the user readable name in
406 the language specified by Language for the
407 driver specified by This was returned in
410 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
412 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
415 @retval EFI_INVALID_PARAMETER Language is NULL.
417 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
419 @retval EFI_UNSUPPORTED The driver specified by This is not currently
420 managing the controller specified by
421 ControllerHandle and ChildHandle.
423 @retval EFI_UNSUPPORTED The driver specified by This does not support
424 the language specified by Language.
429 ConPlatformComponentNameGetControllerName (
430 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
431 IN EFI_HANDLE ControllerHandle
,
432 IN EFI_HANDLE ChildHandle OPTIONAL
,
434 OUT CHAR16
**ControllerName