3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 Portions copyright (c) 2010,Apple Inc. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
14 IN OUT LIST_ENTRY
*ListHead
23 ListHead - The list head
27 EFI_SUCCESS - Free the notify list successfully
28 EFI_INVALID_PARAMETER - ListHead is invalid.
32 EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY
*NotifyNode
;
34 if (ListHead
== NULL
) {
35 return EFI_INVALID_PARAMETER
;
38 while (!IsListEmpty (ListHead
)) {
40 ListHead
->ForwardLink
,
41 EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY
,
43 EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
45 RemoveEntryList (ListHead
->ForwardLink
);
46 gBS
->FreePool (NotifyNode
);
53 Tests to see if this driver supports a given controller. If a child device is provided,
54 it further tests to see if this driver supports creating a handle for the specified child device.
56 This function checks to see if the driver specified by This supports the device specified by
57 ControllerHandle. Drivers will typically use the device path attached to
58 ControllerHandle and/or the services from the bus I/O abstraction attached to
59 ControllerHandle to determine if the driver supports ControllerHandle. This function
60 may be called many times during platform initialization. In order to reduce boot times, the tests
61 performed by this function must be very small, and take as little time as possible to execute. This
62 function must not change the state of any hardware devices, and this function must be aware that the
63 device specified by ControllerHandle may already be managed by the same driver or a
64 different driver. This function must match its calls to AllocatePages() with FreePages(),
65 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
66 Because ControllerHandle may have been previously started by the same driver, if a protocol is
67 already in the opened state, then it must not be closed with CloseProtocol(). This is required
68 to guarantee the state of ControllerHandle is not modified by this function.
70 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
71 @param[in] ControllerHandle The handle of the controller to test. This handle
72 must support a protocol interface that supplies
73 an I/O abstraction to the driver.
74 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
75 parameter is ignored by device drivers, and is optional for bus
76 drivers. For bus drivers, if this parameter is not NULL, then
77 the bus driver must determine if the bus controller specified
78 by ControllerHandle and the child controller specified
79 by RemainingDevicePath are both supported by this
82 @retval EFI_SUCCESS The device specified by ControllerHandle and
83 RemainingDevicePath is supported by the driver specified by This.
84 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
85 RemainingDevicePath is already being managed by the driver
87 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
88 RemainingDevicePath is already being managed by a different
89 driver or an application that requires exclusive access.
90 Currently not implemented.
91 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
92 RemainingDevicePath is not supported by the driver specified by This.
96 EmuGopDriverBindingSupported (
97 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
99 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
103 EMU_IO_THUNK_PROTOCOL
*EmuIoThunk
;
106 // Open the IO Abstraction(s) needed to perform the supported test
108 Status
= gBS
->OpenProtocol (
110 &gEmuIoThunkProtocolGuid
,
111 (VOID
**)&EmuIoThunk
,
112 This
->DriverBindingHandle
,
114 EFI_OPEN_PROTOCOL_BY_DRIVER
116 if (EFI_ERROR (Status
)) {
120 Status
= EmuGopSupported (EmuIoThunk
);
123 // Close the I/O Abstraction(s) used to perform the supported test
127 &gEmuIoThunkProtocolGuid
,
128 This
->DriverBindingHandle
,
136 Starts a device controller or a bus controller.
138 The Start() function is designed to be invoked from the EFI boot service ConnectController().
139 As a result, much of the error checking on the parameters to Start() has been moved into this
140 common boot service. It is legal to call Start() from other locations,
141 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
142 1. ControllerHandle must be a valid EFI_HANDLE.
143 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
144 EFI_DEVICE_PATH_PROTOCOL.
145 3. Prior to calling Start(), the Supported() function for the driver specified by This must
146 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
148 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
149 @param[in] ControllerHandle The handle of the controller to start. This handle
150 must support a protocol interface that supplies
151 an I/O abstraction to the driver.
152 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
153 parameter is ignored by device drivers, and is optional for bus
154 drivers. For a bus driver, if this parameter is NULL, then handles
155 for all the children of Controller are created by this driver.
156 If this parameter is not NULL and the first Device Path Node is
157 not the End of Device Path Node, then only the handle for the
158 child device specified by the first Device Path Node of
159 RemainingDevicePath is created by this driver.
160 If the first Device Path Node of RemainingDevicePath is
161 the End of Device Path Node, no child handle is created by this
164 @retval EFI_SUCCESS The device was started.
165 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
166 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
167 @retval Others The driver failded to start the device.
172 EmuGopDriverBindingStart (
173 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
174 IN EFI_HANDLE Handle
,
175 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
178 EMU_IO_THUNK_PROTOCOL
*EmuIoThunk
;
180 GOP_PRIVATE_DATA
*Private
;
183 // Grab the protocols we need
185 Status
= gBS
->OpenProtocol (
187 &gEmuIoThunkProtocolGuid
,
188 (VOID
**)&EmuIoThunk
,
189 This
->DriverBindingHandle
,
191 EFI_OPEN_PROTOCOL_BY_DRIVER
193 if (EFI_ERROR (Status
)) {
194 return EFI_UNSUPPORTED
;
198 // Allocate Private context data for SGO inteface.
201 Status
= gBS
->AllocatePool (
203 sizeof (GOP_PRIVATE_DATA
),
206 if (EFI_ERROR (Status
)) {
211 // Set up context record
213 Private
->Signature
= GOP_PRIVATE_DATA_SIGNATURE
;
214 Private
->Handle
= Handle
;
215 Private
->EmuIoThunk
= EmuIoThunk
;
216 Private
->WindowName
= EmuIoThunk
->ConfigString
;
217 Private
->ControllerNameTable
= NULL
;
221 gEmuGopComponentName
.SupportedLanguages
,
222 &Private
->ControllerNameTable
,
223 EmuIoThunk
->ConfigString
227 gEmuGopComponentName2
.SupportedLanguages
,
228 &Private
->ControllerNameTable
,
229 EmuIoThunk
->ConfigString
,
233 Status
= EmuGopConstructor (Private
);
234 if (EFI_ERROR (Status
)) {
239 // Publish the Gop interface to the world
241 Status
= gBS
->InstallMultipleProtocolInterfaces (
243 &gEfiGraphicsOutputProtocolGuid
,
244 &Private
->GraphicsOutput
,
245 &gEfiSimpleTextInProtocolGuid
,
246 &Private
->SimpleTextIn
,
247 &gEfiSimplePointerProtocolGuid
,
248 &Private
->SimplePointer
,
249 &gEfiSimpleTextInputExProtocolGuid
,
250 &Private
->SimpleTextInEx
,
255 if (EFI_ERROR (Status
)) {
258 &gEmuIoThunkProtocolGuid
,
259 This
->DriverBindingHandle
,
263 if (Private
!= NULL
) {
265 // On Error Free back private data
267 if (Private
->ControllerNameTable
!= NULL
) {
268 FreeUnicodeStringTable (Private
->ControllerNameTable
);
271 if (Private
->SimpleTextIn
.WaitForKey
!= NULL
) {
272 gBS
->CloseEvent (Private
->SimpleTextIn
.WaitForKey
);
275 if (Private
->SimpleTextInEx
.WaitForKeyEx
!= NULL
) {
276 gBS
->CloseEvent (Private
->SimpleTextInEx
.WaitForKeyEx
);
279 FreeNotifyList (&Private
->NotifyList
);
281 gBS
->FreePool (Private
);
289 Stops a device controller or a bus controller.
291 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
292 As a result, much of the error checking on the parameters to Stop() has been moved
293 into this common boot service. It is legal to call Stop() from other locations,
294 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
295 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
296 same driver's Start() function.
297 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
298 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
299 Start() function, and the Start() function must have called OpenProtocol() on
300 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
302 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
303 @param[in] ControllerHandle A handle to the device being stopped. The handle must
304 support a bus specific I/O protocol for the driver
305 to use to stop the device.
306 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
307 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
308 if NumberOfChildren is 0.
310 @retval EFI_SUCCESS The device was stopped.
311 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
316 EmuGopDriverBindingStop (
317 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
318 IN EFI_HANDLE Handle
,
319 IN UINTN NumberOfChildren
,
320 IN EFI_HANDLE
*ChildHandleBuffer
323 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
325 GOP_PRIVATE_DATA
*Private
;
327 Status
= gBS
->OpenProtocol (
329 &gEfiGraphicsOutputProtocolGuid
,
330 (VOID
**)&GraphicsOutput
,
331 This
->DriverBindingHandle
,
333 EFI_OPEN_PROTOCOL_GET_PROTOCOL
335 if (EFI_ERROR (Status
)) {
337 // If the GOP interface does not exist the driver is not started
339 return EFI_NOT_STARTED
;
343 // Get our private context information
345 Private
= GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput
);
348 // Remove the SGO interface from the system
350 Status
= gBS
->UninstallMultipleProtocolInterfaces (
352 &gEfiGraphicsOutputProtocolGuid
,
353 &Private
->GraphicsOutput
,
354 &gEfiSimpleTextInProtocolGuid
,
355 &Private
->SimpleTextIn
,
356 &gEfiSimplePointerProtocolGuid
,
357 &Private
->SimplePointer
,
358 &gEfiSimpleTextInputExProtocolGuid
,
359 &Private
->SimpleTextInEx
,
362 if (!EFI_ERROR (Status
)) {
364 // Shutdown the hardware
366 Status
= EmuGopDestructor (Private
);
367 if (EFI_ERROR (Status
)) {
368 return EFI_DEVICE_ERROR
;
373 &gEmuIoThunkProtocolGuid
,
374 This
->DriverBindingHandle
,
379 // Free our instance data
381 FreeUnicodeStringTable (Private
->ControllerNameTable
);
383 Status
= gBS
->CloseEvent (Private
->SimpleTextIn
.WaitForKey
);
384 ASSERT_EFI_ERROR (Status
);
386 Status
= gBS
->CloseEvent (Private
->SimpleTextInEx
.WaitForKeyEx
);
387 ASSERT_EFI_ERROR (Status
);
389 FreeNotifyList (&Private
->NotifyList
);
391 gBS
->FreePool (Private
);
398 /// This protocol provides the services required to determine if a driver supports a given controller.
399 /// If a controller is supported, then it also provides routines to start and stop the controller.
401 EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding
= {
402 EmuGopDriverBindingSupported
,
403 EmuGopDriverBindingStart
,
404 EmuGopDriverBindingStop
,
411 The user Entry Point for module EmuGop. The user code starts with this function.
413 @param[in] ImageHandle The firmware allocated handle for the EFI image.
414 @param[in] SystemTable A pointer to the EFI System Table.
416 @retval EFI_SUCCESS The entry point is executed successfully.
417 @retval other Some error occurs when executing this entry point.
423 IN EFI_HANDLE ImageHandle
,
424 IN EFI_SYSTEM_TABLE
*SystemTable
429 Status
= EfiLibInstallDriverBindingComponentName2 (
432 &gEmuGopDriverBinding
,
434 &gEmuGopComponentName
,
435 &gEmuGopComponentName2
437 ASSERT_EFI_ERROR (Status
);