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.
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 Private
= AllocatePool (sizeof (GOP_PRIVATE_DATA
));
129 if (Private
== NULL
) {
133 // Set up context record
135 Private
->Signature
= GOP_PRIVATE_DATA_SIGNATURE
;
136 Private
->Handle
= Handle
;
137 Private
->WinNtThunk
= WinNtIo
->WinNtThunk
;
139 Private
->ControllerNameTable
= NULL
;
143 gWinNtGopComponentName
.SupportedLanguages
,
144 &Private
->ControllerNameTable
,
148 Private
->WindowName
= WinNtIo
->EnvString
;
150 Status
= WinNtGopConstructor (Private
);
151 if (EFI_ERROR (Status
)) {
155 // Publish the Gop interface to the world
157 Status
= gBS
->InstallMultipleProtocolInterfaces (
159 &gEfiGraphicsOutputProtocolGuid
,
160 &Private
->GraphicsOutput
,
161 &gEfiSimpleTextInProtocolGuid
,
162 &Private
->SimpleTextIn
,
167 if (EFI_ERROR (Status
)) {
171 &gEfiWinNtIoProtocolGuid
,
172 This
->DriverBindingHandle
,
176 if (Private
!= NULL
) {
178 // On Error Free back private data
180 if (Private
->ControllerNameTable
!= NULL
) {
181 FreeUnicodeStringTable (Private
->ControllerNameTable
);
198 // TODO: This - add argument and description to function comment
199 // TODO: Handle - add argument and description to function comment
200 // TODO: NumberOfChildren - add argument and description to function comment
201 // TODO: ChildHandleBuffer - add argument and description to function comment
202 // TODO: EFI_NOT_STARTED - add return value to function comment
203 // TODO: EFI_DEVICE_ERROR - add return value to function comment
206 WinNtGopDriverBindingStop (
207 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
208 IN EFI_HANDLE Handle
,
209 IN UINTN NumberOfChildren
,
210 IN EFI_HANDLE
*ChildHandleBuffer
213 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
215 GOP_PRIVATE_DATA
*Private
;
217 Status
= gBS
->OpenProtocol (
219 &gEfiGraphicsOutputProtocolGuid
,
221 This
->DriverBindingHandle
,
223 EFI_OPEN_PROTOCOL_GET_PROTOCOL
225 if (EFI_ERROR (Status
)) {
227 // If the GOP interface does not exist the driver is not started
229 return EFI_NOT_STARTED
;
233 // Get our private context information
235 Private
= GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput
);
238 // Remove the SGO interface from the system
240 Status
= gBS
->UninstallMultipleProtocolInterfaces (
242 &gEfiGraphicsOutputProtocolGuid
,
243 &Private
->GraphicsOutput
,
244 &gEfiSimpleTextInProtocolGuid
,
245 &Private
->SimpleTextIn
,
248 if (!EFI_ERROR (Status
)) {
250 // Shutdown the hardware
252 Status
= WinNtGopDestructor (Private
);
253 if (EFI_ERROR (Status
)) {
254 return EFI_DEVICE_ERROR
;
259 &gEfiWinNtIoProtocolGuid
,
260 This
->DriverBindingHandle
,
265 // Free our instance data
267 FreeUnicodeStringTable (Private
->ControllerNameTable
);
278 Convert a unicode string to a UINTN
280 @param String Unicode string.
282 @return UINTN of the number represented by String.
294 // skip preceeding white space
297 while ((*Str
) && (*Str
== ' ' || *Str
== '"')) {
302 // Convert ot a Number
305 while (*Str
!= '\0') {
306 if ((*Str
>= '0') && (*Str
<= '9')) {
307 Number
= (Number
* 10) +*Str
- '0';