Signed-off-by: Guo Dong <guo.d...@intel.com>
---
 CorebootModulePkg/Include/Coreboot.h              | 19 ++++++++++++
 CorebootModulePkg/Library/CbParseLib/CbParseLib.c | 38 ++++++++++++++++++-----
 2 files changed, 49 insertions(+), 8 deletions(-)

diff --git a/CorebootModulePkg/Include/Coreboot.h 
b/CorebootModulePkg/Include/Coreboot.h
index 703c034..a256d50 100644
--- a/CorebootModulePkg/Include/Coreboot.h
+++ b/CorebootModulePkg/Include/Coreboot.h
@@ -49,10 +49,13 @@
 #pragma warning( disable : 4200 )
 #endif
 
 #define DYN_CBMEM_ALIGN_SIZE (4096)
 
+#define IMD_ENTRY_MAGIC      (~0xC0389481)
+#define CBMEM_ENTRY_MAGIC    (~0xC0389479)
+
 struct cbmem_entry {
   UINT32 magic;
   UINT32 start;
   UINT32 size;
   UINT32 id;
@@ -64,10 +67,26 @@ struct cbmem_root {
   UINT32 locked;
   UINT32 size;
   struct cbmem_entry entries[0];
 };
 
+struct imd_entry {
+  UINT32 magic;
+  UINT32 start_offset;
+  UINT32 size;
+  UINT32 id;
+};
+
+struct imd_root {
+  UINT32 max_entries;
+  UINT32 num_entries;
+  UINT32 flags;
+  UINT32 entry_align;        
+  UINT32 max_offset;
+  struct imd_entry entries[0];
+};
+
 struct cbuint64 {
   UINT32 lo;
   UINT32 hi;
 };
 
diff --git a/CorebootModulePkg/Library/CbParseLib/CbParseLib.c 
b/CorebootModulePkg/Library/CbParseLib/CbParseLib.c
index c9b39b1..0f82b01 100644
--- a/CorebootModulePkg/Library/CbParseLib/CbParseLib.c
+++ b/CorebootModulePkg/Library/CbParseLib/CbParseLib.c
@@ -124,26 +124,48 @@ FindCbTag (
   return TagPtr;
 }
 
 RETURN_STATUS
 FindCbMemTable (  
-  struct  cbmem_root  *root,
+  IN struct cbmem_root  *Root,
   IN UINT32     TableId, 
   IN VOID**     pMemTable,
   IN UINT32*    pMemTableSize
 )
 {      
-       UINTN Idx;
+  UINTN                Idx;
+  BOOLEAN              IsImdEntry;
+  struct cbmem_entry  *Entries;
        
-       if ((!root) || (!pMemTable))
+  if ((!Root) || (!pMemTable))
                return RETURN_INVALID_PARAMETER;
                
-       for (Idx = 0; Idx < root->num_entries; Idx++) {
-    if (root->entries[Idx].id == TableId) {
-       *pMemTable = (VOID *) (UINTN)root->entries[Idx].start;
-       if (pMemTableSize)
-               *pMemTableSize = root->entries[Idx].size;
+  //
+  // Check if the entry is CBMEM or IMD
+  // and handle them separately
+  //
+  Entries    = Root->entries;
+  if (Entries[0].magic == CBMEM_ENTRY_MAGIC) {
+    IsImdEntry = FALSE;
+  } else {
+    Entries    = (struct cbmem_entry *)((struct imd_root *)Root)->entries;
+    if (Entries[0].magic == IMD_ENTRY_MAGIC) {
+      IsImdEntry = TRUE;
+    } else {
+      return RETURN_NOT_FOUND;
+    }
+  }
+
+  for (Idx = 0; Idx < Root->num_entries; Idx++) {
+    if (Entries[Idx].id == TableId) {
+      if (IsImdEntry) {
+        *pMemTable = (VOID *) ((UINTN)Entries[Idx].start + (UINTN)Root);
+      } else {
+        *pMemTable = (VOID *) (UINTN)Entries[Idx].start;
+      }
+      if (pMemTableSize)
+        *pMemTableSize = Entries[Idx].size;
        
        DEBUG ((EFI_D_ERROR, "Find CbMemTable Id 0x%x, base %p, size 0x%x\n", 
TableId, *pMemTable, *pMemTableSize));
        return RETURN_SUCCESS;
     }
   }
-- 
1.9.5.msysgit.0



------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to