1 | /** @file
|
---|
2 | GopBltLib - Library to perform blt using the UEFI Graphics Output Protocol.
|
---|
3 |
|
---|
4 | Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
|
---|
5 | This program and the accompanying materials
|
---|
6 | are licensed and made available under the terms and conditions of the BSD License
|
---|
7 | which accompanies this distribution. The full text of the license may be found at
|
---|
8 | http://opensource.org/licenses/bsd-license.php
|
---|
9 |
|
---|
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
---|
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
---|
12 |
|
---|
13 | **/
|
---|
14 |
|
---|
15 | #include "PiDxe.h"
|
---|
16 |
|
---|
17 | #include <Protocol/GraphicsOutput.h>
|
---|
18 |
|
---|
19 | #include <Library/BaseLib.h>
|
---|
20 | #include <Library/BaseMemoryLib.h>
|
---|
21 | #include <Library/BltLib.h>
|
---|
22 | #include <Library/DebugLib.h>
|
---|
23 | #include <Library/MemoryAllocationLib.h>
|
---|
24 | #include <Library/UefiBootServicesTableLib.h>
|
---|
25 |
|
---|
26 | EFI_GRAPHICS_OUTPUT_PROTOCOL *mGop = NULL;
|
---|
27 |
|
---|
28 |
|
---|
29 | /**
|
---|
30 | Configure the FrameBufferLib instance
|
---|
31 |
|
---|
32 | @param[in] FrameBuffer Pointer to the start of the frame buffer
|
---|
33 | @param[in] FrameBufferInfo Describes the frame buffer characteristics
|
---|
34 |
|
---|
35 | @retval EFI_INVALID_PARAMETER - Invalid parameter
|
---|
36 | @retval EFI_UNSUPPORTED - The BltLib does not support this configuration
|
---|
37 | @retval EFI_SUCCESS - Blt operation success
|
---|
38 |
|
---|
39 | **/
|
---|
40 | EFI_STATUS
|
---|
41 | EFIAPI
|
---|
42 | BltLibConfigure (
|
---|
43 | IN VOID *FrameBuffer,
|
---|
44 | IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo
|
---|
45 | )
|
---|
46 | {
|
---|
47 | EFI_STATUS Status;
|
---|
48 | EFI_HANDLE *HandleBuffer;
|
---|
49 | UINTN HandleCount;
|
---|
50 | UINTN Index;
|
---|
51 | EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop;
|
---|
52 |
|
---|
53 | Status = gBS->LocateHandleBuffer (
|
---|
54 | ByProtocol,
|
---|
55 | &gEfiGraphicsOutputProtocolGuid,
|
---|
56 | NULL,
|
---|
57 | &HandleCount,
|
---|
58 | &HandleBuffer
|
---|
59 | );
|
---|
60 | if (!EFI_ERROR (Status)) {
|
---|
61 | for (Index = 0; Index < HandleCount; Index++) {
|
---|
62 | Status = gBS->HandleProtocol (
|
---|
63 | HandleBuffer[Index],
|
---|
64 | &gEfiGraphicsOutputProtocolGuid,
|
---|
65 | (VOID*) &Gop
|
---|
66 | );
|
---|
67 | if (!EFI_ERROR (Status) &&
|
---|
68 | (FrameBuffer == (VOID*)(UINTN) Gop->Mode->FrameBufferBase)) {
|
---|
69 | mGop = Gop;
|
---|
70 | FreePool (HandleBuffer);
|
---|
71 | return EFI_SUCCESS;
|
---|
72 | }
|
---|
73 | }
|
---|
74 |
|
---|
75 | FreePool (HandleBuffer);
|
---|
76 | }
|
---|
77 |
|
---|
78 | return EFI_UNSUPPORTED;
|
---|
79 | }
|
---|
80 |
|
---|
81 |
|
---|
82 | /**
|
---|
83 | Performs a UEFI Graphics Output Protocol Blt operation.
|
---|
84 |
|
---|
85 | @param[in,out] BltBuffer - The data to transfer to screen
|
---|
86 | @param[in] BltOperation - The operation to perform
|
---|
87 | @param[in] SourceX - The X coordinate of the source for BltOperation
|
---|
88 | @param[in] SourceY - The Y coordinate of the source for BltOperation
|
---|
89 | @param[in] DestinationX - The X coordinate of the destination for BltOperation
|
---|
90 | @param[in] DestinationY - The Y coordinate of the destination for BltOperation
|
---|
91 | @param[in] Width - The width of a rectangle in the blt rectangle in pixels
|
---|
92 | @param[in] Height - The height of a rectangle in the blt rectangle in pixels
|
---|
93 | @param[in] Delta - Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.
|
---|
94 | If a Delta of 0 is used, the entire BltBuffer will be operated on.
|
---|
95 | If a subrectangle of the BltBuffer is used, then Delta represents
|
---|
96 | the number of bytes in a row of the BltBuffer.
|
---|
97 |
|
---|
98 | @retval EFI_DEVICE_ERROR - A hardware error occured
|
---|
99 | @retval EFI_INVALID_PARAMETER - Invalid parameter passed in
|
---|
100 | @retval EFI_SUCCESS - Blt operation success
|
---|
101 |
|
---|
102 | **/
|
---|
103 | EFI_STATUS
|
---|
104 | InternalGopBltCommon (
|
---|
105 | IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL
|
---|
106 | IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
|
---|
107 | IN UINTN SourceX,
|
---|
108 | IN UINTN SourceY,
|
---|
109 | IN UINTN DestinationX,
|
---|
110 | IN UINTN DestinationY,
|
---|
111 | IN UINTN Width,
|
---|
112 | IN UINTN Height,
|
---|
113 | IN UINTN Delta
|
---|
114 | )
|
---|
115 | {
|
---|
116 | if (mGop == NULL) {
|
---|
117 | return EFI_DEVICE_ERROR;
|
---|
118 | }
|
---|
119 |
|
---|
120 | return mGop->Blt (
|
---|
121 | mGop,
|
---|
122 | BltBuffer,
|
---|
123 | BltOperation,
|
---|
124 | SourceX,
|
---|
125 | SourceY,
|
---|
126 | DestinationX,
|
---|
127 | DestinationY,
|
---|
128 | Width,
|
---|
129 | Height,
|
---|
130 | Delta
|
---|
131 | );
|
---|
132 | }
|
---|
133 |
|
---|
134 |
|
---|
135 | /**
|
---|
136 | Performs a UEFI Graphics Output Protocol Blt operation.
|
---|
137 |
|
---|
138 | @param[in,out] BltBuffer - The data to transfer to screen
|
---|
139 | @param[in] BltOperation - The operation to perform
|
---|
140 | @param[in] SourceX - The X coordinate of the source for BltOperation
|
---|
141 | @param[in] SourceY - The Y coordinate of the source for BltOperation
|
---|
142 | @param[in] DestinationX - The X coordinate of the destination for BltOperation
|
---|
143 | @param[in] DestinationY - The Y coordinate of the destination for BltOperation
|
---|
144 | @param[in] Width - The width of a rectangle in the blt rectangle in pixels
|
---|
145 | @param[in] Height - The height of a rectangle in the blt rectangle in pixels
|
---|
146 | @param[in] Delta - Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.
|
---|
147 | If a Delta of 0 is used, the entire BltBuffer will be operated on.
|
---|
148 | If a subrectangle of the BltBuffer is used, then Delta represents
|
---|
149 | the number of bytes in a row of the BltBuffer.
|
---|
150 |
|
---|
151 | @retval EFI_DEVICE_ERROR - A hardware error occured
|
---|
152 | @retval EFI_INVALID_PARAMETER - Invalid parameter passed in
|
---|
153 | @retval EFI_SUCCESS - Blt operation success
|
---|
154 |
|
---|
155 | **/
|
---|
156 | EFI_STATUS
|
---|
157 | EFIAPI
|
---|
158 | BltLibGopBlt (
|
---|
159 | IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL
|
---|
160 | IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
|
---|
161 | IN UINTN SourceX,
|
---|
162 | IN UINTN SourceY,
|
---|
163 | IN UINTN DestinationX,
|
---|
164 | IN UINTN DestinationY,
|
---|
165 | IN UINTN Width,
|
---|
166 | IN UINTN Height,
|
---|
167 | IN UINTN Delta
|
---|
168 | )
|
---|
169 | {
|
---|
170 | return InternalGopBltCommon (
|
---|
171 | BltBuffer,
|
---|
172 | BltOperation,
|
---|
173 | SourceX,
|
---|
174 | SourceY,
|
---|
175 | DestinationX,
|
---|
176 | DestinationY,
|
---|
177 | Width,
|
---|
178 | Height,
|
---|
179 | Delta
|
---|
180 | );
|
---|
181 | }
|
---|
182 |
|
---|
183 |
|
---|
184 | /**
|
---|
185 | Performs a UEFI Graphics Output Protocol Blt Video Fill.
|
---|
186 |
|
---|
187 | @param[in] Color Color to fill the region with
|
---|
188 | @param[in] DestinationX X location to start fill operation
|
---|
189 | @param[in] DestinationY Y location to start fill operation
|
---|
190 | @param[in] Width Width (in pixels) to fill
|
---|
191 | @param[in] Height Height to fill
|
---|
192 |
|
---|
193 | @retval EFI_DEVICE_ERROR - A hardware error occured
|
---|
194 | @retval EFI_INVALID_PARAMETER - Invalid parameter passed in
|
---|
195 | @retval EFI_SUCCESS - The sizes were returned
|
---|
196 |
|
---|
197 | **/
|
---|
198 | EFI_STATUS
|
---|
199 | EFIAPI
|
---|
200 | BltLibVideoFill (
|
---|
201 | IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Color,
|
---|
202 | IN UINTN DestinationX,
|
---|
203 | IN UINTN DestinationY,
|
---|
204 | IN UINTN Width,
|
---|
205 | IN UINTN Height
|
---|
206 | )
|
---|
207 | {
|
---|
208 | return InternalGopBltCommon (
|
---|
209 | Color,
|
---|
210 | EfiBltVideoFill,
|
---|
211 | 0,
|
---|
212 | 0,
|
---|
213 | DestinationX,
|
---|
214 | DestinationY,
|
---|
215 | Width,
|
---|
216 | Height,
|
---|
217 | 0
|
---|
218 | );
|
---|
219 | }
|
---|
220 |
|
---|
221 |
|
---|
222 | /**
|
---|
223 | Performs a UEFI Graphics Output Protocol Blt Video to Buffer operation.
|
---|
224 |
|
---|
225 | @param[out] BltBuffer Output buffer for pixel color data
|
---|
226 | @param[in] SourceX X location within video
|
---|
227 | @param[in] SourceY Y location within video
|
---|
228 | @param[in] Width Width (in pixels)
|
---|
229 | @param[in] Height Height
|
---|
230 |
|
---|
231 | @retval EFI_DEVICE_ERROR - A hardware error occured
|
---|
232 | @retval EFI_INVALID_PARAMETER - Invalid parameter passed in
|
---|
233 | @retval EFI_SUCCESS - The sizes were returned
|
---|
234 |
|
---|
235 | **/
|
---|
236 | EFI_STATUS
|
---|
237 | EFIAPI
|
---|
238 | BltLibVideoToBltBuffer (
|
---|
239 | OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer,
|
---|
240 | IN UINTN SourceX,
|
---|
241 | IN UINTN SourceY,
|
---|
242 | IN UINTN Width,
|
---|
243 | IN UINTN Height
|
---|
244 | )
|
---|
245 | {
|
---|
246 | return InternalGopBltCommon (
|
---|
247 | BltBuffer,
|
---|
248 | EfiBltVideoToBltBuffer,
|
---|
249 | SourceX,
|
---|
250 | SourceY,
|
---|
251 | 0,
|
---|
252 | 0,
|
---|
253 | Width,
|
---|
254 | Height,
|
---|
255 | 0
|
---|
256 | );
|
---|
257 | }
|
---|
258 |
|
---|
259 |
|
---|
260 | /**
|
---|
261 | Performs a UEFI Graphics Output Protocol Blt Video to Buffer operation
|
---|
262 | with extended parameters.
|
---|
263 |
|
---|
264 | @param[out] BltBuffer Output buffer for pixel color data
|
---|
265 | @param[in] SourceX X location within video
|
---|
266 | @param[in] SourceY Y location within video
|
---|
267 | @param[in] DestinationX X location within BltBuffer
|
---|
268 | @param[in] DestinationY Y location within BltBuffer
|
---|
269 | @param[in] Width Width (in pixels)
|
---|
270 | @param[in] Height Height
|
---|
271 | @param[in] Delta Number of bytes in a row of BltBuffer
|
---|
272 |
|
---|
273 | @retval EFI_DEVICE_ERROR - A hardware error occured
|
---|
274 | @retval EFI_INVALID_PARAMETER - Invalid parameter passed in
|
---|
275 | @retval EFI_SUCCESS - The sizes were returned
|
---|
276 |
|
---|
277 | **/
|
---|
278 | EFI_STATUS
|
---|
279 | EFIAPI
|
---|
280 | BltLibVideoToBltBufferEx (
|
---|
281 | OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer,
|
---|
282 | IN UINTN SourceX,
|
---|
283 | IN UINTN SourceY,
|
---|
284 | IN UINTN DestinationX,
|
---|
285 | IN UINTN DestinationY,
|
---|
286 | IN UINTN Width,
|
---|
287 | IN UINTN Height,
|
---|
288 | IN UINTN Delta
|
---|
289 | )
|
---|
290 | {
|
---|
291 | return InternalGopBltCommon (
|
---|
292 | BltBuffer,
|
---|
293 | EfiBltVideoToBltBuffer,
|
---|
294 | SourceX,
|
---|
295 | SourceY,
|
---|
296 | DestinationX,
|
---|
297 | DestinationY,
|
---|
298 | Width,
|
---|
299 | Height,
|
---|
300 | Delta
|
---|
301 | );
|
---|
302 | }
|
---|
303 |
|
---|
304 |
|
---|
305 | /**
|
---|
306 | Performs a UEFI Graphics Output Protocol Blt Buffer to Video operation.
|
---|
307 |
|
---|
308 | @param[in] BltBuffer Output buffer for pixel color data
|
---|
309 | @param[in] DestinationX X location within video
|
---|
310 | @param[in] DestinationY Y location within video
|
---|
311 | @param[in] Width Width (in pixels)
|
---|
312 | @param[in] Height Height
|
---|
313 |
|
---|
314 | @retval EFI_DEVICE_ERROR - A hardware error occured
|
---|
315 | @retval EFI_INVALID_PARAMETER - Invalid parameter passed in
|
---|
316 | @retval EFI_SUCCESS - The sizes were returned
|
---|
317 |
|
---|
318 | **/
|
---|
319 | EFI_STATUS
|
---|
320 | EFIAPI
|
---|
321 | BltLibBufferToVideo (
|
---|
322 | IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer,
|
---|
323 | IN UINTN DestinationX,
|
---|
324 | IN UINTN DestinationY,
|
---|
325 | IN UINTN Width,
|
---|
326 | IN UINTN Height
|
---|
327 | )
|
---|
328 | {
|
---|
329 | return InternalGopBltCommon (
|
---|
330 | BltBuffer,
|
---|
331 | EfiBltBufferToVideo,
|
---|
332 | 0,
|
---|
333 | 0,
|
---|
334 | DestinationX,
|
---|
335 | DestinationY,
|
---|
336 | Width,
|
---|
337 | Height,
|
---|
338 | 0
|
---|
339 | );
|
---|
340 | }
|
---|
341 |
|
---|
342 |
|
---|
343 | /**
|
---|
344 | Performs a UEFI Graphics Output Protocol Blt Buffer to Video operation
|
---|
345 | with extended parameters.
|
---|
346 |
|
---|
347 | @param[in] BltBuffer Output buffer for pixel color data
|
---|
348 | @param[in] SourceX X location within BltBuffer
|
---|
349 | @param[in] SourceY Y location within BltBuffer
|
---|
350 | @param[in] DestinationX X location within video
|
---|
351 | @param[in] DestinationY Y location within video
|
---|
352 | @param[in] Width Width (in pixels)
|
---|
353 | @param[in] Height Height
|
---|
354 | @param[in] Delta Number of bytes in a row of BltBuffer
|
---|
355 |
|
---|
356 | @retval EFI_DEVICE_ERROR - A hardware error occured
|
---|
357 | @retval EFI_INVALID_PARAMETER - Invalid parameter passed in
|
---|
358 | @retval EFI_SUCCESS - The sizes were returned
|
---|
359 |
|
---|
360 | **/
|
---|
361 | EFI_STATUS
|
---|
362 | EFIAPI
|
---|
363 | BltLibBufferToVideoEx (
|
---|
364 | IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer,
|
---|
365 | IN UINTN SourceX,
|
---|
366 | IN UINTN SourceY,
|
---|
367 | IN UINTN DestinationX,
|
---|
368 | IN UINTN DestinationY,
|
---|
369 | IN UINTN Width,
|
---|
370 | IN UINTN Height,
|
---|
371 | IN UINTN Delta
|
---|
372 | )
|
---|
373 | {
|
---|
374 | return InternalGopBltCommon (
|
---|
375 | BltBuffer,
|
---|
376 | EfiBltBufferToVideo,
|
---|
377 | SourceX,
|
---|
378 | SourceY,
|
---|
379 | DestinationX,
|
---|
380 | DestinationY,
|
---|
381 | Width,
|
---|
382 | Height,
|
---|
383 | Delta
|
---|
384 | );
|
---|
385 | }
|
---|
386 |
|
---|
387 |
|
---|
388 | /**
|
---|
389 | Performs a UEFI Graphics Output Protocol Blt Video to Video operation
|
---|
390 |
|
---|
391 | @param[in] SourceX X location within video
|
---|
392 | @param[in] SourceY Y location within video
|
---|
393 | @param[in] DestinationX X location within video
|
---|
394 | @param[in] DestinationY Y location within video
|
---|
395 | @param[in] Width Width (in pixels)
|
---|
396 | @param[in] Height Height
|
---|
397 |
|
---|
398 | @retval EFI_DEVICE_ERROR - A hardware error occured
|
---|
399 | @retval EFI_INVALID_PARAMETER - Invalid parameter passed in
|
---|
400 | @retval EFI_SUCCESS - The sizes were returned
|
---|
401 |
|
---|
402 | **/
|
---|
403 | EFI_STATUS
|
---|
404 | EFIAPI
|
---|
405 | BltLibVideoToVideo (
|
---|
406 | IN UINTN SourceX,
|
---|
407 | IN UINTN SourceY,
|
---|
408 | IN UINTN DestinationX,
|
---|
409 | IN UINTN DestinationY,
|
---|
410 | IN UINTN Width,
|
---|
411 | IN UINTN Height
|
---|
412 | )
|
---|
413 | {
|
---|
414 | return InternalGopBltCommon (
|
---|
415 | NULL,
|
---|
416 | EfiBltVideoToVideo,
|
---|
417 | SourceX,
|
---|
418 | SourceY,
|
---|
419 | DestinationX,
|
---|
420 | DestinationY,
|
---|
421 | Width,
|
---|
422 | Height,
|
---|
423 | 0
|
---|
424 | );
|
---|
425 | }
|
---|
426 |
|
---|
427 | /**
|
---|
428 | Returns the sizes related to the video device
|
---|
429 |
|
---|
430 | @param[out] Width Width (in pixels)
|
---|
431 | @param[out] Height Height (in pixels)
|
---|
432 |
|
---|
433 | @retval EFI_INVALID_PARAMETER - Invalid parameter passed in
|
---|
434 | @retval EFI_SUCCESS - The sizes were returned
|
---|
435 |
|
---|
436 | **/
|
---|
437 | EFI_STATUS
|
---|
438 | EFIAPI
|
---|
439 | BltLibGetSizes (
|
---|
440 | OUT UINTN *Width, OPTIONAL
|
---|
441 | OUT UINTN *Height OPTIONAL
|
---|
442 | )
|
---|
443 | {
|
---|
444 | ASSERT (mGop != NULL);
|
---|
445 |
|
---|
446 | if (Width != NULL) {
|
---|
447 | *Width = mGop->Mode->Info->HorizontalResolution;
|
---|
448 | }
|
---|
449 | if (Height != NULL) {
|
---|
450 | *Height = mGop->Mode->Info->VerticalResolution;
|
---|
451 | }
|
---|
452 |
|
---|
453 | return EFI_SUCCESS;
|
---|
454 | }
|
---|
455 |
|
---|