]> 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 typedef enum {
47 Check,
48 Append,
49 Delete
50 } CONPLATFORM_VAR_OPERATION;
51
52 /**
53 Test to see if specific protocol could be supported on the ControllerHandle.
54
55 @param This Protocol instance pointer.
56 @param ControllerHandle Handle of device to test.
57 @param ProtocolGuid The specfic protocol.
58
59 @retval EFI_SUCCESS This driver supports this device
60 @retval other This driver does not support this device
61
62 **/
63 EFI_STATUS
64 ConPlatformDriverBindingSupported (
65 IN EFI_DRIVER_BINDING_PROTOCOL *This,
66 IN EFI_HANDLE ControllerHandle,
67 IN EFI_GUID *ProtocolGuid
68 );
69
70 /**
71 Test to see if EFI_SIMPLE_TEXT_INPUT_PROTOCOL is supported on ControllerHandle.
72
73 @param This Protocol instance pointer.
74 @param ControllerHandle Handle of device to test.
75 @param RemainingDevicePath Optional parameter use to pick a specific child
76 device to start.
77
78 @retval EFI_SUCCESS This driver supports this device.
79 @retval other This driver does not support this device.
80
81 **/
82 EFI_STATUS
83 EFIAPI
84 ConPlatformTextInDriverBindingSupported (
85 IN EFI_DRIVER_BINDING_PROTOCOL *This,
86 IN EFI_HANDLE Handle,
87 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
88 );
89
90 /**
91 Test to see if EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL is supported on ControllerHandle.
92
93 @param This Protocol instance pointer.
94 @param ControllerHandle Handle of device to test.
95 @param RemainingDevicePath Optional parameter use to pick a specific child
96 device to start.
97
98 @retval EFI_SUCCESS This driver supports this device.
99 @retval other This driver does not support this device.
100
101 **/
102 EFI_STATUS
103 EFIAPI
104 ConPlatformTextOutDriverBindingSupported (
105 IN EFI_DRIVER_BINDING_PROTOCOL *This,
106 IN EFI_HANDLE Handle,
107 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
108 );
109
110 /**
111 Start this driver on the device for console input.
112
113 Start this driver on ControllerHandle by opening Simple Text Input Protocol,
114 reading Device Path, and installing Console In Devcice GUID on ControllerHandle.
115
116 Append its device path into the console environment variables ConInDev.
117
118 @param This Protocol instance pointer.
119 @param ControllerHandle Handle of device to bind driver to
120 @param RemainingDevicePath Optional parameter use to pick a specific child
121 device to start.
122
123 @retval EFI_SUCCESS This driver is added to ControllerHandle
124 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
125 @retval other This driver does not support this device.
126
127 **/
128 EFI_STATUS
129 EFIAPI
130 ConPlatformTextInDriverBindingStart (
131 IN EFI_DRIVER_BINDING_PROTOCOL *This,
132 IN EFI_HANDLE Handle,
133 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
134 );
135
136 /**
137 Start this driver on the device for console output and standard error output.
138
139 Start this driver on ControllerHandle by opening Simple Text Output Protocol,
140 reading Device Path, and installing Console Out Devcic GUID, Standard Error
141 Device GUID on ControllerHandle.
142
143 Append its device path into the console environment variables ConOutDev, ErrOutDev.
144
145 @param This Protocol instance pointer.
146 @param ControllerHandle Handle of device to bind driver to
147 @param RemainingDevicePath Optional parameter use to pick a specific child
148 device to start.
149
150 @retval EFI_SUCCESS This driver is added to ControllerHandle
151 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
152 @retval other This driver does not support this device
153
154 **/
155 EFI_STATUS
156 EFIAPI
157 ConPlatformTextOutDriverBindingStart (
158 IN EFI_DRIVER_BINDING_PROTOCOL *This,
159 IN EFI_HANDLE Handle,
160 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
161 );
162
163 /**
164 Stop this driver on ControllerHandle by removing Console In Devcice GUID
165 and closing the Simple Text Input protocol on ControllerHandle.
166
167 @param This Protocol instance pointer.
168 @param ControllerHandle Handle of device to stop driver on
169 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
170 children is zero stop the entire bus driver.
171 @param ChildHandleBuffer List of Child Handles to Stop.
172
173 @retval EFI_SUCCESS This driver is removed ControllerHandle
174 @retval other This driver was not removed from this device
175
176 **/
177 EFI_STATUS
178 EFIAPI
179 ConPlatformTextInDriverBindingStop (
180 IN EFI_DRIVER_BINDING_PROTOCOL *This,
181 IN EFI_HANDLE Handle,
182 IN UINTN NumberOfChildren,
183 IN EFI_HANDLE *ChildHandleBuffer
184 );
185
186 /**
187 Stop this driver on ControllerHandle by removing Console Out Devcice GUID
188 and closing the Simple Text Output protocol on ControllerHandle.
189
190 @param This Protocol instance pointer.
191 @param ControllerHandle Handle of device to stop driver on
192 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
193 children is zero stop the entire bus driver.
194 @param ChildHandleBuffer List of Child Handles to Stop.
195
196 @retval EFI_SUCCESS This driver is removed ControllerHandle
197 @retval other This driver was not removed from this device
198
199 **/
200 EFI_STATUS
201 EFIAPI
202 ConPlatformTextOutDriverBindingStop (
203 IN EFI_DRIVER_BINDING_PROTOCOL *This,
204 IN EFI_HANDLE Handle,
205 IN UINTN NumberOfChildren,
206 IN EFI_HANDLE *ChildHandleBuffer
207 );
208
209 /**
210 Uninstall the specified protocol.
211
212 @param This Protocol instance pointer.
213 @param Handle Handle of device to uninstall protocol on.
214 @param ProtocolGuid The specified protocol need to be uninstalled.
215
216 **/
217 VOID
218 ConPlatformUnInstallProtocol (
219 IN EFI_DRIVER_BINDING_PROTOCOL *This,
220 IN EFI_HANDLE Handle,
221 IN EFI_GUID *ProtocolGuid
222 );
223
224 /**
225 Read the EFI variable (Name) and return a dynamically allocated
226 buffer, and the size of the buffer. On failure return NULL.
227
228 @param Name String part of EFI variable name
229
230 @return Dynamically allocated memory that contains a copy of the EFI variable.
231 Caller is repsoncible freeing the buffer. Return NULL means Variable
232 was not read.
233
234 **/
235 VOID *
236 ConPlatformGetVariable (
237 IN CHAR16 *Name
238 );
239
240 /**
241 Function compares a device path data structure to that of all the nodes of a
242 second device path instance.
243
244
245 @param Multi A pointer to a multi-instance device path data structure.
246 @param Single A pointer to a single-instance device path data structure.
247 @param NewDevicePath If Delete is TRUE, this parameter must not be null, and it
248 points to the remaining device path data structure.
249 (remaining device path = Multi - Single.)
250 @param Delete If TRUE, means removing Single from Multi.
251 If FALSE, the routine just check whether Single matches
252 with any instance in Multi.
253
254 @retval EFI_SUCCESS If the Single is contained within Multi.
255 @retval EFI_NOT_FOUND If the Single is not contained within Multi.
256 @retval EFI_INVALID_PARAMETER Multi is NULL.
257 @retval EFI_INVALID_PARAMETER Single is NULL.
258 @retval EFI_INVALID_PARAMETER NewDevicePath is NULL when Delete is TRUE.
259
260 **/
261 EFI_STATUS
262 ConPlatformMatchDevicePaths (
263 IN EFI_DEVICE_PATH_PROTOCOL *Multi,
264 IN EFI_DEVICE_PATH_PROTOCOL *Single,
265 OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath OPTIONAL,
266 IN BOOLEAN Delete
267 );
268
269 /**
270 Update console environment variables.
271
272 @param VariableName Console environment variables, ConOutDev, ConInDev
273 StdErrDev, ConIn or ConOut.
274 @param DevicePath Console devcie's device path.
275 @param Operation Variable operations, including APPEND, CHECK and DELETE.
276
277 @retval EFI_SUCCESS Variable operates successfully.
278 @retval EFI_OUT_OF_RESOURCES If variable cannot be appended.
279 @retval other Variable updating failed.
280
281 **/
282 EFI_STATUS
283 ConPlatformUpdateDeviceVariable (
284 IN CHAR16 *VariableName,
285 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
286 IN CONPLATFORM_VAR_OPERATION Operation
287 );
288
289 //
290 // EFI Component Name Functions
291 //
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 Retrieves a Unicode string that is the user readable name of the controller
337 that is being managed by a driver.
338
339 This function retrieves the user readable name of the controller specified by
340 ControllerHandle and ChildHandle in the form of a Unicode string. If the
341 driver specified by This has a user readable name in the language specified by
342 Language, then a pointer to the controller name is returned in ControllerName,
343 and EFI_SUCCESS is returned. If the driver specified by This is not currently
344 managing the controller specified by ControllerHandle and ChildHandle,
345 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
346 support the language specified by Language, then EFI_UNSUPPORTED is returned.
347
348 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
349 EFI_COMPONENT_NAME_PROTOCOL instance.
350 @param ControllerHandle[in] The handle of a controller that the driver
351 specified by This is managing. This handle
352 specifies the controller whose name is to be
353 returned.
354 @param ChildHandle[in] The handle of the child controller to retrieve
355 the name of. This is an optional parameter that
356 may be NULL. It will be NULL for device
357 drivers. It will also be NULL for a bus drivers
358 that wish to retrieve the name of the bus
359 controller. It will not be NULL for a bus
360 driver that wishes to retrieve the name of a
361 child controller.
362 @param Language[in] A pointer to a Null-terminated ASCII string
363 array indicating the language. This is the
364 language of the driver name that the caller is
365 requesting, and it must match one of the
366 languages specified in SupportedLanguages. The
367 number of languages supported by a driver is up
368 to the driver writer. Language is specified in
369 RFC 4646 or ISO 639-2 language code format.
370 @param ControllerName[out] A pointer to the Unicode string to return.
371 This Unicode string is the name of the
372 controller specified by ControllerHandle and
373 ChildHandle in the language specified by
374 Language from the point of view of the driver
375 specified by This.
376
377 @retval EFI_SUCCESS The Unicode string for the user readable name in
378 the language specified by Language for the
379 driver specified by This was returned in
380 DriverName.
381 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
382 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
383 EFI_HANDLE.
384 @retval EFI_INVALID_PARAMETER Language is NULL.
385 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
386 @retval EFI_UNSUPPORTED The driver specified by This is not currently
387 managing the controller specified by
388 ControllerHandle and ChildHandle.
389 @retval EFI_UNSUPPORTED The driver specified by This does not support
390 the language specified by Language.
391
392 **/
393 EFI_STATUS
394 EFIAPI
395 ConPlatformComponentNameGetControllerName (
396 IN EFI_COMPONENT_NAME_PROTOCOL *This,
397 IN EFI_HANDLE ControllerHandle,
398 IN EFI_HANDLE ChildHandle OPTIONAL,
399 IN CHAR8 *Language,
400 OUT CHAR16 **ControllerName
401 );
402
403 /**
404 Update ConOutDev and ErrOutDev variables to add the device path of
405 GOP controller itself and the sibling controllers.
406
407 @param DevicePath Pointer to device's device path.
408
409 @retval TRUE The devcie is a GOP device.
410 @retval FALSE The devcie is not a GOP device.
411
412 **/
413 BOOLEAN
414 ConPlatformUpdateGopCandidate (
415 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
416 );
417
418 #endif