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