Skip to content

Commit

Permalink
refactoring, renaming, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeySlice committed Oct 4, 2019
1 parent 4beb3b6 commit 6a56c29
Show file tree
Hide file tree
Showing 41 changed files with 3,414 additions and 299 deletions.
12 changes: 7 additions & 5 deletions Clover.dsc
Expand Up @@ -151,15 +151,17 @@
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf

OcGuardLib|Library/OcGuardLib/OcGuardLib.inf
MachoLib|Library/MachoLib/MachoLib.inf

#
# Our libs
#
MemLogLib|Library/MemLogLibDefault/MemLogLibDefault.inf
VideoBiosPatchLib|Library/VideoBiosPatchLib/VideoBiosPatchLib.inf
WaveLib|Library/WaveLib/WaveLib.inf

OcGuardLib|Library/OcGuardLib/OcGuardLib.inf
MachoLib|Library/MachoLib/MachoLib.inf
DeviceTreeLib|Library/DeviceTreeLib/DeviceTreeLib.inf


ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
!ifndef NO_CLOVER_SHELL
Expand Down Expand Up @@ -471,7 +473,7 @@
Protocols/HashServiceFix/HashServiceFix.inf
Protocols/AppleKeyAggregator/AppleKeyAggregator.inf
Protocols/AppleKeyFeeder/AppleKeyFeeder.inf
# Protocols/AptioInputFix/AptioInputFix.inf
Protocols/AptioInputFix/AptioInputFix.inf


!ifdef DEBUG_ON_SERIAL_PORT
Expand Down Expand Up @@ -585,7 +587,7 @@
# MemoryFix/OsxAptioFixDrv/OsxAptioFix2Drv.inf
MemoryFix/OsxAptioFixDrv/OsxAptioFix3Drv.inf
MemoryFix/OsxLowMemFixDrv/OsxLowMemFixDrv.inf
# MemoryFix/AptioMemoryFix/AptioMemoryFix.inf
MemoryFix/AptioMemoryFix/AptioMemoryFix.inf
!ifdef DEBUG_ON_SERIAL_PORT
MemoryFix/OsxAptioFixDrv/OsxAptioFixDrv.inf {
#
Expand Down
200 changes: 200 additions & 0 deletions CloverEFI/UefiCpuPkg/Include/Register/Microcode.h
@@ -0,0 +1,200 @@
/** @file
Microcode Definitions.
Microcode Definitions based on contents of the
Intel(R) 64 and IA-32 Architectures Software Developer's Manual
Volume 3A, Section 9.11 Microcode Definitions
Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
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.
@par Specification Reference:
Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3A,
June 2016, Chapter 9 Processor Management and Initialization, Section 9-11.
**/

#ifndef __MICROCODE_H__
#define __MICROCODE_H__

///
/// CPU Microcode Date in BCD format
///
typedef union {
struct {
UINT32 Year:16;
UINT32 Day:8;
UINT32 Month:8;
} Bits;
UINT32 Uint32;
} CPU_MICROCODE_DATE;

///
/// CPU Microcode Processor Signature format
///
typedef union {
struct {
UINT32 Stepping:4;
UINT32 Model:4;
UINT32 Family:4;
UINT32 Type:2;
UINT32 Reserved1:2;
UINT32 ExtendedModel:4;
UINT32 ExtendedFamily:8;
UINT32 Reserved2:4;
} Bits;
UINT32 Uint32;
} CPU_MICROCODE_PROCESSOR_SIGNATURE;

#pragma pack (1)

///
/// Microcode Update Format definition
///
typedef struct {
///
/// Version number of the update header
///
UINT32 HeaderVersion;
///
/// Unique version number for the update, the basis for the update
/// signature provided by the processor to indicate the current update
/// functioning within the processor. Used by the BIOS to authenticate
/// the update and verify that the processor loads successfully. The
/// value in this field cannot be used for processor stepping identification
/// alone. This is a signed 32-bit number.
///
UINT32 UpdateRevision;
///
/// Date of the update creation in binary format: mmddyyyy (e.g.
/// 07/18/98 is 07181998H).
///
CPU_MICROCODE_DATE Date;
///
/// Extended family, extended model, type, family, model, and stepping
/// of processor that requires this particular update revision (e.g.,
/// 00000650H). Each microcode update is designed specifically for a
/// given extended family, extended model, type, family, model, and
/// stepping of the processor.
/// The BIOS uses the processor signature field in conjunction with the
/// CPUID instruction to determine whether or not an update is
/// appropriate to load on a processor. The information encoded within
/// this field exactly corresponds to the bit representations returned by
/// the CPUID instruction.
///
CPU_MICROCODE_PROCESSOR_SIGNATURE ProcessorSignature;
///
/// Checksum of Update Data and Header. Used to verify the integrity of
/// the update header and data. Checksum is correct when the
/// summation of all the DWORDs (including the extended Processor
/// Signature Table) that comprise the microcode update result in
/// 00000000H.
///
UINT32 Checksum;
///
/// Version number of the loader program needed to correctly load this
/// update. The initial version is 00000001H
///
UINT32 LoaderRevision;
///
/// Platform type information is encoded in the lower 8 bits of this 4-
/// byte field. Each bit represents a particular platform type for a given
/// CPUID. The BIOS uses the processor flags field in conjunction with
/// the platform Id bits in MSR (17H) to determine whether or not an
/// update is appropriate to load on a processor. Multiple bits may be set
/// representing support for multiple platform IDs.
///
UINT32 ProcessorFlags;
///
/// Specifies the size of the encrypted data in bytes, and must be a
/// multiple of DWORDs. If this value is 00000000H, then the microcode
/// update encrypted data is 2000 bytes (or 500 DWORDs).
///
UINT32 DataSize;
///
/// Specifies the total size of the microcode update in bytes. It is the
/// summation of the header size, the encrypted data size and the size of
/// the optional extended signature table. This value is always a multiple
/// of 1024.
///
UINT32 TotalSize;
///
/// Reserved fields for future expansion.
///
UINT8 Reserved[12];
} CPU_MICROCODE_HEADER;

///
/// Extended Signature Table Header Field Definitions
///
typedef struct {
///
/// Specifies the number of extended signature structures (Processor
/// Signature[n], processor flags[n] and checksum[n]) that exist in this
/// microcode update
///
UINT32 ExtendedSignatureCount;
///
/// Checksum of update extended processor signature table. Used to
/// verify the integrity of the extended processor signature table.
/// Checksum is correct when the summation of the DWORDs that
/// comprise the extended processor signature table results in
/// 00000000H.
///
UINT32 ExtendedChecksum;
///
/// Reserved fields.
///
UINT8 Reserved[12];
} CPU_MICROCODE_EXTENDED_TABLE_HEADER;

///
/// Extended Signature Table Field Definitions
///
typedef struct {
///
/// Extended family, extended model, type, family, model, and stepping
/// of processor that requires this particular update revision (e.g.,
/// 00000650H). Each microcode update is designed specifically for a
/// given extended family, extended model, type, family, model, and
/// stepping of the processor.
/// The BIOS uses the processor signature field in conjunction with the
/// CPUID instruction to determine whether or not an update is
/// appropriate to load on a processor. The information encoded within
/// this field exactly corresponds to the bit representations returned by
/// the CPUID instruction.
///
CPU_MICROCODE_PROCESSOR_SIGNATURE ProcessorSignature;
///
/// Platform type information is encoded in the lower 8 bits of this 4-
/// byte field. Each bit represents a particular platform type for a given
/// CPUID. The BIOS uses the processor flags field in conjunction with
/// the platform Id bits in MSR (17H) to determine whether or not an
/// update is appropriate to load on a processor. Multiple bits may be set
/// representing support for multiple platform IDs.
///
UINT32 ProcessorFlag;
///
/// Used by utility software to decompose a microcode update into
/// multiple microcode updates where each of the new updates is
/// constructed without the optional Extended Processor Signature
/// Table.
/// To calculate the Checksum, substitute the Primary Processor
/// Signature entry and the Processor Flags entry with the
/// corresponding Extended Patch entry. Delete the Extended Processor
/// Signature Table entries. The Checksum is correct when the
/// summation of all DWORDs that comprise the created Extended
/// Processor Patch results in 00000000H.
///
UINT32 Checksum;
} CPU_MICROCODE_EXTENDED_TABLE;

#pragma pack ()

#endif
36 changes: 26 additions & 10 deletions CloverPkg.dec
Expand Up @@ -35,6 +35,16 @@
## @libraryclass
WaveLib|Include/Library/WaveLib.h

## @libraryclass
DeviceTreeLib|Include/Library/DeviceTreeLib.h

## @libraryclass
OcGuardLib|Include/Library/OcGuardLib.h

## @libraryclass
MachoLib|Include/Library/MachoLib.h



[Guids]
gEfiPciExpressBaseAddressGuid = {0x3677d529, 0x326f, 0x4603, {0xa9, 0x26, 0xea, 0xac, 0xe0, 0x1d, 0xcb, 0xb0 }}
Expand Down Expand Up @@ -68,8 +78,14 @@
gAppleApfsPartitionTypeGuid = {0x7C3457EF, 0x0000, 0x11AA, {0xAA, 0x11, 0x00, 0x30, 0x65, 0x43, 0xEC, 0xAC}}
gAppleApfsContainerInfoGuid = {0x3533CF0D, 0x685F, 0x5EBF, {0x8D, 0xC6, 0x73, 0x93, 0x48, 0x5B, 0xAF, 0xA2}}
gAppleApfsVolumeInfoGuid = {0x900C7693, 0x8C14, 0x58BA, {0xB4, 0x4E, 0x97, 0x45, 0x15, 0xD2, 0x7C, 0x78}}
# Include/Guid/ApplePlatformInfo.h
gAppleKeyboardPlatformInfoGuid = { 0x51871CB9, 0xE25D, 0x44B4, { 0x96, 0x99, 0x0E, 0xE8, 0x64, 0x4C, 0xED, 0x69 }}
# Include/Guid/ApplePlatformInfo.h
gAppleKeyboardPlatformInfoGuid = {0x51871CB9, 0xE25D, 0x44B4, { 0x96, 0x99, 0x0E, 0xE8, 0x64, 0x4C, 0xED, 0x69 }}

## OC guids
gOcVendorVariableGuid = {0x4D1FDA02, 0x38C7, 0x4A6A, { 0x9C, 0xC6, 0x4B, 0xCC, 0xA8, 0xB3, 0x01, 0x02 }}
gOcReadOnlyVariableGuid = {0xE09B9297, 0x7928, 0x4440, { 0x9A, 0xAB, 0xD1, 0xF8, 0x53, 0x6F, 0xBF, 0x0A }}
gOcWriteOnlyVariableGuid = {0xF0B9AF8F, 0x2222, 0x4840, { 0x8A, 0x37, 0xEC, 0xF7, 0xCC, 0x8C, 0x12, 0xE1 }}




Expand All @@ -85,14 +101,14 @@

#Apple's protocols
gEfiConsoleControlProtocolGuid = {0xF42F7782, 0x012E, 0x4C12, {0x99, 0x56, 0x49, 0xF9, 0x43, 0x04, 0xF7, 0x21}}
gAppleScreenInfoProtocolGuid = {0xE316E100, 0x0751, 0x4C49, {0x90, 0x56, 0x48, 0x6C, 0x7E, 0x47, 0x29, 0x03}}
gAppleFramebufferInfoProtocolGuid = {0xE316E100, 0x0751, 0x4C49, {0x90, 0x56, 0x48, 0x6C, 0x7E, 0x47, 0x29, 0x03}}
gAppleGraphConfigProtocolGuid = {0x03622D6D, 0x362A, 0x4E47, {0x97, 0x10, 0xC2, 0x38, 0xB2, 0x37, 0x55, 0xC1}}
gAppleImageCodecProtocolGuid = {0x0DFCE9F6, 0xC4E3, 0x45EE, {0xA0, 0x6A, 0xA8, 0x61, 0x3B, 0x98, 0xA5, 0x07}}
AppleDevicePropertyProtocolGuid = {0x91BD12FE, 0xF6C3, 0x44FB, {0xA5, 0xB7, 0x51, 0x22, 0xAB, 0x30, 0x3A, 0xE0}}
gEfiAppleFirmwarePasswordProtocolGuid = {0x8FFEEB3A, 0x4C98, 0x4630, {0x80, 0x3F, 0x74, 0x0F, 0x95, 0x67, 0x09, 0x1D}}
AppleBootKeyPressProtocolGuid = {0x5B213447, 0x6E73, 0x4901, {0xA4, 0xF1, 0xB8, 0x64, 0xF3, 0xB7, 0xA1, 0x72}}
gAppleDevicePropertyProtocolGuid = {0x91BD12FE, 0xF6C3, 0x44FB, {0xA5, 0xB7, 0x51, 0x22, 0xAB, 0x30, 0x3A, 0xE0}}
gAppleFirmwarePasswordProtocolGuid = {0x8FFEEB3A, 0x4C98, 0x4630, {0x80, 0x3F, 0x74, 0x0F, 0x95, 0x67, 0x09, 0x1D}}
gAppleKeyStateProtocolGuid = {0x5B213447, 0x6E73, 0x4901, {0xA4, 0xF1, 0xB8, 0x64, 0xF3, 0xB7, 0xA1, 0x72}}
gAppleKeyStateProtocolGuid = {0x5B213447, 0x6E73, 0x4901, {0xA4, 0xF1, 0xB8, 0x64, 0xF3, 0xB7, 0xA1, 0x72}}
AppleNetBootProtocolGuid = {0x78EE99FB, 0x6A5E, 0x4186, {0x97, 0xDE, 0xCD, 0x0A, 0xBA, 0x34, 0x5A, 0x74}}
gAppleNetBootProtocolGuid = {0x78EE99FB, 0x6A5E, 0x4186, {0x97, 0xDE, 0xCD, 0x0A, 0xBA, 0x34, 0x5A, 0x74}}
gAppleSMCProtocolGuid = {0x17407e5a, 0xaf6c, 0x4ee8, {0x98, 0xa8, 0x00, 0x21, 0x04, 0x53, 0xcd, 0xd9}}
gAppleSMCStateProtocolGuid = {0x5301FE59, 0x1770, 0x4166, {0xA1, 0x69, 0x00, 0xC4, 0xBD, 0xE4, 0xA1, 0x62}}
gEfiOSInfoProtocolGuid = {0xC5C5DA95, 0x7D5C, 0x45E6, {0xB2, 0xF1, 0x3F, 0xD5, 0x2B, 0xB1, 0x00, 0x77}}
Expand All @@ -112,9 +128,9 @@
gEfiAudioIoProtocolGuid = { 0xF05B559C, 0x1971, 0x4AF5, { 0xB2, 0xAE, 0xD6, 0x08, 0x08, 0xF7, 0x4F, 0x70 }}

## Aptio Fix
gAptioMemoryFixProtocolGuid = { 0xC7CBA84E, 0xCC77, 0x461D, { 0x9E, 0x3C, 0x6B, 0xE0, 0xCB, 0x79, 0xA7, 0xC1 } }
gAmiEfiPointerProtocolGuid = { 0x15A10CE7, 0xEAB5, 0x43BF, { 0x90, 0x42, 0x74, 0x43, 0x2E, 0x69, 0x63, 0x77 } }
gAmiEfiKeycodeProtocolGuid = { 0x0ADFB62D, 0xFF74, 0x484C, { 0x89, 0x44, 0xF8, 0x5C, 0x4B, 0xEA, 0x87, 0xA8 } }
gAptioMemoryFixProtocolGuid = { 0xC7CBA84E, 0xCC77, 0x461D, { 0x9E, 0x3C, 0x6B, 0xE0, 0xCB, 0x79, 0xA7, 0xC1 } }
gAmiEfiPointerProtocolGuid = { 0x15A10CE7, 0xEAB5, 0x43BF, { 0x90, 0x42, 0x74, 0x43, 0x2E, 0x69, 0x63, 0x77 } }
gAmiEfiKeycodeProtocolGuid = { 0x0ADFB62D, 0xFF74, 0x484C, { 0x89, 0x44, 0xF8, 0x5C, 0x4B, 0xEA, 0x87, 0xA8 } }



Expand Down
85 changes: 85 additions & 0 deletions Include/Guid/OcVariables.h
@@ -0,0 +1,85 @@
/** @file
Lilu & OpenCore specific GUIDs for UEFI Variable Storage, version 1.0.
Copyright (c) 2019, vit9696. All rights reserved.<BR>
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_VARIABLES_H
#define OC_VARIABLES_H

//
// Variable used for OpenCore log storage (if enabled).
//
#define OC_LOG_VARIABLE_NAME L"boot-log"

//
// Variable used for OpenCore boot path (if enabled).
//
#define OC_LOG_VARIABLE_PATH L"boot-path"

//
// Variable used for OpenCore request to redirect NVRAM Boot variable write.
// Boot Services only.
// See: https://github.com/acidanthera/bugtracker/issues/308.
//
#define OC_BOOT_REDIRECT_VARIABLE_NAME L"boot-redirect"

//
// Variable used for exposing OpenCore Security -> LoadPolicy.
// Boot Services only.
//
#define OC_LOAD_POLICY_VARIABLE_NAME L"load-policy"

//
// Variable used for exposing OpenCore Security -> ScanPolicy.
// Boot Services only.
//
#define OC_SCAN_POLICY_VARIABLE_NAME L"scan-policy"

//
// Variable used to report OpenCore version in the following format:
// REL-001-2019-01-01. This follows versioning style of Lilu and plugins.
//
#define OC_VERSION_VARIABLE_NAME L"opencore-version"

//
// 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102
// This GUID is specifically used for normal variable access by Lilu kernel extension and its plugins.
//
#define OC_VENDOR_VARIABLE_GUID \
{ 0x4D1FDA02, 0x38C7, 0x4A6A, { 0x9C, 0xC6, 0x4B, 0xCC, 0xA8, 0xB3, 0x01, 0x02 } }

//
// E09B9297-7928-4440-9AAB-D1F8536FBF0A
// This GUID is specifically used for reading variables by Lilu kernel extension and its plugins.
// Any writes to this GUID should be prohibited via EFI_RUNTIME_SERVICES after EXIT_BOOT_SERVICES.
// The expected return code on variable write is EFI_SECURITY_VIOLATION.
//
#define OC_READ_ONLY_VARIABLE_GUID \
{ 0xE09B9297, 0x7928, 0x4440, { 0x9A, 0xAB, 0xD1, 0xF8, 0x53, 0x6F, 0xBF, 0x0A } }

//
// F0B9AF8F-2222-4840-8A37-ECF7CC8C12E1
// This GUID is specifically used for reading variables by Lilu and plugins.
// Any reads from this GUID should be prohibited via EFI_RUNTIME_SERVICES after EXIT_BOOT_SERVICES.
// The expected return code on variable read is EFI_SECURITY_VIOLATION.
//
#define OC_WRITE_ONLY_VARIABLE_GUID \
{ 0xF0B9AF8F, 0x2222, 0x4840, { 0x8A, 0x37, 0xEC, 0xF7, 0xCC, 0x8C, 0x12, 0xE1 } }

//
// External global variables with GUID values.
//
extern EFI_GUID gOcVendorVariableGuid;
extern EFI_GUID gOcReadOnlyVariableGuid;
extern EFI_GUID gOcWriteOnlyVariableGuid;

#endif // OC_VARIABLES_H

0 comments on commit 6a56c29

Please sign in to comment.