Skip to content

Commit

Permalink
OcSmbiosLib: Add support for exposing OEM info
Browse files Browse the repository at this point in the history
  • Loading branch information
vit9696 committed Jan 25, 2020
1 parent 25b3ed1 commit 8f0b7fc
Show file tree
Hide file tree
Showing 8 changed files with 220 additions and 115 deletions.
15 changes: 15 additions & 0 deletions Include/Guid/OcVariables.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
//
#define OC_VERSION_VARIABLE_NAME L"opencore-version"

//
// Variable used to report OEM product from SMBIOS Type1 ProductName.
//
#define OC_OEM_PRODUCT_VARIABLE_NAME L"oem-product"

//
// Variable used to report OEM board vendor from SMBIOS Type2 Manufacturer.
//
#define OC_OEM_VENDOR_VARIABLE_NAME L"oem-vendor"

//
// Variable used to report OEM board vendor from SMBIOS Type2 ProductName.
//
#define OC_OEM_BOARD_VARIABLE_NAME L"oem-board"

//
// 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102
// This GUID is specifically used for normal variable access by Lilu kernel extension and its plugins.
Expand Down
1 change: 1 addition & 0 deletions Include/Library/OcConfigurationLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@
#define OCS_EXPOSE_BOOT_PATH 1U
#define OCS_EXPOSE_VERSION_VAR 2U
#define OCS_EXPOSE_VERSION_UI 4U
#define OCS_EXPOSE_OEM_INFO 8U
#define OCS_EXPOSE_VERSION (OCS_EXPOSE_VERSION_VAR | OCS_EXPOSE_VERSION_UI)

#define OC_MISC_SECURITY_FIELDS(_, __) \
Expand Down
79 changes: 72 additions & 7 deletions Include/Library/OcSmbiosLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define OC_SMBIOS_LIB_H

#include <Library/OcCpuLib.h>
#include <IndustryStandard/AppleSmBios.h>

//
// This GUID is used for storing SMBIOS data when the firmware overwrites SMBIOS data at original
Expand Down Expand Up @@ -136,17 +137,81 @@ typedef enum OC_SMBIOS_UPDATE_MODE_ {
OcSmbiosUpdateCustom = 3,
} OC_SMBIOS_UPDATE_MODE;

//
// Growing SMBIOS table data.
//
typedef struct OC_SMBIOS_TABLE_ {
//
// SMBIOS table.
//
UINT8 *Table;
//
// Current table position.
//
APPLE_SMBIOS_STRUCTURE_POINTER CurrentPtr;
//
// Current string position.
//
CHAR8 *CurrentStrPtr;
//
// Allocated table size, multiple of EFI_PAGE_SIZE.
//
UINT32 AllocatedTableSize;
//
// Incrementable handle.
//
SMBIOS_HANDLE Handle;
//
// Largest structure size within the table.
//
UINT16 MaxStructureSize;
//
// Number of structures within the table.
//
UINT16 NumberOfStructures;
} OC_SMBIOS_TABLE;

/**
Prepare new SMBIOS table based on host data.
@param SmbiosTable
@retval EFI_SUCCESS if buffer is ready to be filled.
**/
EFI_STATUS
OcSmbiosTablePrepare (
IN OUT OC_SMBIOS_TABLE *SmbiosTable
);

/**
Free SMBIOS table
@param[in, out] Table Current table buffer.
@retval EFI_SUCCESS on success
**/
VOID
SmbiosGetSmcVersion (
IN CONST UINT8 *SmcRevision,
OUT UINT8 *SmcVersion
OcSmbiosTableFree (
IN OUT OC_SMBIOS_TABLE *Table
);

EFI_STATUS
CreateSmbios (
IN OC_SMBIOS_DATA *Data,
IN OC_SMBIOS_UPDATE_MODE Mode,
IN OC_CPU_INFO *CpuInfo
OcSmbiosCreate (
IN OUT OC_SMBIOS_TABLE *SmbiosTable,
IN OC_SMBIOS_DATA *Data,
IN OC_SMBIOS_UPDATE_MODE Mode,
IN OC_CPU_INFO *CpuInfo
);

VOID
OcSmbiosExposeOemInfo (
IN OC_SMBIOS_TABLE *SmbiosTable
);

VOID
OcSmbiosGetSmcVersion (
IN CONST UINT8 *SmcRevision,
OUT UINT8 *SmcVersion
);

#endif // OC_SMBIOS_LIB_H
1 change: 1 addition & 0 deletions Library/OcSmbiosLib/OcSmbiosLib.inf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
gEfiSmbiosTableGuid
gEfiSmbios3TableGuid
gOcCustomSmbiosTableGuid
gOcVendorVariableGuid

[Protocols]
gEfiPciRootBridgeIoProtocolGuid
Expand Down
13 changes: 1 addition & 12 deletions Library/OcSmbiosLib/SmbiosInternal.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <Library/MemoryAllocationLib.h>
#include <Library/OcCpuLib.h>
#include <Library/OcMiscLib.h>
#include <Library/OcSmbiosLib.h>
#include <Library/PrintLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiBootServicesTableLib.h>
Expand Down Expand Up @@ -87,18 +88,6 @@ SmbiosExtendTable (
return EFI_SUCCESS;
}

VOID
SmbiosTableFree (
IN OUT OC_SMBIOS_TABLE *Table
)
{
if (Table->Table != NULL) {
FreePool (Table->Table);
}

ZeroMem (Table, sizeof (*Table));
}

UINT8
SmbiosOverrideString (
IN OC_SMBIOS_TABLE *Table,
Expand Down
47 changes: 1 addition & 46 deletions Library/OcSmbiosLib/SmbiosInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <IndustryStandard/AppleSmBios.h>
#include <Library/OcGuardLib.h>
#include <Library/OcSmbiosLib.h>

//
// 2 zero bytes required in the end of each table.
Expand Down Expand Up @@ -99,40 +100,6 @@ enum {

STATIC_ASSERT (OcSmbiosAutomaticHandle > OcSmbiosLastReservedHandle, "Inconsistent handle IDs");

//
// Growing SMBIOS table data.
//
typedef struct OC_SMBIOS_TABLE_ {
//
// SMBIOS table.
//
UINT8 *Table;
//
// Current table position.
//
APPLE_SMBIOS_STRUCTURE_POINTER CurrentPtr;
//
// Current string position.
//
CHAR8 *CurrentStrPtr;
//
// Allocated table size, multiple of EFI_PAGE_SIZE.
//
UINT32 AllocatedTableSize;
//
// Incrementable handle.
//
SMBIOS_HANDLE Handle;
//
// Largest structure size within the table.
//
UINT16 MaxStructureSize;
//
// Number of structures within the table.
//
UINT16 NumberOfStructures;
} OC_SMBIOS_TABLE;

//
// Map old handles to new ones.
//
Expand All @@ -155,18 +122,6 @@ SmbiosExtendTable (
IN UINT32 Size
);

/**
Free SMBIOS table
@param[in, out] Table Current table buffer.
@retval EFI_SUCCESS on success
**/
VOID
SmbiosTableFree (
IN OUT OC_SMBIOS_TABLE *Table
);

/**
Write override string to SMBIOS table
Expand Down
Loading

0 comments on commit 8f0b7fc

Please sign in to comment.