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 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 static EFI_EVENT mUgaScreenExitBootServicesEvent
;
32 IN UGA_PRIVATE_DATA
*Private
,
33 IN UINT32 HorizontalResolution
,
34 IN UINT32 VerticalResolution
,
48 // UGA Protocol Member Functions
54 EFI_UGA_DRAW_PROTOCOL
*This
,
55 UINT32
*HorizontalResolution
,
56 UINT32
*VerticalResolution
,
63 Return the current video mode information.
66 This - Protocol instance pointer.
67 HorizontalResolution - Current video horizontal resolution in pixels
68 VerticalResolution - Current video Vertical resolution in pixels
69 ColorDepth - Current video color depth in bits per pixel
70 RefreshRate - Current video refresh rate in Hz.
73 EFI_SUCCESS - Mode information returned.
74 EFI_NOT_STARTED - Video display is not initialized. Call SetMode ()
75 EFI_INVALID_PARAMETER - One of the input args was NULL.
78 // TODO: ADD IN/OUT description here
80 UGA_PRIVATE_DATA
*Private
;
82 Private
= UGA_DRAW_PRIVATE_DATA_FROM_THIS (This
);
84 if (Private
->HardwareNeedsStarting
) {
85 return EFI_NOT_STARTED
;
88 if ((HorizontalResolution
== NULL
) ||
89 (VerticalResolution
== NULL
) ||
90 (ColorDepth
== NULL
) ||
91 (RefreshRate
== NULL
)) {
92 return EFI_INVALID_PARAMETER
;
95 *HorizontalResolution
= Private
->HorizontalResolution
;
96 *VerticalResolution
= Private
->VerticalResolution
;
97 *ColorDepth
= Private
->ColorDepth
;
98 *RefreshRate
= Private
->RefreshRate
;
105 EFI_UGA_DRAW_PROTOCOL
*This
,
106 UINT32 HorizontalResolution
,
107 UINT32 VerticalResolution
,
114 Return the current video mode information.
117 This - Protocol instance pointer.
118 HorizontalResolution - Current video horizontal resolution in pixels
119 VerticalResolution - Current video Vertical resolution in pixels
120 ColorDepth - Current video color depth in bits per pixel
121 RefreshRate - Current video refresh rate in Hz.
124 EFI_SUCCESS - Mode information returned.
125 EFI_NOT_STARTED - Video display is not initialized. Call SetMode ()
126 EFI_INVALID_PARAMETER - One of the input args was NULL.
129 // TODO: EFI_DEVICE_ERROR - add return value to function comment
130 // TODO: EFI_DEVICE_ERROR - add return value to function comment
131 // TODO: ADD IN/OUT description here
134 UGA_PRIVATE_DATA
*Private
;
137 Private
= UGA_DRAW_PRIVATE_DATA_FROM_THIS (This
);
139 if (Private
->HardwareNeedsStarting
) {
140 Status
= UnixUgaStartWindow (
142 HorizontalResolution
,
147 if (EFI_ERROR (Status
)) {
148 return EFI_DEVICE_ERROR
;
151 Private
->HardwareNeedsStarting
= FALSE
;
153 Status
= Private
->UgaIo
->UgaSize(Private
->UgaIo
,
154 HorizontalResolution
,
157 Private
->HorizontalResolution
= HorizontalResolution
;
158 Private
->VerticalResolution
= VerticalResolution
;
159 Private
->ColorDepth
= ColorDepth
;
160 Private
->RefreshRate
= RefreshRate
;
173 HorizontalResolution
,
175 HorizontalResolution
* sizeof (EFI_UGA_PIXEL
)
183 IN EFI_UGA_DRAW_PROTOCOL
*This
,
184 IN EFI_UGA_PIXEL
*BltBuffer
, OPTIONAL
185 IN EFI_UGA_BLT_OPERATION BltOperation
,
188 IN UINTN DestinationX
,
189 IN UINTN DestinationY
,
192 IN UINTN Delta OPTIONAL
197 Blt pixels from the rectangle (Width X Height) formed by the BltBuffer
198 onto the graphics screen starting a location (X, Y). (0, 0) is defined as
199 the upper left hand side of the screen. (X, Y) can be outside of the
200 current screen geometry and the BltBuffer will be cliped when it is
201 displayed. X and Y can be negative or positive. If Width or Height is
202 bigger than the current video screen the image will be clipped.
205 This - Protocol instance pointer.
206 X - X location on graphics screen.
207 Y - Y location on the graphics screen.
208 Width - Width of BltBuffer.
209 Height - Hight of BltBuffer
210 BltOperation - Operation to perform on BltBuffer and video memory
211 BltBuffer - Buffer containing data to blt into video buffer. This
212 buffer has a size of Width*Height*sizeof(EFI_UGA_PIXEL)
213 SourceX - If the BltOperation is a EfiCopyBlt this is the source
214 of the copy. For other BLT operations this argument is not
216 SourceX - If the BltOperation is a EfiCopyBlt this is the source
217 of the copy. For other BLT operations this argument is not
221 EFI_SUCCESS - The palette is updated with PaletteArray.
222 EFI_INVALID_PARAMETER - BltOperation is not valid.
223 EFI_DEVICE_ERROR - A hardware error occured writting to the video
227 // TODO: SourceY - add argument and description to function comment
228 // TODO: DestinationX - add argument and description to function comment
229 // TODO: DestinationY - add argument and description to function comment
230 // TODO: Delta - add argument and description to function comment
232 UGA_PRIVATE_DATA
*Private
;
236 Private
= UGA_DRAW_PRIVATE_DATA_FROM_THIS (This
);
238 if ((BltOperation
< 0) || (BltOperation
>= EfiUgaBltMax
)) {
239 return EFI_INVALID_PARAMETER
;
242 if (Width
== 0 || Height
== 0) {
243 return EFI_INVALID_PARAMETER
;
246 // If Delta is zero, then the entire BltBuffer is being used, so Delta
247 // is the number of bytes in each row of BltBuffer. Since BltBuffer is Width pixels size,
248 // the number of bytes in each row can be computed.
251 Delta
= Width
* sizeof (EFI_UGA_PIXEL
);
255 // We have to raise to TPL Notify, so we make an atomic write the frame buffer.
256 // We would not want a timer based event (Cursor, ...) to come in while we are
257 // doing this operation.
259 OriginalTPL
= gBS
->RaiseTPL (EFI_TPL_NOTIFY
);
261 Status
= Private
->UgaIo
->UgaBlt (Private
->UgaIo
,
265 DestinationX
, DestinationY
,
269 gBS
->RestoreTPL (OriginalTPL
);
276 // Construction and Destruction functions
281 IN EFI_UNIX_IO_PROTOCOL
*UnixIo
294 // TODO: UnixIo - add argument and description to function comment
295 // TODO: EFI_UNSUPPORTED - add return value to function comment
296 // TODO: EFI_SUCCESS - add return value to function comment
299 // Check to see if the IO abstraction represents a device type we support.
301 // This would be replaced a check of PCI subsystem ID, etc.
303 if (!CompareGuid (UnixIo
->TypeGuid
, &gEfiUnixUgaGuid
)) {
304 return EFI_UNSUPPORTED
;
314 IN UGA_PRIVATE_DATA
*Private
,
315 IN UINT32 HorizontalResolution
,
316 IN UINT32 VerticalResolution
,
317 IN UINT32 ColorDepth
,
318 IN UINT32 RefreshRate
324 TODO: Add function description
328 Private - TODO: add argument description
329 HorizontalResolution - TODO: add argument description
330 VerticalResolution - TODO: add argument description
331 ColorDepth - TODO: add argument description
332 RefreshRate - TODO: add argument description
336 TODO: add return values
342 mUnix
= Private
->UnixThunk
;
344 Private
->HorizontalResolution
= HorizontalResolution
;
345 Private
->VerticalResolution
= VerticalResolution
;
348 // Register to be notified on exit boot services so we can destroy the window.
350 Status
= gBS
->CreateEvent (
351 EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES
,
355 &mUgaScreenExitBootServicesEvent
358 Status
= Private
->UnixThunk
->UgaCreate(&Private
->UgaIo
, Private
->WindowName
);
364 UGA_PRIVATE_DATA
*Private
377 // TODO: Private - add argument and description to function comment
378 // TODO: EFI_SUCCESS - add return value to function comment
381 Private
->UgaDraw
.GetMode
= UnixUgaGetMode
;
382 Private
->UgaDraw
.SetMode
= UnixUgaSetMode
;
383 Private
->UgaDraw
.Blt
= UnixUgaBlt
;
385 Private
->HardwareNeedsStarting
= TRUE
;
386 Private
->UgaIo
= NULL
;
388 UnixUgaInitializeSimpleTextInForWindow (Private
);
395 UGA_PRIVATE_DATA
*Private
408 // TODO: Private - add argument and description to function comment
409 // TODO: EFI_SUCCESS - add return value to function comment
411 if (!Private
->HardwareNeedsStarting
) {
412 Private
->UgaIo
->UgaClose(Private
->UgaIo
);
413 Private
->UgaIo
= NULL
;
430 This is the UGA screen's callback notification function for exit-boot-services.
431 All we do here is call UnixUgaDestructor().
436 Context - pointer to the Private structure.
445 Status
= UnixUgaDestructor (Context
);