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