mirror of https://github.com/acidanthera/audk.git
CorebootModulePkg/CbParseLib: Support current Coreboot IMD
The latest coreboot use IMD (In Memory Database) to report Tables. This patch adds IMD support in UEFI payload. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Guo Dong <guo.dong@intel.com> Reviewed-by: Maurice Ma <maurice.ma@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17484 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
eef538572f
commit
165c00599e
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Coreboot PEI module include file.
|
Coreboot PEI module include file.
|
||||||
|
|
||||||
Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -51,6 +51,9 @@
|
||||||
|
|
||||||
#define DYN_CBMEM_ALIGN_SIZE (4096)
|
#define DYN_CBMEM_ALIGN_SIZE (4096)
|
||||||
|
|
||||||
|
#define IMD_ENTRY_MAGIC (~0xC0389481)
|
||||||
|
#define CBMEM_ENTRY_MAGIC (~0xC0389479)
|
||||||
|
|
||||||
struct cbmem_entry {
|
struct cbmem_entry {
|
||||||
UINT32 magic;
|
UINT32 magic;
|
||||||
UINT32 start;
|
UINT32 start;
|
||||||
|
@ -66,6 +69,22 @@ struct cbmem_root {
|
||||||
struct cbmem_entry entries[0];
|
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 {
|
struct cbuint64 {
|
||||||
UINT32 lo;
|
UINT32 lo;
|
||||||
UINT32 hi;
|
UINT32 hi;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
This library will parse the coreboot table in memory and extract those required
|
This library will parse the coreboot table in memory and extract those required
|
||||||
information.
|
information.
|
||||||
|
|
||||||
Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -126,24 +126,48 @@ FindCbTag (
|
||||||
|
|
||||||
RETURN_STATUS
|
RETURN_STATUS
|
||||||
FindCbMemTable (
|
FindCbMemTable (
|
||||||
struct cbmem_root *root,
|
IN struct cbmem_root *Root,
|
||||||
IN UINT32 TableId,
|
IN UINT32 TableId,
|
||||||
IN VOID** pMemTable,
|
OUT VOID **pMemTable,
|
||||||
IN UINT32* pMemTableSize
|
OUT UINT32 *pMemTableSize
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINTN Idx;
|
UINTN Idx;
|
||||||
|
BOOLEAN IsImdEntry;
|
||||||
|
struct cbmem_entry *Entries;
|
||||||
|
|
||||||
if ((!root) || (!pMemTable))
|
if ((Root == NULL) || (pMemTable == NULL)) {
|
||||||
return RETURN_INVALID_PARAMETER;
|
return RETURN_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
for (Idx = 0; Idx < root->num_entries; Idx++) {
|
//
|
||||||
if (root->entries[Idx].id == TableId) {
|
// Check if the entry is CBMEM or IMD
|
||||||
*pMemTable = (VOID *) (UINTN)root->entries[Idx].start;
|
// and handle them separately
|
||||||
if (pMemTableSize)
|
//
|
||||||
*pMemTableSize = root->entries[Idx].size;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DEBUG ((EFI_D_ERROR, "Find CbMemTable Id 0x%x, base %p, size 0x%x\n", TableId, *pMemTable, *pMemTableSize));
|
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 != NULL) {
|
||||||
|
*pMemTableSize = Entries[Idx].size;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG ((EFI_D_INFO, "Find CbMemTable Id 0x%x, base %p, size 0x%x\n", TableId, *pMemTable, *pMemTableSize));
|
||||||
return RETURN_SUCCESS;
|
return RETURN_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue