3 Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
12 This file implements the UEFI Device Driver model requirements for GOP
14 GOP is short hand for Graphics Output Protocol.
22 IN OUT LIST_ENTRY
*ListHead
30 ListHead - The list head
34 EFI_SUCCESS - Free the notify list successfully
35 EFI_INVALID_PARAMETER - ListHead is invalid.
39 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
*NotifyNode
;
41 if (ListHead
== NULL
) {
42 return EFI_INVALID_PARAMETER
;
44 while (!IsListEmpty (ListHead
)) {
46 ListHead
->ForwardLink
,
47 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
,
49 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
51 RemoveEntryList (ListHead
->ForwardLink
);
52 gBS
->FreePool (NotifyNode
);
58 EFI_DRIVER_BINDING_PROTOCOL gWinNtGopDriverBinding
= {
59 WinNtGopDriverBindingSupported
,
60 WinNtGopDriverBindingStart
,
61 WinNtGopDriverBindingStop
,
68 The user Entry Point for module WinNtGop. The user code starts with this function.
70 @param[in] ImageHandle The firmware allocated handle for the EFI image.
71 @param[in] SystemTable A pointer to the EFI System Table.
73 @retval EFI_SUCCESS The entry point is executed successfully.
74 @retval other Some error occurs when executing this entry point.
80 IN EFI_HANDLE ImageHandle
,
81 IN EFI_SYSTEM_TABLE
*SystemTable
87 // Install driver model protocol(s).
89 Status
= EfiLibInstallDriverBindingComponentName2 (
92 &gWinNtGopDriverBinding
,
94 &gWinNtGopComponentName
,
95 &gWinNtGopComponentName2
97 ASSERT_EFI_ERROR (Status
);
109 // TODO: This - add argument and description to function comment
110 // TODO: Handle - add argument and description to function comment
111 // TODO: RemainingDevicePath - add argument and description to function comment
114 WinNtGopDriverBindingSupported (
115 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
116 IN EFI_HANDLE Handle
,
117 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
121 EFI_WIN_NT_IO_PROTOCOL
*WinNtIo
;
124 // Open the IO Abstraction(s) needed to perform the supported test
126 Status
= gBS
->OpenProtocol (
128 &gEfiWinNtIoProtocolGuid
,
130 This
->DriverBindingHandle
,
132 EFI_OPEN_PROTOCOL_BY_DRIVER
134 if (EFI_ERROR (Status
)) {
138 Status
= WinNtGopSupported (WinNtIo
);
141 // Close the I/O Abstraction(s) used to perform the supported test
145 &gEfiWinNtIoProtocolGuid
,
146 This
->DriverBindingHandle
,
160 // TODO: This - add argument and description to function comment
161 // TODO: Handle - add argument and description to function comment
162 // TODO: RemainingDevicePath - add argument and description to function comment
163 // TODO: EFI_UNSUPPORTED - add return value to function comment
166 WinNtGopDriverBindingStart (
167 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
168 IN EFI_HANDLE Handle
,
169 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
172 EFI_WIN_NT_IO_PROTOCOL
*WinNtIo
;
174 GOP_PRIVATE_DATA
*Private
;
177 // Grab the protocols we need
179 Status
= gBS
->OpenProtocol (
181 &gEfiWinNtIoProtocolGuid
,
183 This
->DriverBindingHandle
,
185 EFI_OPEN_PROTOCOL_BY_DRIVER
187 if (EFI_ERROR (Status
)) {
188 return EFI_UNSUPPORTED
;
192 // Allocate Private context data for SGO inteface.
195 Private
= AllocatePool (sizeof (GOP_PRIVATE_DATA
));
196 if (Private
== NULL
) {
197 Status
= EFI_OUT_OF_RESOURCES
;
201 // Set up context record
203 Private
->Signature
= GOP_PRIVATE_DATA_SIGNATURE
;
204 Private
->Handle
= Handle
;
205 Private
->WinNtThunk
= WinNtIo
->WinNtThunk
;
207 Private
->ControllerNameTable
= NULL
;
211 gWinNtGopComponentName
.SupportedLanguages
,
212 &Private
->ControllerNameTable
,
218 gWinNtGopComponentName2
.SupportedLanguages
,
219 &Private
->ControllerNameTable
,
225 Private
->WindowName
= WinNtIo
->EnvString
;
227 Status
= WinNtGopConstructor (Private
);
228 if (EFI_ERROR (Status
)) {
232 // Publish the Gop interface to the world
234 Status
= gBS
->InstallMultipleProtocolInterfaces (
236 &gEfiGraphicsOutputProtocolGuid
,
237 &Private
->GraphicsOutput
,
238 &gEfiSimpleTextInProtocolGuid
,
239 &Private
->SimpleTextIn
,
240 &gEfiSimpleTextInputExProtocolGuid
,
241 &Private
->SimpleTextInEx
,
246 if (EFI_ERROR (Status
)) {
250 &gEfiWinNtIoProtocolGuid
,
251 This
->DriverBindingHandle
,
255 if (Private
!= NULL
) {
257 // On Error Free back private data
259 if (Private
->ControllerNameTable
!= NULL
) {
260 FreeUnicodeStringTable (Private
->ControllerNameTable
);
263 if (Private
->SimpleTextIn
.WaitForKey
!= NULL
) {
264 gBS
->CloseEvent (Private
->SimpleTextIn
.WaitForKey
);
266 if (Private
->SimpleTextInEx
.WaitForKeyEx
!= NULL
) {
267 gBS
->CloseEvent (Private
->SimpleTextInEx
.WaitForKeyEx
);
269 FreeNotifyList (&Private
->NotifyList
);
284 // TODO: This - add argument and description to function comment
285 // TODO: Handle - add argument and description to function comment
286 // TODO: NumberOfChildren - add argument and description to function comment
287 // TODO: ChildHandleBuffer - add argument and description to function comment
288 // TODO: EFI_NOT_STARTED - add return value to function comment
289 // TODO: EFI_DEVICE_ERROR - add return value to function comment
292 WinNtGopDriverBindingStop (
293 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
294 IN EFI_HANDLE Handle
,
295 IN UINTN NumberOfChildren
,
296 IN EFI_HANDLE
*ChildHandleBuffer
299 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
301 GOP_PRIVATE_DATA
*Private
;
303 Status
= gBS
->OpenProtocol (
305 &gEfiGraphicsOutputProtocolGuid
,
306 (VOID
**) &GraphicsOutput
,
307 This
->DriverBindingHandle
,
309 EFI_OPEN_PROTOCOL_GET_PROTOCOL
311 if (EFI_ERROR (Status
)) {
313 // If the GOP interface does not exist the driver is not started
315 return EFI_NOT_STARTED
;
319 // Get our private context information
321 Private
= GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput
);
324 // Remove the SGO interface from the system
326 Status
= gBS
->UninstallMultipleProtocolInterfaces (
328 &gEfiGraphicsOutputProtocolGuid
,
329 &Private
->GraphicsOutput
,
330 &gEfiSimpleTextInProtocolGuid
,
331 &Private
->SimpleTextIn
,
332 &gEfiSimpleTextInputExProtocolGuid
,
333 &Private
->SimpleTextInEx
,
336 if (!EFI_ERROR (Status
)) {
338 // Shutdown the hardware
340 Status
= WinNtGopDestructor (Private
);
341 if (EFI_ERROR (Status
)) {
342 return EFI_DEVICE_ERROR
;
347 &gEfiWinNtIoProtocolGuid
,
348 This
->DriverBindingHandle
,
353 // Free our instance data
355 FreeUnicodeStringTable (Private
->ControllerNameTable
);
356 Status
= gBS
->CloseEvent (Private
->SimpleTextIn
.WaitForKey
);
357 ASSERT_EFI_ERROR (Status
);
358 Status
= gBS
->CloseEvent (Private
->SimpleTextInEx
.WaitForKeyEx
);
359 ASSERT_EFI_ERROR (Status
);
360 FreeNotifyList (&Private
->NotifyList
);
362 gBS
->FreePool (Private
);