提交 8ea219ed 编写于 作者: V vit9696

Initial import of SMBIOS code from OC

上级 eb46e450
/** @file
OcSmbiosLib
Copyright (c) 2019, vit9696
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.
**/
#ifndef OC_SMBIOS_LIB_H
#define OC_SMBIOS_LIB_H
EFI_STATUS
CreateSmBios (
VOID
);
#endif // OC_SMBIOS_LIB_H
......@@ -22,6 +22,7 @@
[Packages]
MdePkg/MdePkg.dec
OcSupportPkg/OcSupportPkg.dec
EfiPkg/EfiPkg.dec
[LibraryClasses]
BaseMemoryLib
......
/** @file
Copyright (C) 2016 - 2017, The HermitCrabs Lab. All rights reserved.
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.
**/
#include <Uefi.h>
#include <Protocol/PciRootBridgeIo.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/OcCpuLib.h>
#include <Library/OcMiscLib.h>
#include <Library/OcProtocolLib.h>
#include <Library/PrintLib.h>
#include <Library/OcVariableLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Macros.h>
#include "OcSmbiosInternal.h"
#include "DebugSmbios.h"
// SmbiosGetString
/**
@param[in] SmbiosTable
@param[in] StringIndex String Index to retrieve
@retval
**/
CHAR8 *
SmbiosGetString (
IN APPLE_SMBIOS_STRUCTURE_POINTER SmbiosTable,
IN SMBIOS_TABLE_STRING String
)
{
CHAR8 *AString = (CHAR8 *)(SmbiosTable.Raw + SmbiosTable.Standard.Hdr->Length);
UINT8 Index = 1;
if (String == 0)
return NULL;
while (Index != String) {
while (*AString != 0) {
AString ++;
}
AString ++;
if (*AString == 0) {
return AString;
}
Index ++;
}
return AString;
}
// SmbiosSetString
/**
@param[in] Buffer Pointer to location containing the current address within the buffer.
@param[in] StringIndex String Index to retrieve
@param[in] String Buffer containing the null terminated ascii string
@retval
**/
UINT8
SmbiosSetString (
IN CHAR8 **Buffer,
IN CHAR8 *String,
IN UINT8 *Index
)
{
UINTN Length = 0;
VOID *Target = (VOID *)*((UINTN *)Buffer);
if (String == NULL) {
return 0;
}
Length = AsciiStrLen (String);
// Remove any spaces found at the end
while ((Length != 0) && (String[Length - 1] == ' '))
{
Length--;
}
if (Length == 0)
{
return 0;
}
CopyMem (Target, String, Length);
*Buffer += (Length + 1);
return *Index += 1;
}
// SmbiosSetStringHex
/**
@param[in] Buffer Pointer to location containing the current address within the buffer.
@param[in] StringIndex String Index to retrieve
@param[in] String Buffer containing the null terminated ascii string
@retval
**/
UINT8
SmbiosSetStringHex (
IN CHAR8 **Buffer,
IN CHAR8 *String,
IN UINT8 *Index
)
{
UINTN Length = 0;
CHAR8 Digit;
CHAR8 *Target = (VOID *)*((UINTN *)Buffer);
if (String == NULL) {
return 0;
}
Length = AsciiStrLen (String);
if (Length == 0) {
return 0;
}
// Remove any spaces found at the end
while ((Length != 0) && (String[Length - 1] == ' '))
{
Length--;
}
if (Length == 0)
{
return 0;
}
*Target++ = '0';
*Target++ = 'x';
while ((Length != 0) && (*String) != 0)
{
Digit = *String++;
*Target++ = "0123456789ABCDEF"[((Digit >> 4) & 0xF)];
*Target++ = "0123456789ABCDEF"[(Digit & 0xF)];
Length--;
}
*Buffer += (Target - *Buffer) + 1;
return *Index += 1;
}
// SmbiosSetOverrideString
/**
@param[in] Buffer Pointer to location containing the current address within the buffer.
@param[in] StringIndex String Index to retrieve
@param[in] String Buffer containing the null terminated ascii string
@retval
**/
UINT8
SmbiosSetOverrideString (
IN CHAR8 **Buffer,
IN CHAR8 *VariableName,
IN UINT8 *Index
)
{
EFI_STATUS Status;
CHAR8 *Data;
UINTN Length;
if ((Buffer != NULL) && (VariableName != NULL)) {
Data = *Buffer;
Length = SMBIOS_STRING_MAX_LENGTH;
//FIXME: BROKEN
Status = EFI_INVALID_PARAMETER; /*OcGetVariable (
VariableName,
&gOpenCoreOverridesGuid,
(VOID **)&Data,
&Length
);*/
if (!EFI_ERROR (Status)) {
*Buffer += (Length + 1);
return *Index += 1;
}
}
return 0;
}
// SmbiosGetTableLength
/**
@retval
**/
UINTN
SmbiosGetTableLength (
IN APPLE_SMBIOS_STRUCTURE_POINTER SmbiosTable
)
{
CHAR8 *AChar;
UINTN Length;
AChar = (CHAR8 *)(SmbiosTable.Raw + SmbiosTable.Standard.Hdr->Length);
while ((*AChar != 0) || (*(AChar + 1) != 0)) {
AChar ++;
}
Length = ((UINTN)AChar - (UINTN)SmbiosTable.Raw + 2);
return Length;
}
// SmbiosGetTableFromType
/**
@param[in] Smbios Pointer to smbios entry point structure.
@param[in] Type
@param[in] Index
@retval
**/
APPLE_SMBIOS_STRUCTURE_POINTER
SmbiosGetTableFromType (
IN SMBIOS_TABLE_ENTRY_POINT *Smbios,
IN SMBIOS_TYPE Type,
IN UINTN Index
)
{
APPLE_SMBIOS_STRUCTURE_POINTER SmbiosTable;
UINTN SmbiosTypeIndex;
SmbiosTypeIndex = 1;
SmbiosTable.Raw = (UINT8 *)(UINTN)Smbios->TableAddress;
if (SmbiosTable.Raw == NULL) {
return SmbiosTable;
}
while ((SmbiosTypeIndex != Index) || (SmbiosTable.Standard.Hdr->Type != Type)) {
if (SmbiosTable.Standard.Hdr->Type == SMBIOS_TYPE_END_OF_TABLE) {
SmbiosTable.Raw = NULL;
break;
}
if (SmbiosTable.Standard.Hdr->Type == Type) {
SmbiosTypeIndex ++;
}
SmbiosTable.Raw = (UINT8 *)(SmbiosTable.Raw + SmbiosGetTableLength (SmbiosTable));
if (SmbiosTable.Raw > (UINT8 *)(UINTN)(Smbios->TableAddress + Smbios->TableLength)) {
SmbiosTable.Raw = NULL;
break;
}
}
return SmbiosTable;
}
// SmbiosGetTableFromHandle
/**
@param[in] Smbios Pointer to smbios entry point structure.
@param[in] Handle
@retval
**/
APPLE_SMBIOS_STRUCTURE_POINTER
SmbiosGetTableFromHandle (
IN SMBIOS_TABLE_ENTRY_POINT *Smbios,
IN SMBIOS_HANDLE Handle
)
{
APPLE_SMBIOS_STRUCTURE_POINTER SmbiosTable;
SmbiosTable.Raw = (UINT8 *)(UINTN)Smbios->TableAddress;
if (SmbiosTable.Raw == NULL) {
return SmbiosTable;
}
while (SmbiosTable.Standard.Hdr->Handle != Handle) {
if (SmbiosTable.Standard.Hdr->Type == SMBIOS_TYPE_END_OF_TABLE) {
SmbiosTable.Raw = NULL;
break;
}
SmbiosTable.Raw = (UINT8 *)(SmbiosTable.Raw + SmbiosGetTableLength (SmbiosTable));
if (SmbiosTable.Raw > (UINT8 *)(UINTN)(Smbios->TableAddress + Smbios->TableLength)) {
SmbiosTable.Raw = NULL;
break;
}
}
return SmbiosTable;
}
// SmbiosGetTableCount
/**
@param[in] Smbios Pointer to smbios entry point structure.
@param[in] Type
@retval
**/
UINTN
SmbiosGetTableCount (
IN SMBIOS_TABLE_ENTRY_POINT *Smbios,
IN SMBIOS_TYPE Type
)
{
APPLE_SMBIOS_STRUCTURE_POINTER SmbiosTable;
UINTN SmbiosTypeIndex;
SmbiosTypeIndex = 1;
SmbiosTable.Raw = (UINT8 *)(UINTN)Smbios->TableAddress;
if (SmbiosTable.Raw == NULL) {
return SmbiosTypeIndex;
}
while (SmbiosTable.Standard.Hdr->Type != SMBIOS_TYPE_END_OF_TABLE) {
if (SmbiosTable.Standard.Hdr->Type == Type) {
SmbiosTypeIndex ++;
}
SmbiosTable.Raw = (UINT8 *)(SmbiosTable.Raw + SmbiosGetTableLength (SmbiosTable));
if (SmbiosTable.Raw > (UINT8 *)(UINTN)(Smbios->TableAddress + Smbios->TableLength)) {
break;
}
}
return SmbiosTypeIndex;
}
/** @file
Copyright (C) 2016 - 2017, The HermitCrabs Lab. All rights reserved.
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.
**/
#include <Base.h>
#include <IndustryStandard/AppleSmBios.h>
#include <Library/DebugLib.h>
#include <Library/UefiLib.h>
#include <Macros.h>
#include "DebugSmbios.h"
#include "OcSmbiosInternal.h"
// String Conversion Lookup Table
GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *SlotDataWidthStrings[] = {
"",
"Other",
"Unknown",
"8Bit",
"16Bit",
"32Bit",
"64Bit",
"128Bit",
"1X",
"2X",
"4X",
"8X",
"12X",
"16X",
"32X"
};
VOID
SmbiosDebugGeneric (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
)
{
DEBUG_SMBIOS ((
DEBUG_INFO,
"Handle 0x%02X Type %d Length 0x%02X\n",
Record.Standard.Hdr->Handle,
Record.Standard.Hdr->Type,
Record.Standard.Hdr->Length
));
}
VOID
SmbiosDebugBiosInformation (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
)
{
SmbiosDebugGeneric (Record);
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"Vendor",
SmbiosGetString (Record, Record.Standard.Type0->Vendor)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"BiosVersion",
SmbiosGetString (Record, Record.Standard.Type0->BiosVersion)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"BiosReleaseDate",
SmbiosGetString (Record, Record.Standard.Type0->BiosReleaseDate)
));
}
VOID
SmbiosDebugSystemInformation (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
)
{
SmbiosDebugGeneric (Record);
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"Manufacturer",
SmbiosGetString (Record, Record.Standard.Type1->Manufacturer)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"ProductName",
SmbiosGetString (Record, Record.Standard.Type1->ProductName)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"Version",
SmbiosGetString (Record, Record.Standard.Type1->Version)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"SerialNumber",
SmbiosGetString (Record, Record.Standard.Type1->SerialNumber)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %g\n",
"Uuid",
Record.Standard.Type1->Uuid
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"SKUNumber",
SmbiosGetString (Record, Record.Standard.Type1->SKUNumber)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"Family",
SmbiosGetString (Record, Record.Standard.Type1->Family)
));
}
VOID
SmbiosDebugBaseboardInformation (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
)
{
SmbiosDebugGeneric (Record);
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"Manufacturer",
SmbiosGetString (Record, Record.Standard.Type2->Manufacturer)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"ProductName",
SmbiosGetString (Record, Record.Standard.Type2->ProductName)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"Version",
SmbiosGetString (Record, Record.Standard.Type2->Version)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"SerialNumber",
SmbiosGetString (Record, Record.Standard.Type2->SerialNumber)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"Location",
SmbiosGetString (Record, Record.Standard.Type2->LocationInChassis)
));
}
VOID
SmbiosDebugSystemEnclosure (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
)
{
SmbiosDebugGeneric (Record);
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"Manufacturer",
SmbiosGetString (Record, Record.Standard.Type3->Manufacturer)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"Version",
SmbiosGetString (Record, Record.Standard.Type3->Version)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"SerialNumber",
SmbiosGetString (Record, Record.Standard.Type3->SerialNumber)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"AssetTag",
SmbiosGetString (Record, Record.Standard.Type3->AssetTag)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"SKUNumber",
SmbiosGetString (Record, *(PTR_OFFSET(Record.Raw,
MultU64x32 (
Record.Standard.Type3->ContainedElementCount,
Record.Standard.Type3->ContainedElementRecordLength) + 0x15,
UINT8 *)))
));
}
VOID
SmbiosDebugProcessorInformation (
IN SMBIOS_TABLE_ENTRY_POINT *Smbios,
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
)
{
SmbiosDebugGeneric (Record);
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"Socket",
SmbiosGetString (Record, Record.Standard.Type4->Socket)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"Manufacturer",
SmbiosGetString (Record, Record.Standard.Type4->ProcessorManufacture)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"Version",
SmbiosGetString (Record, Record.Standard.Type4->ProcessorVersion)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %d MHz\n",
"External Clock",
Record.Standard.Type4->ExternalClock
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %d MHz\n",
"Max Speed",
Record.Standard.Type4->MaxSpeed
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %d MHz\n",
"Current Speed",
Record.Standard.Type4->CurrentSpeed
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a 0x%02X\n",
"Family",
Record.Standard.Type4->ProcessorFamily
));
// Not present before 2.7 specifications
if (((Smbios->MajorVersion == 2) && (Smbios->MinorVersion >= 7)) ||
(Smbios->MajorVersion == 3))
{
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a 0x%02X\n",
"Family2",
Record.Standard.Type4->ProcessorFamily2
));
}
}
VOID
SmbiosDebugSystemPorts (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
)
{
SmbiosDebugGeneric (Record);
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"Internal",
SmbiosGetString (Record, Record.Standard.Type8->InternalReferenceDesignator)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %X\n",
"Type",
Record.Standard.Type8->InternalConnectorType
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"External",
SmbiosGetString (Record, Record.Standard.Type8->ExternalReferenceDesignator)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %X\n",
"Type",
Record.Standard.Type8->ExternalConnectorType
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %X\n",
"Port Type",
Record.Standard.Type8->PortType
));
}
VOID
SmbiosDebugCacheInformation (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
)
{
SmbiosDebugGeneric (Record);
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"Socket",
SmbiosGetString (Record, Record.Standard.Type7->SocketDesignation)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %d KB\n",
"Maximum Size",
Record.Standard.Type7->MaximumCacheSize
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %d KB\n",
"Installed Size",
Record.Standard.Type7->InstalledSize
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %d\n",
"Associativity",
Record.Standard.Type7->Associativity
));
}
VOID
SmbiosDebugSystemSlots (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
)
{
SmbiosDebugGeneric (Record);
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"Designation",
SmbiosGetString (Record, Record.Standard.Type9->SlotDesignation)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %X\n",
"Type",
Record.Standard.Type9->SlotType
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"DataBus Width",
SlotDataWidthStrings[Record.Standard.Type9->SlotDataBusWidth]
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"Current Usage",
(Record.Standard.Type9->CurrentUsage == SlotUsageAvailable ? "Free" : "InUse")
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"Length",
(Record.Standard.Type9->SlotLength == SlotLengthShort ? "Short" : "Long")
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %X\n",
"Id",
Record.Standard.Type9->SlotID
));
}
VOID
SmbiosDebugPhysicalMemoryArray (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
)
{
SmbiosDebugGeneric (Record);
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %d\n",
"Location",
Record.Standard.Type16->Location
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %d\n",
"Use",
Record.Standard.Type16->Use
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %d\n",
"ErrorCorrection",
Record.Standard.Type16->MemoryErrorCorrection
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %d GB\n",
"Maximum Capacity",
(Record.Standard.Type16->MaximumCapacity >> 20)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %d\n",
"No Of Devices",
Record.Standard.Type16->NumberOfMemoryDevices
));
}
VOID
SmbiosDebugMemoryDevice (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
)
{
SmbiosDebugGeneric (Record);
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"DeviceLocator",
SmbiosGetString (Record, Record.Standard.Type17->DeviceLocator)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"BankLocator",
SmbiosGetString (Record, Record.Standard.Type17->BankLocator)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %d Bits\n",
"TotalWidth",
Record.Standard.Type17->TotalWidth
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %d Bits\n",
"DataWidth",
Record.Standard.Type17->DataWidth
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %d MB\n",
"Size", Record.Standard.Type17->Size
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %d MHz\n",
"Speed", Record.Standard.Type17->Speed
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"Manufacturer",
SmbiosGetString (Record, Record.Standard.Type17->Manufacturer)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"SerialNumber",
SmbiosGetString (Record, Record.Standard.Type17->SerialNumber)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"AssetTag",
SmbiosGetString (Record, Record.Standard.Type17->AssetTag)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"PartNumber",
SmbiosGetString (Record, Record.Standard.Type17->PartNumber)
));
}
VOID
SmbiosDebugType19Device (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
)
{
SmbiosDebugGeneric (Record);
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a 0x%08X\n",
"Starting Address",
Record.Standard.Type19->StartingAddress
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a 0x%08X\n",
"Ending Address",
Record.Standard.Type19->EndingAddress
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a 0x%04X\n",
"Array Handle",
Record.Standard.Type19->MemoryArrayHandle
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %d\n",
"Partition Width",
Record.Standard.Type19->PartitionWidth
));
}
VOID
SmbiosDebugType20Device (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
)
{
SmbiosDebugGeneric (Record);
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a 0x%08X\n",
"Starting Address",
Record.Standard.Type20->StartingAddress
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a 0x%08X\n",
"Ending Address",
Record.Standard.Type20->EndingAddress
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a 0x%02X\n",
"Device Handle",
Record.Standard.Type20->MemoryDeviceHandle
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a 0x%04X\n",
"Array Handle",
Record.Standard.Type20->MemoryArrayMappedAddressHandle
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %d\n",
"Row Position",
Record.Standard.Type20->PartitionRowPosition
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %d\n",
"Data Depth",
Record.Standard.Type20->InterleavedDataDepth
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %d\n",
"Interleave Position",
Record.Standard.Type20->InterleavePosition
));
}
VOID
SmbiosDebugPortableBatteryDevice (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
)
{
SmbiosDebugGeneric (Record);
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"Location",
SmbiosGetString (Record, Record.Standard.Type22->Location)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"Manufacturer",
SmbiosGetString (Record, Record.Standard.Type22->Manufacturer)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"Serial Number",
SmbiosGetString (Record, Record.Standard.Type22->SerialNumber)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"Device Name",
SmbiosGetString (Record, Record.Standard.Type22->DeviceName)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"SBDS Version",
SmbiosGetString (Record, Record.Standard.Type22->SBDSVersionNumber)
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %a\n",
"SBDS Chemistry",
SmbiosGetString (Record, Record.Standard.Type22->SBDSDeviceChemistry)
));
}
VOID
SmbiosDebugBootInformation (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
)
{
SmbiosDebugGeneric (Record);
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a 0x%02X\n",
"BootStatus",
Record.Standard.Type32->BootStatus
));
}
VOID
SmbiosDebugAppleFirmwareVolume (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
)
{
SmbiosDebugGeneric (Record);
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a 0x%08X\n",
"Features",
Record.Type128->FirmwareFeatures
));
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a 0x%08X\n",
"Features Mask",
Record.Type128->FirmwareFeaturesMask
));
}
VOID
SmbiosDebugAppleProcessorType (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
)
{
SmbiosDebugGeneric (Record);
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %04X\n",
"Cpu Type",
Record.Type131->ProcessorType
));
}
VOID
SmbiosDebugAppleProcessorSpeed (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
)
{
SmbiosDebugGeneric (Record);
DEBUG_SMBIOS ((
DEBUG_INFO,
" %-16a %d\n",
"Cpu Bus Speed",
Record.Type132->ProcessorBusSpeed
));
}
/** @file
Copyright (C) 2016 - 2017, The HermitCrabs Lab. All rights reserved.
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.
**/
#ifndef DEBUG_SMBIOS_H_
#define DEBUG_SMBIOS_H_
// TODO: Use PCD?
#define LOG_SMBIOS
#ifdef LOG_SMBIOS
#define DEBUG_SMBIOS(arg) DEBUG (arg)
#else
#define DEBUG_SMBIOS(arg)
#endif
VOID
SmbiosDebugGeneric (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
);
VOID
SmbiosDebugBiosInformation (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
);
VOID
SmbiosDebugSystemInformation (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
);
VOID
SmbiosDebugBaseboardInformation (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
);
VOID
SmbiosDebugSystemEnclosure (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
);
VOID
SmbiosDebugProcessorInformation (
IN SMBIOS_TABLE_ENTRY_POINT *Smbios,
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
);
VOID
SmbiosDebugCacheInformation (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
);
VOID
SmbiosDebugSystemPorts (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
);
VOID
SmbiosDebugSystemSlots (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
);
VOID
SmbiosDebugPhysicalMemoryArray (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
);
VOID
SmbiosDebugMemoryDevice (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
);
VOID
SmbiosDebugType19Device (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
);
VOID
SmbiosDebugType20Device (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
);
VOID
SmbiosDebugPortableBatteryDevice (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
);
VOID
SmbiosDebugBootInformation (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
);
VOID
SmbiosDebugAppleFirmwareVolume (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
);
VOID
SmbiosDebugAppleProcessorType (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
);
VOID
SmbiosDebugAppleProcessorSpeed (
IN APPLE_SMBIOS_STRUCTURE_POINTER Record
);
#endif // DEBUG_SMBIOS_H_
/** @file
Copyright (C) 2016 - 2017, The HermitCrabs Lab. All rights reserved.
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.
**/
#ifndef OC_SMBIOS_INTERNAL_H
#define OC_SMBIOS_INTERNAL_H
#include <IndustryStandard/AppleSmBios.h>
// SmbiosGetString
/**
@retval
**/
CHAR8 *
SmbiosGetString (
IN APPLE_SMBIOS_STRUCTURE_POINTER SmbiosTable,
IN SMBIOS_TABLE_STRING String
);
// SmbiosSetString
/**
@param[in] Buffer Pointer to the buffer where to create the smbios string.
@param[in] String Pointer to the null terminated ascii string to set.
@param[in] Index Pointer to byte index.
@retval
**/
UINT8
SmbiosSetString (
IN CHAR8 **Buffer,
IN CHAR8 *String,
IN UINT8 *Index
);
// SmbiosSetStringHex
/**
@param[in] Buffer Pointer to location containing the current address within the buffer.
@param[in] StringIndex String Index to retrieve
@param[in] String Buffer containing the null terminated ascii string
@retval
**/
UINT8
SmbiosSetStringHex (
IN CHAR8 **Buffer,
IN CHAR8 *String,
IN UINT8 *Index
);
// SmbiosSetOverrideString
/**
@param[in] Buffer Pointer to the buffer where to create the smbios string.
@param[in] VariableName Pointer to the null terminated ascii variable name.
@param[in] Index Pointer to byte index.
@retval
**/
UINT8
SmbiosSetOverrideString (
IN CHAR8 **Buffer,
IN CHAR8 *VariableName,
IN UINT8 *Index
);
// SmbiosGetTableLength
/**
@retval
**/
UINTN
SmbiosGetTableLength (
IN APPLE_SMBIOS_STRUCTURE_POINTER SmbiosTable
);
// SmbiosGetTableFromType
/**
@retval
**/
APPLE_SMBIOS_STRUCTURE_POINTER
SmbiosGetTableFromType (
IN SMBIOS_TABLE_ENTRY_POINT *Smbios,
IN SMBIOS_TYPE Type,
IN UINTN Index
);
// SmbiosGetTableFromHandle
/**
@retval
**/
APPLE_SMBIOS_STRUCTURE_POINTER
SmbiosGetTableFromHandle (
IN SMBIOS_TABLE_ENTRY_POINT *Smbios,
IN SMBIOS_HANDLE Handle
);
// SmbiosGetTableCount
/**
@retval
**/
UINTN
SmbiosGetTableCount (
IN SMBIOS_TABLE_ENTRY_POINT *Smbios,
IN UINT8 Type
);
// CreateSmBios
/**
@retval EFI_SUCCESS The smbios structure was created and installed successfully.
**/
EFI_STATUS
CreateSmBios (
VOID
);
#endif // OC_SMBIOS_INTERNAL_H
## @file
#
# Component description file for the library producing the Oc Smbios Gen protocol.
#
# Copyright (C) 2016 - 2017, The HermitCrabs Lab. All rights reserved.<BR>
#
# 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.
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = OcSmbiosLib
FILE_GUID = D8D99FA0-BDA2-4B5C-A090-3253205BE9B7
MODULE_TYPE = UEFI_APPLICATION
VERSION_STRING = 1.0
LIBRARY_CLASS = OcSmbiosLib|PEIM DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_DRIVER UEFI_APPLICATION DXE_SMM_DRIVER
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
[Sources]
AutoSmbios.c
DebugSmbios.c
SmbiosPatch.c
OcSmbiosInternal.h
[Packages]
EfiPkg/EfiPkg.dec
MdePkg/MdePkg.dec
OcSupportPkg/OcSupportPkg.dec
[Guids]
gEfiEndOfDxeEventGroupGuid
gEfiSmbiosTableGuid
[Protocols]
gEfiPciRootBridgeIoProtocolGuid
此差异已折叠。
......@@ -46,13 +46,7 @@
[LibraryClasses]
## @libraryclass
OcPngLib|Include/Library/OcPngLib.h
## @libraryclass
OcCryptoLib|Include/Library/OcCryptoLib.h
## @libraryclass
OcGuardLib|Include/Library/OcGuardLib.h
OcAcpiLib|Include/Library/OcAcpiLib.h
## @libraryclass
OcAppleBootPolicyLib|Include/Library/OcAppleBootPolicyLib.h
......@@ -64,46 +58,55 @@
OcAppleImageVerificationLib|Include/Library/OcAppleImageVerificationLib.h
## @libraryclass
OcAcpiLib|Include/Library/OcAcpiLib.h
OcCpuLib|Include/Library/OcCpuLib.h
## @libraryclass
OcCpuLib|Include/Library/OcCpuLib.h
OcCryptoLib|Include/Library/OcCryptoLib.h
## @libraryclass
OcDevicePathLib|Include/Library/OcDevicePathLib.h
## @libraryclass
OcDevicePropertyLib|Include/Library/OcDevicePropertyLib.h
## @libraryclass
OcFileLib|Include/Library/OcFileLib.h
## @libraryclass
OcMiscLib|Include/Library/OcMiscLib.h
OcFirmwarePasswordLib|Include/Library/OcFirmwarePasswordLib.h
## @libraryclass
OcProtocolLib|Include/Library/OcProtocolLib.h
OcGuardLib|Include/Library/OcGuardLib.h
## @libraryclass
OcStringLib|Include/Library/OcStringLib.h
OcMachoLib|Include/Library/OcMachoLib.h
## @libraryclass
OcTimerLib|Include/Library/OcTimerLib.h
OcMiscLib|Include/Library/OcMiscLib.h
## @libraryclass
OcVariableLib|Include/Library/OcVariableLib.h
OcPngLib|Include/Library/OcPngLib.h
## @libraryclass
OcDevicePropertyLib|Include/Library/OcDevicePropertyLib.h
OcProtocolLib|Include/Library/OcProtocolLib.h
## @libraryclass
OcFirmwarePasswordLib|Include/Library/OcFirmwarePasswordLib.h
OcSerializeLib|Include/Library/OcSerializeLib.h
## @libraryclass
OcMachoLib|Include/Library/OcMachoLib.h
OcSmbiosLib|Include/Library/OcSmbiosLib.h
## @libraryclass
OcSerializeLib|Include/Library/OcSerializeLib.h
OcStringLib|Include/Library/OcStringLib.h
## @libraryclass
OcTemplateLib|Include/Library/OcTemplateLib.h
## @libraryclass
OcTimerLib|Include/Library/OcTimerLib.h
## @libraryclass
OcVariableLib|Include/Library/OcVariableLib.h
## @libraryclass
OcXmlLib|Include/Library/OcXmlLib.h
......@@ -48,27 +48,28 @@
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
[Components]
OcSupportPkg/Library/OcAcpiLib/OcAcpiLib.inf
OcSupportPkg/Library/OcAppleBootPolicyLib/OcAppleBootPolicyLib.inf
OcSupportPkg/Library/OcAppleChunklistLib/OcAppleChunklistLib.inf
OcSupportPkg/Library/OcAppleImageVerificationLib/OcAppleImageVerificationLib.inf
OcSupportPkg/Library/OcCryptoLib/OcCryptoLib.inf
OcSupportPkg/Library/OcGuardLib/OcGuardLib.inf
OcSupportPkg/Library/OcPngLib/OcPngLib.inf
OcSupportPkg/Library/OcAcpiLib/OcAcpiLib.inf
OcSupportPkg/Library/OcCpuLib/OcCpuLib.inf
OcSupportPkg/Library/OcCryptoLib/OcCryptoLib.inf
OcSupportPkg/Library/OcDebugLogLib/OcDebugLogLib.inf
OcSupportPkg/Library/OcDevicePathLib/OcDevicePathLib.inf
OcSupportPkg/Library/OcDevicePropertyLib/OcDevicePropertyLib.inf
OcSupportPkg/Library/OcFileLib/OcFileLib.inf
OcSupportPkg/Library/OcFirmwarePasswordLib/OcFirmwarePasswordLib.inf
OcSupportPkg/Library/OcGuardLib/OcGuardLib.inf
OcSupportPkg/Library/OcMachoLib/OcMachoLib.inf
OcSupportPkg/Library/OcMiscLib/OcMiscLib.inf
OcSupportPkg/Library/OcPngLib/OcPngLib.inf
OcSupportPkg/Library/OcProtocolLib/OcProtocolLib.inf
OcSupportPkg/Library/OcSerializeLib/OcSerializeLib.inf
OcSupportPkg/Library/OcSmbiosLib/OcSmbiosLib.inf
OcSupportPkg/Library/OcStringLib/OcStringLib.inf
OcSupportPkg/Library/OcTemplateLib/OcTemplateLib.inf
OcSupportPkg/Library/OcTimerLib/OcTimerLib.inf
OcSupportPkg/Library/OcVariableLib/OcVariableLib.inf
OcSupportPkg/Library/OcDevicePropertyLib/OcDevicePropertyLib.inf
OcSupportPkg/Library/OcFirmwarePasswordLib/OcFirmwarePasswordLib.inf
OcSupportPkg/Library/OcMachoLib/OcMachoLib.inf
OcSupportPkg/Library/OcSerializeLib/OcSerializeLib.inf
OcSupportPkg/Library/OcTemplateLib/OcTemplateLib.inf
OcSupportPkg/Library/OcXmlLib/OcXmlLib.inf
OcSupportPkg/Debug/GdbSyms/GdbSyms.inf
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册