3 Copyright (c) 2006 - 2010, 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 produces the graphics abstration of UGA. It is called by
19 UnixUgaDriver.c file which deals with the EFI 1.1 driver model.
20 This file just does graphics.
26 EFI_UNIX_THUNK_PROTOCOL
*mUnix
;
27 EFI_EVENT mUgaScreenExitBootServicesEvent
;
31 IN UGA_PRIVATE_DATA
*Private
,
32 IN UINT32 HorizontalResolution
,
33 IN UINT32 VerticalResolution
,
46 // UGA Protocol Member Functions
52 EFI_UGA_DRAW_PROTOCOL
*This
,
53 UINT32
*HorizontalResolution
,
54 UINT32
*VerticalResolution
,
61 Return the current video mode information.
64 This - Protocol instance pointer.
65 HorizontalResolution - Current video horizontal resolution in pixels
66 VerticalResolution - Current video Vertical resolution in pixels
67 ColorDepth - Current video color depth in bits per pixel
68 RefreshRate - Current video refresh rate in Hz.
71 EFI_SUCCESS - Mode information returned.
72 EFI_NOT_STARTED - Video display is not initialized. Call SetMode ()
73 EFI_INVALID_PARAMETER - One of the input args was NULL.
76 // TODO: ADD IN/OUT description here
78 UGA_PRIVATE_DATA
*Private
;
80 Private
= UGA_DRAW_PRIVATE_DATA_FROM_THIS (This
);
82 if (Private
->HardwareNeedsStarting
) {
83 return EFI_NOT_STARTED
;
86 if ((HorizontalResolution
== NULL
) ||
87 (VerticalResolution
== NULL
) ||
88 (ColorDepth
== NULL
) ||
89 (RefreshRate
== NULL
)) {
90 return EFI_INVALID_PARAMETER
;
93 *HorizontalResolution
= Private
->HorizontalResolution
;
94 *VerticalResolution
= Private
->VerticalResolution
;
95 *ColorDepth
= Private
->ColorDepth
;
96 *RefreshRate
= Private
->RefreshRate
;
103 EFI_UGA_DRAW_PROTOCOL
*This
,
104 UINT32 HorizontalResolution
,
105 UINT32 VerticalResolution
,
112 Return the current video mode information.
115 This - Protocol instance pointer.
116 HorizontalResolution - Current video horizontal resolution in pixels
117 VerticalResolution - Current video Vertical resolution in pixels
118 ColorDepth - Current video color depth in bits per pixel
119 RefreshRate - Current video refresh rate in Hz.
122 EFI_SUCCESS - Mode information returned.
123 EFI_NOT_STARTED - Video display is not initialized. Call SetMode ()
124 EFI_INVALID_PARAMETER - One of the input args was NULL.
127 // TODO: EFI_DEVICE_ERROR - add return value to function comment
128 // TODO: EFI_DEVICE_ERROR - add return value to function comment
129 // TODO: ADD IN/OUT description here
132 UGA_PRIVATE_DATA
*Private
;
135 Private
= UGA_DRAW_PRIVATE_DATA_FROM_THIS (This
);
137 if (Private
->HardwareNeedsStarting
) {
138 Status
= UnixUgaStartWindow (
140 HorizontalResolution
,
145 if (EFI_ERROR (Status
)) {
146 return EFI_DEVICE_ERROR
;
149 Private
->HardwareNeedsStarting
= FALSE
;
151 Status
= Private
->UgaIo
->UgaSize(Private
->UgaIo
,
152 HorizontalResolution
,
155 Private
->HorizontalResolution
= HorizontalResolution
;
156 Private
->VerticalResolution
= VerticalResolution
;
157 Private
->ColorDepth
= ColorDepth
;
158 Private
->RefreshRate
= RefreshRate
;
171 HorizontalResolution
,
173 HorizontalResolution
* sizeof (EFI_UGA_PIXEL
)
181 IN EFI_UGA_DRAW_PROTOCOL
*This
,
182 IN EFI_UGA_PIXEL
*BltBuffer
, OPTIONAL
183 IN EFI_UGA_BLT_OPERATION BltOperation
,
186 IN UINTN DestinationX
,
187 IN UINTN DestinationY
,
190 IN UINTN Delta OPTIONAL
195 Blt pixels from the rectangle (Width X Height) formed by the BltBuffer
196 onto the graphics screen starting a location (X, Y). (0, 0) is defined as
197 the upper left hand side of the screen. (X, Y) can be outside of the
198 current screen geometry and the BltBuffer will be cliped when it is
199 displayed. X and Y can be negative or positive. If Width or Height is
200 bigger than the current video screen the image will be clipped.
203 This - Protocol instance pointer.
204 X - X location on graphics screen.
205 Y - Y location on the graphics screen.
206 Width - Width of BltBuffer.
207 Height - Hight of BltBuffer
208 BltOperation - Operation to perform on BltBuffer and video memory
209 BltBuffer - Buffer containing data to blt into video buffer. This
210 buffer has a size of Width*Height*sizeof(EFI_UGA_PIXEL)
211 SourceX - If the BltOperation is a EfiCopyBlt this is the source
212 of the copy. For other BLT operations this argument is not
214 SourceX - If the BltOperation is a EfiCopyBlt this is the source
215 of the copy. For other BLT operations this argument is not
219 EFI_SUCCESS - The palette is updated with PaletteArray.
220 EFI_INVALID_PARAMETER - BltOperation is not valid.
221 EFI_DEVICE_ERROR - A hardware error occured writting to the video
225 // TODO: SourceY - add argument and description to function comment
226 // TODO: DestinationX - add argument and description to function comment
227 // TODO: DestinationY - add argument and description to function comment
228 // TODO: Delta - add argument and description to function comment
230 UGA_PRIVATE_DATA
*Private
;
233 UGA_BLT_ARGS UgaBltArgs
;
235 Private
= UGA_DRAW_PRIVATE_DATA_FROM_THIS (This
);
237 if ((BltOperation
< 0) || (BltOperation
>= EfiUgaBltMax
)) {
238 return EFI_INVALID_PARAMETER
;
241 if (Width
== 0 || Height
== 0) {
242 return EFI_INVALID_PARAMETER
;
245 // If Delta is zero, then the entire BltBuffer is being used, so Delta
246 // is the number of bytes in each row of BltBuffer. Since BltBuffer is Width pixels size,
247 // the number of bytes in each row can be computed.
250 Delta
= Width
* sizeof (EFI_UGA_PIXEL
);
254 // We have to raise to TPL Notify, so we make an atomic write the frame buffer.
255 // We would not want a timer based event (Cursor, ...) to come in while we are
256 // doing this operation.
258 OriginalTPL
= gBS
->RaiseTPL (TPL_NOTIFY
);
261 // Pack UGA Draw protocol parameters to UGA_BLT_ARGS structure to adapt to
262 // UgaBlt() API of Unix UGA IO protocol.
264 UgaBltArgs
.DestinationX
= DestinationX
;
265 UgaBltArgs
.DestinationY
= DestinationY
;
266 UgaBltArgs
.Height
= Height
;
267 UgaBltArgs
.Width
= Width
;
268 UgaBltArgs
.SourceX
= SourceX
;
269 UgaBltArgs
.SourceY
= SourceY
;
270 UgaBltArgs
.Delta
= Delta
;
271 Status
= Private
->UgaIo
->UgaBlt (Private
->UgaIo
,
277 gBS
->RestoreTPL (OriginalTPL
);
284 // Construction and Destruction functions
289 IN EFI_UNIX_IO_PROTOCOL
*UnixIo
302 // TODO: UnixIo - add argument and description to function comment
303 // TODO: EFI_UNSUPPORTED - add return value to function comment
304 // TODO: EFI_SUCCESS - add return value to function comment
307 // Check to see if the IO abstraction represents a device type we support.
309 // This would be replaced a check of PCI subsystem ID, etc.
311 if (!CompareGuid (UnixIo
->TypeGuid
, &gEfiUnixUgaGuid
)) {
312 return EFI_UNSUPPORTED
;
321 IN UGA_PRIVATE_DATA
*Private
,
322 IN UINT32 HorizontalResolution
,
323 IN UINT32 VerticalResolution
,
324 IN UINT32 ColorDepth
,
325 IN UINT32 RefreshRate
331 TODO: Add function description
335 Private - TODO: add argument description
336 HorizontalResolution - TODO: add argument description
337 VerticalResolution - TODO: add argument description
338 ColorDepth - TODO: add argument description
339 RefreshRate - TODO: add argument description
343 TODO: add return values
349 mUnix
= Private
->UnixThunk
;
351 Private
->HorizontalResolution
= HorizontalResolution
;
352 Private
->VerticalResolution
= VerticalResolution
;
355 // Register to be notified on exit boot services so we can destroy the window.
357 Status
= gBS
->CreateEvent (
358 EVT_SIGNAL_EXIT_BOOT_SERVICES
,
362 &mUgaScreenExitBootServicesEvent
365 Status
= Private
->UnixThunk
->UgaCreate(&Private
->UgaIo
, Private
->WindowName
);
371 UGA_PRIVATE_DATA
*Private
384 // TODO: Private - add argument and description to function comment
385 // TODO: EFI_SUCCESS - add return value to function comment
388 Private
->UgaDraw
.GetMode
= UnixUgaGetMode
;
389 Private
->UgaDraw
.SetMode
= UnixUgaSetMode
;
390 Private
->UgaDraw
.Blt
= UnixUgaBlt
;
392 Private
->HardwareNeedsStarting
= TRUE
;
393 Private
->UgaIo
= NULL
;
395 UnixUgaInitializeSimpleTextInForWindow (Private
);
397 UnixUgaInitializeSimplePointerForWindow (Private
);
404 UGA_PRIVATE_DATA
*Private
417 // TODO: Private - add argument and description to function comment
418 // TODO: EFI_SUCCESS - add return value to function comment
420 if (!Private
->HardwareNeedsStarting
) {
421 Private
->UgaIo
->UgaClose(Private
->UgaIo
);
422 Private
->UgaIo
= NULL
;
438 This is the UGA screen's callback notification function for exit-boot-services.
439 All we do here is call UnixUgaDestructor().
444 Context - pointer to the Private structure.
453 Status
= UnixUgaDestructor (Context
);