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 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
;
234 Private
= UGA_DRAW_PRIVATE_DATA_FROM_THIS (This
);
236 if ((BltOperation
< 0) || (BltOperation
>= EfiUgaBltMax
)) {
237 return EFI_INVALID_PARAMETER
;
240 if (Width
== 0 || Height
== 0) {
241 return EFI_INVALID_PARAMETER
;
244 // If Delta is zero, then the entire BltBuffer is being used, so Delta
245 // is the number of bytes in each row of BltBuffer. Since BltBuffer is Width pixels size,
246 // the number of bytes in each row can be computed.
249 Delta
= Width
* sizeof (EFI_UGA_PIXEL
);
253 // We have to raise to TPL Notify, so we make an atomic write the frame buffer.
254 // We would not want a timer based event (Cursor, ...) to come in while we are
255 // doing this operation.
257 OriginalTPL
= gBS
->RaiseTPL (TPL_NOTIFY
);
259 Status
= Private
->UgaIo
->UgaBlt (Private
->UgaIo
,
263 DestinationX
, DestinationY
,
267 gBS
->RestoreTPL (OriginalTPL
);
274 // Construction and Destruction functions
279 IN EFI_UNIX_IO_PROTOCOL
*UnixIo
292 // TODO: UnixIo - add argument and description to function comment
293 // TODO: EFI_UNSUPPORTED - add return value to function comment
294 // TODO: EFI_SUCCESS - add return value to function comment
297 // Check to see if the IO abstraction represents a device type we support.
299 // This would be replaced a check of PCI subsystem ID, etc.
301 if (!CompareGuid (UnixIo
->TypeGuid
, &gEfiUnixUgaGuid
)) {
302 return EFI_UNSUPPORTED
;
311 IN UGA_PRIVATE_DATA
*Private
,
312 IN UINT32 HorizontalResolution
,
313 IN UINT32 VerticalResolution
,
314 IN UINT32 ColorDepth
,
315 IN UINT32 RefreshRate
321 TODO: Add function description
325 Private - TODO: add argument description
326 HorizontalResolution - TODO: add argument description
327 VerticalResolution - TODO: add argument description
328 ColorDepth - TODO: add argument description
329 RefreshRate - TODO: add argument description
333 TODO: add return values
339 mUnix
= Private
->UnixThunk
;
341 Private
->HorizontalResolution
= HorizontalResolution
;
342 Private
->VerticalResolution
= VerticalResolution
;
345 // Register to be notified on exit boot services so we can destroy the window.
347 Status
= gBS
->CreateEvent (
348 EVT_SIGNAL_EXIT_BOOT_SERVICES
,
352 &mUgaScreenExitBootServicesEvent
355 Status
= Private
->UnixThunk
->UgaCreate(&Private
->UgaIo
, Private
->WindowName
);
361 UGA_PRIVATE_DATA
*Private
374 // TODO: Private - add argument and description to function comment
375 // TODO: EFI_SUCCESS - add return value to function comment
378 Private
->UgaDraw
.GetMode
= UnixUgaGetMode
;
379 Private
->UgaDraw
.SetMode
= UnixUgaSetMode
;
380 Private
->UgaDraw
.Blt
= UnixUgaBlt
;
382 Private
->HardwareNeedsStarting
= TRUE
;
383 Private
->UgaIo
= NULL
;
385 UnixUgaInitializeSimpleTextInForWindow (Private
);
392 UGA_PRIVATE_DATA
*Private
405 // TODO: Private - add argument and description to function comment
406 // TODO: EFI_SUCCESS - add return value to function comment
408 if (!Private
->HardwareNeedsStarting
) {
409 Private
->UgaIo
->UgaClose(Private
->UgaIo
);
410 Private
->UgaIo
= NULL
;
426 This is the UGA screen's callback notification function for exit-boot-services.
427 All we do here is call UnixUgaDestructor().
432 Context - pointer to the Private structure.
441 Status
= UnixUgaDestructor (Context
);