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
15 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
;
37 while (!IsListEmpty (ListHead
)) {
39 ListHead
->ForwardLink
,
40 EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY
,
42 EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
44 RemoveEntryList (ListHead
->ForwardLink
);
45 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
,
137 Starts a device controller or a bus controller.
139 The Start() function is designed to be invoked from the EFI boot service ConnectController().
140 As a result, much of the error checking on the parameters to Start() has been moved into this
141 common boot service. It is legal to call Start() from other locations,
142 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
143 1. ControllerHandle must be a valid EFI_HANDLE.
144 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
145 EFI_DEVICE_PATH_PROTOCOL.
146 3. Prior to calling Start(), the Supported() function for the driver specified by This must
147 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
149 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
150 @param[in] ControllerHandle The handle of the controller to start. This handle
151 must support a protocol interface that supplies
152 an I/O abstraction to the driver.
153 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
154 parameter is ignored by device drivers, and is optional for bus
155 drivers. For a bus driver, if this parameter is NULL, then handles
156 for all the children of Controller are created by this driver.
157 If this parameter is not NULL and the first Device Path Node is
158 not the End of Device Path Node, then only the handle for the
159 child device specified by the first Device Path Node of
160 RemainingDevicePath is created by this driver.
161 If the first Device Path Node of RemainingDevicePath is
162 the End of Device Path Node, no child handle is created by this
165 @retval EFI_SUCCESS The device was started.
166 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
167 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
168 @retval Others The driver failded to start the device.
173 EmuGopDriverBindingStart (
174 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
175 IN EFI_HANDLE Handle
,
176 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
179 EMU_IO_THUNK_PROTOCOL
*EmuIoThunk
;
181 GOP_PRIVATE_DATA
*Private
;
184 // Grab the protocols we need
186 Status
= gBS
->OpenProtocol (
188 &gEmuIoThunkProtocolGuid
,
189 (VOID
**)&EmuIoThunk
,
190 This
->DriverBindingHandle
,
192 EFI_OPEN_PROTOCOL_BY_DRIVER
194 if (EFI_ERROR (Status
)) {
195 return EFI_UNSUPPORTED
;
199 // Allocate Private context data for SGO inteface.
202 Status
= gBS
->AllocatePool (
204 sizeof (GOP_PRIVATE_DATA
),
207 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
)) {
238 // Publish the Gop interface to the world
240 Status
= gBS
->InstallMultipleProtocolInterfaces (
242 &gEfiGraphicsOutputProtocolGuid
, &Private
->GraphicsOutput
,
243 &gEfiSimpleTextInProtocolGuid
, &Private
->SimpleTextIn
,
244 &gEfiSimplePointerProtocolGuid
, &Private
->SimplePointer
,
245 &gEfiSimpleTextInputExProtocolGuid
, &Private
->SimpleTextInEx
,
250 if (EFI_ERROR (Status
)) {
254 &gEmuIoThunkProtocolGuid
,
255 This
->DriverBindingHandle
,
259 if (Private
!= NULL
) {
261 // On Error Free back private data
263 if (Private
->ControllerNameTable
!= NULL
) {
264 FreeUnicodeStringTable (Private
->ControllerNameTable
);
266 if (Private
->SimpleTextIn
.WaitForKey
!= NULL
) {
267 gBS
->CloseEvent (Private
->SimpleTextIn
.WaitForKey
);
269 if (Private
->SimpleTextInEx
.WaitForKeyEx
!= NULL
) {
270 gBS
->CloseEvent (Private
->SimpleTextInEx
.WaitForKeyEx
);
272 FreeNotifyList (&Private
->NotifyList
);
274 gBS
->FreePool (Private
);
284 Stops a device controller or a bus controller.
286 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
287 As a result, much of the error checking on the parameters to Stop() has been moved
288 into this common boot service. It is legal to call Stop() from other locations,
289 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
290 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
291 same driver's Start() function.
292 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
293 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
294 Start() function, and the Start() function must have called OpenProtocol() on
295 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
297 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
298 @param[in] ControllerHandle A handle to the device being stopped. The handle must
299 support a bus specific I/O protocol for the driver
300 to use to stop the device.
301 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
302 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
303 if NumberOfChildren is 0.
305 @retval EFI_SUCCESS The device was stopped.
306 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
311 EmuGopDriverBindingStop (
312 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
313 IN EFI_HANDLE Handle
,
314 IN UINTN NumberOfChildren
,
315 IN EFI_HANDLE
*ChildHandleBuffer
318 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
320 GOP_PRIVATE_DATA
*Private
;
322 Status
= gBS
->OpenProtocol (
324 &gEfiGraphicsOutputProtocolGuid
,
325 (VOID
**)&GraphicsOutput
,
326 This
->DriverBindingHandle
,
328 EFI_OPEN_PROTOCOL_GET_PROTOCOL
330 if (EFI_ERROR (Status
)) {
332 // If the GOP interface does not exist the driver is not started
334 return EFI_NOT_STARTED
;
338 // Get our private context information
340 Private
= GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput
);
343 // Remove the SGO interface from the system
345 Status
= gBS
->UninstallMultipleProtocolInterfaces (
347 &gEfiGraphicsOutputProtocolGuid
, &Private
->GraphicsOutput
,
348 &gEfiSimpleTextInProtocolGuid
, &Private
->SimpleTextIn
,
349 &gEfiSimplePointerProtocolGuid
, &Private
->SimplePointer
,
350 &gEfiSimpleTextInputExProtocolGuid
, &Private
->SimpleTextInEx
,
353 if (!EFI_ERROR (Status
)) {
355 // Shutdown the hardware
357 Status
= EmuGopDestructor (Private
);
358 if (EFI_ERROR (Status
)) {
359 return EFI_DEVICE_ERROR
;
364 &gEmuIoThunkProtocolGuid
,
365 This
->DriverBindingHandle
,
370 // Free our instance data
372 FreeUnicodeStringTable (Private
->ControllerNameTable
);
374 Status
= gBS
->CloseEvent (Private
->SimpleTextIn
.WaitForKey
);
375 ASSERT_EFI_ERROR (Status
);
377 Status
= gBS
->CloseEvent (Private
->SimpleTextInEx
.WaitForKeyEx
);
378 ASSERT_EFI_ERROR (Status
);
380 FreeNotifyList (&Private
->NotifyList
);
382 gBS
->FreePool (Private
);
391 /// This protocol provides the services required to determine if a driver supports a given controller.
392 /// If a controller is supported, then it also provides routines to start and stop the controller.
394 EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding
= {
395 EmuGopDriverBindingSupported
,
396 EmuGopDriverBindingStart
,
397 EmuGopDriverBindingStop
,
406 The user Entry Point for module EmuGop. The user code starts with this function.
408 @param[in] ImageHandle The firmware allocated handle for the EFI image.
409 @param[in] SystemTable A pointer to the EFI System Table.
411 @retval EFI_SUCCESS The entry point is executed successfully.
412 @retval other Some error occurs when executing this entry point.
418 IN EFI_HANDLE ImageHandle
,
419 IN EFI_SYSTEM_TABLE
*SystemTable
424 Status
= EfiLibInstallDriverBindingComponentName2 (
427 &gEmuGopDriverBinding
,
429 &gEmuGopComponentName
,
430 &gEmuGopComponentName2
432 ASSERT_EFI_ERROR (Status
);