]>
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 | |
1436aea4 | 135 | EDKII_BOOT_LOGO2_PROTOCOL mBootLogo2ProtocolTemplate = {\r |
77773606 MK |
136 | SetBootLogo2,\r |
137 | GetBootLogo2\r | |
138 | };\r | |
139 | \r | |
53be7721 MK |
140 | EFI_EVENT mBootGraphicsReadyToBootEvent;\r |
141 | UINTN mBootGraphicsResourceTableKey = 0;\r | |
1436aea4 MK |
142 | BOOLEAN mIsLogoValid = FALSE;\r |
143 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL *mLogoBltBuffer = NULL;\r | |
144 | UINTN mLogoDestX = 0;\r | |
145 | UINTN mLogoDestY = 0;\r | |
146 | UINTN mLogoWidth = 0;\r | |
147 | UINTN mLogoHeight = 0;\r | |
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 | |
1436aea4 | 155 | EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE mBootGraphicsResourceTableTemplate = {\r |
0284e90c LG |
156 | {\r |
157 | EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE_SIGNATURE,\r | |
158 | sizeof (EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE),\r | |
1436aea4 MK |
159 | EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE_REVISION, // Revision\r |
160 | 0x00, // Checksum will be updated at runtime\r | |
0284e90c | 161 | //\r |
e84f07b5 | 162 | // It is expected that these values will be updated at EntryPoint.\r |
0284e90c | 163 | //\r |
1436aea4 | 164 | { 0x00 }, // OEM ID is a 6 bytes long field\r |
e84f07b5 SZ |
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 | |
1436aea4 MK |
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 | |
0284e90c | 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 | 252 | if (BltBuffer == NULL) {\r |
1436aea4 | 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 | |
1436aea4 | 261 | if ((Width == 0) || (Height == 0)) {\r |
0284e90c LG |
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 |
1436aea4 | 273 | \r |
53be7721 MK |
274 | Status = SafeUintnToUint32 (DestinationY, &Result32);\r |
275 | if (EFI_ERROR (Status)) {\r | |
276 | return EFI_INVALID_PARAMETER;\r | |
277 | }\r | |
1436aea4 | 278 | \r |
53be7721 MK |
279 | Status = SafeUintnToUint32 (Width, &Result32);\r |
280 | if (EFI_ERROR (Status)) {\r | |
281 | return EFI_INVALID_PARAMETER;\r | |
282 | }\r | |
1436aea4 | 283 | \r |
53be7721 MK |
284 | Status = SafeUintnToUint32 (Height, &Result32);\r |
285 | if (EFI_ERROR (Status)) {\r | |
286 | return EFI_INVALID_PARAMETER;\r | |
287 | }\r | |
288 | \r | |
a46c3657 | 289 | //\r |
53be7721 MK |
290 | // Ensure the Height * Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) does\r |
291 | // not overflow UINTN\r | |
a46c3657 | 292 | //\r |
53be7721 MK |
293 | Status = SafeUintnMult (\r |
294 | Width,\r | |
295 | Height,\r | |
296 | &BufferSize\r | |
297 | );\r | |
298 | if (EFI_ERROR (Status)) {\r | |
299 | return EFI_UNSUPPORTED;\r | |
300 | }\r | |
1436aea4 | 301 | \r |
53be7721 MK |
302 | Status = SafeUintnMult (\r |
303 | BufferSize,\r | |
304 | sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL),\r | |
305 | &BufferSize\r | |
306 | );\r | |
307 | if (EFI_ERROR (Status)) {\r | |
a46c3657 ED |
308 | return EFI_UNSUPPORTED;\r |
309 | }\r | |
53be7721 | 310 | \r |
a46c3657 | 311 | //\r |
53be7721 | 312 | // Update state\r |
a46c3657 | 313 | //\r |
53be7721 MK |
314 | mAcpiBgrtBufferChanged = TRUE;\r |
315 | \r | |
316 | //\r | |
317 | // Free old logo buffer\r | |
318 | //\r | |
319 | if (mLogoBltBuffer != NULL) {\r | |
320 | FreePool (mLogoBltBuffer);\r | |
321 | mLogoBltBuffer = NULL;\r | |
a46c3657 | 322 | }\r |
0284e90c | 323 | \r |
53be7721 MK |
324 | //\r |
325 | // Allocate new logo buffer\r | |
326 | //\r | |
327 | mLogoBltBuffer = AllocateCopyPool (BufferSize, BltBuffer);\r | |
0284e90c LG |
328 | if (mLogoBltBuffer == NULL) {\r |
329 | return EFI_OUT_OF_RESOURCES;\r | |
330 | }\r | |
53be7721 MK |
331 | \r |
332 | mLogoDestX = DestinationX;\r | |
333 | mLogoDestY = DestinationY;\r | |
334 | mLogoWidth = Width;\r | |
335 | mLogoHeight = Height;\r | |
0284e90c LG |
336 | mIsLogoValid = TRUE;\r |
337 | \r | |
338 | return EFI_SUCCESS;\r | |
339 | }\r | |
340 | \r | |
77773606 MK |
341 | /**\r |
342 | Get the location of the boot logo on the screen.\r | |
343 | \r | |
344 | @param[in] This The pointer to the Boot Logo Protocol 2 instance\r | |
345 | @param[out] BltBuffer Returns pointer to the GOP BLT buffer that was\r | |
346 | previously registered with SetBootLogo2(). The\r | |
347 | buffer returned must not be modified or freed.\r | |
348 | @param[out] DestinationX Returns the X start position of the GOP BLT buffer\r | |
349 | that was previously registered with SetBootLogo2().\r | |
350 | @param[out] DestinationY Returns the Y start position of the GOP BLT buffer\r | |
351 | that was previously registered with SetBootLogo2().\r | |
352 | @param[out] Width Returns the width of the GOP BLT buffer\r | |
353 | that was previously registered with SetBootLogo2().\r | |
354 | @param[out] Height Returns the height of the GOP BLT buffer\r | |
355 | that was previously registered with SetBootLogo2().\r | |
356 | \r | |
357 | @retval EFI_SUCCESS The location of the boot logo was returned.\r | |
358 | @retval EFI_NOT_READY The boot logo has not been set.\r | |
359 | @retval EFI_INVALID_PARAMETER BltBuffer is NULL.\r | |
360 | @retval EFI_INVALID_PARAMETER DestinationX is NULL.\r | |
361 | @retval EFI_INVALID_PARAMETER DestinationY is NULL.\r | |
362 | @retval EFI_INVALID_PARAMETER Width is NULL.\r | |
363 | @retval EFI_INVALID_PARAMETER Height is NULL.\r | |
364 | **/\r | |
365 | EFI_STATUS\r | |
366 | EFIAPI\r | |
367 | GetBootLogo2 (\r | |
368 | IN EDKII_BOOT_LOGO2_PROTOCOL *This,\r | |
369 | OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **BltBuffer,\r | |
370 | OUT UINTN *DestinationX,\r | |
371 | OUT UINTN *DestinationY,\r | |
372 | OUT UINTN *Width,\r | |
373 | OUT UINTN *Height\r | |
374 | )\r | |
375 | {\r | |
376 | //\r | |
377 | // If the boot logo has not been set with SetBootLogo() or SetBootLogo() was\r | |
378 | // called with a NULL BltBuffer then the boot logo is not valid and\r | |
379 | // EFI_NOT_READY is returned.\r | |
380 | //\r | |
381 | if (mLogoBltBuffer == NULL) {\r | |
382 | DEBUG ((DEBUG_ERROR, "Request to get boot logo location before boot logo has been set.\n"));\r | |
383 | return EFI_NOT_READY;\r | |
384 | }\r | |
385 | \r | |
386 | //\r | |
387 | // Make sure none of the boot logo location parameters are NULL.\r | |
388 | //\r | |
1436aea4 MK |
389 | if ((BltBuffer == NULL) || (DestinationX == NULL) || (DestinationY == NULL) ||\r |
390 | (Width == NULL) || (Height == NULL))\r | |
391 | {\r | |
77773606 MK |
392 | return EFI_INVALID_PARAMETER;\r |
393 | }\r | |
394 | \r | |
395 | //\r | |
396 | // Boot logo is valid. Return values from module globals.\r | |
397 | //\r | |
398 | *BltBuffer = mLogoBltBuffer;\r | |
399 | *DestinationX = mLogoDestX;\r | |
400 | *DestinationY = mLogoDestY;\r | |
401 | *Width = mLogoWidth;\r | |
402 | *Height = mLogoHeight;\r | |
403 | \r | |
404 | return EFI_SUCCESS;\r | |
405 | }\r | |
406 | \r | |
0284e90c | 407 | /**\r |
53be7721 MK |
408 | Notify function for event group EFI_EVENT_GROUP_READY_TO_BOOT. This is used to\r |
409 | install the Boot Graphics Resource Table.\r | |
0284e90c | 410 | \r |
53be7721 MK |
411 | @param[in] Event The Event that is being processed.\r |
412 | @param[in] Context The Event Context.\r | |
0284e90c LG |
413 | \r |
414 | **/\r | |
415 | VOID\r | |
53be7721 MK |
416 | EFIAPI\r |
417 | BgrtReadyToBootEventNotify (\r | |
418 | IN EFI_EVENT Event,\r | |
419 | IN VOID *Context\r | |
0284e90c LG |
420 | )\r |
421 | {\r | |
53be7721 MK |
422 | EFI_STATUS Status;\r |
423 | EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol;\r | |
424 | VOID *ImageBuffer;\r | |
425 | UINT32 BmpSize;\r | |
0284e90c | 426 | \r |
0284e90c LG |
427 | //\r |
428 | // Get ACPI Table protocol.\r | |
429 | //\r | |
53be7721 MK |
430 | Status = gBS->LocateProtocol (\r |
431 | &gEfiAcpiTableProtocolGuid,\r | |
432 | NULL,\r | |
1436aea4 | 433 | (VOID **)&AcpiTableProtocol\r |
53be7721 | 434 | );\r |
0284e90c | 435 | if (EFI_ERROR (Status)) {\r |
53be7721 | 436 | return;\r |
0284e90c LG |
437 | }\r |
438 | \r | |
439 | //\r | |
cbafa15e | 440 | // Check whether Boot Graphics Resource Table is already installed.\r |
0284e90c | 441 | //\r |
cbafa15e | 442 | if (mAcpiBgrtInstalled) {\r |
443 | if (!mAcpiBgrtStatusChanged && !mAcpiBgrtBufferChanged) {\r | |
444 | //\r | |
445 | // Nothing has changed\r | |
446 | //\r | |
53be7721 | 447 | return;\r |
cbafa15e | 448 | } else {\r |
449 | //\r | |
53be7721 | 450 | // If BGRT data change happens, then uninstall orignal AcpiTable first\r |
cbafa15e | 451 | //\r |
452 | Status = AcpiTableProtocol->UninstallAcpiTable (\r | |
453 | AcpiTableProtocol,\r | |
454 | mBootGraphicsResourceTableKey\r | |
455 | );\r | |
456 | if (EFI_ERROR (Status)) {\r | |
53be7721 MK |
457 | return;\r |
458 | }\r | |
cbafa15e | 459 | }\r |
460 | } else {\r | |
461 | //\r | |
53be7721 | 462 | // Check whether Logo exists\r |
cbafa15e | 463 | //\r |
53be7721 MK |
464 | if (mLogoBltBuffer == NULL) {\r |
465 | return;\r | |
cbafa15e | 466 | }\r |
0284e90c LG |
467 | }\r |
468 | \r | |
cbafa15e | 469 | if (mAcpiBgrtBufferChanged) {\r |
470 | //\r | |
53be7721 | 471 | // Free the old BMP image buffer\r |
cbafa15e | 472 | //\r |
53be7721 MK |
473 | ImageBuffer = (UINT8 *)(UINTN)mBootGraphicsResourceTableTemplate.ImageAddress;\r |
474 | if (ImageBuffer != NULL) {\r | |
475 | FreePool (ImageBuffer);\r | |
cbafa15e | 476 | }\r |
0284e90c | 477 | \r |
cbafa15e | 478 | //\r |
53be7721 MK |
479 | // Convert GOP Blt buffer to BMP image. Pass in ImageBuffer set to NULL\r |
480 | // so the BMP image is allocated by TranslateGopBltToBmp().\r | |
cbafa15e | 481 | //\r |
53be7721 | 482 | ImageBuffer = NULL;\r |
1436aea4 MK |
483 | Status = TranslateGopBltToBmp (\r |
484 | mLogoBltBuffer,\r | |
485 | (UINT32)mLogoHeight,\r | |
486 | (UINT32)mLogoWidth,\r | |
487 | &ImageBuffer,\r | |
488 | &BmpSize\r | |
489 | );\r | |
53be7721 MK |
490 | if (EFI_ERROR (Status)) {\r |
491 | return;\r | |
a46c3657 | 492 | }\r |
4c58575e CZ |
493 | \r |
494 | //\r | |
53be7721 | 495 | // Free the logo buffer\r |
cbafa15e | 496 | //\r |
cbafa15e | 497 | FreePool (mLogoBltBuffer);\r |
498 | mLogoBltBuffer = NULL;\r | |
499 | \r | |
53be7721 MK |
500 | //\r |
501 | // Update BMP image fields of the Boot Graphics Resource Table\r | |
502 | //\r | |
503 | mBootGraphicsResourceTableTemplate.ImageAddress = (UINT64)(UINTN)ImageBuffer;\r | |
504 | mBootGraphicsResourceTableTemplate.ImageOffsetX = (UINT32)mLogoDestX;\r | |
505 | mBootGraphicsResourceTableTemplate.ImageOffsetY = (UINT32)mLogoDestY;\r | |
0284e90c | 506 | }\r |
0284e90c | 507 | \r |
53be7721 MK |
508 | //\r |
509 | // Update Status field of Boot Graphics Resource Table\r | |
510 | //\r | |
511 | if (mIsLogoValid) {\r | |
512 | mBootGraphicsResourceTableTemplate.Status = EFI_ACPI_5_0_BGRT_STATUS_VALID;\r | |
513 | } else {\r | |
514 | mBootGraphicsResourceTableTemplate.Status = EFI_ACPI_5_0_BGRT_STATUS_INVALID;\r | |
515 | }\r | |
0284e90c LG |
516 | \r |
517 | //\r | |
53be7721 | 518 | // Update Checksum of Boot Graphics Resource Table\r |
0284e90c | 519 | //\r |
53be7721 MK |
520 | mBootGraphicsResourceTableTemplate.Header.Checksum = 0;\r |
521 | mBootGraphicsResourceTableTemplate.Header.Checksum =\r | |
522 | CalculateCheckSum8 (\r | |
523 | (UINT8 *)&mBootGraphicsResourceTableTemplate,\r | |
524 | sizeof (EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE)\r | |
525 | );\r | |
0284e90c LG |
526 | \r |
527 | //\r | |
528 | // Publish Boot Graphics Resource Table.\r | |
529 | //\r | |
530 | Status = AcpiTableProtocol->InstallAcpiTable (\r | |
531 | AcpiTableProtocol,\r | |
532 | &mBootGraphicsResourceTableTemplate,\r | |
533 | sizeof (EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE),\r | |
534 | &mBootGraphicsResourceTableKey\r | |
535 | );\r | |
536 | if (EFI_ERROR (Status)) {\r | |
53be7721 | 537 | return;\r |
0284e90c LG |
538 | }\r |
539 | \r | |
53be7721 | 540 | mAcpiBgrtInstalled = TRUE;\r |
cbafa15e | 541 | mAcpiBgrtStatusChanged = FALSE;\r |
542 | mAcpiBgrtBufferChanged = FALSE;\r | |
0284e90c LG |
543 | }\r |
544 | \r | |
545 | /**\r | |
546 | The module Entry Point of the Boot Graphics Resource Table DXE driver.\r | |
547 | \r | |
548 | @param[in] ImageHandle The firmware allocated handle for the EFI image.\r | |
549 | @param[in] SystemTable A pointer to the EFI System Table.\r | |
550 | \r | |
551 | @retval EFI_SUCCESS The entry point is executed successfully.\r | |
552 | @retval Other Some error occurs when executing this entry point.\r | |
553 | \r | |
554 | **/\r | |
555 | EFI_STATUS\r | |
556 | EFIAPI\r | |
557 | BootGraphicsDxeEntryPoint (\r | |
53be7721 MK |
558 | IN EFI_HANDLE ImageHandle,\r |
559 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
0284e90c LG |
560 | )\r |
561 | {\r | |
53be7721 MK |
562 | EFI_STATUS Status;\r |
563 | EFI_ACPI_DESCRIPTION_HEADER *Header;\r | |
e84f07b5 | 564 | \r |
53be7721 MK |
565 | //\r |
566 | // Update Header fields of Boot Graphics Resource Table from PCDs\r | |
567 | //\r | |
568 | Header = &mBootGraphicsResourceTableTemplate.Header;\r | |
569 | ZeroMem (Header->OemId, sizeof (Header->OemId));\r | |
e84f07b5 | 570 | CopyMem (\r |
53be7721 | 571 | Header->OemId,\r |
e84f07b5 | 572 | PcdGetPtr (PcdAcpiDefaultOemId),\r |
53be7721 | 573 | MIN (PcdGetSize (PcdAcpiDefaultOemId), sizeof (Header->OemId))\r |
e84f07b5 | 574 | );\r |
53be7721 MK |
575 | WriteUnaligned64 (&Header->OemTableId, PcdGet64 (PcdAcpiDefaultOemTableId));\r |
576 | Header->OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision);\r | |
577 | Header->CreatorId = PcdGet32 (PcdAcpiDefaultCreatorId);\r | |
578 | Header->CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision);\r | |
0284e90c LG |
579 | \r |
580 | //\r | |
77773606 | 581 | // Install Boot Logo and Boot Logo 2 Protocols.\r |
0284e90c LG |
582 | //\r |
583 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
584 | &mBootLogoHandle,\r | |
585 | &gEfiBootLogoProtocolGuid,\r | |
586 | &mBootLogoProtocolTemplate,\r | |
77773606 MK |
587 | &gEdkiiBootLogo2ProtocolGuid,\r |
588 | &mBootLogo2ProtocolTemplate,\r | |
0284e90c LG |
589 | NULL\r |
590 | );\r | |
591 | ASSERT_EFI_ERROR (Status);\r | |
592 | \r | |
593 | //\r | |
594 | // Register notify function to install BGRT on ReadyToBoot Event.\r | |
595 | //\r | |
596 | Status = gBS->CreateEventEx (\r | |
597 | EVT_NOTIFY_SIGNAL,\r | |
598 | TPL_CALLBACK,\r | |
599 | BgrtReadyToBootEventNotify,\r | |
600 | NULL,\r | |
601 | &gEfiEventReadyToBootGuid,\r | |
602 | &mBootGraphicsReadyToBootEvent\r | |
603 | );\r | |
604 | ASSERT_EFI_ERROR (Status);\r | |
605 | \r | |
606 | return Status;\r | |
607 | }\r |