3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 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 UnixThunk system calls as an IO
23 abstraction. For a PCI device UnixIo would be replaced with
24 a PCI IO abstraction that abstracted a specific PCI device.
30 EFI_DRIVER_BINDING_PROTOCOL gUnixUgaDriverBinding
= {
31 UnixUgaDriverBindingSupported
,
32 UnixUgaDriverBindingStart
,
33 UnixUgaDriverBindingStop
,
42 UnixUgaDriverBindingSupported (
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_UNIX_IO_PROTOCOL
*UnixIo
;
66 // Open the IO Abstraction(s) needed to perform the supported test
68 Status
= gBS
->OpenProtocol (
70 &gEfiUnixIoProtocolGuid
,
72 This
->DriverBindingHandle
,
74 EFI_OPEN_PROTOCOL_BY_DRIVER
76 if (EFI_ERROR (Status
)) {
80 Status
= UnixUgaSupported (UnixIo
);
83 // Close the I/O Abstraction(s) used to perform the supported test
87 &gEfiUnixIoProtocolGuid
,
88 This
->DriverBindingHandle
,
97 UnixUgaDriverBindingStart (
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_UNIX_IO_PROTOCOL
*UnixIo
;
120 UGA_PRIVATE_DATA
*Private
;
123 // Grab the protocols we need
125 Status
= gBS
->OpenProtocol (
127 &gEfiUnixIoProtocolGuid
,
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.
141 Status
= gBS
->AllocatePool (
143 sizeof (UGA_PRIVATE_DATA
),
146 if (EFI_ERROR (Status
)) {
150 // Set up context record
152 Private
->Signature
= UGA_PRIVATE_DATA_SIGNATURE
;
153 Private
->Handle
= Handle
;
154 Private
->UnixThunk
= UnixIo
->UnixThunk
;
156 Private
->ControllerNameTable
= NULL
;
160 gUnixUgaComponentName
.SupportedLanguages
,
161 &Private
->ControllerNameTable
,
165 Private
->WindowName
= UnixIo
->EnvString
;
167 Status
= UnixUgaConstructor (Private
);
168 if (EFI_ERROR (Status
)) {
172 // Publish the Uga interface to the world
174 Status
= gBS
->InstallMultipleProtocolInterfaces (
176 &gEfiUgaDrawProtocolGuid
,
178 &gEfiSimpleTextInProtocolGuid
,
179 &Private
->SimpleTextIn
,
180 &gEfiSimplePointerProtocolGuid
,
181 &Private
->SimplePointer
,
186 if (EFI_ERROR (Status
)) {
190 &gEfiUnixIoProtocolGuid
,
191 This
->DriverBindingHandle
,
195 if (Private
!= NULL
) {
197 // On Error Free back private data
199 if (Private
->ControllerNameTable
!= NULL
) {
200 FreeUnicodeStringTable (Private
->ControllerNameTable
);
203 gBS
->FreePool (Private
);
212 UnixUgaDriverBindingStop (
213 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
214 IN EFI_HANDLE Handle
,
215 IN UINTN NumberOfChildren
,
216 IN EFI_HANDLE
*ChildHandleBuffer
229 // TODO: This - add argument and description to function comment
230 // TODO: Handle - add argument and description to function comment
231 // TODO: NumberOfChildren - add argument and description to function comment
232 // TODO: ChildHandleBuffer - add argument and description to function comment
233 // TODO: EFI_NOT_STARTED - add return value to function comment
234 // TODO: EFI_DEVICE_ERROR - add return value to function comment
236 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
238 UGA_PRIVATE_DATA
*Private
;
240 Status
= gBS
->OpenProtocol (
242 &gEfiUgaDrawProtocolGuid
,
244 This
->DriverBindingHandle
,
246 EFI_OPEN_PROTOCOL_GET_PROTOCOL
248 if (EFI_ERROR (Status
)) {
250 // If the UGA interface does not exist the driver is not started
252 return EFI_NOT_STARTED
;
256 // Get our private context information
258 Private
= UGA_DRAW_PRIVATE_DATA_FROM_THIS (UgaDraw
);
261 // Remove the SGO interface from the system
263 Status
= gBS
->UninstallMultipleProtocolInterfaces (
265 &gEfiUgaDrawProtocolGuid
,
267 &gEfiSimpleTextInProtocolGuid
,
268 &Private
->SimpleTextIn
,
269 &gEfiSimplePointerProtocolGuid
,
270 &Private
->SimplePointer
,
273 if (!EFI_ERROR (Status
)) {
275 // Shutdown the hardware
277 Status
= UnixUgaDestructor (Private
);
278 if (EFI_ERROR (Status
)) {
279 return EFI_DEVICE_ERROR
;
284 &gEfiUnixIoProtocolGuid
,
285 This
->DriverBindingHandle
,
290 // Free our instance data
292 FreeUnicodeStringTable (Private
->ControllerNameTable
);
294 gBS
->FreePool (Private
);