mirror of https://github.com/acidanthera/audk.git
1. PI SMBIOS Checkin. Major change include:
1) Produce PI SMBIOS protocol in MdeModulePkg 2) Update all consumers (in CorePkgs and native platform pkgs) to consume SMBIOS protocol instead of DataHub 3) Pass ECC tool; Verify Nt32, Duet, Unix platform git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9454 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
a2bb197e80
commit
21020c7c8b
|
@ -133,7 +133,7 @@
|
|||
MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
|
||||
|
||||
|
||||
DuetPkg/DataHubGenDxe/DataHubGen.inf
|
||||
DuetPkg/SmbiosGenDxe/SmbiosGen.inf
|
||||
#DuetPkg/FvbRuntimeService/DUETFwh.inf
|
||||
DuetPkg/EfiLdr/EfiLdr.inf {
|
||||
<LibraryClasses>
|
||||
|
|
|
@ -77,7 +77,7 @@ INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
|
|||
INF IntelFrameworkModulePkg/Universal/DataHubDxe/DataHubDxe.inf
|
||||
INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
|
||||
INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
|
||||
INF DuetPkg/DataHubGenDxe/DataHubGen.inf
|
||||
INF DuetPkg/SmbiosGenDxe/SmbiosGen.inf
|
||||
#INF DuetPkg/FvbRuntimeService/DUETFwh.inf
|
||||
INF IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf
|
||||
INF UefiCpuPkg/CpuIoDxe/CpuIo.inf
|
||||
|
|
|
@ -0,0 +1,344 @@
|
|||
/** @file
|
||||
|
||||
Copyright (c) 2009, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
|
||||
SmbiosGen.c
|
||||
|
||||
Abstract:
|
||||
|
||||
**/
|
||||
|
||||
#include "SmbiosGen.h"
|
||||
EFI_HII_DATABASE_PROTOCOL *gHiiDatabase;
|
||||
extern UINT8 SmbiosGenDxeStrings[];
|
||||
EFI_SMBIOS_PROTOCOL *gSmbios;
|
||||
EFI_HII_HANDLE gStringHandle;
|
||||
|
||||
VOID *
|
||||
GetSmbiosTablesFromHob (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_PHYSICAL_ADDRESS *Table;
|
||||
EFI_PEI_HOB_POINTERS GuidHob;
|
||||
//
|
||||
// Get Hob List
|
||||
//
|
||||
GuidHob.Raw = GetHobList ();
|
||||
GuidHob.Raw = GetNextGuidHob (&gEfiSmbiosTableGuid, GuidHob.Raw);
|
||||
if (GuidHob.Raw != NULL) {
|
||||
Table = GET_GUID_HOB_DATA (GuidHob.Guid);
|
||||
if (Table != NULL) {
|
||||
return (VOID *)(UINTN)*Table;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
InstallProcessorSmbios (
|
||||
IN VOID *Smbios
|
||||
)
|
||||
{
|
||||
SMBIOS_STRUCTURE_POINTER SmbiosTable;
|
||||
CHAR8 *AString;
|
||||
CHAR16 *UString;
|
||||
STRING_REF Token;
|
||||
|
||||
//
|
||||
// Processor info (TYPE 4)
|
||||
//
|
||||
SmbiosTable = GetSmbiosTableFromType ((SMBIOS_TABLE_ENTRY_POINT *)Smbios, 4, 0);
|
||||
if (SmbiosTable.Raw == NULL) {
|
||||
DEBUG ((EFI_D_ERROR, "SmbiosTable: Type 4 (Processor Info) not found!\n"));
|
||||
return ;
|
||||
}
|
||||
|
||||
//
|
||||
// Log Smbios Record Type4
|
||||
//
|
||||
LogSmbiosData(gSmbios,(UINT8*)SmbiosTable.Type4);
|
||||
|
||||
//
|
||||
// Set ProcessorVersion string
|
||||
//
|
||||
AString = GetSmbiosString (SmbiosTable, SmbiosTable.Type4->ProcessorVersion);
|
||||
UString = AllocateZeroPool ((AsciiStrLen(AString) + 1) * sizeof(CHAR16));
|
||||
ASSERT (UString != NULL);
|
||||
AsciiStrToUnicodeStr (AString, UString);
|
||||
|
||||
Token = HiiSetString (gStringHandle, 0, UString, NULL);
|
||||
if (Token == 0) {
|
||||
gBS->FreePool (UString);
|
||||
return ;
|
||||
}
|
||||
gBS->FreePool (UString);
|
||||
return ;
|
||||
}
|
||||
|
||||
VOID
|
||||
InstallCacheSmbios (
|
||||
IN VOID *Smbios
|
||||
)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
VOID
|
||||
InstallMemorySmbios (
|
||||
IN VOID *Smbios
|
||||
)
|
||||
{
|
||||
SMBIOS_STRUCTURE_POINTER SmbiosTable;
|
||||
|
||||
//
|
||||
// Generate Memory Array Mapped Address info (TYPE 19)
|
||||
//
|
||||
SmbiosTable = GetSmbiosTableFromType ((SMBIOS_TABLE_ENTRY_POINT *)Smbios, 19, 0);
|
||||
if (SmbiosTable.Raw == NULL) {
|
||||
DEBUG ((EFI_D_ERROR, "SmbiosTable: Type 19 (Memory Array Mapped Address Info) not found!\n"));
|
||||
return ;
|
||||
}
|
||||
|
||||
//
|
||||
// Record Smbios Type 19
|
||||
//
|
||||
LogSmbiosData(gSmbios, (UINT8*)SmbiosTable.Type19);
|
||||
return ;
|
||||
}
|
||||
|
||||
VOID
|
||||
InstallMiscSmbios (
|
||||
IN VOID *Smbios
|
||||
)
|
||||
{
|
||||
SMBIOS_STRUCTURE_POINTER SmbiosTable;
|
||||
CHAR8 *AString;
|
||||
CHAR16 *UString;
|
||||
STRING_REF Token;
|
||||
|
||||
//
|
||||
// BIOS information (TYPE 0)
|
||||
//
|
||||
SmbiosTable = GetSmbiosTableFromType ((SMBIOS_TABLE_ENTRY_POINT *)Smbios, 0, 0);
|
||||
if (SmbiosTable.Raw == NULL) {
|
||||
DEBUG ((EFI_D_ERROR, "SmbiosTable: Type 0 (BIOS Information) not found!\n"));
|
||||
return ;
|
||||
}
|
||||
|
||||
//
|
||||
// Record Type 2
|
||||
//
|
||||
AString = GetSmbiosString (SmbiosTable, SmbiosTable.Type0->BiosVersion);
|
||||
UString = AllocateZeroPool ((AsciiStrLen(AString) + 1) * sizeof(CHAR16) + sizeof(FIRMWARE_BIOS_VERSIONE));
|
||||
ASSERT (UString != NULL);
|
||||
CopyMem (UString, FIRMWARE_BIOS_VERSIONE, sizeof(FIRMWARE_BIOS_VERSIONE));
|
||||
AsciiStrToUnicodeStr (AString, UString + sizeof(FIRMWARE_BIOS_VERSIONE) / sizeof(CHAR16) - 1);
|
||||
|
||||
Token = HiiSetString (gStringHandle, 0, UString, NULL);
|
||||
if (Token == 0) {
|
||||
gBS->FreePool (UString);
|
||||
return ;
|
||||
}
|
||||
gBS->FreePool (UString);
|
||||
|
||||
//
|
||||
// Log Smios Type 0
|
||||
//
|
||||
LogSmbiosData(gSmbios, (UINT8*)SmbiosTable.Type0);
|
||||
|
||||
//
|
||||
// System information (TYPE 1)
|
||||
//
|
||||
SmbiosTable = GetSmbiosTableFromType ((SMBIOS_TABLE_ENTRY_POINT *)Smbios, 1, 0);
|
||||
if (SmbiosTable.Raw == NULL) {
|
||||
DEBUG ((EFI_D_ERROR, "SmbiosTable: Type 1 (System Information) not found!\n"));
|
||||
return ;
|
||||
}
|
||||
|
||||
//
|
||||
// Record Type 3
|
||||
//
|
||||
AString = GetSmbiosString (SmbiosTable, SmbiosTable.Type1->ProductName);
|
||||
UString = AllocateZeroPool ((AsciiStrLen(AString) + 1) * sizeof(CHAR16) + sizeof(FIRMWARE_PRODUCT_NAME));
|
||||
ASSERT (UString != NULL);
|
||||
CopyMem (UString, FIRMWARE_PRODUCT_NAME, sizeof(FIRMWARE_PRODUCT_NAME));
|
||||
AsciiStrToUnicodeStr (AString, UString + sizeof(FIRMWARE_PRODUCT_NAME) / sizeof(CHAR16) - 1);
|
||||
|
||||
Token = HiiSetString (gStringHandle, 0, UString, NULL);
|
||||
if (Token == 0) {
|
||||
gBS->FreePool (UString);
|
||||
return ;
|
||||
}
|
||||
gBS->FreePool (UString);
|
||||
|
||||
//
|
||||
// Log Smbios Type 1
|
||||
//
|
||||
LogSmbiosData(gSmbios, (UINT8*)SmbiosTable.Type1);
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmbiosGenEntrypoint (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
VOID *Smbios;
|
||||
|
||||
Smbios = GetSmbiosTablesFromHob ();
|
||||
if (Smbios == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
Status = gBS->LocateProtocol (
|
||||
&gEfiSmbiosProtocolGuid,
|
||||
NULL,
|
||||
(VOID**)&gSmbios
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = gBS->LocateProtocol (
|
||||
&gEfiHiiDatabaseProtocolGuid,
|
||||
NULL,
|
||||
(VOID**)&gHiiDatabase
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
gStringHandle = HiiAddPackages (
|
||||
&gEfiCallerIdGuid,
|
||||
NULL,
|
||||
SmbiosGenDxeStrings,
|
||||
NULL
|
||||
);
|
||||
ASSERT (gStringHandle != NULL);
|
||||
|
||||
InstallProcessorSmbios (Smbios);
|
||||
InstallCacheSmbios (Smbios);
|
||||
InstallMemorySmbios (Smbios);
|
||||
InstallMiscSmbios (Smbios);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// Internal function
|
||||
//
|
||||
|
||||
UINTN
|
||||
SmbiosTableLength (
|
||||
IN SMBIOS_STRUCTURE_POINTER SmbiosTable
|
||||
)
|
||||
{
|
||||
CHAR8 *AChar;
|
||||
UINTN Length;
|
||||
|
||||
AChar = (CHAR8 *)(SmbiosTable.Raw + SmbiosTable.Hdr->Length);
|
||||
while ((*AChar != 0) || (*(AChar + 1) != 0)) {
|
||||
AChar ++;
|
||||
}
|
||||
Length = ((UINTN)AChar - (UINTN)SmbiosTable.Raw + 2);
|
||||
|
||||
return Length;
|
||||
}
|
||||
|
||||
SMBIOS_STRUCTURE_POINTER
|
||||
GetSmbiosTableFromType (
|
||||
IN SMBIOS_TABLE_ENTRY_POINT *Smbios,
|
||||
IN UINT8 Type,
|
||||
IN UINTN Index
|
||||
)
|
||||
{
|
||||
SMBIOS_STRUCTURE_POINTER SmbiosTable;
|
||||
UINTN SmbiosTypeIndex;
|
||||
|
||||
SmbiosTypeIndex = 0;
|
||||
SmbiosTable.Raw = (UINT8 *)(UINTN)Smbios->TableAddress;
|
||||
if (SmbiosTable.Raw == NULL) {
|
||||
return SmbiosTable;
|
||||
}
|
||||
while ((SmbiosTypeIndex != Index) || (SmbiosTable.Hdr->Type != Type)) {
|
||||
if (SmbiosTable.Hdr->Type == 127) {
|
||||
SmbiosTable.Raw = NULL;
|
||||
return SmbiosTable;
|
||||
}
|
||||
if (SmbiosTable.Hdr->Type == Type) {
|
||||
SmbiosTypeIndex ++;
|
||||
}
|
||||
SmbiosTable.Raw = (UINT8 *)(SmbiosTable.Raw + SmbiosTableLength (SmbiosTable));
|
||||
}
|
||||
|
||||
return SmbiosTable;
|
||||
}
|
||||
|
||||
CHAR8 *
|
||||
GetSmbiosString (
|
||||
IN SMBIOS_STRUCTURE_POINTER SmbiosTable,
|
||||
IN SMBIOS_TABLE_STRING String
|
||||
)
|
||||
{
|
||||
CHAR8 *AString;
|
||||
UINT8 Index;
|
||||
|
||||
Index = 1;
|
||||
AString = (CHAR8 *)(SmbiosTable.Raw + SmbiosTable.Hdr->Length);
|
||||
while (Index != String) {
|
||||
while (*AString != 0) {
|
||||
AString ++;
|
||||
}
|
||||
AString ++;
|
||||
if (*AString == 0) {
|
||||
return AString;
|
||||
}
|
||||
Index ++;
|
||||
}
|
||||
|
||||
return AString;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Logs SMBIOS record.
|
||||
|
||||
@param Smbios Pointer to SMBIOS protocol instance.
|
||||
@param Buffer Pointer to the data buffer.
|
||||
|
||||
**/
|
||||
VOID
|
||||
LogSmbiosData (
|
||||
IN EFI_SMBIOS_PROTOCOL *Smbios,
|
||||
IN UINT8 *Buffer
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_SMBIOS_HANDLE SmbiosHandle;
|
||||
|
||||
SmbiosHandle = 0;
|
||||
Status = Smbios->Add (
|
||||
Smbios,
|
||||
NULL,
|
||||
&SmbiosHandle,
|
||||
(EFI_SMBIOS_TABLE_HEADER*)Buffer
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/** @file
|
||||
|
||||
Copyright (c) 2009, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
|
||||
DataHubGen.h
|
||||
|
||||
Abstract:
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _SMBIOS_GEN_H_
|
||||
#define _SMBIOS_GEN_H_
|
||||
|
||||
#include <FrameworkDxe.h>
|
||||
#include <IndustryStandard/SmBios.h>
|
||||
|
||||
#include <Guid/HobList.h>
|
||||
#include <Guid/SmBios.h>
|
||||
#include <Guid/DataHubRecords.h>
|
||||
|
||||
#include <Protocol/Smbios.h>
|
||||
#include <Protocol/FrameworkHii.h>
|
||||
#include <Protocol/HiiDatabase.h>
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/HobLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/HiiLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
|
||||
#define PRODUCT_NAME L"DUET"
|
||||
#define PRODUCT_VERSION L"Beta"
|
||||
|
||||
#define FIRMWARE_PRODUCT_NAME (PRODUCT_NAME L": ")
|
||||
#ifdef EFI32
|
||||
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
|
||||
#define FIRMWARE_BIOS_VERSIONE (PRODUCT_NAME L"(IA32.UEFI)" PRODUCT_VERSION L": ")
|
||||
#else
|
||||
#define FIRMWARE_BIOS_VERSIONE (PRODUCT_NAME L"(IA32.EFI)" PRODUCT_VERSION L": ")
|
||||
#endif
|
||||
#else // EFIX64
|
||||
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
|
||||
#define FIRMWARE_BIOS_VERSIONE (PRODUCT_NAME L"(X64.UEFI)" PRODUCT_VERSION L": ")
|
||||
#else
|
||||
#define FIRMWARE_BIOS_VERSIONE (PRODUCT_NAME L"(X64.EFI)" PRODUCT_VERSION L": ")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
SMBIOS_STRUCTURE_POINTER
|
||||
GetSmbiosTableFromType (
|
||||
IN SMBIOS_TABLE_ENTRY_POINT *Smbios,
|
||||
IN UINT8 Type,
|
||||
IN UINTN Index
|
||||
);
|
||||
|
||||
CHAR8 *
|
||||
GetSmbiosString (
|
||||
IN SMBIOS_STRUCTURE_POINTER SmbiosTable,
|
||||
IN SMBIOS_TABLE_STRING String
|
||||
);
|
||||
|
||||
/**
|
||||
Logs SMBIOS record.
|
||||
|
||||
@param Smbios Pointer to SMBIOS protocol instance.
|
||||
@param Buffer Pointer to the data buffer.
|
||||
|
||||
**/
|
||||
VOID
|
||||
LogSmbiosData (
|
||||
IN EFI_SMBIOS_PROTOCOL *Smbios,
|
||||
IN UINT8 *Buffer
|
||||
);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,63 @@
|
|||
#/*++
|
||||
#
|
||||
# Copyright (c) 2009, Intel Corporation
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# SmbiosGen.inf
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# Component description file for SmbiosGen module.
|
||||
#
|
||||
#--*/
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = SmbiosGenDxe
|
||||
FILE_GUID = 0021001C-3CE3-41f8-99C6-ECF5DA754731
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
EDK_RELEASE_VERSION = 0x00020000
|
||||
EFI_SPECIFICATION_VERSION = 0x00020000
|
||||
ENTRY_POINT = SmbiosGenEntrypoint
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
IntelFrameworkPkg/IntelFrameworkPkg.dec
|
||||
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
UefiLib
|
||||
HobLib
|
||||
UefiBootServicesTableLib
|
||||
BaseMemoryLib
|
||||
MemoryAllocationLib
|
||||
UefiDriverEntryPoint
|
||||
BaseLib
|
||||
HiiLib
|
||||
|
||||
[Sources.common]
|
||||
SmbiosGen.c
|
||||
SmbiosGen.h
|
||||
SmbiosGenStrings.uni
|
||||
|
||||
[Guids.common]
|
||||
gEfiSmbiosTableGuid
|
||||
|
||||
[Protocols]
|
||||
gEfiHiiDatabaseProtocolGuid
|
||||
gEfiSmbiosProtocolGuid
|
||||
gEfiHiiProtocolGuid
|
||||
|
||||
[Depex]
|
||||
gEfiSmbiosProtocolGuid AND gEfiHiiDatabaseProtocolGuid
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue