]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.h
46518154b0cea1af3356a31b9f3c9a68f745992a
[mirror_edk2.git] / MdeModulePkg / Universal / Console / ConPlatformDxe / ConPlatform.h
1 /** @file
2 Header file for Console Platfrom DXE Driver.
3
4 Copyright (c) 2006 - 2010, 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
24 #include <Guid/GlobalVariable.h>
25 #include <Guid/ConsoleInDevice.h>
26 #include <Guid/StandardErrorDevice.h>
27 #include <Guid/ConsoleOutDevice.h>
28
29 #include <Library/DebugLib.h>
30 #include <Library/UefiDriverEntryPoint.h>
31 #include <Library/UefiLib.h>
32 #include <Library/BaseMemoryLib.h>
33 #include <Library/UefiBootServicesTableLib.h>
34 #include <Library/UefiRuntimeServicesTableLib.h>
35 #include <Library/DevicePathLib.h>
36 #include <Library/MemoryAllocationLib.h>
37
38 //
39 // Driver Binding Externs
40 //
41 extern EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextInDriverBinding;
42 extern EFI_COMPONENT_NAME_PROTOCOL gConPlatformComponentName;
43 extern EFI_COMPONENT_NAME2_PROTOCOL gConPlatformComponentName2;
44 extern EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextOutDriverBinding;
45 extern EFI_COMPONENT_NAME_PROTOCOL gConPlatformComponentName;
46 extern EFI_COMPONENT_NAME2_PROTOCOL gConPlatformComponentName2;
47
48
49 typedef enum {
50 Check,
51 Append,
52 Delete
53 } CONPLATFORM_VAR_OPERATION;
54
55 /**
56 Test to see if specific protocol could be supported on the ControllerHandle.
57
58 @param This Protocol instance pointer.
59 @param ControllerHandle Handle of device to test.
60 @param ProtocolGuid The specfic protocol.
61
62 @retval EFI_SUCCESS This driver supports this device
63 @retval other This driver does not support this device
64
65 **/
66 EFI_STATUS
67 ConPlatformDriverBindingSupported (
68 IN EFI_DRIVER_BINDING_PROTOCOL *This,
69 IN EFI_HANDLE ControllerHandle,
70 IN EFI_GUID *ProtocolGuid
71 );
72
73 /**
74 Test to see if EFI_SIMPLE_TEXT_INPUT_PROTOCOL is supported on ControllerHandle.
75
76 @param This Protocol instance pointer.
77 @param ControllerHandle Handle of device to test.
78 @param RemainingDevicePath Optional parameter use to pick a specific child
79 device to start.
80
81 @retval EFI_SUCCESS This driver supports this device.
82 @retval other This driver does not support this device.
83
84 **/
85 EFI_STATUS
86 EFIAPI
87 ConPlatformTextInDriverBindingSupported (
88 IN EFI_DRIVER_BINDING_PROTOCOL *This,
89 IN EFI_HANDLE Handle,
90 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
91 );
92
93 /**
94 Test to see if EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL is supported on ControllerHandle.
95
96 @param This Protocol instance pointer.
97 @param ControllerHandle Handle of device to test.
98 @param RemainingDevicePath Optional parameter use to pick a specific child
99 device to start.
100
101 @retval EFI_SUCCESS This driver supports this device.
102 @retval other This driver does not support this device.
103
104 **/
105 EFI_STATUS
106 EFIAPI
107 ConPlatformTextOutDriverBindingSupported (
108 IN EFI_DRIVER_BINDING_PROTOCOL *This,
109 IN EFI_HANDLE Handle,
110 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
111 );
112
113 /**
114 Start this driver on the device for console input.
115
116 Start this driver on ControllerHandle by opening Simple Text Input 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 the device for console output and stardard error output.
142
143 Start this driver on ControllerHandle by opening Simple Text Output Protocol,
144 reading Device Path, and installing Console Out Devcic 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 Input 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 Output 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 **/
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 @param Name String part of EFI variable name
234
235 @return Dynamically allocated memory that contains a copy of the EFI variable.
236 Caller is repsoncible freeing the buffer. Return NULL means Variable
237 was not read.
238
239 **/
240 VOID *
241 ConPlatformGetVariable (
242 IN CHAR16 *Name
243 );
244
245 /**
246 Function compares a device path data structure to that of all the nodes of a
247 second device path instance.
248
249
250 @param Multi A pointer to a multi-instance device path data structure.
251 @param Single A pointer to a single-instance device path data structure.
252 @param NewDevicePath If Delete is TRUE, this parameter must not be null, and it
253 points to the remaining device path data structure.
254 (remaining device path = Multi - Single.)
255 @param Delete If TRUE, means removing Single from Multi.
256 If FALSE, the routine just check whether Single matches
257 with any instance in Multi.
258
259 @retval EFI_SUCCESS If the Single is contained within Multi.
260 @retval EFI_NOT_FOUND If the Single is not contained within Multi.
261 @retval EFI_INVALID_PARAMETER Multi is NULL.
262 @retval EFI_INVALID_PARAMETER Single is NULL.
263 @retval EFI_INVALID_PARAMETER NewDevicePath is NULL when Delete is TRUE.
264
265 **/
266 EFI_STATUS
267 ConPlatformMatchDevicePaths (
268 IN EFI_DEVICE_PATH_PROTOCOL *Multi,
269 IN EFI_DEVICE_PATH_PROTOCOL *Single,
270 OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath OPTIONAL,
271 IN BOOLEAN Delete
272 );
273
274 /**
275 Update console environment variables.
276
277 @param VariableName Console environment variables, ConOutDev, ConInDev
278 StdErrDev, ConIn or ConOut.
279 @param DevicePath Console devcie's device path.
280 @param Operation Variable operations, including APPEND, CHECK and DELETE.
281
282 @retval EFI_SUCCESS Variable operates successfully.
283 @retval EFI_OUT_OF_RESOURCES If variable cannot be appended.
284 @retval other Variable updating failed.
285
286 **/
287 EFI_STATUS
288 ConPlatformUpdateDeviceVariable (
289 IN CHAR16 *VariableName,
290 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
291 IN CONPLATFORM_VAR_OPERATION Operation
292 );
293
294 /**
295 Check if the device supports hot-plug through its device path.
296
297 This function could be updated to check more types of Hot Plug devices.
298 Currently, it checks USB and PCCard device.
299
300 @param DevicePath Pointer to device's device path.
301
302 @retval TRUE The devcie is a hot-plug device
303 @retval FALSE The devcie is not a hot-plug device.
304
305 **/
306 BOOLEAN
307 IsHotPlugDevice (
308 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
309 );
310
311 //
312 // EFI Component Name Functions
313 //
314 /**
315 Retrieves a Unicode string that is the user readable name of the driver.
316
317 This function retrieves the user readable name of a driver in the form of a
318 Unicode string. If the driver specified by This has a user readable name in
319 the language specified by Language, then a pointer to the driver name is
320 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
321 by This does not support the language specified by Language,
322 then EFI_UNSUPPORTED is returned.
323
324 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
325 EFI_COMPONENT_NAME_PROTOCOL instance.
326 @param Language[in] A pointer to a Null-terminated ASCII string
327 array indicating the language. This is the
328 language of the driver name that the caller is
329 requesting, and it must match one of the
330 languages specified in SupportedLanguages. The
331 number of languages supported by a driver is up
332 to the driver writer. Language is specified
333 in RFC 4646 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.
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 @retval EFI_INVALID_PARAMETER Language is NULL.
343 @retval EFI_INVALID_PARAMETER DriverName is NULL.
344 @retval EFI_UNSUPPORTED The driver specified by This does not support
345 the language specified by Language.
346
347 **/
348 EFI_STATUS
349 EFIAPI
350 ConPlatformComponentNameGetDriverName (
351 IN EFI_COMPONENT_NAME_PROTOCOL *This,
352 IN CHAR8 *Language,
353 OUT CHAR16 **DriverName
354 );
355
356
357 /**
358 Retrieves a Unicode string that is the user readable name of the controller
359 that is being managed by a driver.
360
361 This function retrieves the user readable name of the controller specified by
362 ControllerHandle and ChildHandle in the form of a Unicode string. If the
363 driver specified by This has a user readable name in the language specified by
364 Language, then a pointer to the controller name is returned in ControllerName,
365 and EFI_SUCCESS is returned. If the driver specified by This is not currently
366 managing the controller specified by ControllerHandle and ChildHandle,
367 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
368 support the language specified by Language, then EFI_UNSUPPORTED is returned.
369
370 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
371 EFI_COMPONENT_NAME_PROTOCOL instance.
372 @param ControllerHandle[in] The handle of a controller that the driver
373 specified by This is managing. This handle
374 specifies the controller whose name is to be
375 returned.
376 @param ChildHandle[in] The handle of the child controller to retrieve
377 the name of. This is an optional parameter that
378 may be NULL. It will be NULL for device
379 drivers. It will also be NULL for a bus drivers
380 that wish to retrieve the name of the bus
381 controller. It will not be NULL for a bus
382 driver that wishes to retrieve the name of a
383 child controller.
384 @param Language[in] A pointer to a Null-terminated ASCII string
385 array indicating the language. This is the
386 language of the driver name that the caller is
387 requesting, and it must match one of the
388 languages specified in SupportedLanguages. The
389 number of languages supported by a driver is up
390 to the driver writer. Language is specified in
391 RFC 4646 or ISO 639-2 language code format.
392 @param ControllerName[out] A pointer to the Unicode string to return.
393 This Unicode string is the name of the
394 controller specified by ControllerHandle and
395 ChildHandle in the language specified by
396 Language from the point of view of the driver
397 specified by This.
398
399 @retval EFI_SUCCESS The Unicode string for the user readable name in
400 the language specified by Language for the
401 driver specified by This was returned in
402 DriverName.
403 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
404 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
405 EFI_HANDLE.
406 @retval EFI_INVALID_PARAMETER Language is NULL.
407 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
408 @retval EFI_UNSUPPORTED The driver specified by This is not currently
409 managing the controller specified by
410 ControllerHandle and ChildHandle.
411 @retval EFI_UNSUPPORTED The driver specified by This does not support
412 the language specified by Language.
413
414 **/
415 EFI_STATUS
416 EFIAPI
417 ConPlatformComponentNameGetControllerName (
418 IN EFI_COMPONENT_NAME_PROTOCOL *This,
419 IN EFI_HANDLE ControllerHandle,
420 IN EFI_HANDLE ChildHandle OPTIONAL,
421 IN CHAR8 *Language,
422 OUT CHAR16 **ControllerName
423 );
424
425
426 #endif