]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.h
add functions header for ConPlatformDxe and ConSplitterdxe modules.
[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 #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>
27
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>
36
37 //
38 // Driver Binding Externs
39 //
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;
46
47
48 typedef enum {
49 CHECK,
50 APPEND,
51 DELETE
52 } CONPLATFORM_VAR_OPERATION;
53
54 /**
55 Test to see if specific Protocol could be supported on the ControllerHandle.
56
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
60 device to start.
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_DEVICE_PATH_PROTOCOL *RemainingDevicePath,
72 IN EFI_GUID *ProtocolGuid
73 );
74
75 /**
76 Test to see if EFI Text In Protocol could be supported on the ControllerHandle.
77
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
81 device to start.
82
83 @retval EFI_SUCCESS This driver supports this device
84 @retval other This driver does not support this device
85
86 **/
87 EFI_STATUS
88 EFIAPI
89 ConPlatformTextInDriverBindingSupported (
90 IN EFI_DRIVER_BINDING_PROTOCOL *This,
91 IN EFI_HANDLE Handle,
92 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
93 );
94
95 /**
96 Test to see if EFI Text Out Protocol could be supported on the ControllerHandle.
97
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
101 device to start.
102
103 @retval EFI_SUCCESS This driver supports this device
104 @retval other This driver does not support this device
105
106 **/
107 EFI_STATUS
108 EFIAPI
109 ConPlatformTextOutDriverBindingSupported (
110 IN EFI_DRIVER_BINDING_PROTOCOL *This,
111 IN EFI_HANDLE Handle,
112 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
113 );
114
115 /**
116 Start this driver on ControllerHandle by opening Simple Text In protocol,
117 reading Device Path, and installing Console In Devcice GUID on ControllerHandle.
118
119 If this devcie is not one hot-plug devce, append its device path into the
120 console environment variables ConInDev.
121
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
125 device to start.
126
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
130
131 **/
132 EFI_STATUS
133 EFIAPI
134 ConPlatformTextInDriverBindingStart (
135 IN EFI_DRIVER_BINDING_PROTOCOL *This,
136 IN EFI_HANDLE Handle,
137 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
138 );
139
140 /**
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.
144
145 If this devcie is not one hot-plug devce, append its device path into the
146 console environment variables ConOutDev, StdErrDev.
147
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
151 device to start.
152
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
156
157 **/
158 EFI_STATUS
159 EFIAPI
160 ConPlatformTextOutDriverBindingStart (
161 IN EFI_DRIVER_BINDING_PROTOCOL *This,
162 IN EFI_HANDLE Handle,
163 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
164 );
165
166 /**
167 Stop this driver on ControllerHandle by removing Console In Devcice GUID
168 and closing the Simple Text In protocol on ControllerHandle.
169
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.
175
176 @retval EFI_SUCCESS This driver is removed ControllerHandle
177 @retval other This driver was not removed from this device
178
179 **/
180 EFI_STATUS
181 EFIAPI
182 ConPlatformTextInDriverBindingStop (
183 IN EFI_DRIVER_BINDING_PROTOCOL *This,
184 IN EFI_HANDLE Handle,
185 IN UINTN NumberOfChildren,
186 IN EFI_HANDLE *ChildHandleBuffer
187 );
188
189 /**
190 Stop this driver on ControllerHandle by removing Console Out Devcice GUID
191 and closing the Simple Text Out protocol on ControllerHandle.
192
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.
198
199 @retval EFI_SUCCESS This driver is removed ControllerHandle
200 @retval other This driver was not removed from this device
201
202 **/
203 EFI_STATUS
204 EFIAPI
205 ConPlatformTextOutDriverBindingStop (
206 IN EFI_DRIVER_BINDING_PROTOCOL *This,
207 IN EFI_HANDLE Handle,
208 IN UINTN NumberOfChildren,
209 IN EFI_HANDLE *ChildHandleBuffer
210 );
211
212 /**
213 Unstall the specific protocol.
214
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.
218
219 @return None.
220
221 **/
222 VOID
223 ConPlatformUnInstallProtocol (
224 IN EFI_DRIVER_BINDING_PROTOCOL *This,
225 IN EFI_HANDLE Handle,
226 IN EFI_GUID *ProtocolGuid
227 );
228
229 /**
230 Read the EFI variable (Name) and return a dynamically allocated
231 buffer, and the size of the buffer. On failure return NULL.
232
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.
238 NULL - Variable 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 @return The function returns EFI_SUCCESS if the Single is contained within Multi.
261 Otherwise, EFI_NOT_FOUND is returned.
262
263 **/
264 EFI_STATUS
265 ConPlatformMatchDevicePaths (
266 IN EFI_DEVICE_PATH_PROTOCOL *Multi,
267 IN EFI_DEVICE_PATH_PROTOCOL *Single,
268 IN EFI_DEVICE_PATH_PROTOCOL **NewDevicePath OPTIONAL,
269 IN BOOLEAN Delete
270 );
271
272 /**
273 Update console devicein console environment variables.
274
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.
279
280 @retval EFI_SUCCESS Variable operates successfully.
281 @retval EFI_OUT_OF_RESOURCES If variable cannot be appended.
282 @retval other Variable updating failed.
283
284 **/
285 EFI_STATUS
286 ConPlatformUpdateDeviceVariable (
287 IN CHAR16 *VariableName,
288 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
289 IN CONPLATFORM_VAR_OPERATION Operation
290 );
291
292 /**
293 Check if the device is one hot-plug supported.
294
295 @param DriverBindingHandle Protocol instance pointer.
296 @param ControllerHandle Handle of device to check.
297
298 @retval TRUE The devcie is a hot-plug device
299 @retval FALSE The devcie is not a hot-plug device.
300
301 **/
302 BOOLEAN
303 IsHotPlugDevice (
304 EFI_HANDLE DriverBindingHandle,
305 EFI_HANDLE ControllerHandle
306 );
307
308 //
309 // EFI Component Name Functions
310 //
311 /**
312 Retrieves a Unicode string that is the user readable name of the driver.
313
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.
320
321 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
322 EFI_COMPONENT_NAME_PROTOCOL instance.
323
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.
332
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.
337
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.
341
342 @retval EFI_INVALID_PARAMETER Language is NULL.
343
344 @retval EFI_INVALID_PARAMETER DriverName is NULL.
345
346 @retval EFI_UNSUPPORTED The driver specified by This does not support
347 the language specified by Language.
348
349 **/
350 EFI_STATUS
351 EFIAPI
352 ConPlatformComponentNameGetDriverName (
353 IN EFI_COMPONENT_NAME_PROTOCOL *This,
354 IN CHAR8 *Language,
355 OUT CHAR16 **DriverName
356 );
357
358
359 /**
360 Retrieves a Unicode string that is the user readable name of the controller
361 that is being managed by a driver.
362
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.
371
372 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
373 EFI_COMPONENT_NAME_PROTOCOL instance.
374
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
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
387 child controller.
388
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.
397
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
403 specified by This.
404
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
408 DriverName.
409
410 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
411
412 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
413 EFI_HANDLE.
414
415 @retval EFI_INVALID_PARAMETER Language is NULL.
416
417 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
418
419 @retval EFI_UNSUPPORTED The driver specified by This is not currently
420 managing the controller specified by
421 ControllerHandle and ChildHandle.
422
423 @retval EFI_UNSUPPORTED The driver specified by This does not support
424 the language specified by Language.
425
426 **/
427 EFI_STATUS
428 EFIAPI
429 ConPlatformComponentNameGetControllerName (
430 IN EFI_COMPONENT_NAME_PROTOCOL *This,
431 IN EFI_HANDLE ControllerHandle,
432 IN EFI_HANDLE ChildHandle OPTIONAL,
433 IN CHAR8 *Language,
434 OUT CHAR16 **ControllerName
435 );
436
437
438 #endif