3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 Portions copyright (c) 2010, Apple, Inc. All rights reserved.<BR>
5 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
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.
19 This file implements the EFI 1.1 Device Driver model requirements for UGA
21 UGA is short hand for Universal Graphics Abstraction protocol.
23 This file is a verision of UgaIo the uses UnixThunk system calls as an IO
24 abstraction. For a PCI device UnixIo would be replaced with
25 a PCI IO abstraction that abstracted a specific PCI device.
34 IN OUT LIST_ENTRY
*ListHead
42 ListHead - The list head
46 EFI_SUCCESS - Free the notify list successfully
47 EFI_INVALID_PARAMETER - ListHead is invalid.
51 UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY
*NotifyNode
;
53 if (ListHead
== NULL
) {
54 return EFI_INVALID_PARAMETER
;
56 while (!IsListEmpty (ListHead
)) {
58 ListHead
->ForwardLink
,
59 UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY
,
61 UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
63 RemoveEntryList (ListHead
->ForwardLink
);
64 gBS
->FreePool (NotifyNode
);
73 UnixGopDriverBindingSupported (
74 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
76 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
89 // TODO: This - add argument and description to function comment
90 // TODO: Handle - add argument and description to function comment
91 // TODO: RemainingDevicePath - add argument and description to function comment
94 EFI_UNIX_IO_PROTOCOL
*UnixIo
;
97 // Open the IO Abstraction(s) needed to perform the supported test
99 Status
= gBS
->OpenProtocol (
101 &gEfiUnixIoProtocolGuid
,
103 This
->DriverBindingHandle
,
105 EFI_OPEN_PROTOCOL_BY_DRIVER
107 if (EFI_ERROR (Status
)) {
111 Status
= UnixGopSupported (UnixIo
);
114 // Close the I/O Abstraction(s) used to perform the supported test
118 &gEfiUnixIoProtocolGuid
,
119 This
->DriverBindingHandle
,
128 UnixGopDriverBindingStart (
129 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
130 IN EFI_HANDLE Handle
,
131 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
144 // TODO: This - add argument and description to function comment
145 // TODO: Handle - add argument and description to function comment
146 // TODO: RemainingDevicePath - add argument and description to function comment
147 // TODO: EFI_UNSUPPORTED - add return value to function comment
149 EFI_UNIX_IO_PROTOCOL
*UnixIo
;
151 GOP_PRIVATE_DATA
*Private
;
154 // Grab the protocols we need
156 Status
= gBS
->OpenProtocol (
158 &gEfiUnixIoProtocolGuid
,
160 This
->DriverBindingHandle
,
162 EFI_OPEN_PROTOCOL_BY_DRIVER
164 if (EFI_ERROR (Status
)) {
165 return EFI_UNSUPPORTED
;
169 // Allocate Private context data for SGO inteface.
172 Status
= gBS
->AllocatePool (
174 sizeof (GOP_PRIVATE_DATA
),
177 if (EFI_ERROR (Status
)) {
181 // Set up context record
183 Private
->Signature
= GOP_PRIVATE_DATA_SIGNATURE
;
184 Private
->Handle
= Handle
;
185 Private
->UnixThunk
= UnixIo
->UnixThunk
;
187 Private
->ControllerNameTable
= NULL
;
191 gUnixGopComponentName
.SupportedLanguages
,
192 &Private
->ControllerNameTable
,
197 gUnixGopComponentName2
.SupportedLanguages
,
198 &Private
->ControllerNameTable
,
203 Private
->WindowName
= UnixIo
->EnvString
;
205 Status
= UnixGopConstructor (Private
);
206 if (EFI_ERROR (Status
)) {
210 // Publish the Gop interface to the world
212 Status
= gBS
->InstallMultipleProtocolInterfaces (
214 &gEfiGraphicsOutputProtocolGuid
, &Private
->GraphicsOutput
,
215 &gEfiSimpleTextInProtocolGuid
, &Private
->SimpleTextIn
,
216 &gEfiSimplePointerProtocolGuid
, &Private
->SimplePointer
,
217 // &gEfiSimpleTextInputExProtocolGuid, &Private->SimpleTextInEx,
222 if (EFI_ERROR (Status
)) {
226 &gEfiUnixIoProtocolGuid
,
227 This
->DriverBindingHandle
,
231 if (Private
!= NULL
) {
233 // On Error Free back private data
235 if (Private
->ControllerNameTable
!= NULL
) {
236 FreeUnicodeStringTable (Private
->ControllerNameTable
);
238 if (Private
->SimpleTextIn
.WaitForKey
!= NULL
) {
239 gBS
->CloseEvent (Private
->SimpleTextIn
.WaitForKey
);
241 if (Private
->SimpleTextInEx
.WaitForKeyEx
!= NULL
) {
242 gBS
->CloseEvent (Private
->SimpleTextInEx
.WaitForKeyEx
);
244 FreeNotifyList (&Private
->NotifyList
);
246 gBS
->FreePool (Private
);
255 UnixGopDriverBindingStop (
256 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
257 IN EFI_HANDLE Handle
,
258 IN UINTN NumberOfChildren
,
259 IN EFI_HANDLE
*ChildHandleBuffer
272 // TODO: This - add argument and description to function comment
273 // TODO: Handle - add argument and description to function comment
274 // TODO: NumberOfChildren - add argument and description to function comment
275 // TODO: ChildHandleBuffer - add argument and description to function comment
276 // TODO: EFI_NOT_STARTED - add return value to function comment
277 // TODO: EFI_DEVICE_ERROR - add return value to function comment
279 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
281 GOP_PRIVATE_DATA
*Private
;
283 Status
= gBS
->OpenProtocol (
285 &gEfiGraphicsOutputProtocolGuid
,
286 (VOID
**)&GraphicsOutput
,
287 This
->DriverBindingHandle
,
289 EFI_OPEN_PROTOCOL_GET_PROTOCOL
291 if (EFI_ERROR (Status
)) {
293 // If the GOP interface does not exist the driver is not started
295 return EFI_NOT_STARTED
;
299 // Get our private context information
301 Private
= GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput
);
304 // Remove the SGO interface from the system
306 Status
= gBS
->UninstallMultipleProtocolInterfaces (
308 &gEfiGraphicsOutputProtocolGuid
, &Private
->GraphicsOutput
,
309 &gEfiSimpleTextInProtocolGuid
, &Private
->SimpleTextIn
,
310 &gEfiSimplePointerProtocolGuid
, &Private
->SimplePointer
,
311 // &gEfiSimpleTextInputExProtocolGuid, &Private->SimpleTextInEx,
314 if (!EFI_ERROR (Status
)) {
316 // Shutdown the hardware
318 Status
= UnixGopDestructor (Private
);
319 if (EFI_ERROR (Status
)) {
320 return EFI_DEVICE_ERROR
;
325 &gEfiUnixIoProtocolGuid
,
326 This
->DriverBindingHandle
,
331 // Free our instance data
333 FreeUnicodeStringTable (Private
->ControllerNameTable
);
335 Status
= gBS
->CloseEvent (Private
->SimpleTextIn
.WaitForKey
);
336 ASSERT_EFI_ERROR (Status
);
338 Status
= gBS
->CloseEvent (Private
->SimpleTextInEx
.WaitForKeyEx
);
339 ASSERT_EFI_ERROR (Status
);
341 FreeNotifyList (&Private
->NotifyList
);
343 gBS
->FreePool (Private
);
353 EFI_DRIVER_BINDING_PROTOCOL gUnixGopDriverBinding
= {
354 UnixGopDriverBindingSupported
,
355 UnixGopDriverBindingStart
,
356 UnixGopDriverBindingStop
,
365 The user Entry Point for module UnixGop. The user code starts with this function.
367 @param[in] ImageHandle The firmware allocated handle for the EFI image.
368 @param[in] SystemTable A pointer to the EFI System Table.
370 @retval EFI_SUCCESS The entry point is executed successfully.
371 @retval other Some error occurs when executing this entry point.
377 IN EFI_HANDLE ImageHandle
,
378 IN EFI_SYSTEM_TABLE
*SystemTable
383 Status
= EfiLibInstallDriverBindingComponentName2 (
386 &gUnixGopDriverBinding
,
388 &gUnixGopComponentName
,
389 &gUnixGopComponentName2
391 ASSERT_EFI_ERROR (Status
);