3 Copyright (c) 2006 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 This file implements the UEFI Device Driver model requirements for GOP
20 GOP is short hand for Graphics Output Protocol.
29 IN OUT LIST_ENTRY
*ListHead
37 ListHead - The list head
41 EFI_SUCCESS - Free the notify list successfully
42 EFI_INVALID_PARAMETER - ListHead is invalid.
46 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
*NotifyNode
;
48 if (ListHead
== NULL
) {
49 return EFI_INVALID_PARAMETER
;
51 while (!IsListEmpty (ListHead
)) {
53 ListHead
->ForwardLink
,
54 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
,
56 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
58 RemoveEntryList (ListHead
->ForwardLink
);
59 gBS
->FreePool (NotifyNode
);
65 EFI_DRIVER_BINDING_PROTOCOL gWinNtGopDriverBinding
= {
66 WinNtGopDriverBindingSupported
,
67 WinNtGopDriverBindingStart
,
68 WinNtGopDriverBindingStop
,
75 The user Entry Point for module WinNtGop. The user code starts with this function.
77 @param[in] ImageHandle The firmware allocated handle for the EFI image.
78 @param[in] SystemTable A pointer to the EFI System Table.
80 @retval EFI_SUCCESS The entry point is executed successfully.
81 @retval other Some error occurs when executing this entry point.
87 IN EFI_HANDLE ImageHandle
,
88 IN EFI_SYSTEM_TABLE
*SystemTable
94 // Install driver model protocol(s).
96 Status
= EfiLibInstallDriverBindingComponentName2 (
99 &gWinNtGopDriverBinding
,
101 &gWinNtGopComponentName
,
102 &gWinNtGopComponentName2
104 ASSERT_EFI_ERROR (Status
);
116 // TODO: This - add argument and description to function comment
117 // TODO: Handle - add argument and description to function comment
118 // TODO: RemainingDevicePath - add argument and description to function comment
121 WinNtGopDriverBindingSupported (
122 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
123 IN EFI_HANDLE Handle
,
124 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
128 EFI_WIN_NT_IO_PROTOCOL
*WinNtIo
;
131 // Open the IO Abstraction(s) needed to perform the supported test
133 Status
= gBS
->OpenProtocol (
135 &gEfiWinNtIoProtocolGuid
,
137 This
->DriverBindingHandle
,
139 EFI_OPEN_PROTOCOL_BY_DRIVER
141 if (EFI_ERROR (Status
)) {
145 Status
= WinNtGopSupported (WinNtIo
);
148 // Close the I/O Abstraction(s) used to perform the supported test
152 &gEfiWinNtIoProtocolGuid
,
153 This
->DriverBindingHandle
,
167 // TODO: This - add argument and description to function comment
168 // TODO: Handle - add argument and description to function comment
169 // TODO: RemainingDevicePath - add argument and description to function comment
170 // TODO: EFI_UNSUPPORTED - add return value to function comment
173 WinNtGopDriverBindingStart (
174 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
175 IN EFI_HANDLE Handle
,
176 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
179 EFI_WIN_NT_IO_PROTOCOL
*WinNtIo
;
181 GOP_PRIVATE_DATA
*Private
;
184 // Grab the protocols we need
186 Status
= gBS
->OpenProtocol (
188 &gEfiWinNtIoProtocolGuid
,
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 Private
= AllocatePool (sizeof (GOP_PRIVATE_DATA
));
203 if (Private
== NULL
) {
204 Status
= EFI_OUT_OF_RESOURCES
;
208 // Set up context record
210 Private
->Signature
= GOP_PRIVATE_DATA_SIGNATURE
;
211 Private
->Handle
= Handle
;
212 Private
->WinNtThunk
= WinNtIo
->WinNtThunk
;
214 Private
->ControllerNameTable
= NULL
;
218 gWinNtGopComponentName
.SupportedLanguages
,
219 &Private
->ControllerNameTable
,
225 gWinNtGopComponentName2
.SupportedLanguages
,
226 &Private
->ControllerNameTable
,
232 Private
->WindowName
= WinNtIo
->EnvString
;
234 Status
= WinNtGopConstructor (Private
);
235 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 &gEfiSimpleTextInputExProtocolGuid
,
248 &Private
->SimpleTextInEx
,
253 if (EFI_ERROR (Status
)) {
257 &gEfiWinNtIoProtocolGuid
,
258 This
->DriverBindingHandle
,
262 if (Private
!= NULL
) {
264 // On Error Free back private data
266 if (Private
->ControllerNameTable
!= NULL
) {
267 FreeUnicodeStringTable (Private
->ControllerNameTable
);
270 if (Private
->SimpleTextIn
.WaitForKey
!= NULL
) {
271 gBS
->CloseEvent (Private
->SimpleTextIn
.WaitForKey
);
273 if (Private
->SimpleTextInEx
.WaitForKeyEx
!= NULL
) {
274 gBS
->CloseEvent (Private
->SimpleTextInEx
.WaitForKeyEx
);
276 FreeNotifyList (&Private
->NotifyList
);
291 // TODO: This - add argument and description to function comment
292 // TODO: Handle - add argument and description to function comment
293 // TODO: NumberOfChildren - add argument and description to function comment
294 // TODO: ChildHandleBuffer - add argument and description to function comment
295 // TODO: EFI_NOT_STARTED - add return value to function comment
296 // TODO: EFI_DEVICE_ERROR - add return value to function comment
299 WinNtGopDriverBindingStop (
300 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
301 IN EFI_HANDLE Handle
,
302 IN UINTN NumberOfChildren
,
303 IN EFI_HANDLE
*ChildHandleBuffer
306 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
308 GOP_PRIVATE_DATA
*Private
;
310 Status
= gBS
->OpenProtocol (
312 &gEfiGraphicsOutputProtocolGuid
,
314 This
->DriverBindingHandle
,
316 EFI_OPEN_PROTOCOL_GET_PROTOCOL
318 if (EFI_ERROR (Status
)) {
320 // If the GOP interface does not exist the driver is not started
322 return EFI_NOT_STARTED
;
326 // Get our private context information
328 Private
= GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput
);
331 // Remove the SGO interface from the system
333 Status
= gBS
->UninstallMultipleProtocolInterfaces (
335 &gEfiGraphicsOutputProtocolGuid
,
336 &Private
->GraphicsOutput
,
337 &gEfiSimpleTextInProtocolGuid
,
338 &Private
->SimpleTextIn
,
339 &gEfiSimpleTextInputExProtocolGuid
,
340 &Private
->SimpleTextInEx
,
343 if (!EFI_ERROR (Status
)) {
345 // Shutdown the hardware
347 Status
= WinNtGopDestructor (Private
);
348 if (EFI_ERROR (Status
)) {
349 return EFI_DEVICE_ERROR
;
354 &gEfiWinNtIoProtocolGuid
,
355 This
->DriverBindingHandle
,
360 // Free our instance data
362 FreeUnicodeStringTable (Private
->ControllerNameTable
);
363 Status
= gBS
->CloseEvent (Private
->SimpleTextIn
.WaitForKey
);
364 ASSERT_EFI_ERROR (Status
);
365 Status
= gBS
->CloseEvent (Private
->SimpleTextInEx
.WaitForKeyEx
);
366 ASSERT_EFI_ERROR (Status
);
367 FreeNotifyList (&Private
->NotifyList
);
369 gBS
->FreePool (Private
);