This library will parse the coreboot table in memory and extract those required\r
information.\r
\r
- Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
\r
RETURN_STATUS\r
FindCbMemTable ( \r
- struct cbmem_root *root,\r
- IN UINT32 TableId, \r
- IN VOID** pMemTable,\r
- IN UINT32* pMemTableSize\r
+ IN struct cbmem_root *Root,\r
+ IN UINT32 TableId,\r
+ OUT VOID **pMemTable,\r
+ OUT UINT32 *pMemTableSize\r
)\r
{ \r
- UINTN Idx;\r
+ UINTN Idx;\r
+ BOOLEAN IsImdEntry;\r
+ struct cbmem_entry *Entries;\r
\r
- if ((!root) || (!pMemTable))\r
- return RETURN_INVALID_PARAMETER;\r
+ if ((Root == NULL) || (pMemTable == NULL)) {\r
+ return RETURN_INVALID_PARAMETER;\r
+ }\r
\r
- for (Idx = 0; Idx < root->num_entries; Idx++) {\r
- if (root->entries[Idx].id == TableId) {\r
- *pMemTable = (VOID *) (UINTN)root->entries[Idx].start;\r
- if (pMemTableSize)\r
- *pMemTableSize = root->entries[Idx].size;\r
+ //\r
+ // Check if the entry is CBMEM or IMD\r
+ // and handle them separately\r
+ //\r
+ Entries = Root->entries;\r
+ if (Entries[0].magic == CBMEM_ENTRY_MAGIC) {\r
+ IsImdEntry = FALSE;\r
+ } else {\r
+ Entries = (struct cbmem_entry *)((struct imd_root *)Root)->entries;\r
+ if (Entries[0].magic == IMD_ENTRY_MAGIC) {\r
+ IsImdEntry = TRUE;\r
+ } else {\r
+ return RETURN_NOT_FOUND;\r
+ }\r
+ }\r
+\r
+ for (Idx = 0; Idx < Root->num_entries; Idx++) {\r
+ if (Entries[Idx].id == TableId) {\r
+ if (IsImdEntry) {\r
+ *pMemTable = (VOID *) ((UINTN)Entries[Idx].start + (UINTN)Root);\r
+ } else {\r
+ *pMemTable = (VOID *) (UINTN)Entries[Idx].start;\r
+ }\r
+ if (pMemTableSize != NULL) {\r
+ *pMemTableSize = Entries[Idx].size;\r
+ }\r
\r
- DEBUG ((EFI_D_ERROR, "Find CbMemTable Id 0x%x, base %p, size 0x%x\n", TableId, *pMemTable, *pMemTableSize));\r
+ DEBUG ((EFI_D_INFO, "Find CbMemTable Id 0x%x, base %p, size 0x%x\n", TableId, *pMemTable, *pMemTableSize));\r
return RETURN_SUCCESS;\r
}\r
}\r