2019-09-03 11:58:42 +02:00
|
|
|
//
|
|
|
|
/// @file rEFIt_UEFI/Platform/DataHubCpu.c
|
|
|
|
///
|
|
|
|
/// VirtualBox CPU descriptors
|
|
|
|
///
|
|
|
|
/// VirtualBox CPU descriptors also used to set OS X-used NVRAM variables and DataHub data
|
|
|
|
///
|
|
|
|
|
|
|
|
// Copyright(C) 2009-2010 Oracle Corporation
|
|
|
|
//
|
|
|
|
// This file is part of VirtualBox Open Source Edition(OSE), as
|
|
|
|
// available from http://www.virtualbox.org. This file is free software;
|
|
|
|
// you can redistribute it and/or modify it under the terms of the GNU
|
|
|
|
// General Public License(GPL) as published by the Free Software
|
|
|
|
// Foundation, in version 2 as it comes in the "COPYING" file of the
|
|
|
|
// VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
|
|
|
// hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
|
|
|
|
|
|
|
//
|
|
|
|
// CHANGELOG:
|
|
|
|
//
|
|
|
|
// 2019/06/08
|
|
|
|
// vector sigma
|
2021-04-03 16:42:49 +02:00
|
|
|
// don't inject REV, RBr and EPCI keys if gSettings.Smbios.REV is zeroed
|
2019-09-03 11:58:42 +02:00
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef DEBUG_ALL
|
|
|
|
#define DEBUG_DH 1
|
|
|
|
#else
|
|
|
|
#define DEBUG_DH DEBUG_ALL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if DEBUG_DH == 0
|
|
|
|
#define DBG(...)
|
|
|
|
#else
|
|
|
|
#define DBG(...) DebugLog(DEBUG_DH, __VA_ARGS__)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2020-08-17 21:40:52 +02:00
|
|
|
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile
|
2023-11-18 11:04:54 +01:00
|
|
|
#include "../cpp_lib/MemoryTracker.h"
|
2021-02-06 18:16:46 +01:00
|
|
|
#include "../include/OSTypes.h"
|
2020-04-16 09:15:26 +02:00
|
|
|
#include "Nvram.h"
|
|
|
|
#include "platformdata.h"
|
|
|
|
#include "smbios.h"
|
|
|
|
#include "cpu.h"
|
2020-09-28 11:05:37 +02:00
|
|
|
#include "DataHubCpu.h"
|
2021-04-28 20:30:34 +02:00
|
|
|
#include "../Platform/CloverVersion.h"
|
2020-04-16 09:15:26 +02:00
|
|
|
|
2019-09-03 11:58:42 +02:00
|
|
|
#include <Guid/DataHubRecords.h>
|
2022-08-04 19:22:25 +02:00
|
|
|
#include <Protocol/AppleSystemInfo.h>
|
2022-08-16 20:30:49 +02:00
|
|
|
#include <Protocol/AppleImageCodecProtocol.h>
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
#define EFI_CPU_DATA_MAXIMUM_LENGTH 0x100
|
2022-09-02 21:14:43 +02:00
|
|
|
//const char CDM[16] = "sha2-384";
|
2022-09-09 20:51:31 +02:00
|
|
|
//const char HW[16] = "x86legacyap";
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
// gDataHub
|
|
|
|
/// A pointer to the DataHubProtocol
|
|
|
|
EFI_DATA_HUB_PROTOCOL *gDataHub;
|
|
|
|
|
|
|
|
EFI_SUBCLASS_TYPE1_HEADER mCpuDataRecordHeader = {
|
|
|
|
EFI_PROCESSOR_SUBCLASS_VERSION, // Version
|
|
|
|
sizeof(EFI_SUBCLASS_TYPE1_HEADER), // Header Size
|
|
|
|
0, // Instance (initialize later)
|
|
|
|
EFI_SUBCLASS_INSTANCE_NON_APPLICABLE, // SubInstance
|
|
|
|
0 // RecordType (initialize later)
|
|
|
|
};
|
|
|
|
|
|
|
|
// gDataHubPlatformGuid
|
2022-04-26 00:55:56 +02:00
|
|
|
/// The EFI_GUID of the DataHubProtocol
|
|
|
|
constexpr const EFI_GUID gDataHubPlatformGuid = {
|
2019-09-03 11:58:42 +02:00
|
|
|
0x64517cc8, 0x6561, 0x4051, { 0xb0, 0x3c, 0x59, 0x64, 0xb6, 0x0f, 0x4c, 0x7a }
|
|
|
|
};
|
|
|
|
|
|
|
|
extern APPLE_SMC_IO_PROTOCOL *gAppleSmc;
|
2022-07-02 09:08:53 +02:00
|
|
|
extern UINT32 mCurrentColor;
|
2022-08-16 20:30:49 +02:00
|
|
|
extern APPLE_IMAGE_CODEC_PROTOCOL gAppleImageCodec;
|
2019-09-12 12:37:33 +02:00
|
|
|
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
typedef union {
|
|
|
|
EFI_CPU_DATA_RECORD *DataRecord;
|
|
|
|
UINT8 *Raw;
|
|
|
|
} EFI_CPU_DATA_RECORD_BUFFER;
|
|
|
|
|
|
|
|
// PLATFORM_DATA
|
|
|
|
/// The struct passed to "LogDataHub" holing key and value to be added
|
|
|
|
#pragma pack(1)
|
|
|
|
typedef struct {
|
|
|
|
EFI_SUBCLASS_TYPE1_HEADER Hdr; /// 0x48
|
|
|
|
UINT32 NameLen; /// 0x58 (in bytes)
|
|
|
|
UINT32 ValLen; /// 0x5c
|
|
|
|
UINT8 Data[1]; /// 0x60 Name Value
|
2020-08-15 15:47:56 +02:00
|
|
|
} PLATFORM_DATA_RECORD;
|
2019-09-03 11:58:42 +02:00
|
|
|
#pragma pack()
|
|
|
|
|
|
|
|
// CopyRecord
|
|
|
|
/// Copy the data provided in arguments into a PLATFORM_DATA buffer
|
|
|
|
///
|
|
|
|
/// @param Rec The buffer the data should be copied into
|
|
|
|
/// @param Name The value for the member "name"
|
|
|
|
/// @param Val The data the object should have
|
|
|
|
/// @param ValLen The length of the parameter "Val"
|
|
|
|
///
|
|
|
|
/// @return The size of the new PLATFORM_DATA object is returned
|
|
|
|
UINT32 EFIAPI
|
2020-08-15 15:47:56 +02:00
|
|
|
CopyRecord(IN PLATFORM_DATA_RECORD *Rec,
|
2019-09-03 11:58:42 +02:00
|
|
|
IN CONST CHAR16 *Name,
|
2020-10-03 19:02:31 +02:00
|
|
|
IN const void *Val,
|
2019-09-03 11:58:42 +02:00
|
|
|
IN UINT32 ValLen)
|
|
|
|
{
|
|
|
|
CopyMem(&Rec->Hdr, &mCpuDataRecordHeader, sizeof(EFI_SUBCLASS_TYPE1_HEADER));
|
|
|
|
Rec->NameLen = (UINT32)StrLen(Name) * sizeof(CHAR16);
|
|
|
|
Rec->ValLen = ValLen;
|
|
|
|
CopyMem(Rec->Data, Name, Rec->NameLen);
|
|
|
|
CopyMem(Rec->Data + Rec->NameLen, Val, ValLen);
|
|
|
|
|
|
|
|
return (sizeof(EFI_SUBCLASS_TYPE1_HEADER) + 8 + Rec->NameLen + Rec->ValLen);
|
|
|
|
}
|
|
|
|
|
|
|
|
// LogDataHub
|
|
|
|
/// Adds a key-value-pair to the DataHubProtocol
|
|
|
|
EFI_STATUS EFIAPI
|
2022-04-26 00:55:56 +02:00
|
|
|
LogDataHub(const EFI_GUID& TypeGuid,
|
2020-02-17 21:41:09 +01:00
|
|
|
IN CONST CHAR16 *Name,
|
2020-10-03 19:02:31 +02:00
|
|
|
IN const void *Data,
|
2020-08-15 15:47:56 +02:00
|
|
|
IN UINT32 DataSize)
|
2019-09-03 11:58:42 +02:00
|
|
|
{
|
|
|
|
UINT32 RecordSize;
|
|
|
|
EFI_STATUS Status;
|
2020-08-15 15:47:56 +02:00
|
|
|
PLATFORM_DATA_RECORD *platform_data_record;
|
2019-09-03 11:58:42 +02:00
|
|
|
|
2020-08-15 15:47:56 +02:00
|
|
|
platform_data_record = (PLATFORM_DATA_RECORD*)AllocatePool(sizeof(PLATFORM_DATA_RECORD) + DataSize + EFI_CPU_DATA_MAXIMUM_LENGTH);
|
|
|
|
if (platform_data_record == NULL) {
|
2019-09-03 11:58:42 +02:00
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
|
2020-08-15 15:47:56 +02:00
|
|
|
RecordSize = CopyRecord(platform_data_record, Name, Data, DataSize);
|
2019-09-03 11:58:42 +02:00
|
|
|
Status = gDataHub->LogData(gDataHub,
|
|
|
|
TypeGuid, // DataRecordGuid
|
2022-04-26 00:55:56 +02:00
|
|
|
gDataHubPlatformGuid, // ProducerName (always)
|
2019-09-03 11:58:42 +02:00
|
|
|
EFI_DATA_RECORD_CLASS_DATA,
|
2020-08-15 15:47:56 +02:00
|
|
|
platform_data_record,
|
2019-09-03 11:58:42 +02:00
|
|
|
RecordSize);
|
|
|
|
|
2020-08-15 15:47:56 +02:00
|
|
|
FreePool(platform_data_record);
|
2019-09-03 11:58:42 +02:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2020-08-15 15:47:56 +02:00
|
|
|
EFI_STATUS EFIAPI
|
2022-04-26 00:55:56 +02:00
|
|
|
LogDataHubXString8(const EFI_GUID& TypeGuid,
|
2020-08-15 15:47:56 +02:00
|
|
|
IN CONST CHAR16 *Name,
|
|
|
|
const XString8& s)
|
|
|
|
{
|
2022-01-23 13:19:15 +01:00
|
|
|
#ifdef JIEF_DEBUG
|
2020-08-15 15:47:56 +02:00
|
|
|
if ( s.sizeInBytesIncludingTerminator() > MAX_UINT32 ) panic("LogDataHub s.length > MAX_UINT32");
|
2021-02-21 14:49:09 +01:00
|
|
|
#else
|
|
|
|
if ( s.sizeInBytesIncludingTerminator() > MAX_UINT32 ) return EFI_OUT_OF_RESOURCES;
|
|
|
|
#endif
|
2020-08-15 15:47:56 +02:00
|
|
|
return LogDataHub(TypeGuid, Name, (void*)s.c_str(), (UINT32)s.sizeInBytesIncludingTerminator());
|
|
|
|
}
|
|
|
|
|
|
|
|
EFI_STATUS EFIAPI
|
2022-04-26 00:55:56 +02:00
|
|
|
LogDataHubXStringW(const EFI_GUID& TypeGuid,
|
2020-08-15 15:47:56 +02:00
|
|
|
IN CONST CHAR16 *Name,
|
|
|
|
const XStringW& s)
|
|
|
|
{
|
2022-01-23 13:19:15 +01:00
|
|
|
#ifdef JIEF_DEBUG
|
2020-08-15 15:47:56 +02:00
|
|
|
if ( s.sizeInBytesIncludingTerminator() > MAX_UINT32 ) panic("LogDataHub s.length > MAX_UINT32");
|
2021-02-21 14:49:09 +01:00
|
|
|
#else
|
|
|
|
if ( s.sizeInBytesIncludingTerminator() > MAX_UINT32 ) return EFI_OUT_OF_RESOURCES;
|
|
|
|
#endif
|
2020-08-15 15:47:56 +02:00
|
|
|
return LogDataHub(TypeGuid, Name, (void*)s.wc_str(), (UINT32)s.sizeInBytesIncludingTerminator());
|
|
|
|
}
|
2020-05-14 09:03:06 +02:00
|
|
|
|
|
|
|
|
2019-09-03 11:58:42 +02:00
|
|
|
// SetVariablesForOSX
|
2020-02-16 13:00:20 +01:00
|
|
|
/** Installs our runtime services overrides. */
|
|
|
|
/** Original runtime services. */
|
|
|
|
EFI_RUNTIME_SERVICES gOrgRS;
|
|
|
|
|
|
|
|
EFI_STATUS EFIAPI
|
|
|
|
OvrSetVariable(
|
|
|
|
IN CHAR16 *VariableName,
|
2022-04-26 00:55:56 +02:00
|
|
|
const EFI_GUID& VendorGuid,
|
2020-02-16 13:00:20 +01:00
|
|
|
IN UINT32 Attributes,
|
|
|
|
IN UINTN DataSize,
|
2020-10-03 19:02:31 +02:00
|
|
|
IN void *Data
|
2020-02-16 13:00:20 +01:00
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
UINTN i;
|
|
|
|
|
2021-03-26 10:43:15 +01:00
|
|
|
for (i = 0; i < gSettings.RtVariables.BlockRtVariableArray.size(); i++) {
|
2021-03-28 11:12:43 +02:00
|
|
|
if ( gSettings.RtVariables.BlockRtVariableArray[i].Disabled ) {
|
|
|
|
continue;
|
|
|
|
}
|
2022-04-26 00:55:56 +02:00
|
|
|
if ( gSettings.RtVariables.BlockRtVariableArray[i].Guid != VendorGuid ) {
|
2020-02-16 13:00:20 +01:00
|
|
|
continue;
|
|
|
|
}
|
2021-03-26 10:43:15 +01:00
|
|
|
if (gSettings.RtVariables.BlockRtVariableArray[i].Name.isEmpty() || gSettings.RtVariables.BlockRtVariableArray[i].Name[0] == L'*' || gSettings.RtVariables.BlockRtVariableArray[i].Name == LStringW(VariableName) ) {
|
2020-02-16 13:00:20 +01:00
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Status = gOrgRS.SetVariable(VariableName, VendorGuid, Attributes, DataSize, Data);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
EFI_STATUS EFIAPI
|
|
|
|
OvrRuntimeServices(EFI_RUNTIME_SERVICES *RS)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
CopyMem(&gOrgRS, RS, sizeof(EFI_RUNTIME_SERVICES));
|
2020-02-17 21:41:09 +01:00
|
|
|
RS->SetVariable = (EFI_SET_VARIABLE)OvrSetVariable;
|
2020-02-16 13:00:20 +01:00
|
|
|
RS->Hdr.CRC32 = 0;
|
|
|
|
Status = gBS->CalculateCrc32(RS, RS->Hdr.HeaderSize, &RS->Hdr.CRC32);
|
|
|
|
return Status;
|
2019-09-12 12:37:33 +02:00
|
|
|
}
|
|
|
|
|
2019-09-03 11:58:42 +02:00
|
|
|
/// Sets the volatile and non-volatile variables used by OS X
|
|
|
|
EFI_STATUS EFIAPI
|
|
|
|
SetVariablesForOSX(LOADER_ENTRY *Entry)
|
|
|
|
{
|
|
|
|
// The variable names used should be made global constants to prevent them being allocated multiple times
|
|
|
|
UINT32 Attributes;
|
|
|
|
UINT32 Color;
|
2020-02-17 21:41:09 +01:00
|
|
|
CONST CHAR8 *None;
|
|
|
|
CONST CHAR8 *NvidiaWebValue;
|
2019-09-03 11:58:42 +02:00
|
|
|
|
2020-02-17 21:41:09 +01:00
|
|
|
CONST CHAR16 *KbdPrevLang;
|
2019-09-03 11:58:42 +02:00
|
|
|
UINTN LangLen;
|
2020-10-03 19:02:31 +02:00
|
|
|
void *OldData;
|
2020-11-12 22:25:56 +01:00
|
|
|
// UINT64 os_version = AsciiOSVersionToUint64(Entry->OSVersion);
|
2019-09-03 11:58:42 +02:00
|
|
|
CHAR8 *PlatformLang;
|
|
|
|
|
2022-04-26 00:55:56 +02:00
|
|
|
EFI_GUID uuid = gSettings.getUUID();
|
2020-09-23 15:47:47 +02:00
|
|
|
|
2019-09-03 11:58:42 +02:00
|
|
|
//
|
|
|
|
// firmware Variables
|
|
|
|
//
|
2021-03-26 10:43:15 +01:00
|
|
|
if (gSettings.RtVariables.BlockRtVariableArray.size() > 0) {
|
2020-02-16 13:00:20 +01:00
|
|
|
OvrRuntimeServices(gRT);
|
2019-09-12 12:37:33 +02:00
|
|
|
}
|
|
|
|
|
2019-09-03 11:58:42 +02:00
|
|
|
// As found on a real Mac, the system-id variable solely has the BS flag
|
|
|
|
SetNvramVariable(L"system-id",
|
2022-04-26 00:55:56 +02:00
|
|
|
gEfiAppleNvramGuid,
|
2019-09-03 11:58:42 +02:00
|
|
|
EFI_VARIABLE_BOOTSERVICE_ACCESS,
|
2020-09-23 15:47:47 +02:00
|
|
|
sizeof(uuid),
|
|
|
|
&uuid);
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
Attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;
|
|
|
|
|
2021-03-26 10:43:15 +01:00
|
|
|
if (GlobalConfig.RtMLB.notEmpty()) {
|
|
|
|
if ( GlobalConfig.RtMLB.length() != 17 ) {
|
2019-09-03 11:58:42 +02:00
|
|
|
DBG("** Warning: Your MLB is not suitable for iMessage(must be 17 chars long) !\n");
|
|
|
|
}
|
|
|
|
|
2020-08-15 15:47:56 +02:00
|
|
|
SetNvramXString8(L"MLB",
|
2022-04-26 00:55:56 +02:00
|
|
|
gEfiAppleNvramGuid,
|
2019-09-03 11:58:42 +02:00
|
|
|
Attributes,
|
2021-03-26 10:43:15 +01:00
|
|
|
GlobalConfig.RtMLB);
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
|
2021-03-26 10:43:15 +01:00
|
|
|
if (GlobalConfig.RtROM.notEmpty()) {
|
2019-09-03 11:58:42 +02:00
|
|
|
SetNvramVariable(L"ROM",
|
2022-04-26 00:55:56 +02:00
|
|
|
gEfiAppleNvramGuid,
|
2019-09-03 11:58:42 +02:00
|
|
|
Attributes,
|
2021-03-26 10:43:15 +01:00
|
|
|
GlobalConfig.RtROM.size(),
|
|
|
|
GlobalConfig.RtROM.vdata());
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
SetNvramVariable(L"FirmwareFeatures",
|
2022-04-26 00:55:56 +02:00
|
|
|
gEfiAppleNvramGuid,
|
2019-09-03 11:58:42 +02:00
|
|
|
Attributes,
|
2021-04-28 20:30:34 +02:00
|
|
|
sizeof(gSettings.Smbios.FirmwareFeatures),
|
|
|
|
&gSettings.Smbios.FirmwareFeatures);
|
2019-09-03 11:58:42 +02:00
|
|
|
|
2021-09-25 13:33:16 +02:00
|
|
|
SetNvramVariable(L"FirmwareFeaturesMask",
|
2022-04-26 00:55:56 +02:00
|
|
|
gEfiAppleNvramGuid,
|
2019-09-03 11:58:42 +02:00
|
|
|
Attributes,
|
2021-04-28 20:30:34 +02:00
|
|
|
sizeof(gSettings.Smbios.FirmwareFeaturesMask),
|
|
|
|
&gSettings.Smbios.FirmwareFeaturesMask);
|
2019-09-03 11:58:42 +02:00
|
|
|
|
2021-09-25 13:33:16 +02:00
|
|
|
SetNvramVariable(L"ExtendedFirmwareFeatures",
|
2022-04-26 00:55:56 +02:00
|
|
|
gEfiAppleNvramGuid,
|
2021-09-25 13:33:16 +02:00
|
|
|
Attributes,
|
|
|
|
sizeof(gSettings.Smbios.ExtendedFirmwareFeatures),
|
|
|
|
&gSettings.Smbios.ExtendedFirmwareFeatures);
|
|
|
|
|
|
|
|
SetNvramVariable(L"ExtendedFirmwareFeaturesMask",
|
2022-04-26 00:55:56 +02:00
|
|
|
gEfiAppleNvramGuid,
|
2021-09-25 13:33:16 +02:00
|
|
|
Attributes,
|
|
|
|
sizeof(gSettings.Smbios.ExtendedFirmwareFeaturesMask),
|
|
|
|
&gSettings.Smbios.ExtendedFirmwareFeaturesMask);
|
|
|
|
|
2019-09-03 11:58:42 +02:00
|
|
|
// HW_MLB and HW_ROM are also around on some Macs with the same values as MLB and ROM
|
2022-04-26 00:55:56 +02:00
|
|
|
AddNvramXString8(L"HW_BID", gEfiAppleNvramGuid, Attributes, gSettings.Smbios.BoardNumber);
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// OS X non-volatile Variables
|
|
|
|
//
|
|
|
|
|
|
|
|
// note: some gEfiAppleBootGuid vars present in nvram.plist are already set by PutNvramPlistToRtVars()
|
|
|
|
// we should think how to handle those vars from nvram.plist and ones set here from gSettings
|
|
|
|
|
2021-03-19 21:32:42 +01:00
|
|
|
if ((gFirmwareClover && gDriversFlags.EmuVariableLoaded) || gSettings.GUI.KbdPrevLang) {
|
2019-09-03 11:58:42 +02:00
|
|
|
// using AddNvramVariable content instead of calling the function to do LangLen calculation only when necessary
|
|
|
|
// Do not mess with prev-lang:kbd on UEFI systems without NVRAM emulation; it's OS X's business
|
|
|
|
KbdPrevLang = L"prev-lang:kbd";
|
2022-04-26 00:55:56 +02:00
|
|
|
OldData = (__typeof__(OldData))GetNvramVariable(KbdPrevLang, gEfiAppleBootGuid, NULL, NULL);
|
2020-08-17 21:40:52 +02:00
|
|
|
if (OldData == NULL) {
|
2021-04-03 16:42:49 +02:00
|
|
|
gSettings.GUI.Language.trim();
|
2022-04-26 00:55:56 +02:00
|
|
|
SetNvramXString8(KbdPrevLang, gEfiAppleBootGuid, Attributes, gSettings.GUI.Language);
|
2020-08-17 21:40:52 +02:00
|
|
|
} else {
|
|
|
|
FreePool(OldData);
|
|
|
|
}
|
2019-09-03 11:58:42 +02:00
|
|
|
} else {
|
|
|
|
Attributes |= EFI_VARIABLE_NON_VOLATILE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//#define EFI_PLATFORM_LANG_VARIABLE_NAME L"PlatformLang"
|
2022-04-26 00:55:56 +02:00
|
|
|
PlatformLang = (__typeof__(PlatformLang))GetNvramVariable(EFI_PLATFORM_LANG_VARIABLE_NAME, gEfiGlobalVariableGuid, NULL, NULL);
|
2019-09-03 11:58:42 +02:00
|
|
|
//
|
|
|
|
// On some platforms with missing gEfiUnicodeCollation2ProtocolGuid EFI_PLATFORM_LANG_VARIABLE_NAME is set
|
|
|
|
// to the value different from "en-...". This is not going to work with our driver UEFI Shell load failures.
|
|
|
|
// We did not overwrite EFI_PLATFORM_LANG_VARIABLE_NAME, but it uses some other language.
|
|
|
|
//
|
|
|
|
// if (!PlatformLang || AsciiStrnCmp (PlatformLang, "en-", 3)) {
|
|
|
|
if (!PlatformLang) {
|
2022-04-26 00:55:56 +02:00
|
|
|
SetNvramVariable(EFI_PLATFORM_LANG_VARIABLE_NAME, gEfiGlobalVariableGuid,
|
2019-09-03 11:58:42 +02:00
|
|
|
Attributes,
|
|
|
|
6, "en-US");
|
|
|
|
}
|
|
|
|
if (PlatformLang) {
|
|
|
|
FreePool(PlatformLang);
|
|
|
|
}
|
|
|
|
|
|
|
|
None = "none";
|
2022-04-26 00:55:56 +02:00
|
|
|
AddNvramVariable(L"security-mode", gEfiAppleBootGuid, Attributes, 5, (void*)None);
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
// we should have two UUID: platform and system
|
|
|
|
// NO! Only Platform is the best solution
|
2020-09-23 15:47:47 +02:00
|
|
|
if (!gSettings.ShouldInjectSystemID()) {
|
2022-04-26 00:55:56 +02:00
|
|
|
if (gSettings.Smbios.SmUUID.notNull()) {
|
|
|
|
SetNvramVariable(L"platform-uuid", gEfiAppleBootGuid, Attributes, sizeof(uuid), &uuid);
|
2019-09-03 11:58:42 +02:00
|
|
|
} else {
|
2022-04-26 00:55:56 +02:00
|
|
|
AddNvramVariable(L"platform-uuid", gEfiAppleBootGuid, Attributes, sizeof(uuid), &uuid);
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Download-Fritz: Do not mess with BacklightLevel; it's OS X's business
|
|
|
|
if (gMobile) {
|
2021-03-25 15:32:56 +01:00
|
|
|
if (gSettings.SystemParameters.BacklightLevelConfig) {
|
2022-04-26 00:55:56 +02:00
|
|
|
SetNvramVariable(L"backlight-level", gEfiAppleBootGuid, Attributes, sizeof(gSettings.SystemParameters.BacklightLevel), &gSettings.SystemParameters.BacklightLevel);
|
2019-09-03 11:58:42 +02:00
|
|
|
} else {
|
2022-04-26 00:55:56 +02:00
|
|
|
AddNvramVariable(L"backlight-level", gEfiAppleBootGuid, Attributes, sizeof(gSettings.SystemParameters.BacklightLevel), &gSettings.SystemParameters.BacklightLevel);
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-03 16:42:49 +02:00
|
|
|
if (gSettings.BootGraphics.DefaultBackgroundColor == 0x80000000) {
|
2022-04-26 00:55:56 +02:00
|
|
|
DeleteNvramVariable(L"DefaultBackgroundColor", gEfiAppleNvramGuid);
|
2019-09-03 11:58:42 +02:00
|
|
|
} else {
|
|
|
|
UINT16 ActualDensity = 0xE1;
|
|
|
|
UINT16 DensityThreshold = 0x96;
|
|
|
|
UINT64 ConfigStatus = 0;
|
2021-04-03 16:42:49 +02:00
|
|
|
Color = gSettings.BootGraphics.DefaultBackgroundColor;
|
2022-07-02 09:08:53 +02:00
|
|
|
mCurrentColor = Color;
|
2020-06-18 18:08:00 +02:00
|
|
|
DBG("set DefaultBackgroundColor=0x%x\n", Color);
|
2022-04-26 00:55:56 +02:00
|
|
|
SetNvramVariable(L"DefaultBackgroundColor", gEfiAppleNvramGuid, Attributes, 4, &Color);
|
2019-09-03 11:58:42 +02:00
|
|
|
// add some UI variables
|
2022-04-26 00:55:56 +02:00
|
|
|
SetNvramVariable(L"ActualDensity", gEfiAppleBootGuid, Attributes, 2, &ActualDensity);
|
|
|
|
SetNvramVariable(L"DensityThreshold", gEfiAppleBootGuid, Attributes, 2, &DensityThreshold);
|
|
|
|
SetNvramVariable(L"gfx-saved-config-restore-status", gEfiAppleNvramGuid, Attributes, 8, &ConfigStatus);
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
|
2021-04-03 16:42:49 +02:00
|
|
|
if (gSettings.BootGraphics.UIScale == 0x80000000) {
|
2022-04-26 00:55:56 +02:00
|
|
|
DeleteNvramVariable(L"UIScale", gEfiAppleNvramGuid);
|
2019-09-03 11:58:42 +02:00
|
|
|
} else {
|
2022-04-26 00:55:56 +02:00
|
|
|
SetNvramVariable(L"UIScale", gEfiAppleNvramGuid, Attributes, 1, &gSettings.BootGraphics.UIScale);
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
|
2021-04-03 16:42:49 +02:00
|
|
|
if (gSettings.BootGraphics.EFILoginHiDPI == 0x80000000) {
|
2022-04-26 00:55:56 +02:00
|
|
|
DeleteNvramVariable(L"EFILoginHiDPI", gEfiAppleBootGuid);
|
2019-09-03 11:58:42 +02:00
|
|
|
} else {
|
2022-04-26 00:55:56 +02:00
|
|
|
SetNvramVariable(L"EFILoginHiDPI", gEfiAppleBootGuid, Attributes, 4, &gSettings.BootGraphics.EFILoginHiDPI);
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ->GetVariable(flagstate, gEfiAppleBootGuid, 0/0, 20, 10FE110) = Not Found
|
2021-04-11 07:18:52 +02:00
|
|
|
if (GlobalConfig.flagstate[3] == 0x80) {
|
2022-04-26 00:55:56 +02:00
|
|
|
DeleteNvramVariable(L"flagstate", gEfiAppleBootGuid);
|
2019-09-03 11:58:42 +02:00
|
|
|
} else {
|
2022-04-26 00:55:56 +02:00
|
|
|
SetNvramVariable(L"flagstate", gEfiAppleBootGuid, Attributes, 32, &GlobalConfig.flagstate);
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
|
2021-03-26 10:43:15 +01:00
|
|
|
if (gSettings.RtVariables.CsrActiveConfig != 0xFFFF) {
|
2022-04-26 00:55:56 +02:00
|
|
|
SetNvramVariable(L"csr-active-config", gEfiAppleBootGuid, Attributes, sizeof(gSettings.RtVariables.CsrActiveConfig), &gSettings.RtVariables.CsrActiveConfig);
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
2021-10-08 21:49:07 +02:00
|
|
|
|
2022-02-05 13:57:08 +01:00
|
|
|
if (gSettings.RtVariables.HWTarget.isEmpty()) {
|
2023-01-05 09:42:49 +01:00
|
|
|
// if (Entry->macOSVersion >= MacOsVersion("13"_XS8)) {
|
|
|
|
//test legacy model
|
|
|
|
// GlobalConfig.CurrentModel = iMac183;
|
|
|
|
// }
|
2022-02-05 13:57:08 +01:00
|
|
|
gSettings.RtVariables.HWTarget = GetHWTarget(GlobalConfig.CurrentModel);
|
|
|
|
}
|
|
|
|
|
2022-08-04 19:22:25 +02:00
|
|
|
extern APPLE_SYSTEM_INFO_PROTOCOL mSystemInfo;
|
|
|
|
if (gSettings.RtVariables.HWTarget.notEmpty()) {
|
|
|
|
//install gibraltar
|
|
|
|
/*Status=*/gBS->InstallProtocolInterface (&gImageHandle,
|
|
|
|
&gAppleSystemInfoProtocolGuid,
|
|
|
|
EFI_NATIVE_INTERFACE,
|
|
|
|
&mSystemInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-11 22:07:37 +02:00
|
|
|
if (gSettings.RtVariables.HWTarget.notEmpty() && (Entry->LoaderType != OSTYPE_OSX_INSTALLER) &&
|
2023-01-05 09:42:49 +01:00
|
|
|
(Entry->macOSVersion < MacOsVersion("13"_XS8)) ) { //test legacy model
|
2022-04-26 00:55:56 +02:00
|
|
|
SetNvramXString8(L"BridgeOSHardwareModel", gEfiAppleNvramGuid, Attributes, gSettings.RtVariables.HWTarget);
|
2022-08-12 20:06:10 +02:00
|
|
|
// SetNvramVariable(L"BridgeOSBootSessionUUID", gEfiAppleBootGuid, Attributes, sizeof(uuid), &uuid);
|
2021-10-08 21:49:07 +02:00
|
|
|
} else {
|
2022-04-26 00:55:56 +02:00
|
|
|
DeleteNvramVariable(L"BridgeOSHardwareModel", gEfiAppleNvramGuid);
|
2022-08-12 20:06:10 +02:00
|
|
|
// DeleteNvramVariable(L"BridgeOSBootSessionUUID", gEfiAppleBootGuid);
|
2021-10-08 21:49:07 +02:00
|
|
|
}
|
|
|
|
|
2021-03-26 10:43:15 +01:00
|
|
|
if ( gSettings.RtVariables.BooterCfgStr.notEmpty() ) {
|
2022-04-26 00:55:56 +02:00
|
|
|
SetNvramXString8(L"bootercfg", gEfiAppleBootGuid, Attributes, gSettings.RtVariables.BooterCfgStr);
|
2019-09-03 11:58:42 +02:00
|
|
|
} else {
|
2022-04-26 00:55:56 +02:00
|
|
|
DeleteNvramVariable(L"bootercfg", gEfiAppleBootGuid);
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
2021-03-25 15:32:56 +01:00
|
|
|
if (gSettings.SystemParameters.NvidiaWeb) {
|
2019-09-03 11:58:42 +02:00
|
|
|
NvidiaWebValue = "1";
|
2022-04-26 00:55:56 +02:00
|
|
|
SetNvramVariable(L"nvda_drv", gEfiAppleBootGuid, Attributes, 2, (void*)NvidiaWebValue);
|
2019-09-03 11:58:42 +02:00
|
|
|
} else {
|
2022-04-26 00:55:56 +02:00
|
|
|
DeleteNvramVariable(L"nvda_drv", gEfiAppleBootGuid);
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!gDriversFlags.AptioMemFixLoaded) {
|
2022-04-26 00:55:56 +02:00
|
|
|
DeleteNvramVariable(L"recovery-boot-mode", gEfiAppleBootGuid);
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
2022-07-21 19:33:09 +02:00
|
|
|
/*
|
2019-09-03 11:58:42 +02:00
|
|
|
// Check for AptioFix2Drv loaded to store efi-boot-device for special boot
|
|
|
|
if (gDriversFlags.AptioFix2Loaded || gDriversFlags.AptioFixLoaded ||
|
|
|
|
gDriversFlags.AptioFix3Loaded || gDriversFlags.AptioMemFixLoaded) {
|
|
|
|
EFI_STATUS Status;
|
|
|
|
REFIT_VOLUME *Volume = Entry->Volume;
|
2020-09-28 17:57:50 +02:00
|
|
|
const EFI_DEVICE_PATH_PROTOCOL *DevicePath = Volume->DevicePath;
|
2019-09-03 11:58:42 +02:00
|
|
|
// We need to remember from which device we boot, to make silence boot while special recovery boot
|
2022-04-26 00:55:56 +02:00
|
|
|
Status = gRT->SetVariable(L"specialbootdevice", gEfiAppleBootGuid,
|
2019-09-03 11:58:42 +02:00
|
|
|
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
|
|
|
GetDevicePathSize(DevicePath), (UINT8 *)DevicePath);
|
|
|
|
if (EFI_ERROR(Status)) {
|
|
|
|
DBG("can't set specialbootdevice!\n");
|
|
|
|
}
|
|
|
|
}
|
2022-07-21 19:33:09 +02:00
|
|
|
*/
|
2019-09-03 11:58:42 +02:00
|
|
|
// Sherlocks: to fix "OSInstall.mpkg appears to be missing or damaged" in 10.13+, we should remove this variables.
|
|
|
|
if (Entry->LoaderType == OSTYPE_OSX_INSTALLER) {
|
2021-01-31 10:50:23 +01:00
|
|
|
if (Entry->macOSVersion.isEmpty() || Entry->macOSVersion > MacOsVersion("10.12"_XS8)) {
|
2022-04-26 00:55:56 +02:00
|
|
|
DeleteNvramVariable(L"install-product-url", gEfiAppleBootGuid);
|
|
|
|
DeleteNvramVariable(L"previous-system-uuid", gEfiAppleBootGuid);
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
}
|
2020-04-21 21:51:07 +02:00
|
|
|
|
|
|
|
//one more variable can be set for 10.15.4
|
|
|
|
//sudo nvram wake-failure=%00%00%00%00%00
|
2020-04-22 06:42:10 +02:00
|
|
|
LangLen = 0;
|
2022-04-26 00:55:56 +02:00
|
|
|
AddNvramVariable(L"wake-failure", gEfiAppleBootGuid, Attributes, 5, &LangLen);
|
2019-09-03 11:58:42 +02:00
|
|
|
|
2022-09-05 21:23:30 +02:00
|
|
|
//clear OC garbage
|
2022-04-26 00:55:56 +02:00
|
|
|
DeleteNvramVariable(L"opencore-version", gEfiAppleBootGuid);
|
2022-09-05 21:23:30 +02:00
|
|
|
DeleteNvramVariable(L"ApBoardID", gAppleSecureBootVariableGuid);
|
|
|
|
DeleteNvramVariable(L"ApSecurityDomain", gAppleSecureBootVariableGuid);
|
|
|
|
DeleteNvramVariable(L"ApProductionStatus", gAppleSecureBootVariableGuid);
|
|
|
|
DeleteNvramVariable(L"ApSecurityMode", gAppleSecureBootVariableGuid);
|
|
|
|
DeleteNvramVariable(L"EffectiveProductionStatus", gAppleSecureBootVariableGuid);
|
|
|
|
DeleteNvramVariable(L"EffectiveSecurityMode", gAppleSecureBootVariableGuid);
|
|
|
|
DeleteNvramVariable(L"CertificateEpoch", gAppleSecureBootVariableGuid);
|
|
|
|
DeleteNvramVariable(L"MixNMatchPreventionStatus", gAppleSecureBootVariableGuid);
|
|
|
|
DeleteNvramVariable(L"CryptoDigestMethod", gAppleSecureBootVariableGuid);
|
|
|
|
DeleteNvramVariable(L"InternalUseOnlyUnit", gAppleSecureBootVariableGuid);
|
2022-09-09 20:51:31 +02:00
|
|
|
DeleteNvramVariable(L"ApECID", gAppleSecureBootVariableGuid);
|
|
|
|
DeleteNvramVariable(L"HardwareModel", gAppleSecureBootVariableGuid);
|
|
|
|
|
2021-12-19 06:17:30 +01:00
|
|
|
|
2022-08-29 21:44:10 +02:00
|
|
|
//Now we want manually install some SecureBoot Variables while boot.efi do this automatically.
|
|
|
|
//set same values
|
2023-01-05 09:42:49 +01:00
|
|
|
//test legacy model
|
2022-09-09 20:51:31 +02:00
|
|
|
// UINT64 ecid = 0;
|
|
|
|
// CopyMem(&ecid, &uuid, 8);
|
|
|
|
// SetNvramVariable(L"ApECID", gAppleSecureBootVariableGuid, Attributes, 8, &ecid);
|
|
|
|
// SetNvramVariable(L"HardwareModel", gAppleSecureBootVariableGuid, Attributes, 16, HW);
|
2022-08-29 21:44:10 +02:00
|
|
|
|
2019-09-03 11:58:42 +02:00
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2020-10-03 19:02:31 +02:00
|
|
|
void
|
2019-09-03 11:58:42 +02:00
|
|
|
AddSMCkey(SMC_KEY Key, SMC_DATA_SIZE Size, SMC_KEY_TYPE Type, SMC_DATA *Data)
|
|
|
|
{
|
2023-11-18 11:04:54 +01:00
|
|
|
if (gAppleSmc && (gAppleSmc->Signature == NON_APPLE_SMC_SIGNATURE))
|
|
|
|
{
|
|
|
|
MemoryStopRecord msr; // Do not record allocation made by SmcAddKey
|
2019-09-03 11:58:42 +02:00
|
|
|
gAppleSmc->SmcAddKey(gAppleSmc, Key, Size, Type, 0xC0);
|
|
|
|
gAppleSmc->SmcWriteValue(gAppleSmc, Key, Size, Data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetupDataForOSX
|
|
|
|
/// Sets the DataHub data used by OS X
|
2020-10-03 19:02:31 +02:00
|
|
|
void EFIAPI
|
2021-09-28 10:28:45 +02:00
|
|
|
SetupDataForOSX(XBool Hibernate)
|
2019-09-03 11:58:42 +02:00
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
|
|
|
|
UINT32 DevPathSupportedVal;
|
|
|
|
UINT64 FrontSideBus;
|
|
|
|
UINT64 CpuSpeed;
|
|
|
|
UINT64 TscFrequency;
|
|
|
|
UINT64 ARTFrequency;
|
|
|
|
UINTN Revision;
|
|
|
|
UINT16 Zero = 0;
|
2021-10-18 21:06:19 +02:00
|
|
|
XBool isRevLess = (ApplePlatformDataArray[GlobalConfig.CurrentModel].smcRevision[0] == 0 &&
|
|
|
|
ApplePlatformDataArray[GlobalConfig.CurrentModel].smcRevision[1] == 0 &&
|
|
|
|
ApplePlatformDataArray[GlobalConfig.CurrentModel].smcRevision[2] == 0 &&
|
|
|
|
ApplePlatformDataArray[GlobalConfig.CurrentModel].smcRevision[3] == 0 &&
|
|
|
|
ApplePlatformDataArray[GlobalConfig.CurrentModel].smcRevision[4] == 0 &&
|
|
|
|
ApplePlatformDataArray[GlobalConfig.CurrentModel].smcRevision[5] == 0);
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
Revision = StrDecimalToUintn(gFirmwareRevision);
|
|
|
|
|
|
|
|
// fool proof
|
|
|
|
FrontSideBus = gCPUStructure.FSBFrequency;
|
|
|
|
if ((FrontSideBus < (50 * Mega)) || (FrontSideBus > (1000 * Mega))) {
|
2020-03-25 19:32:44 +01:00
|
|
|
DBG("Wrong FrontSideBus=%llu, set to 100MHz\n", FrontSideBus);
|
2019-09-03 11:58:42 +02:00
|
|
|
FrontSideBus = 100 * Mega;
|
|
|
|
}
|
|
|
|
|
2021-03-19 16:35:01 +01:00
|
|
|
if (gSettings.CPU.QEMU) {
|
2019-09-03 11:58:42 +02:00
|
|
|
FrontSideBus = gCPUStructure.TSCFrequency;
|
|
|
|
switch (gCPUStructure.Model) {
|
|
|
|
case CPU_MODEL_DOTHAN:
|
|
|
|
case CPU_MODEL_YONAH:
|
|
|
|
case CPU_MODEL_MEROM:
|
|
|
|
case CPU_MODEL_PENRYN:
|
|
|
|
FrontSideBus = DivU64x32(FrontSideBus, 4);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2020-03-25 19:32:44 +01:00
|
|
|
DBG("Using QEMU FrontSideBus=%llull\n", FrontSideBus);
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Save values into gSettings for the genconfig aim
|
2021-03-19 16:35:01 +01:00
|
|
|
gSettings.CPU.BusSpeed = (UINT32)DivU64x32(FrontSideBus, Kilo);
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
CpuSpeed = gCPUStructure.CPUFrequency;
|
2021-03-19 16:35:01 +01:00
|
|
|
gSettings.CPU.CpuFreqMHz = (UINT32)DivU64x32(CpuSpeed, Mega);
|
2019-09-03 11:58:42 +02:00
|
|
|
|
2021-04-11 07:18:52 +02:00
|
|
|
char RBr[8];
|
2021-05-04 12:03:40 +02:00
|
|
|
getRBr(GlobalConfig.CurrentModel, gCPUStructure.Model, gSettings.Smbios.Mobile, RBr);
|
2021-04-11 07:18:52 +02:00
|
|
|
char RPlt[8];
|
2021-05-04 12:03:40 +02:00
|
|
|
getRPlt(GlobalConfig.CurrentModel, gCPUStructure.Model, gSettings.Smbios.Mobile, RPlt);
|
2021-04-11 07:18:52 +02:00
|
|
|
|
2019-09-03 11:58:42 +02:00
|
|
|
// Locate DataHub Protocol
|
2022-04-26 00:55:56 +02:00
|
|
|
Status = gBS->LocateProtocol(gEfiDataHubProtocolGuid, NULL, (void**)&gDataHub);
|
2019-09-03 11:58:42 +02:00
|
|
|
if (!EFI_ERROR(Status)) {
|
2020-08-09 17:55:30 +02:00
|
|
|
XStringW ProductName;
|
2021-04-03 16:42:49 +02:00
|
|
|
ProductName.takeValueFrom(gSettings.Smbios.ProductName);
|
2019-09-03 11:58:42 +02:00
|
|
|
|
2020-08-09 17:55:30 +02:00
|
|
|
XStringW SerialNumber;
|
2021-04-03 16:42:49 +02:00
|
|
|
SerialNumber.takeValueFrom(gSettings.Smbios.SerialNr);
|
2019-09-03 11:58:42 +02:00
|
|
|
|
2022-04-26 00:55:56 +02:00
|
|
|
LogDataHub(gEfiProcessorSubClassGuid, L"FSBFrequency", &FrontSideBus, sizeof(UINT64));
|
2019-09-03 11:58:42 +02:00
|
|
|
|
2021-03-19 16:35:01 +01:00
|
|
|
if (gCPUStructure.ARTFrequency && gSettings.CPU.UseARTFreq) {
|
2019-09-03 11:58:42 +02:00
|
|
|
ARTFrequency = gCPUStructure.ARTFrequency;
|
2022-04-26 00:55:56 +02:00
|
|
|
LogDataHub(gEfiProcessorSubClassGuid, L"ARTFrequency", &ARTFrequency, sizeof(UINT64));
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TscFrequency = 0; //gCPUStructure.TSCFrequency;
|
2022-04-26 00:55:56 +02:00
|
|
|
LogDataHub(gEfiProcessorSubClassGuid, L"InitialTSC", &TscFrequency, sizeof(UINT64));
|
|
|
|
LogDataHub(gEfiProcessorSubClassGuid, L"CPUFrequency", &CpuSpeed, sizeof(UINT64));
|
2019-09-03 11:58:42 +02:00
|
|
|
|
2021-04-03 16:42:49 +02:00
|
|
|
//gSettings.Smbios.BoardNumber
|
2022-04-26 00:55:56 +02:00
|
|
|
LogDataHubXString8(gEfiMiscSubClassGuid, L"board-id", gSettings.Smbios.BoardNumber);
|
2019-09-03 11:58:42 +02:00
|
|
|
TscFrequency++;
|
2022-04-26 00:55:56 +02:00
|
|
|
LogDataHub(gEfiProcessorSubClassGuid, L"board-rev", &TscFrequency, 1);
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
DevPathSupportedVal = 1;
|
2022-04-26 00:55:56 +02:00
|
|
|
LogDataHub(gEfiMiscSubClassGuid, L"DevicePathsSupported", &DevPathSupportedVal, sizeof(UINT32));
|
|
|
|
LogDataHubXStringW(gEfiMiscSubClassGuid, L"Model", ProductName);
|
|
|
|
LogDataHubXStringW(gEfiMiscSubClassGuid, L"SystemSerialNumber", SerialNumber);
|
2019-09-03 11:58:42 +02:00
|
|
|
|
2020-09-23 15:47:47 +02:00
|
|
|
if (gSettings.ShouldInjectSystemID()) {
|
2022-04-26 00:55:56 +02:00
|
|
|
EFI_GUID uuid = gSettings.getUUID();
|
|
|
|
LogDataHub(gEfiMiscSubClassGuid, L"system-id", &uuid, sizeof(uuid));
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
|
2022-04-26 00:55:56 +02:00
|
|
|
LogDataHub(gEfiProcessorSubClassGuid, L"clovergui-revision", &Revision, sizeof(UINT32));
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
// collect info about real hardware
|
2022-04-26 00:55:56 +02:00
|
|
|
LogDataHubXString8(gEfiMiscSubClassGuid, L"OEMVendor", GlobalConfig.OEMVendorFromSmbios);
|
|
|
|
LogDataHubXString8(gEfiMiscSubClassGuid, L"OEMProduct", GlobalConfig.OEMProductFromSmbios);
|
|
|
|
LogDataHubXString8(gEfiMiscSubClassGuid, L"OEMBoard", GlobalConfig.OEMBoardFromSmbios);
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
// SMC helper
|
|
|
|
if (!isRevLess) {
|
2022-04-26 00:55:56 +02:00
|
|
|
LogDataHub(gEfiMiscSubClassGuid, L"RBr", &RBr, 8);
|
|
|
|
LogDataHub(gEfiMiscSubClassGuid, L"EPCI", &ApplePlatformDataArray[GlobalConfig.CurrentModel].smcConfig, 4);
|
|
|
|
LogDataHub(gEfiMiscSubClassGuid, L"REV", &ApplePlatformDataArray[GlobalConfig.CurrentModel].smcRevision, 6);
|
2022-07-09 05:52:23 +02:00
|
|
|
LogDataHub(gEfiMiscSubClassGuid, L"RVBF", &ApplePlatformDataArray[GlobalConfig.CurrentModel].smcRevision, 6);
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
2022-04-26 00:55:56 +02:00
|
|
|
LogDataHub(gEfiMiscSubClassGuid, L"RPlt", RPlt, 8);
|
|
|
|
LogDataHub(gEfiMiscSubClassGuid, L"BEMB", &gSettings.Smbios.Mobile, 1);
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
// all current settings
|
2021-02-11 12:41:59 +01:00
|
|
|
// XBuffer<UINT8> xb = gSettings.serialize();
|
|
|
|
// LogDataHub(&gEfiMiscSubClassGuid, L"Settings", xb.data(), (UINT32)xb.size());
|
2020-11-18 22:49:02 +01:00
|
|
|
}else{
|
|
|
|
MsgLog("DataHub protocol not located. Smbios not send to datahub\n");
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
if (!gAppleSmc) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!isRevLess) {
|
2021-04-11 07:18:52 +02:00
|
|
|
AddSMCkey(SMC_MAKE_KEY('R','B','r',' '), 8, SmcKeyTypeCh8, (SMC_DATA *)&RBr);
|
2021-10-18 21:06:19 +02:00
|
|
|
AddSMCkey(SMC_MAKE_KEY('E','P','C','I'), 4, SmcKeyTypeUint32, (SMC_DATA *)&ApplePlatformDataArray[GlobalConfig.CurrentModel].smcConfig);
|
|
|
|
AddSMCkey(SMC_MAKE_KEY('R','E','V',' '), 6, SmcKeyTypeCh8, (SMC_DATA *)&ApplePlatformDataArray[GlobalConfig.CurrentModel].smcRevision);
|
2022-07-08 17:41:16 +02:00
|
|
|
AddSMCkey(SMC_MAKE_KEY('R','V','B','F'), 6, SmcKeyTypeCh8, (SMC_DATA *)&ApplePlatformDataArray[GlobalConfig.CurrentModel].smcRevision);
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
2021-04-11 07:18:52 +02:00
|
|
|
AddSMCkey(SMC_MAKE_KEY('R','P','l','t'), 8, SmcKeyTypeCh8, (SMC_DATA *)&RPlt);
|
2021-04-03 16:42:49 +02:00
|
|
|
AddSMCkey(SMC_MAKE_KEY('B','E','M','B'), 1, SmcKeyTypeFlag, (SMC_DATA *)&gSettings.Smbios.Mobile);
|
2019-09-03 11:58:42 +02:00
|
|
|
//laptop battery keys will be better to import from nvram.plist or read from ACPI(?)
|
|
|
|
//they are needed for FileVault2 who want to draw battery status
|
|
|
|
AddSMCkey(SMC_MAKE_KEY('B','A','T','P'), 1, SmcKeyTypeFlag, (SMC_DATA *)&Zero); //isBatteryPowered
|
2021-04-03 16:42:49 +02:00
|
|
|
AddSMCkey(SMC_MAKE_KEY('B','N','u','m'), 1, SmcKeyTypeUint8, (SMC_DATA *)&gSettings.Smbios.Mobile); // Num Batteries
|
|
|
|
if (gSettings.Smbios.Mobile) {
|
|
|
|
AddSMCkey(SMC_MAKE_KEY('B','B','I','N'), 1, SmcKeyTypeUint8, (SMC_DATA *)&gSettings.Smbios.Mobile); //Battery inserted
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
AddSMCkey(SMC_MAKE_KEY('M','S','T','c'), 1, SmcKeyTypeUint8, (SMC_DATA *)&Zero); // CPU Plimit
|
|
|
|
AddSMCkey(SMC_MAKE_KEY('M','S','A','c'), 2, SmcKeyTypeUint16, (SMC_DATA *)&Zero);// GPU Plimit
|
|
|
|
// AddSMCkey(SMC_MAKE_KEY('M','S','L','D'), 1, SmcKeyTypeUint8, (SMC_DATA *)&Zero); //isLidClosed
|
2021-02-02 10:02:21 +01:00
|
|
|
Zero = Hibernate?((ResumeFromCoreStorage||gSettings.Boot.HibernationFixup)?25:29):0;
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
AddSMCkey(SMC_MAKE_KEY('M','S','W','r'), 1, SmcKeyTypeUint8, (SMC_DATA *)&Zero);
|
|
|
|
Zero = 1;
|
|
|
|
AddSMCkey(SMC_MAKE_KEY('M','S','F','W'), 2, SmcKeyTypeUint8, (SMC_DATA *)&Zero);
|
|
|
|
Zero = 0x300;
|
|
|
|
AddSMCkey(SMC_MAKE_KEY('M','S','P','S'), 2, SmcKeyTypeUint16, (SMC_DATA *)&Zero);
|
|
|
|
}
|