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