3 Copyright (c) 2006, 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.
27 EFI_DRIVER_BINDING_PROTOCOL gWinNtGopDriverBinding
= {
28 WinNtGopDriverBindingSupported
,
29 WinNtGopDriverBindingStart
,
30 WinNtGopDriverBindingStop
,
42 // TODO: This - add argument and description to function comment
43 // TODO: Handle - add argument and description to function comment
44 // TODO: RemainingDevicePath - add argument and description to function comment
47 WinNtGopDriverBindingSupported (
48 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
50 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
54 EFI_WIN_NT_IO_PROTOCOL
*WinNtIo
;
57 // Open the IO Abstraction(s) needed to perform the supported test
59 Status
= gBS
->OpenProtocol (
61 &gEfiWinNtIoProtocolGuid
,
63 This
->DriverBindingHandle
,
65 EFI_OPEN_PROTOCOL_BY_DRIVER
67 if (EFI_ERROR (Status
)) {
71 Status
= WinNtGopSupported (WinNtIo
);
74 // Close the I/O Abstraction(s) used to perform the supported test
78 &gEfiWinNtIoProtocolGuid
,
79 This
->DriverBindingHandle
,
93 // TODO: This - add argument and description to function comment
94 // TODO: Handle - add argument and description to function comment
95 // TODO: RemainingDevicePath - add argument and description to function comment
96 // TODO: EFI_UNSUPPORTED - add return value to function comment
99 WinNtGopDriverBindingStart (
100 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
101 IN EFI_HANDLE Handle
,
102 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
105 EFI_WIN_NT_IO_PROTOCOL
*WinNtIo
;
107 GOP_PRIVATE_DATA
*Private
;
110 // Grab the protocols we need
112 Status
= gBS
->OpenProtocol (
114 &gEfiWinNtIoProtocolGuid
,
116 This
->DriverBindingHandle
,
118 EFI_OPEN_PROTOCOL_BY_DRIVER
120 if (EFI_ERROR (Status
)) {
121 return EFI_UNSUPPORTED
;
125 // Allocate Private context data for SGO inteface.
128 Status
= gBS
->AllocatePool (
130 sizeof (GOP_PRIVATE_DATA
),
133 if (EFI_ERROR (Status
)) {
137 // Set up context record
139 Private
->Signature
= GOP_PRIVATE_DATA_SIGNATURE
;
140 Private
->Handle
= Handle
;
141 Private
->WinNtThunk
= WinNtIo
->WinNtThunk
;
143 Private
->ControllerNameTable
= NULL
;
147 gWinNtGopComponentName
.SupportedLanguages
,
148 &Private
->ControllerNameTable
,
152 Private
->WindowName
= WinNtIo
->EnvString
;
154 Status
= WinNtGopConstructor (Private
);
155 if (EFI_ERROR (Status
)) {
159 // Publish the Gop interface to the world
161 Status
= gBS
->InstallMultipleProtocolInterfaces (
163 &gEfiGraphicsOutputProtocolGuid
,
164 &Private
->GraphicsOutput
,
165 &gEfiSimpleTextInProtocolGuid
,
166 &Private
->SimpleTextIn
,
171 if (EFI_ERROR (Status
)) {
175 &gEfiWinNtIoProtocolGuid
,
176 This
->DriverBindingHandle
,
180 if (Private
!= NULL
) {
182 // On Error Free back private data
184 if (Private
->ControllerNameTable
!= NULL
) {
185 FreeUnicodeStringTable (Private
->ControllerNameTable
);
188 gBS
->FreePool (Private
);
202 // TODO: This - add argument and description to function comment
203 // TODO: Handle - add argument and description to function comment
204 // TODO: NumberOfChildren - add argument and description to function comment
205 // TODO: ChildHandleBuffer - add argument and description to function comment
206 // TODO: EFI_NOT_STARTED - add return value to function comment
207 // TODO: EFI_DEVICE_ERROR - add return value to function comment
210 WinNtGopDriverBindingStop (
211 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
212 IN EFI_HANDLE Handle
,
213 IN UINTN NumberOfChildren
,
214 IN EFI_HANDLE
*ChildHandleBuffer
217 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
219 GOP_PRIVATE_DATA
*Private
;
221 Status
= gBS
->OpenProtocol (
223 &gEfiGraphicsOutputProtocolGuid
,
225 This
->DriverBindingHandle
,
227 EFI_OPEN_PROTOCOL_GET_PROTOCOL
229 if (EFI_ERROR (Status
)) {
231 // If the GOP interface does not exist the driver is not started
233 return EFI_NOT_STARTED
;
237 // Get our private context information
239 Private
= GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput
);
242 // Remove the SGO interface from the system
244 Status
= gBS
->UninstallMultipleProtocolInterfaces (
246 &gEfiGraphicsOutputProtocolGuid
,
247 &Private
->GraphicsOutput
,
248 &gEfiSimpleTextInProtocolGuid
,
249 &Private
->SimpleTextIn
,
252 if (!EFI_ERROR (Status
)) {
254 // Shutdown the hardware
256 Status
= WinNtGopDestructor (Private
);
257 if (EFI_ERROR (Status
)) {
258 return EFI_DEVICE_ERROR
;
263 &gEfiWinNtIoProtocolGuid
,
264 This
->DriverBindingHandle
,
269 // Free our instance data
271 FreeUnicodeStringTable (Private
->ControllerNameTable
);
273 gBS
->FreePool (Private
);
282 Convert a unicode string to a UINTN
284 @param String Unicode string.
286 @return UINTN of the number represented by String.
298 // skip preceeding white space
301 while ((*Str
) && (*Str
== ' ' || *Str
== '"')) {
306 // Convert ot a Number
309 while (*Str
!= '\0') {
310 if ((*Str
>= '0') && (*Str
<= '9')) {
311 Number
= (Number
* 10) +*Str
- '0';