]> git.proxmox.com Git - mirror_edk2.git/blame - CorebootModulePkg/Library/CbParseLib/CbParseLib.c
CorebootModulePkg/CbParseLib: Support current Coreboot IMD
[mirror_edk2.git] / CorebootModulePkg / Library / CbParseLib / CbParseLib.c
CommitLineData
fce4ecd9
MM
1/** @file\r
2 This library will parse the coreboot table in memory and extract those required\r
3 information.\r
4\r
165c0059 5 Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>\r
fce4ecd9
MM
6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#include <Uefi/UefiBaseType.h>\r
17#include <Library/BaseLib.h>\r
18#include <Library/BaseMemoryLib.h>\r
19#include <Library/DebugLib.h>\r
20#include <Library/PcdLib.h>\r
21#include <Library/CbParseLib.h>\r
22\r
23#include <IndustryStandard/Acpi.h>\r
24\r
25#include "Coreboot.h"\r
26\r
27/* Helpful inlines */\r
28\r
29static UINT64 cb_unpack64(struct cbuint64 val)\r
30{\r
5451fff4 31 return LShiftU64 (val.hi, 32) | val.lo;\r
fce4ecd9
MM
32}\r
33\r
fce4ecd9
MM
34UINT16\r
35CbCheckSum16 (\r
36 IN UINT16 *Buffer,\r
37 IN UINTN Length\r
38 )\r
39{\r
40 UINT32 Sum, TmpValue;\r
41 UINTN Idx;\r
42 UINT8 *TmpPtr;\r
43 \r
44 Sum = 0;\r
45 TmpPtr = (UINT8 *)Buffer;\r
46 for(Idx = 0; Idx < Length; Idx++) {\r
47 TmpValue = TmpPtr[Idx];\r
48 if (Idx % 2 == 1) {\r
49 TmpValue <<= 8;\r
50 }\r
51 \r
52 Sum += TmpValue;\r
53 \r
54 // Wrap\r
55 if (Sum >= 0x10000) {\r
56 Sum = (Sum + (Sum >> 16)) & 0xFFFF;\r
57 }\r
58 }\r
59 \r
60 return (UINT16)((~Sum) & 0xFFFF); \r
61}\r
62\r
63VOID *\r
64FindCbTag (\r
65 IN VOID *Start,\r
66 IN UINT32 Tag\r
67 )\r
68{\r
69 struct cb_header *Header;\r
70 struct cb_record *Record;\r
71 UINT8 *TmpPtr; \r
72 UINT8 *TagPtr; \r
73 UINTN Idx; \r
74 UINT16 CheckSum;\r
75 \r
76 Header = NULL;\r
77 TmpPtr = (UINT8 *)Start;\r
78 for (Idx = 0; Idx < 4096; Idx += 16, TmpPtr += 16) {\r
79 Header = (struct cb_header *)TmpPtr;\r
80 if (Header->signature == CB_HEADER_SIGNATURE) {\r
81 break;\r
82 }\r
83 }\r
84 \r
85 if (Idx >= 4096)\r
86 return NULL;\r
87 \r
88 if (Header == NULL || !Header->table_bytes)\r
89 return NULL;\r
90 \r
91 //\r
92 // Check the checksum of the coreboot table header\r
93 //\r
94 CheckSum = CbCheckSum16 ((UINT16 *)Header, sizeof (*Header));\r
95 if (CheckSum != 0) {\r
96 DEBUG ((EFI_D_ERROR, "Invalid coreboot table header checksum\n"));\r
97 return NULL;\r
98 } \r
99 \r
100 CheckSum = CbCheckSum16 ((UINT16 *)(TmpPtr + sizeof (*Header)), Header->table_bytes);\r
101 if (CheckSum != Header->table_checksum) {\r
102 DEBUG ((EFI_D_ERROR, "Incorrect checksum of all the coreboot table entries\n"));\r
103 return NULL;\r
104 }\r
105 \r
106 TagPtr = NULL;\r
107 TmpPtr += Header->header_bytes;\r
108 for (Idx = 0; Idx < Header->table_entries; Idx++) {\r
109 Record = (struct cb_record *)TmpPtr; \r
110 if (Record->tag == CB_TAG_FORWARD) {\r
111 TmpPtr = (VOID *)(UINTN)((struct cb_forward *)(UINTN)Record)->forward;\r
112 if (Tag == CB_TAG_FORWARD)\r
113 return TmpPtr;\r
114 else \r
115 return FindCbTag (TmpPtr, Tag);\r
116 } \r
117 if (Record->tag == Tag) {\r
118 TagPtr = TmpPtr;\r
119 break;\r
120 }\r
121 TmpPtr += Record->size; \r
122 }\r
123 \r
124 return TagPtr;\r
125}\r
126\r
127RETURN_STATUS\r
128FindCbMemTable ( \r
165c0059
GD
129 IN struct cbmem_root *Root,\r
130 IN UINT32 TableId,\r
131 OUT VOID **pMemTable,\r
132 OUT UINT32 *pMemTableSize\r
fce4ecd9
MM
133)\r
134{ \r
165c0059
GD
135 UINTN Idx;\r
136 BOOLEAN IsImdEntry;\r
137 struct cbmem_entry *Entries;\r
fce4ecd9 138 \r
165c0059
GD
139 if ((Root == NULL) || (pMemTable == NULL)) {\r
140 return RETURN_INVALID_PARAMETER;\r
141 }\r
fce4ecd9 142 \r
165c0059
GD
143 //\r
144 // Check if the entry is CBMEM or IMD\r
145 // and handle them separately\r
146 //\r
147 Entries = Root->entries;\r
148 if (Entries[0].magic == CBMEM_ENTRY_MAGIC) {\r
149 IsImdEntry = FALSE;\r
150 } else {\r
151 Entries = (struct cbmem_entry *)((struct imd_root *)Root)->entries;\r
152 if (Entries[0].magic == IMD_ENTRY_MAGIC) {\r
153 IsImdEntry = TRUE;\r
154 } else {\r
155 return RETURN_NOT_FOUND;\r
156 }\r
157 }\r
158\r
159 for (Idx = 0; Idx < Root->num_entries; Idx++) {\r
160 if (Entries[Idx].id == TableId) {\r
161 if (IsImdEntry) {\r
162 *pMemTable = (VOID *) ((UINTN)Entries[Idx].start + (UINTN)Root);\r
163 } else {\r
164 *pMemTable = (VOID *) (UINTN)Entries[Idx].start;\r
165 }\r
166 if (pMemTableSize != NULL) {\r
167 *pMemTableSize = Entries[Idx].size;\r
168 }\r
fce4ecd9 169 \r
165c0059 170 DEBUG ((EFI_D_INFO, "Find CbMemTable Id 0x%x, base %p, size 0x%x\n", TableId, *pMemTable, *pMemTableSize));\r
fce4ecd9
MM
171 return RETURN_SUCCESS;\r
172 }\r
173 }\r
174 \r
175 return RETURN_NOT_FOUND; \r
176}\r
177\r
178\r
179/**\r
180 Acquire the memory information from the coreboot table in memory.\r
181\r
182 @param pLowMemorySize Pointer to the variable of low memory size\r
183 @param pHighMemorySize Pointer to the variable of high memory size\r
184\r
185 @retval RETURN_SUCCESS Successfully find out the memory information.\r
186 @retval RETURN_INVALID_PARAMETER Invalid input parameters.\r
187 @retval RETURN_NOT_FOUND Failed to find the memory information.\r
188\r
189**/\r
190RETURN_STATUS\r
191CbParseMemoryInfo (\r
192 IN UINT64* pLowMemorySize,\r
193 IN UINT64* pHighMemorySize\r
194 )\r
195{\r
196 struct cb_memory* rec;\r
197 struct cb_memory_range* Range;\r
198 UINT64 Start;\r
199 UINT64 Size;\r
200 UINTN Index;\r
201 \r
202 if ((!pLowMemorySize) || (!pHighMemorySize))\r
203 return RETURN_INVALID_PARAMETER;\r
204 \r
205 //\r
206 // Get the coreboot memory table\r
207 //\r
208 rec = (struct cb_memory *)FindCbTag (0, CB_TAG_MEMORY);\r
209 if (!rec) \r
210 rec = (struct cb_memory *)FindCbTag ((VOID *)(UINTN)PcdGet32 (PcdCbHeaderPointer), CB_TAG_MEMORY);\r
211 \r
212 if (!rec) \r
213 return RETURN_NOT_FOUND;\r
214 \r
215 *pLowMemorySize = 0;\r
216 *pHighMemorySize = 0;\r
217 \r
218 for (Index = 0; Index < MEM_RANGE_COUNT(rec); Index++) {\r
219 Range = MEM_RANGE_PTR(rec, Index); \r
220 Start = cb_unpack64(Range->start);\r
221 Size = cb_unpack64(Range->size);\r
222 DEBUG ((EFI_D_ERROR, "%d. %016lx - %016lx [%02x]\n",\r
223 Index, Start, Start + Size - 1, Range->type));\r
224 \r
225 if (Range->type != CB_MEM_RAM) {\r
226 continue;\r
227 }\r
228 \r
229 if (Start + Size < 0x100000000ULL) {\r
230 *pLowMemorySize = Start + Size;\r
231 } else { \r
232 *pHighMemorySize = Start + Size - 0x100000000ULL;\r
233 }\r
234 }\r
235 \r
42e548a8 236 DEBUG ((EFI_D_ERROR, "Low memory 0x%lx, High Memory 0x%lx\n", *pLowMemorySize, *pHighMemorySize));\r
fce4ecd9
MM
237 \r
238 return RETURN_SUCCESS; \r
239}\r
240\r
241\r
242/**\r
243 Acquire the coreboot memory table with the given table id\r
244\r
245 @param TableId Table id to be searched\r
246 @param pMemTable Pointer to the base address of the memory table\r
247 @param pMemTableSize Pointer to the size of the memory table\r
248\r
249 @retval RETURN_SUCCESS Successfully find out the memory table.\r
250 @retval RETURN_INVALID_PARAMETER Invalid input parameters.\r
251 @retval RETURN_NOT_FOUND Failed to find the memory table.\r
252\r
253**/\r
254RETURN_STATUS\r
255CbParseCbMemTable (\r
256 IN UINT32 TableId, \r
257 IN VOID** pMemTable,\r
258 IN UINT32* pMemTableSize\r
259 )\r
260{\r
261 struct cb_memory* rec;\r
262 struct cb_memory_range* Range;\r
263 UINT64 Start;\r
264 UINT64 Size;\r
265 UINTN Index;\r
266 \r
267 if (!pMemTable)\r
268 return RETURN_INVALID_PARAMETER;\r
269 \r
270 *pMemTable = NULL;\r
271 \r
272 //\r
273 // Get the coreboot memory table\r
274 //\r
275 rec = (struct cb_memory *)FindCbTag (0, CB_TAG_MEMORY);\r
276 if (!rec)\r
277 rec = (struct cb_memory *)FindCbTag ((VOID *)(UINTN)PcdGet32 (PcdCbHeaderPointer), CB_TAG_MEMORY);\r
278 \r
279 if (!rec)\r
280 return RETURN_NOT_FOUND;\r
281 \r
282 for (Index = 0; Index < MEM_RANGE_COUNT(rec); Index++) {\r
283 Range = MEM_RANGE_PTR(rec, Index); \r
284 Start = cb_unpack64(Range->start);\r
285 Size = cb_unpack64(Range->size);\r
286 \r
287 if ((Range->type == CB_MEM_TABLE) && (Start > 0x1000)) {\r
288 if (FindCbMemTable ((struct cbmem_root *)(UINTN)(Start + Size - DYN_CBMEM_ALIGN_SIZE), TableId, pMemTable, pMemTableSize) == RETURN_SUCCESS)\r
289 return RETURN_SUCCESS;\r
290 }\r
291 }\r
292 \r
293 return RETURN_NOT_FOUND;\r
294}\r
295\r
296\r
297/**\r
298 Acquire the acpi table from coreboot\r
299\r
300 @param pMemTable Pointer to the base address of the memory table\r
301 @param pMemTableSize Pointer to the size of the memory table\r
302\r
303 @retval RETURN_SUCCESS Successfully find out the memory table.\r
304 @retval RETURN_INVALID_PARAMETER Invalid input parameters.\r
305 @retval RETURN_NOT_FOUND Failed to find the memory table.\r
306\r
307**/\r
308RETURN_STATUS\r
309CbParseAcpiTable (\r
3b17ae9e 310 IN VOID* pMemTable,\r
fce4ecd9
MM
311 IN UINT32* pMemTableSize\r
312 )\r
313{\r
3b17ae9e 314 return CbParseCbMemTable (SIGNATURE_32 ('I', 'P', 'C', 'A'), (VOID **)pMemTable, pMemTableSize); \r
fce4ecd9
MM
315}\r
316\r
317/**\r
318 Acquire the smbios table from coreboot\r
319\r
320 @param pMemTable Pointer to the base address of the memory table\r
321 @param pMemTableSize Pointer to the size of the memory table\r
322\r
323 @retval RETURN_SUCCESS Successfully find out the memory table.\r
324 @retval RETURN_INVALID_PARAMETER Invalid input parameters.\r
325 @retval RETURN_NOT_FOUND Failed to find the memory table.\r
326\r
327**/\r
328RETURN_STATUS\r
329CbParseSmbiosTable (\r
330 IN VOID** pMemTable,\r
331 IN UINT32* pMemTableSize\r
332 )\r
333{\r
334 return CbParseCbMemTable (SIGNATURE_32 ('T', 'B', 'M', 'S'), pMemTable, pMemTableSize); \r
335}\r
336\r
337/**\r
338 Find the required fadt information\r
339\r
340 @param pPmCtrlReg Pointer to the address of power management control register\r
341 @param pPmTimerReg Pointer to the address of power management timer register\r
342 @param pResetReg Pointer to the address of system reset register\r
343 @param pResetValue Pointer to the value to be writen to the system reset register\r
344\r
345 @retval RETURN_SUCCESS Successfully find out all the required fadt information.\r
346 @retval RETURN_NOT_FOUND Failed to find the fadt table.\r
347\r
348**/\r
349RETURN_STATUS\r
350CbParseFadtInfo (\r
351 IN UINTN* pPmCtrlReg,\r
352 IN UINTN* pPmTimerReg,\r
353 IN UINTN* pResetReg,\r
354 IN UINTN* pResetValue\r
355 )\r
356{\r
357 EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER* Rsdp;\r
358 EFI_ACPI_DESCRIPTION_HEADER* Rsdt;\r
359 UINT32* Entry32;\r
360 UINTN Entry32Num;\r
361 EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE* Fadt;\r
362 EFI_ACPI_DESCRIPTION_HEADER* Xsdt; \r
363 UINT64* Entry64;\r
364 UINTN Entry64Num;\r
365 UINTN Idx;\r
366 RETURN_STATUS Status;\r
367 \r
368 Rsdp = NULL;\r
369 Status = RETURN_SUCCESS;\r
370 \r
371 Status = CbParseAcpiTable (&Rsdp, NULL);\r
372 if (RETURN_ERROR(Status))\r
373 return Status;\r
374 \r
375 if (!Rsdp)\r
376 return RETURN_NOT_FOUND;\r
377 \r
42e548a8
SD
378 DEBUG ((EFI_D_ERROR, "Find Rsdp at %p\n", Rsdp));\r
379 DEBUG ((EFI_D_ERROR, "Find Rsdt 0x%x, Xsdt 0x%lx\n", Rsdp->RsdtAddress, Rsdp->XsdtAddress));\r
fce4ecd9
MM
380 \r
381 //\r
382 // Search Rsdt First\r
383 //\r
384 Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)(Rsdp->RsdtAddress); \r
385 if (Rsdt != NULL) {\r
386 Entry32 = (UINT32 *)(Rsdt + 1);\r
387 Entry32Num = (Rsdt->Length - sizeof(EFI_ACPI_DESCRIPTION_HEADER)) >> 2;\r
388 for (Idx = 0; Idx < Entry32Num; Idx++) {\r
389 if (*(UINT32 *)(UINTN)(Entry32[Idx]) == EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE) {\r
390 Fadt = (EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *)(UINTN)(Entry32[Idx]); \r
391 if (pPmCtrlReg)\r
392 *pPmCtrlReg = Fadt->Pm1aCntBlk; \r
393 DEBUG ((EFI_D_ERROR, "PmCtrl Reg 0x%x\n", Fadt->Pm1aCntBlk));\r
394 \r
395 if (pPmTimerReg) \r
396 *pPmTimerReg = Fadt->PmTmrBlk; \r
397 DEBUG ((EFI_D_ERROR, "PmTimer Reg 0x%x\n", Fadt->PmTmrBlk));\r
398 \r
399 if (pResetReg) \r
400 *pResetReg = (UINTN)Fadt->ResetReg.Address; \r
42e548a8 401 DEBUG ((EFI_D_ERROR, "Reset Reg 0x%lx\n", Fadt->ResetReg.Address));\r
fce4ecd9
MM
402 \r
403 if (pResetValue) \r
404 *pResetValue = Fadt->ResetValue;\r
405 DEBUG ((EFI_D_ERROR, "Reset Value 0x%x\n", Fadt->ResetValue));\r
406 \r
407 return RETURN_SUCCESS; \r
408 }\r
409 }\r
410 }\r
411 \r
412 //\r
413 // Search Xsdt Second\r
414 //\r
415 Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)(Rsdp->XsdtAddress); \r
416 if (Xsdt != NULL) {\r
417 Entry64 = (UINT64 *)(Xsdt + 1);\r
418 Entry64Num = (Xsdt->Length - sizeof(EFI_ACPI_DESCRIPTION_HEADER)) >> 3;\r
419 for (Idx = 0; Idx < Entry64Num; Idx++) {\r
420 if (*(UINT32 *)(UINTN)(Entry64[Idx]) == EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE) {\r
421 Fadt = (EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *)(UINTN)(Entry64[Idx]); \r
422 if (pPmCtrlReg)\r
423 *pPmCtrlReg = Fadt->Pm1aCntBlk; \r
424 DEBUG ((EFI_D_ERROR, "PmCtrl Reg 0x%x\n", Fadt->Pm1aCntBlk));\r
425 \r
426 if (pPmTimerReg) \r
427 *pPmTimerReg = Fadt->PmTmrBlk; \r
428 DEBUG ((EFI_D_ERROR, "PmTimer Reg 0x%x\n", Fadt->PmTmrBlk));\r
429 \r
430 if (pResetReg) \r
431 *pResetReg = (UINTN)Fadt->ResetReg.Address; \r
42e548a8 432 DEBUG ((EFI_D_ERROR, "Reset Reg 0x%lx\n", Fadt->ResetReg.Address));\r
fce4ecd9
MM
433 \r
434 if (pResetValue) \r
435 *pResetValue = Fadt->ResetValue;\r
436 DEBUG ((EFI_D_ERROR, "Reset Value 0x%x\n", Fadt->ResetValue));\r
437 \r
438 return RETURN_SUCCESS; \r
439 }\r
440 }\r
441 } \r
442 \r
443 return RETURN_NOT_FOUND;\r
444}\r
445\r
446/**\r
447 Find the serial port information\r
448\r
449 @param pRegBase Pointer to the base address of serial port registers\r
450 @param pRegAccessType Pointer to the access type of serial port registers\r
451 @param pBaudrate Pointer to the serial port baudrate\r
452\r
453 @retval RETURN_SUCCESS Successfully find the serial port information.\r
454 @retval RETURN_NOT_FOUND Failed to find the serial port information .\r
455\r
456**/\r
457RETURN_STATUS\r
458CbParseSerialInfo (\r
459 IN UINT32* pRegBase,\r
460 IN UINT32* pRegAccessType,\r
461 IN UINT32* pBaudrate\r
462 )\r
463{\r
464 struct cb_serial* CbSerial;\r
465 \r
466 CbSerial = FindCbTag (0, CB_TAG_SERIAL);\r
467 if (!CbSerial)\r
468 CbSerial = FindCbTag ((VOID *)(UINTN)PcdGet32 (PcdCbHeaderPointer), CB_TAG_SERIAL);\r
469 \r
470 if (!CbSerial)\r
471 return RETURN_NOT_FOUND;\r
472 \r
473 if (pRegBase)\r
474 *pRegBase = CbSerial->baseaddr;\r
475 \r
476 if (pRegAccessType)\r
477 *pRegAccessType = CbSerial->type;\r
478 \r
479 if (pBaudrate)\r
480 *pBaudrate = CbSerial->baud;\r
481 \r
482 return RETURN_SUCCESS;\r
483}\r
484\r
485/**\r
486 Search for the coreboot table header\r
487\r
488 @param Level Level of the search depth\r
489 @param HeaderPtr Pointer to the pointer of coreboot table header\r
490\r
491 @retval RETURN_SUCCESS Successfully find the coreboot table header .\r
492 @retval RETURN_NOT_FOUND Failed to find the coreboot table header .\r
493\r
494**/\r
495RETURN_STATUS\r
496CbParseGetCbHeader (\r
497 IN UINTN Level,\r
498 IN VOID** HeaderPtr\r
499 )\r
500{\r
501 UINTN Index;\r
502 VOID* TempPtr;\r
503 \r
504 if (!HeaderPtr)\r
505 return RETURN_NOT_FOUND;\r
506 \r
507 TempPtr = NULL; \r
508 for (Index = 0; Index < Level; Index++) {\r
509 TempPtr = FindCbTag (TempPtr, CB_TAG_FORWARD);\r
510 if (!TempPtr)\r
511 break; \r
512 }\r
513 \r
514 if ((Index >= Level) && (TempPtr != NULL)) {\r
515 *HeaderPtr = TempPtr;\r
516 return RETURN_SUCCESS;\r
517 }\r
518 \r
519 return RETURN_NOT_FOUND;\r
520}\r
521\r
522/**\r
523 Find the video frame buffer information\r
524\r
525 @param pFbInfo Pointer to the FRAME_BUFFER_INFO structure\r
526\r
527 @retval RETURN_SUCCESS Successfully find the video frame buffer information.\r
528 @retval RETURN_NOT_FOUND Failed to find the video frame buffer information .\r
529\r
530**/\r
531RETURN_STATUS\r
532CbParseFbInfo (\r
533 IN FRAME_BUFFER_INFO* pFbInfo\r
534 )\r
535{\r
536 struct cb_framebuffer* CbFbRec;\r
537 \r
538 if (!pFbInfo)\r
539 return RETURN_INVALID_PARAMETER;\r
540 \r
541 CbFbRec = FindCbTag (0, CB_TAG_FRAMEBUFFER);\r
542 if (!CbFbRec)\r
543 CbFbRec = FindCbTag ((VOID *)(UINTN)PcdGet32 (PcdCbHeaderPointer), CB_TAG_FRAMEBUFFER);\r
544 \r
545 if (!CbFbRec)\r
546 return RETURN_NOT_FOUND;\r
547 \r
548 DEBUG ((EFI_D_ERROR, "Found coreboot video frame buffer information\n"));\r
42e548a8 549 DEBUG ((EFI_D_ERROR, "physical_address: 0x%lx\n", CbFbRec->physical_address));\r
fce4ecd9
MM
550 DEBUG ((EFI_D_ERROR, "x_resolution: 0x%x\n", CbFbRec->x_resolution));\r
551 DEBUG ((EFI_D_ERROR, "y_resolution: 0x%x\n", CbFbRec->y_resolution));\r
552 DEBUG ((EFI_D_ERROR, "bits_per_pixel: 0x%x\n", CbFbRec->bits_per_pixel));\r
553 DEBUG ((EFI_D_ERROR, "bytes_per_line: 0x%x\n", CbFbRec->bytes_per_line));\r
554 \r
555 DEBUG ((EFI_D_ERROR, "red_mask_size: 0x%x\n", CbFbRec->red_mask_size));\r
556 DEBUG ((EFI_D_ERROR, "red_mask_pos: 0x%x\n", CbFbRec->red_mask_pos));\r
557 DEBUG ((EFI_D_ERROR, "green_mask_size: 0x%x\n", CbFbRec->green_mask_size));\r
558 DEBUG ((EFI_D_ERROR, "green_mask_pos: 0x%x\n", CbFbRec->green_mask_pos));\r
559 DEBUG ((EFI_D_ERROR, "blue_mask_size: 0x%x\n", CbFbRec->blue_mask_size));\r
560 DEBUG ((EFI_D_ERROR, "blue_mask_pos: 0x%x\n", CbFbRec->blue_mask_pos));\r
561 DEBUG ((EFI_D_ERROR, "reserved_mask_size: 0x%x\n", CbFbRec->reserved_mask_size));\r
562 DEBUG ((EFI_D_ERROR, "reserved_mask_pos: 0x%x\n", CbFbRec->reserved_mask_pos));\r
563 \r
564 pFbInfo->LinearFrameBuffer = CbFbRec->physical_address; \r
565 pFbInfo->HorizontalResolution = CbFbRec->x_resolution;\r
566 pFbInfo->VerticalResolution = CbFbRec->y_resolution;\r
567 pFbInfo->BitsPerPixel = CbFbRec->bits_per_pixel;\r
568 pFbInfo->BytesPerScanLine = (UINT16)CbFbRec->bytes_per_line;\r
569 pFbInfo->Red.Mask = (1 << CbFbRec->red_mask_size) - 1;\r
570 pFbInfo->Red.Position = CbFbRec->red_mask_pos;\r
571 pFbInfo->Green.Mask = (1 << CbFbRec->green_mask_size) - 1;\r
572 pFbInfo->Green.Position = CbFbRec->green_mask_pos;\r
573 pFbInfo->Blue.Mask = (1 << CbFbRec->blue_mask_size) - 1;\r
574 pFbInfo->Blue.Position = CbFbRec->blue_mask_pos;\r
575 pFbInfo->Reserved.Mask = (1 << CbFbRec->reserved_mask_size) - 1;\r
576 pFbInfo->Reserved.Position = CbFbRec->reserved_mask_pos; \r
577 \r
578 return RETURN_SUCCESS;\r
579}\r
580\r
581\r