Commit | Line | Data |
---|---|---|
0284e90c LG |
1 | /** @file\r |
2 | This module install ACPI Boot Graphics Resource Table (BGRT).\r | |
3 | \r | |
53be7721 | 4 | Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r |
77773606 | 5 | Copyright (c) 2016, Microsoft Corporation<BR>\r |
9d510e61 | 6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
0284e90c LG |
7 | **/\r |
8 | \r | |
9 | #include <Uefi.h>\r | |
10 | \r | |
96f0d1ca | 11 | #include <IndustryStandard/Acpi.h>\r |
0284e90c LG |
12 | \r |
13 | #include <Protocol/AcpiTable.h>\r | |
14 | #include <Protocol/GraphicsOutput.h>\r | |
15 | #include <Protocol/BootLogo.h>\r | |
77773606 | 16 | #include <Protocol/BootLogo2.h>\r |
0284e90c LG |
17 | \r |
18 | #include <Guid/EventGroup.h>\r | |
19 | \r | |
20 | #include <Library/BaseLib.h>\r | |
21 | #include <Library/BaseMemoryLib.h>\r | |
22 | #include <Library/MemoryAllocationLib.h>\r | |
23 | #include <Library/UefiBootServicesTableLib.h>\r | |
24 | #include <Library/DebugLib.h>\r | |
e84f07b5 | 25 | #include <Library/PcdLib.h>\r |
53be7721 MK |
26 | #include <Library/SafeIntLib.h>\r |
27 | #include <Library/BmpSupportLib.h>\r | |
0284e90c | 28 | \r |
53be7721 MK |
29 | /**\r |
30 | Update information of logo image drawn on screen.\r | |
31 | \r | |
77773606 MK |
32 | @param[in] This The pointer to the Boot Logo protocol 2 instance.\r |
33 | @param[in] BltBuffer The BLT buffer for logo drawn on screen. If BltBuffer\r | |
34 | is set to NULL, it indicates that logo image is no\r | |
35 | longer on the screen.\r | |
36 | @param[in] DestinationX X coordinate of destination for the BltBuffer.\r | |
37 | @param[in] DestinationY Y coordinate of destination for the BltBuffer.\r | |
38 | @param[in] Width Width of rectangle in BltBuffer in pixels.\r | |
39 | @param[in] Height Hight of rectangle in BltBuffer in pixels.\r | |
40 | \r | |
41 | @retval EFI_SUCCESS The boot logo information was updated.\r | |
42 | @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r | |
43 | @retval EFI_OUT_OF_RESOURCES The logo information was not updated due to\r | |
44 | insufficient memory resources.\r | |
53be7721 MK |
45 | **/\r |
46 | EFI_STATUS\r | |
47 | EFIAPI\r | |
48 | SetBootLogo (\r | |
49 | IN EFI_BOOT_LOGO_PROTOCOL *This,\r | |
50 | IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL,\r | |
51 | IN UINTN DestinationX,\r | |
52 | IN UINTN DestinationY,\r | |
53 | IN UINTN Width,\r | |
54 | IN UINTN Height\r | |
55 | );\r | |
56 | \r | |
77773606 MK |
57 | /**\r |
58 | Update information of logo image drawn on screen.\r | |
59 | \r | |
60 | @param[in] This The pointer to the Boot Logo protocol 2 instance.\r | |
61 | @param[in] BltBuffer The BLT buffer for logo drawn on screen. If BltBuffer\r | |
62 | is set to NULL, it indicates that logo image is no\r | |
63 | longer on the screen.\r | |
64 | @param[in] DestinationX X coordinate of destination for the BltBuffer.\r | |
65 | @param[in] DestinationY Y coordinate of destination for the BltBuffer.\r | |
66 | @param[in] Width Width of rectangle in BltBuffer in pixels.\r | |
67 | @param[in] Height Hight of rectangle in BltBuffer in pixels.\r | |
68 | \r | |
69 | @retval EFI_SUCCESS The boot logo information was updated.\r | |
70 | @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r | |
71 | @retval EFI_OUT_OF_RESOURCES The logo information was not updated due to\r | |
72 | insufficient memory resources.\r | |
73 | **/\r | |
74 | EFI_STATUS\r | |
75 | EFIAPI\r | |
76 | SetBootLogo2 (\r | |
77 | IN EDKII_BOOT_LOGO2_PROTOCOL *This,\r | |
78 | IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL,\r | |
79 | IN UINTN DestinationX,\r | |
80 | IN UINTN DestinationY,\r | |
81 | IN UINTN Width,\r | |
82 | IN UINTN Height\r | |
83 | );\r | |
84 | \r | |
85 | /**\r | |
86 | Get the location of the boot logo on the screen.\r | |
87 | \r | |
88 | @param[in] This The pointer to the Boot Logo Protocol 2 instance\r | |
89 | @param[out] BltBuffer Returns pointer to the GOP BLT buffer that was\r | |
90 | previously registered with SetBootLogo2(). The\r | |
91 | buffer returned must not be modified or freed.\r | |
92 | @param[out] DestinationX Returns the X start position of the GOP BLT buffer\r | |
93 | that was previously registered with SetBootLogo2().\r | |
94 | @param[out] DestinationY Returns the Y start position of the GOP BLT buffer\r | |
95 | that was previously registered with SetBootLogo2().\r | |
96 | @param[out] Width Returns the width of the GOP BLT buffer\r | |
97 | that was previously registered with SetBootLogo2().\r | |
98 | @param[out] Height Returns the height of the GOP BLT buffer\r | |
99 | that was previously registered with SetBootLogo2().\r | |
100 | \r | |
101 | @retval EFI_SUCCESS The location of the boot logo was returned.\r | |
102 | @retval EFI_NOT_READY The boot logo has not been set.\r | |
103 | @retval EFI_INVALID_PARAMETER BltBuffer is NULL.\r | |
104 | @retval EFI_INVALID_PARAMETER DestinationX is NULL.\r | |
105 | @retval EFI_INVALID_PARAMETER DestinationY is NULL.\r | |
106 | @retval EFI_INVALID_PARAMETER Width is NULL.\r | |
107 | @retval EFI_INVALID_PARAMETER Height is NULL.\r | |
108 | **/\r | |
109 | EFI_STATUS\r | |
110 | EFIAPI\r | |
111 | GetBootLogo2 (\r | |
112 | IN EDKII_BOOT_LOGO2_PROTOCOL *This,\r | |
113 | OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **BltBuffer,\r | |
114 | OUT UINTN *DestinationX,\r | |
115 | OUT UINTN *DestinationY,\r | |
116 | OUT UINTN *Width,\r | |
117 | OUT UINTN *Height\r | |
118 | );\r | |
119 | \r | |
53be7721 MK |
120 | //\r |
121 | // Boot Logo Protocol Handle\r | |
0284e90c | 122 | //\r |
53be7721 MK |
123 | EFI_HANDLE mBootLogoHandle = NULL;\r |
124 | \r | |
125 | //\r | |
126 | // Boot Logo Protocol Instance\r | |
0284e90c | 127 | //\r |
53be7721 MK |
128 | EFI_BOOT_LOGO_PROTOCOL mBootLogoProtocolTemplate = {\r |
129 | SetBootLogo\r | |
130 | };\r | |
0284e90c | 131 | \r |
77773606 MK |
132 | ///\r |
133 | /// Boot Logo 2 Protocol instance\r | |
134 | ///\r | |
135 | EDKII_BOOT_LOGO2_PROTOCOL mBootLogo2ProtocolTemplate = {\r | |
136 | SetBootLogo2,\r | |
137 | GetBootLogo2\r | |
138 | };\r | |
139 | \r | |
53be7721 MK |
140 | EFI_EVENT mBootGraphicsReadyToBootEvent;\r |
141 | UINTN mBootGraphicsResourceTableKey = 0;\r | |
0284e90c LG |
142 | BOOLEAN mIsLogoValid = FALSE;\r |
143 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL *mLogoBltBuffer = NULL;\r | |
53be7721 MK |
144 | UINTN mLogoDestX = 0;\r |
145 | UINTN mLogoDestY = 0;\r | |
146 | UINTN mLogoWidth = 0;\r | |
0284e90c | 147 | UINTN mLogoHeight = 0;\r |
53be7721 MK |
148 | BOOLEAN mAcpiBgrtInstalled = FALSE;\r |
149 | BOOLEAN mAcpiBgrtStatusChanged = FALSE;\r | |
150 | BOOLEAN mAcpiBgrtBufferChanged = FALSE;\r | |
0284e90c | 151 | \r |
53be7721 MK |
152 | //\r |
153 | // ACPI Boot Graphics Resource Table template\r | |
154 | //\r | |
0284e90c LG |
155 | EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE mBootGraphicsResourceTableTemplate = {\r |
156 | {\r | |
157 | EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE_SIGNATURE,\r | |
158 | sizeof (EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE),\r | |
159 | EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE_REVISION, // Revision\r | |
160 | 0x00, // Checksum will be updated at runtime\r | |
161 | //\r | |
e84f07b5 | 162 | // It is expected that these values will be updated at EntryPoint.\r |
0284e90c | 163 | //\r |
e84f07b5 SZ |
164 | {0x00}, // OEM ID is a 6 bytes long field\r |
165 | 0x00, // OEM Table ID(8 bytes long)\r | |
166 | 0x00, // OEM Revision\r | |
167 | 0x00, // Creator ID\r | |
168 | 0x00, // Creator Revision\r | |
0284e90c LG |
169 | },\r |
170 | EFI_ACPI_5_0_BGRT_VERSION, // Version\r | |
171 | EFI_ACPI_5_0_BGRT_STATUS_VALID, // Status\r | |
172 | EFI_ACPI_5_0_BGRT_IMAGE_TYPE_BMP, // Image Type\r | |
173 | 0, // Image Address\r | |
174 | 0, // Image Offset X\r | |
175 | 0 // Image Offset Y\r | |
176 | };\r | |
177 | \r | |
0284e90c LG |
178 | /**\r |
179 | Update information of logo image drawn on screen.\r | |
180 | \r | |
181 | @param This The pointer to the Boot Logo protocol instance.\r | |
182 | @param BltBuffer The BLT buffer for logo drawn on screen. If BltBuffer\r | |
183 | is set to NULL, it indicates that logo image is no\r | |
184 | longer on the screen.\r | |
185 | @param DestinationX X coordinate of destination for the BltBuffer.\r | |
186 | @param DestinationY Y coordinate of destination for the BltBuffer.\r | |
187 | @param Width Width of rectangle in BltBuffer in pixels.\r | |
188 | @param Height Hight of rectangle in BltBuffer in pixels.\r | |
189 | \r | |
190 | @retval EFI_SUCCESS The boot logo information was updated.\r | |
191 | @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r | |
192 | @retval EFI_OUT_OF_RESOURCES The logo information was not updated due to\r | |
193 | insufficient memory resources.\r | |
194 | \r | |
195 | **/\r | |
196 | EFI_STATUS\r | |
197 | EFIAPI\r | |
198 | SetBootLogo (\r | |
199 | IN EFI_BOOT_LOGO_PROTOCOL *This,\r | |
200 | IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL,\r | |
201 | IN UINTN DestinationX,\r | |
202 | IN UINTN DestinationY,\r | |
203 | IN UINTN Width,\r | |
204 | IN UINTN Height\r | |
205 | )\r | |
77773606 MK |
206 | {\r |
207 | //\r | |
208 | // Call same service in Boot Logo 2 Protocol\r | |
209 | //\r | |
210 | return SetBootLogo2 (\r | |
211 | &mBootLogo2ProtocolTemplate,\r | |
212 | BltBuffer,\r | |
213 | DestinationX,\r | |
214 | DestinationY,\r | |
215 | Width,\r | |
216 | Height\r | |
217 | );\r | |
218 | }\r | |
219 | \r | |
220 | /**\r | |
221 | Update information of logo image drawn on screen.\r | |
222 | \r | |
223 | @param[in] This The pointer to the Boot Logo protocol 2 instance.\r | |
224 | @param[in] BltBuffer The BLT buffer for logo drawn on screen. If BltBuffer\r | |
225 | is set to NULL, it indicates that logo image is no\r | |
226 | longer on the screen.\r | |
227 | @param[in] DestinationX X coordinate of destination for the BltBuffer.\r | |
228 | @param[in] DestinationY Y coordinate of destination for the BltBuffer.\r | |
229 | @param[in] Width Width of rectangle in BltBuffer in pixels.\r | |
230 | @param[in] Height Hight of rectangle in BltBuffer in pixels.\r | |
231 | \r | |
232 | @retval EFI_SUCCESS The boot logo information was updated.\r | |
233 | @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r | |
234 | @retval EFI_OUT_OF_RESOURCES The logo information was not updated due to\r | |
235 | insufficient memory resources.\r | |
236 | **/\r | |
237 | EFI_STATUS\r | |
238 | EFIAPI\r | |
239 | SetBootLogo2 (\r | |
240 | IN EDKII_BOOT_LOGO2_PROTOCOL *This,\r | |
241 | IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL,\r | |
242 | IN UINTN DestinationX,\r | |
243 | IN UINTN DestinationY,\r | |
244 | IN UINTN Width,\r | |
245 | IN UINTN Height\r | |
246 | )\r | |
0284e90c | 247 | {\r |
53be7721 MK |
248 | EFI_STATUS Status;\r |
249 | UINTN BufferSize;\r | |
250 | UINT32 Result32;\r | |
a46c3657 | 251 | \r |
0284e90c LG |
252 | if (BltBuffer == NULL) {\r |
253 | mIsLogoValid = FALSE;\r | |
cbafa15e | 254 | mAcpiBgrtStatusChanged = TRUE;\r |
0284e90c LG |
255 | return EFI_SUCCESS;\r |
256 | }\r | |
257 | \r | |
53be7721 MK |
258 | //\r |
259 | // Width and height are not allowed to be zero.\r | |
260 | //\r | |
0284e90c LG |
261 | if (Width == 0 || Height == 0) {\r |
262 | return EFI_INVALID_PARAMETER;\r | |
263 | }\r | |
53be7721 MK |
264 | \r |
265 | //\r | |
266 | // Verify destination, width, and height do not overflow 32-bit values.\r | |
267 | // The Boot Graphics Resource Table only has 32-bit fields for these values.\r | |
268 | //\r | |
269 | Status = SafeUintnToUint32 (DestinationX, &Result32);\r | |
270 | if (EFI_ERROR (Status)) {\r | |
271 | return EFI_INVALID_PARAMETER;\r | |
0284e90c | 272 | }\r |
53be7721 MK |
273 | Status = SafeUintnToUint32 (DestinationY, &Result32);\r |
274 | if (EFI_ERROR (Status)) {\r | |
275 | return EFI_INVALID_PARAMETER;\r | |
276 | }\r | |
277 | Status = SafeUintnToUint32 (Width, &Result32);\r | |
278 | if (EFI_ERROR (Status)) {\r | |
279 | return EFI_INVALID_PARAMETER;\r | |
280 | }\r | |
281 | Status = SafeUintnToUint32 (Height, &Result32);\r | |
282 | if (EFI_ERROR (Status)) {\r | |
283 | return EFI_INVALID_PARAMETER;\r | |
284 | }\r | |
285 | \r | |
a46c3657 | 286 | //\r |
53be7721 MK |
287 | // Ensure the Height * Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) does\r |
288 | // not overflow UINTN\r | |
a46c3657 | 289 | //\r |
53be7721 MK |
290 | Status = SafeUintnMult (\r |
291 | Width,\r | |
292 | Height,\r | |
293 | &BufferSize\r | |
294 | );\r | |
295 | if (EFI_ERROR (Status)) {\r | |
296 | return EFI_UNSUPPORTED;\r | |
297 | }\r | |
298 | Status = SafeUintnMult (\r | |
299 | BufferSize,\r | |
300 | sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL),\r | |
301 | &BufferSize\r | |
302 | );\r | |
303 | if (EFI_ERROR (Status)) {\r | |
a46c3657 ED |
304 | return EFI_UNSUPPORTED;\r |
305 | }\r | |
53be7721 | 306 | \r |
a46c3657 | 307 | //\r |
53be7721 | 308 | // Update state\r |
a46c3657 | 309 | //\r |
53be7721 MK |
310 | mAcpiBgrtBufferChanged = TRUE;\r |
311 | \r | |
312 | //\r | |
313 | // Free old logo buffer\r | |
314 | //\r | |
315 | if (mLogoBltBuffer != NULL) {\r | |
316 | FreePool (mLogoBltBuffer);\r | |
317 | mLogoBltBuffer = NULL;\r | |
a46c3657 | 318 | }\r |
0284e90c | 319 | \r |
53be7721 MK |
320 | //\r |
321 | // Allocate new logo buffer\r | |
322 | //\r | |
323 | mLogoBltBuffer = AllocateCopyPool (BufferSize, BltBuffer);\r | |
0284e90c LG |
324 | if (mLogoBltBuffer == NULL) {\r |
325 | return EFI_OUT_OF_RESOURCES;\r | |
326 | }\r | |
53be7721 MK |
327 | \r |
328 | mLogoDestX = DestinationX;\r | |
329 | mLogoDestY = DestinationY;\r | |
330 | mLogoWidth = Width;\r | |
331 | mLogoHeight = Height;\r | |
0284e90c LG |
332 | mIsLogoValid = TRUE;\r |
333 | \r | |
334 | return EFI_SUCCESS;\r | |
335 | }\r | |
336 | \r | |
77773606 MK |
337 | /**\r |
338 | Get the location of the boot logo on the screen.\r | |
339 | \r | |
340 | @param[in] This The pointer to the Boot Logo Protocol 2 instance\r | |
341 | @param[out] BltBuffer Returns pointer to the GOP BLT buffer that was\r | |
342 | previously registered with SetBootLogo2(). The\r | |
343 | buffer returned must not be modified or freed.\r | |
344 | @param[out] DestinationX Returns the X start position of the GOP BLT buffer\r | |
345 | that was previously registered with SetBootLogo2().\r | |
346 | @param[out] DestinationY Returns the Y start position of the GOP BLT buffer\r | |
347 | that was previously registered with SetBootLogo2().\r | |
348 | @param[out] Width Returns the width of the GOP BLT buffer\r | |
349 | that was previously registered with SetBootLogo2().\r | |
350 | @param[out] Height Returns the height of the GOP BLT buffer\r | |
351 | that was previously registered with SetBootLogo2().\r | |
352 | \r | |
353 | @retval EFI_SUCCESS The location of the boot logo was returned.\r | |
354 | @retval EFI_NOT_READY The boot logo has not been set.\r | |
355 | @retval EFI_INVALID_PARAMETER BltBuffer is NULL.\r | |
356 | @retval EFI_INVALID_PARAMETER DestinationX is NULL.\r | |
357 | @retval EFI_INVALID_PARAMETER DestinationY is NULL.\r | |
358 | @retval EFI_INVALID_PARAMETER Width is NULL.\r | |
359 | @retval EFI_INVALID_PARAMETER Height is NULL.\r | |
360 | **/\r | |
361 | EFI_STATUS\r | |
362 | EFIAPI\r | |
363 | GetBootLogo2 (\r | |
364 | IN EDKII_BOOT_LOGO2_PROTOCOL *This,\r | |
365 | OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **BltBuffer,\r | |
366 | OUT UINTN *DestinationX,\r | |
367 | OUT UINTN *DestinationY,\r | |
368 | OUT UINTN *Width,\r | |
369 | OUT UINTN *Height\r | |
370 | )\r | |
371 | {\r | |
372 | //\r | |
373 | // If the boot logo has not been set with SetBootLogo() or SetBootLogo() was\r | |
374 | // called with a NULL BltBuffer then the boot logo is not valid and\r | |
375 | // EFI_NOT_READY is returned.\r | |
376 | //\r | |
377 | if (mLogoBltBuffer == NULL) {\r | |
378 | DEBUG ((DEBUG_ERROR, "Request to get boot logo location before boot logo has been set.\n"));\r | |
379 | return EFI_NOT_READY;\r | |
380 | }\r | |
381 | \r | |
382 | //\r | |
383 | // Make sure none of the boot logo location parameters are NULL.\r | |
384 | //\r | |
385 | if (BltBuffer == NULL || DestinationX == NULL || DestinationY == NULL ||\r | |
386 | Width == NULL || Height == NULL) {\r | |
387 | return EFI_INVALID_PARAMETER;\r | |
388 | }\r | |
389 | \r | |
390 | //\r | |
391 | // Boot logo is valid. Return values from module globals.\r | |
392 | //\r | |
393 | *BltBuffer = mLogoBltBuffer;\r | |
394 | *DestinationX = mLogoDestX;\r | |
395 | *DestinationY = mLogoDestY;\r | |
396 | *Width = mLogoWidth;\r | |
397 | *Height = mLogoHeight;\r | |
398 | \r | |
399 | return EFI_SUCCESS;\r | |
400 | }\r | |
401 | \r | |
0284e90c | 402 | /**\r |
53be7721 MK |
403 | Notify function for event group EFI_EVENT_GROUP_READY_TO_BOOT. This is used to\r |
404 | install the Boot Graphics Resource Table.\r | |
0284e90c | 405 | \r |
53be7721 MK |
406 | @param[in] Event The Event that is being processed.\r |
407 | @param[in] Context The Event Context.\r | |
0284e90c LG |
408 | \r |
409 | **/\r | |
410 | VOID\r | |
53be7721 MK |
411 | EFIAPI\r |
412 | BgrtReadyToBootEventNotify (\r | |
413 | IN EFI_EVENT Event,\r | |
414 | IN VOID *Context\r | |
0284e90c LG |
415 | )\r |
416 | {\r | |
53be7721 MK |
417 | EFI_STATUS Status;\r |
418 | EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol;\r | |
419 | VOID *ImageBuffer;\r | |
420 | UINT32 BmpSize;\r | |
0284e90c | 421 | \r |
0284e90c LG |
422 | //\r |
423 | // Get ACPI Table protocol.\r | |
424 | //\r | |
53be7721 MK |
425 | Status = gBS->LocateProtocol (\r |
426 | &gEfiAcpiTableProtocolGuid,\r | |
427 | NULL,\r | |
428 | (VOID **) &AcpiTableProtocol\r | |
429 | );\r | |
0284e90c | 430 | if (EFI_ERROR (Status)) {\r |
53be7721 | 431 | return;\r |
0284e90c LG |
432 | }\r |
433 | \r | |
434 | //\r | |
cbafa15e | 435 | // Check whether Boot Graphics Resource Table is already installed.\r |
0284e90c | 436 | //\r |
cbafa15e | 437 | if (mAcpiBgrtInstalled) {\r |
438 | if (!mAcpiBgrtStatusChanged && !mAcpiBgrtBufferChanged) {\r | |
439 | //\r | |
440 | // Nothing has changed\r | |
441 | //\r | |
53be7721 | 442 | return;\r |
cbafa15e | 443 | } else {\r |
444 | //\r | |
53be7721 | 445 | // If BGRT data change happens, then uninstall orignal AcpiTable first\r |
cbafa15e | 446 | //\r |
447 | Status = AcpiTableProtocol->UninstallAcpiTable (\r | |
448 | AcpiTableProtocol,\r | |
449 | mBootGraphicsResourceTableKey\r | |
450 | );\r | |
451 | if (EFI_ERROR (Status)) {\r | |
53be7721 MK |
452 | return;\r |
453 | }\r | |
cbafa15e | 454 | }\r |
455 | } else {\r | |
456 | //\r | |
53be7721 | 457 | // Check whether Logo exists\r |
cbafa15e | 458 | //\r |
53be7721 MK |
459 | if (mLogoBltBuffer == NULL) {\r |
460 | return;\r | |
cbafa15e | 461 | }\r |
0284e90c LG |
462 | }\r |
463 | \r | |
cbafa15e | 464 | if (mAcpiBgrtBufferChanged) {\r |
465 | //\r | |
53be7721 | 466 | // Free the old BMP image buffer\r |
cbafa15e | 467 | //\r |
53be7721 MK |
468 | ImageBuffer = (UINT8 *)(UINTN)mBootGraphicsResourceTableTemplate.ImageAddress;\r |
469 | if (ImageBuffer != NULL) {\r | |
470 | FreePool (ImageBuffer);\r | |
cbafa15e | 471 | }\r |
0284e90c | 472 | \r |
cbafa15e | 473 | //\r |
53be7721 MK |
474 | // Convert GOP Blt buffer to BMP image. Pass in ImageBuffer set to NULL\r |
475 | // so the BMP image is allocated by TranslateGopBltToBmp().\r | |
cbafa15e | 476 | //\r |
53be7721 MK |
477 | ImageBuffer = NULL;\r |
478 | Status = TranslateGopBltToBmp (\r | |
479 | mLogoBltBuffer,\r | |
480 | (UINT32)mLogoHeight,\r | |
481 | (UINT32)mLogoWidth,\r | |
482 | &ImageBuffer,\r | |
483 | &BmpSize\r | |
484 | );\r | |
485 | if (EFI_ERROR (Status)) {\r | |
486 | return;\r | |
a46c3657 | 487 | }\r |
4c58575e CZ |
488 | \r |
489 | //\r | |
53be7721 | 490 | // Free the logo buffer\r |
cbafa15e | 491 | //\r |
cbafa15e | 492 | FreePool (mLogoBltBuffer);\r |
493 | mLogoBltBuffer = NULL;\r | |
494 | \r | |
53be7721 MK |
495 | //\r |
496 | // Update BMP image fields of the Boot Graphics Resource Table\r | |
497 | //\r | |
498 | mBootGraphicsResourceTableTemplate.ImageAddress = (UINT64)(UINTN)ImageBuffer;\r | |
499 | mBootGraphicsResourceTableTemplate.ImageOffsetX = (UINT32)mLogoDestX;\r | |
500 | mBootGraphicsResourceTableTemplate.ImageOffsetY = (UINT32)mLogoDestY;\r | |
0284e90c | 501 | }\r |
0284e90c | 502 | \r |
53be7721 MK |
503 | //\r |
504 | // Update Status field of Boot Graphics Resource Table\r | |
505 | //\r | |
506 | if (mIsLogoValid) {\r | |
507 | mBootGraphicsResourceTableTemplate.Status = EFI_ACPI_5_0_BGRT_STATUS_VALID;\r | |
508 | } else {\r | |
509 | mBootGraphicsResourceTableTemplate.Status = EFI_ACPI_5_0_BGRT_STATUS_INVALID;\r | |
510 | }\r | |
0284e90c LG |
511 | \r |
512 | //\r | |
53be7721 | 513 | // Update Checksum of Boot Graphics Resource Table\r |
0284e90c | 514 | //\r |
53be7721 MK |
515 | mBootGraphicsResourceTableTemplate.Header.Checksum = 0;\r |
516 | mBootGraphicsResourceTableTemplate.Header.Checksum =\r | |
517 | CalculateCheckSum8 (\r | |
518 | (UINT8 *)&mBootGraphicsResourceTableTemplate,\r | |
519 | sizeof (EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE)\r | |
520 | );\r | |
0284e90c LG |
521 | \r |
522 | //\r | |
523 | // Publish Boot Graphics Resource Table.\r | |
524 | //\r | |
525 | Status = AcpiTableProtocol->InstallAcpiTable (\r | |
526 | AcpiTableProtocol,\r | |
527 | &mBootGraphicsResourceTableTemplate,\r | |
528 | sizeof (EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE),\r | |
529 | &mBootGraphicsResourceTableKey\r | |
530 | );\r | |
531 | if (EFI_ERROR (Status)) {\r | |
53be7721 | 532 | return;\r |
0284e90c LG |
533 | }\r |
534 | \r | |
53be7721 | 535 | mAcpiBgrtInstalled = TRUE;\r |
cbafa15e | 536 | mAcpiBgrtStatusChanged = FALSE;\r |
537 | mAcpiBgrtBufferChanged = FALSE;\r | |
0284e90c LG |
538 | }\r |
539 | \r | |
540 | /**\r | |
541 | The module Entry Point of the Boot Graphics Resource Table DXE driver.\r | |
542 | \r | |
543 | @param[in] ImageHandle The firmware allocated handle for the EFI image.\r | |
544 | @param[in] SystemTable A pointer to the EFI System Table.\r | |
545 | \r | |
546 | @retval EFI_SUCCESS The entry point is executed successfully.\r | |
547 | @retval Other Some error occurs when executing this entry point.\r | |
548 | \r | |
549 | **/\r | |
550 | EFI_STATUS\r | |
551 | EFIAPI\r | |
552 | BootGraphicsDxeEntryPoint (\r | |
53be7721 MK |
553 | IN EFI_HANDLE ImageHandle,\r |
554 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
0284e90c LG |
555 | )\r |
556 | {\r | |
53be7721 MK |
557 | EFI_STATUS Status;\r |
558 | EFI_ACPI_DESCRIPTION_HEADER *Header;\r | |
e84f07b5 | 559 | \r |
53be7721 MK |
560 | //\r |
561 | // Update Header fields of Boot Graphics Resource Table from PCDs\r | |
562 | //\r | |
563 | Header = &mBootGraphicsResourceTableTemplate.Header;\r | |
564 | ZeroMem (Header->OemId, sizeof (Header->OemId));\r | |
e84f07b5 | 565 | CopyMem (\r |
53be7721 | 566 | Header->OemId,\r |
e84f07b5 | 567 | PcdGetPtr (PcdAcpiDefaultOemId),\r |
53be7721 | 568 | MIN (PcdGetSize (PcdAcpiDefaultOemId), sizeof (Header->OemId))\r |
e84f07b5 | 569 | );\r |
53be7721 MK |
570 | WriteUnaligned64 (&Header->OemTableId, PcdGet64 (PcdAcpiDefaultOemTableId));\r |
571 | Header->OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision);\r | |
572 | Header->CreatorId = PcdGet32 (PcdAcpiDefaultCreatorId);\r | |
573 | Header->CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision);\r | |
0284e90c LG |
574 | \r |
575 | //\r | |
77773606 | 576 | // Install Boot Logo and Boot Logo 2 Protocols.\r |
0284e90c LG |
577 | //\r |
578 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
579 | &mBootLogoHandle,\r | |
580 | &gEfiBootLogoProtocolGuid,\r | |
581 | &mBootLogoProtocolTemplate,\r | |
77773606 MK |
582 | &gEdkiiBootLogo2ProtocolGuid,\r |
583 | &mBootLogo2ProtocolTemplate,\r | |
0284e90c LG |
584 | NULL\r |
585 | );\r | |
586 | ASSERT_EFI_ERROR (Status);\r | |
587 | \r | |
588 | //\r | |
589 | // Register notify function to install BGRT on ReadyToBoot Event.\r | |
590 | //\r | |
591 | Status = gBS->CreateEventEx (\r | |
592 | EVT_NOTIFY_SIGNAL,\r | |
593 | TPL_CALLBACK,\r | |
594 | BgrtReadyToBootEventNotify,\r | |
595 | NULL,\r | |
596 | &gEfiEventReadyToBootGuid,\r | |
597 | &mBootGraphicsReadyToBootEvent\r | |
598 | );\r | |
599 | ASSERT_EFI_ERROR (Status);\r | |
600 | \r | |
601 | return Status;\r | |
602 | }\r |