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.
28 IN OUT LIST_ENTRY
*ListHead
36 ListHead - The list head
40 EFI_SUCCESS - Free the notify list successfully
41 EFI_INVALID_PARAMETER - ListHead is invalid.
45 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
*NotifyNode
;
47 if (ListHead
== NULL
) {
48 return EFI_INVALID_PARAMETER
;
50 while (!IsListEmpty (ListHead
)) {
52 ListHead
->ForwardLink
,
53 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
,
55 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
57 RemoveEntryList (ListHead
->ForwardLink
);
58 gBS
->FreePool (NotifyNode
);
64 EFI_DRIVER_BINDING_PROTOCOL gWinNtGopDriverBinding
= {
65 WinNtGopDriverBindingSupported
,
66 WinNtGopDriverBindingStart
,
67 WinNtGopDriverBindingStop
,
74 The user Entry Point for module WinNtGop. The user code starts with this function.
76 @param[in] ImageHandle The firmware allocated handle for the EFI image.
77 @param[in] SystemTable A pointer to the EFI System Table.
79 @retval EFI_SUCCESS The entry point is executed successfully.
80 @retval other Some error occurs when executing this entry point.
86 IN EFI_HANDLE ImageHandle
,
87 IN EFI_SYSTEM_TABLE
*SystemTable
93 // Install driver model protocol(s).
95 Status
= EfiLibInstallDriverBindingComponentName2 (
98 &gWinNtGopDriverBinding
,
100 &gWinNtGopComponentName
,
101 &gWinNtGopComponentName2
103 ASSERT_EFI_ERROR (Status
);
115 // TODO: This - add argument and description to function comment
116 // TODO: Handle - add argument and description to function comment
117 // TODO: RemainingDevicePath - add argument and description to function comment
120 WinNtGopDriverBindingSupported (
121 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
122 IN EFI_HANDLE Handle
,
123 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
127 EFI_WIN_NT_IO_PROTOCOL
*WinNtIo
;
130 // Open the IO Abstraction(s) needed to perform the supported test
132 Status
= gBS
->OpenProtocol (
134 &gEfiWinNtIoProtocolGuid
,
136 This
->DriverBindingHandle
,
138 EFI_OPEN_PROTOCOL_BY_DRIVER
140 if (EFI_ERROR (Status
)) {
144 Status
= WinNtGopSupported (WinNtIo
);
147 // Close the I/O Abstraction(s) used to perform the supported test
151 &gEfiWinNtIoProtocolGuid
,
152 This
->DriverBindingHandle
,
166 // TODO: This - add argument and description to function comment
167 // TODO: Handle - add argument and description to function comment
168 // TODO: RemainingDevicePath - add argument and description to function comment
169 // TODO: EFI_UNSUPPORTED - add return value to function comment
172 WinNtGopDriverBindingStart (
173 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
174 IN EFI_HANDLE Handle
,
175 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
178 EFI_WIN_NT_IO_PROTOCOL
*WinNtIo
;
180 GOP_PRIVATE_DATA
*Private
;
183 // Grab the protocols we need
185 Status
= gBS
->OpenProtocol (
187 &gEfiWinNtIoProtocolGuid
,
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 Private
= AllocatePool (sizeof (GOP_PRIVATE_DATA
));
202 if (Private
== NULL
) {
203 Status
= EFI_OUT_OF_RESOURCES
;
207 // Set up context record
209 Private
->Signature
= GOP_PRIVATE_DATA_SIGNATURE
;
210 Private
->Handle
= Handle
;
211 Private
->WinNtThunk
= WinNtIo
->WinNtThunk
;
213 Private
->ControllerNameTable
= NULL
;
217 gWinNtGopComponentName
.SupportedLanguages
,
218 &Private
->ControllerNameTable
,
224 gWinNtGopComponentName2
.SupportedLanguages
,
225 &Private
->ControllerNameTable
,
231 Private
->WindowName
= WinNtIo
->EnvString
;
233 Status
= WinNtGopConstructor (Private
);
234 if (EFI_ERROR (Status
)) {
238 // Publish the Gop interface to the world
240 Status
= gBS
->InstallMultipleProtocolInterfaces (
242 &gEfiGraphicsOutputProtocolGuid
,
243 &Private
->GraphicsOutput
,
244 &gEfiSimpleTextInProtocolGuid
,
245 &Private
->SimpleTextIn
,
246 &gEfiSimpleTextInputExProtocolGuid
,
247 &Private
->SimpleTextInEx
,
252 if (EFI_ERROR (Status
)) {
256 &gEfiWinNtIoProtocolGuid
,
257 This
->DriverBindingHandle
,
261 if (Private
!= NULL
) {
263 // On Error Free back private data
265 if (Private
->ControllerNameTable
!= NULL
) {
266 FreeUnicodeStringTable (Private
->ControllerNameTable
);
269 if (Private
->SimpleTextIn
.WaitForKey
!= NULL
) {
270 gBS
->CloseEvent (Private
->SimpleTextIn
.WaitForKey
);
272 if (Private
->SimpleTextInEx
.WaitForKeyEx
!= NULL
) {
273 gBS
->CloseEvent (Private
->SimpleTextInEx
.WaitForKeyEx
);
275 FreeNotifyList (&Private
->NotifyList
);
290 // TODO: This - add argument and description to function comment
291 // TODO: Handle - add argument and description to function comment
292 // TODO: NumberOfChildren - add argument and description to function comment
293 // TODO: ChildHandleBuffer - add argument and description to function comment
294 // TODO: EFI_NOT_STARTED - add return value to function comment
295 // TODO: EFI_DEVICE_ERROR - add return value to function comment
298 WinNtGopDriverBindingStop (
299 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
300 IN EFI_HANDLE Handle
,
301 IN UINTN NumberOfChildren
,
302 IN EFI_HANDLE
*ChildHandleBuffer
305 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
307 GOP_PRIVATE_DATA
*Private
;
309 Status
= gBS
->OpenProtocol (
311 &gEfiGraphicsOutputProtocolGuid
,
312 (VOID
**) &GraphicsOutput
,
313 This
->DriverBindingHandle
,
315 EFI_OPEN_PROTOCOL_GET_PROTOCOL
317 if (EFI_ERROR (Status
)) {
319 // If the GOP interface does not exist the driver is not started
321 return EFI_NOT_STARTED
;
325 // Get our private context information
327 Private
= GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput
);
330 // Remove the SGO interface from the system
332 Status
= gBS
->UninstallMultipleProtocolInterfaces (
334 &gEfiGraphicsOutputProtocolGuid
,
335 &Private
->GraphicsOutput
,
336 &gEfiSimpleTextInProtocolGuid
,
337 &Private
->SimpleTextIn
,
338 &gEfiSimpleTextInputExProtocolGuid
,
339 &Private
->SimpleTextInEx
,
342 if (!EFI_ERROR (Status
)) {
344 // Shutdown the hardware
346 Status
= WinNtGopDestructor (Private
);
347 if (EFI_ERROR (Status
)) {
348 return EFI_DEVICE_ERROR
;
353 &gEfiWinNtIoProtocolGuid
,
354 This
->DriverBindingHandle
,
359 // Free our instance data
361 FreeUnicodeStringTable (Private
->ControllerNameTable
);
362 Status
= gBS
->CloseEvent (Private
->SimpleTextIn
.WaitForKey
);
363 ASSERT_EFI_ERROR (Status
);
364 Status
= gBS
->CloseEvent (Private
->SimpleTextInEx
.WaitForKeyEx
);
365 ASSERT_EFI_ERROR (Status
);
366 FreeNotifyList (&Private
->NotifyList
);
368 gBS
->FreePool (Private
);