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 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
,
184 if (EFI_ERROR (Status
)) {
188 &gEfiUnixIoProtocolGuid
,
189 This
->DriverBindingHandle
,
193 if (Private
!= NULL
) {
195 // On Error Free back private data
197 if (Private
->ControllerNameTable
!= NULL
) {
198 FreeUnicodeStringTable (Private
->ControllerNameTable
);
201 gBS
->FreePool (Private
);
210 UnixUgaDriverBindingStop (
211 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
212 IN EFI_HANDLE Handle
,
213 IN UINTN NumberOfChildren
,
214 IN EFI_HANDLE
*ChildHandleBuffer
227 // TODO: This - add argument and description to function comment
228 // TODO: Handle - add argument and description to function comment
229 // TODO: NumberOfChildren - add argument and description to function comment
230 // TODO: ChildHandleBuffer - add argument and description to function comment
231 // TODO: EFI_NOT_STARTED - add return value to function comment
232 // TODO: EFI_DEVICE_ERROR - add return value to function comment
234 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
236 UGA_PRIVATE_DATA
*Private
;
238 Status
= gBS
->OpenProtocol (
240 &gEfiUgaDrawProtocolGuid
,
242 This
->DriverBindingHandle
,
244 EFI_OPEN_PROTOCOL_GET_PROTOCOL
246 if (EFI_ERROR (Status
)) {
248 // If the UGA interface does not exist the driver is not started
250 return EFI_NOT_STARTED
;
254 // Get our private context information
256 Private
= UGA_DRAW_PRIVATE_DATA_FROM_THIS (UgaDraw
);
259 // Remove the SGO interface from the system
261 Status
= gBS
->UninstallMultipleProtocolInterfaces (
263 &gEfiUgaDrawProtocolGuid
,
265 &gEfiSimpleTextInProtocolGuid
,
266 &Private
->SimpleTextIn
,
269 if (!EFI_ERROR (Status
)) {
271 // Shutdown the hardware
273 Status
= UnixUgaDestructor (Private
);
274 if (EFI_ERROR (Status
)) {
275 return EFI_DEVICE_ERROR
;
280 &gEfiUnixIoProtocolGuid
,
281 This
->DriverBindingHandle
,
286 // Free our instance data
288 FreeUnicodeStringTable (Private
->ControllerNameTable
);
290 gBS
->FreePool (Private
);