]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.h
Check comments, format and fix some typo.
[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
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 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.
297
298 @param DriverBindingHandle Protocol instance pointer.
299 @param ControllerHandle Handle of device to check.
300
301 @retval TRUE The devcie is a hot-plug device
302 @retval FALSE The devcie is not a hot-plug device.
303
304 **/
305 BOOLEAN
306 IsHotPlugDevice (
307 EFI_HANDLE DriverBindingHandle,
308 EFI_HANDLE ControllerHandle
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 3066 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 3066 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