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