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 EFI 1.1 Device Driver model requirements for UGA
20 UGA is short hand for Universal Graphics Abstraction protocol.
22 This file is a verision of UgaIo the uses WinNtThunk system calls as an IO
23 abstraction. For a PCI device WinNtIo would be replaced with
24 a PCI IO abstraction that abstracted a specific PCI device.
30 EFI_DRIVER_BINDING_PROTOCOL gWinNtUgaDriverBinding
= {
31 WinNtUgaDriverBindingSupported
,
32 WinNtUgaDriverBindingStart
,
33 WinNtUgaDriverBindingStop
,
42 WinNtUgaDriverBindingSupported (
43 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
45 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
58 // TODO: This - add argument and description to function comment
59 // TODO: Handle - add argument and description to function comment
60 // TODO: RemainingDevicePath - add argument and description to function comment
63 EFI_WIN_NT_IO_PROTOCOL
*WinNtIo
;
66 // Open the IO Abstraction(s) needed to perform the supported test
68 Status
= gBS
->OpenProtocol (
70 &gEfiWinNtIoProtocolGuid
,
72 This
->DriverBindingHandle
,
74 EFI_OPEN_PROTOCOL_BY_DRIVER
76 if (EFI_ERROR (Status
)) {
80 Status
= WinNtUgaSupported (WinNtIo
);
83 // Close the I/O Abstraction(s) used to perform the supported test
87 &gEfiWinNtIoProtocolGuid
,
88 This
->DriverBindingHandle
,
97 WinNtUgaDriverBindingStart (
98 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
100 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
113 // TODO: This - add argument and description to function comment
114 // TODO: Handle - add argument and description to function comment
115 // TODO: RemainingDevicePath - add argument and description to function comment
116 // TODO: EFI_UNSUPPORTED - add return value to function comment
118 EFI_WIN_NT_IO_PROTOCOL
*WinNtIo
;
120 UGA_PRIVATE_DATA
*Private
;
123 // Grab the protocols we need
125 Status
= gBS
->OpenProtocol (
127 &gEfiWinNtIoProtocolGuid
,
129 This
->DriverBindingHandle
,
131 EFI_OPEN_PROTOCOL_BY_DRIVER
133 if (EFI_ERROR (Status
)) {
134 return EFI_UNSUPPORTED
;
138 // Allocate Private context data for SGO inteface.
140 Private
= AllocatePool (sizeof (UGA_PRIVATE_DATA
));
141 if (Private
== NULL
) {
145 // Set up context record
147 Private
->Signature
= UGA_PRIVATE_DATA_SIGNATURE
;
148 Private
->Handle
= Handle
;
149 Private
->WinNtThunk
= WinNtIo
->WinNtThunk
;
151 Private
->ControllerNameTable
= NULL
;
155 gWinNtUgaComponentName
.SupportedLanguages
,
156 &Private
->ControllerNameTable
,
160 Private
->WindowName
= WinNtIo
->EnvString
;
162 Status
= WinNtUgaConstructor (Private
);
163 if (EFI_ERROR (Status
)) {
167 // Publish the Uga interface to the world
169 Status
= gBS
->InstallMultipleProtocolInterfaces (
171 &gEfiUgaDrawProtocolGuid
,
173 &gEfiSimpleTextInProtocolGuid
,
174 &Private
->SimpleTextIn
,
179 if (EFI_ERROR (Status
)) {
183 &gEfiWinNtIoProtocolGuid
,
184 This
->DriverBindingHandle
,
188 if (Private
!= NULL
) {
190 // On Error Free back private data
192 if (Private
->ControllerNameTable
!= NULL
) {
193 FreeUnicodeStringTable (Private
->ControllerNameTable
);
205 WinNtUgaDriverBindingStop (
206 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
207 IN EFI_HANDLE Handle
,
208 IN UINTN NumberOfChildren
,
209 IN EFI_HANDLE
*ChildHandleBuffer
222 // TODO: This - add argument and description to function comment
223 // TODO: Handle - add argument and description to function comment
224 // TODO: NumberOfChildren - add argument and description to function comment
225 // TODO: ChildHandleBuffer - add argument and description to function comment
226 // TODO: EFI_NOT_STARTED - add return value to function comment
227 // TODO: EFI_DEVICE_ERROR - add return value to function comment
229 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
231 UGA_PRIVATE_DATA
*Private
;
233 Status
= gBS
->OpenProtocol (
235 &gEfiUgaDrawProtocolGuid
,
237 This
->DriverBindingHandle
,
239 EFI_OPEN_PROTOCOL_GET_PROTOCOL
241 if (EFI_ERROR (Status
)) {
243 // If the UGA interface does not exist the driver is not started
245 return EFI_NOT_STARTED
;
249 // Get our private context information
251 Private
= UGA_DRAW_PRIVATE_DATA_FROM_THIS (UgaDraw
);
254 // Remove the SGO interface from the system
256 Status
= gBS
->UninstallMultipleProtocolInterfaces (
258 &gEfiUgaDrawProtocolGuid
,
260 &gEfiSimpleTextInProtocolGuid
,
261 &Private
->SimpleTextIn
,
264 if (!EFI_ERROR (Status
)) {
266 // Shutdown the hardware
268 Status
= WinNtUgaDestructor (Private
);
269 if (EFI_ERROR (Status
)) {
270 return EFI_DEVICE_ERROR
;
275 &gEfiWinNtIoProtocolGuid
,
276 This
->DriverBindingHandle
,
281 // Free our instance data
283 FreeUnicodeStringTable (Private
->ControllerNameTable
);
300 Convert a unicode string to a UINTN
304 String - Unicode string.
308 UINTN of the number represented by String.
316 // skip preceeding white space
319 while ((*Str
) && (*Str
== ' ' || *Str
== '"')) {
324 // Convert ot a Number
327 while (*Str
!= '\0') {
328 if ((*Str
>= '0') && (*Str
<= '9')) {
329 Number
= (Number
* 10) +*Str
- '0';