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