]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.h
Code scrub.
[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 <PiDxe.h>
19
20 #include <Protocol/SimpleTextOut.h>
21 #include <Protocol/DevicePath.h>
22 #include <Protocol/SimpleTextIn.h>
23
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>
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 RemainingDevicePath Optional parameter use to pick a specific child
62 device to start.
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_DEVICE_PATH_PROTOCOL *RemainingDevicePath,
74 IN EFI_GUID *ProtocolGuid
75 );
76
77 /**
78 Test to see if EFI Text In Protocol could be supported on the 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
95 );
96
97 /**
98 Test to see if EFI Text Out Protocol could be supported on the 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
115 );
116
117 /**
118 Start this driver on ControllerHandle by opening Simple Text In protocol,
119 reading Device Path, and installing Console In Devcice GUID on ControllerHandle.
120
121 If this devcie is not one hot-plug devce, append its device path into the
122 console environment variables ConInDev.
123
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
127 device to start.
128
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
132
133 **/
134 EFI_STATUS
135 EFIAPI
136 ConPlatformTextInDriverBindingStart (
137 IN EFI_DRIVER_BINDING_PROTOCOL *This,
138 IN EFI_HANDLE Handle,
139 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
140 );
141
142 /**
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.
146
147 If this devcie is not one hot-plug devce, append its device path into the
148 console environment variables ConOutDev, StdErrDev.
149
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
153 device to start.
154
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
158
159 **/
160 EFI_STATUS
161 EFIAPI
162 ConPlatformTextOutDriverBindingStart (
163 IN EFI_DRIVER_BINDING_PROTOCOL *This,
164 IN EFI_HANDLE Handle,
165 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
166 );
167
168 /**
169 Stop this driver on ControllerHandle by removing Console In Devcice GUID
170 and closing the Simple Text In protocol on ControllerHandle.
171
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.
177
178 @retval EFI_SUCCESS This driver is removed ControllerHandle
179 @retval other This driver was not removed from this device
180
181 **/
182 EFI_STATUS
183 EFIAPI
184 ConPlatformTextInDriverBindingStop (
185 IN EFI_DRIVER_BINDING_PROTOCOL *This,
186 IN EFI_HANDLE Handle,
187 IN UINTN NumberOfChildren,
188 IN EFI_HANDLE *ChildHandleBuffer
189 );
190
191 /**
192 Stop this driver on ControllerHandle by removing Console Out Devcice GUID
193 and closing the Simple Text Out protocol on ControllerHandle.
194
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.
200
201 @retval EFI_SUCCESS This driver is removed ControllerHandle
202 @retval other This driver was not removed from this device
203
204 **/
205 EFI_STATUS
206 EFIAPI
207 ConPlatformTextOutDriverBindingStop (
208 IN EFI_DRIVER_BINDING_PROTOCOL *This,
209 IN EFI_HANDLE Handle,
210 IN UINTN NumberOfChildren,
211 IN EFI_HANDLE *ChildHandleBuffer
212 );
213
214 /**
215 Uninstall the specified protocol.
216
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.
220
221 @return None.
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
264 **/
265 EFI_STATUS
266 ConPlatformMatchDevicePaths (
267 IN EFI_DEVICE_PATH_PROTOCOL *Multi,
268 IN EFI_DEVICE_PATH_PROTOCOL *Single,
269 IN EFI_DEVICE_PATH_PROTOCOL **NewDevicePath OPTIONAL,
270 IN BOOLEAN Delete
271 );
272
273 /**
274 Update console environment variables.
275
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.
280
281 @retval EFI_SUCCESS Variable operates successfully.
282 @retval EFI_OUT_OF_RESOURCES If variable cannot be appended.
283 @retval other Variable updating failed.
284
285 **/
286 EFI_STATUS
287 ConPlatformUpdateDeviceVariable (
288 IN CHAR16 *VariableName,
289 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
290 IN CONPLATFORM_VAR_OPERATION Operation
291 );
292
293 /**
294 Check if the device is one hot-plug supported.
295
296 @param DriverBindingHandle Protocol instance pointer.
297 @param ControllerHandle Handle of device to check.
298
299 @retval TRUE The devcie is a hot-plug device
300 @retval FALSE The devcie is not a hot-plug device.
301
302 **/
303 BOOLEAN
304 IsHotPlugDevice (
305 EFI_HANDLE DriverBindingHandle,
306 EFI_HANDLE ControllerHandle
307 );
308
309 //
310 // EFI Component Name Functions
311 //
312 /**
313 Retrieves a Unicode string that is the user readable name of the driver.
314
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.
321
322 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
323 EFI_COMPONENT_NAME_PROTOCOL instance.
324
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.
333
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.
338
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.
342
343 @retval EFI_INVALID_PARAMETER Language is NULL.
344
345 @retval EFI_INVALID_PARAMETER DriverName is NULL.
346
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
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
379 returned.
380
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
388 child controller.
389
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.
398
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
404 specified by This.
405
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
409 DriverName.
410
411 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
412
413 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
414 EFI_HANDLE.
415
416 @retval EFI_INVALID_PARAMETER Language is NULL.
417
418 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
419
420 @retval EFI_UNSUPPORTED The driver specified by This is not currently
421 managing the controller specified by
422 ControllerHandle and ChildHandle.
423
424 @retval EFI_UNSUPPORTED The driver specified by This does not support
425 the language specified by Language.
426
427 **/
428 EFI_STATUS
429 EFIAPI
430 ConPlatformComponentNameGetControllerName (
431 IN EFI_COMPONENT_NAME_PROTOCOL *This,
432 IN EFI_HANDLE ControllerHandle,
433 IN EFI_HANDLE ChildHandle OPTIONAL,
434 IN CHAR8 *Language,
435 OUT CHAR16 **ControllerName
436 );
437
438
439 #endif