embed SMC protocol

Signed-off-by: SergeySlice <sergey.slice@gmail.com>
This commit is contained in:
SergeySlice 2022-07-25 22:29:12 +03:00
parent b25888a4e5
commit 6b0669f249
5 changed files with 52 additions and 17 deletions

View File

@ -232,7 +232,7 @@
# OcFirmwareVolumeLib|OpenCorePkg/Library/OcFirmwareVolumeLib/OcFirmwareVolumeLib.inf # OcFirmwareVolumeLib|OpenCorePkg/Library/OcFirmwareVolumeLib/OcFirmwareVolumeLib.inf
OcHashServicesLib|OpenCorePkg/Library/OcHashServicesLib/OcHashServicesLib.inf OcHashServicesLib|OpenCorePkg/Library/OcHashServicesLib/OcHashServicesLib.inf
OcSmbiosLib|OpenCorePkg/Library/OcSmbiosLib/OcSmbiosLib.inf OcSmbiosLib|OpenCorePkg/Library/OcSmbiosLib/OcSmbiosLib.inf
OcSmcLib|OpenCorePkg/Library/OcSmcLib/OcSmcLib.inf # OcSmcLib|OpenCorePkg/Library/OcSmcLib/OcSmcLib.inf
OcUnicodeCollationEngGenericLib|OpenCorePkg/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngGenericLib.inf OcUnicodeCollationEngGenericLib|OpenCorePkg/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngGenericLib.inf
OcPeCoffExtLib|OpenCorePkg/Library/OcPeCoffExtLib/OcPeCoffExtLib.inf OcPeCoffExtLib|OpenCorePkg/Library/OcPeCoffExtLib/OcPeCoffExtLib.inf
OcPeCoffLib|OpenCorePkg/Library/OcPeCoffLib/OcPeCoffLib.inf OcPeCoffLib|OpenCorePkg/Library/OcPeCoffLib/OcPeCoffLib.inf
@ -497,10 +497,10 @@
<BuildOptions> <BuildOptions>
*_*_*_CC_FLAGS = $(OC_INCLUDE_FLAG) *_*_*_CC_FLAGS = $(OC_INCLUDE_FLAG)
} }
OpenCorePkg/Library/OcSmcLib/OcSmcLib.inf { # OpenCorePkg/Library/OcSmcLib/OcSmcLib.inf {
<BuildOptions> # <BuildOptions>
*_*_*_CC_FLAGS = $(OC_INCLUDE_FLAG) # *_*_*_CC_FLAGS = $(OC_INCLUDE_FLAG)
} # }
OpenCorePkg/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngGenericLib.inf { OpenCorePkg/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngGenericLib.inf {
<BuildOptions> <BuildOptions>
*_*_*_CC_FLAGS = $(OC_INCLUDE_FLAG) *_*_*_CC_FLAGS = $(OC_INCLUDE_FLAG)
@ -770,7 +770,7 @@
# Misc # Misc
FSInject/FSInject.inf FSInject/FSInject.inf
Protocols/MsgLog/MsgLog.inf Protocols/MsgLog/MsgLog.inf
Protocols/SMCHelper/SMCHelper.inf #Protocols/SMCHelper/SMCHelper.inf
#Protocols/FirmwareVolume/FirmwareVolume.inf #Protocols/FirmwareVolume/FirmwareVolume.inf
Protocols/AppleImageCodec/AppleImageCodec.inf Protocols/AppleImageCodec/AppleImageCodec.inf
#Protocols/AppleUITheme/AppleUITheme.inf #Protocols/AppleUITheme/AppleUITheme.inf

@ -1 +1 @@
Subproject commit e288a05cb05511a5b86d1677b43b0f0304fe4326 Subproject commit ac03fdb3174877a17da5b3834104bd5034eea0c8

View File

@ -4,7 +4,7 @@
* Created by Slice on 03.10.2016. * Created by Slice on 03.10.2016.
* *
*/ */
/*
#include <Library/BaseLib.h> #include <Library/BaseLib.h>
#include <Library/UefiLib.h> #include <Library/UefiLib.h>
#include <Library/UefiBootServicesTableLib.h> #include <Library/UefiBootServicesTableLib.h>
@ -16,6 +16,8 @@
#include <Library/MemLogLib.h> #include <Library/MemLogLib.h>
#include <Protocol/AppleSMC.h> #include <Protocol/AppleSMC.h>
*/
#include "SmcHelper.h"
// DBG_TO: 0=no debug, 1=serial, 2=console 3=log // DBG_TO: 0=no debug, 1=serial, 2=console 3=log
// serial requires // serial requires
@ -40,7 +42,7 @@
#define APPLE_SMC_SIGNATURE SIGNATURE_64('A','P','P','L','E','S','M','C') #define APPLE_SMC_SIGNATURE SIGNATURE_64('A','P','P','L','E','S','M','C')
#define NON_APPLE_SMC_SIGNATURE SIGNATURE_64('S','M','C','H','E','L','P','E') #define NON_APPLE_SMC_SIGNATURE SIGNATURE_64('S','M','C','H','E','L','P','E')
EFI_HANDLE mHandle = NULL; EFI_HANDLE m7Handle = NULL;
//EFI_BOOT_SERVICES* gBS; //EFI_BOOT_SERVICES* gBS;
extern EFI_GUID gEfiAppleBootGuid; extern EFI_GUID gEfiAppleBootGuid;
@ -497,7 +499,7 @@ APPLE_SMC_STATE_PROTOCOL SMCStateProtocol = {
#if SEPARATE_SMC_DRIVER
/**************************************************************** /****************************************************************
* Entry point * Entry point
***************************************************************/ ***************************************************************/
@ -517,7 +519,7 @@ SMCHelperEntrypoint (
// gBS = SystemTable->BootServices; // gBS = SystemTable->BootServices;
Status = gBS->InstallMultipleProtocolInterfaces ( Status = gBS->InstallMultipleProtocolInterfaces (
&mHandle, &m7Handle,
&gAppleSMCProtocolGuid, &gAppleSMCProtocolGuid,
&SMCHelperProtocol, &SMCHelperProtocol,
&gAppleSMCStateProtocolGuid, &gAppleSMCStateProtocolGuid,
@ -527,3 +529,22 @@ SMCHelperEntrypoint (
return Status; return Status;
} }
#else
EFI_STATUS SMCHelperInstall(EFI_HANDLE* Handle)
{
EFI_STATUS Status; // = EFI_SUCCESS;
// gBS = SystemTable->BootServices;
Status = gBS->InstallMultipleProtocolInterfaces (
Handle,
&gAppleSMCProtocolGuid,
&SMCHelperProtocol,
&gAppleSMCStateProtocolGuid,
&SMCStateProtocol,
NULL
);
return Status;
}
#endif

View File

@ -21,9 +21,12 @@
#include <Efi.h> #include <Efi.h>
//#include <Protocol/OcQuirksProtocol4Clover.h> //#include <Protocol/OcQuirksProtocol4Clover.h>
#include "Injectors.h" #include "Injectors.h"
//#include "../include/SmcHelper.h"
#include "../Platform/Settings.h" #include "../Platform/Settings.h"
#include <Protocol/FirmwareVolume.h> #include <Protocol/FirmwareVolume.h>
#include <Protocol/AppleSMC.h>
#ifndef DEBUG_ALL #ifndef DEBUG_ALL
#define DEBUG_PRO 1 #define DEBUG_PRO 1
@ -369,6 +372,8 @@ STATIC APPLE_USER_INTERFACE_THEME_PROTOCOL mAppleUserInterfaceThemeProtocol = {
extern EFI_FIRMWARE_VOLUME_PROTOCOL FirmwareVolume; extern EFI_FIRMWARE_VOLUME_PROTOCOL FirmwareVolume;
extern APPLE_SMC_IO_PROTOCOL SMCHelperProtocol;
extern APPLE_SMC_STATE_PROTOCOL SMCStateProtocol;
EFI_STATUS EFI_STATUS
SetPrivateVarProto(void) SetPrivateVarProto(void)
@ -389,8 +394,13 @@ SetPrivateVarProto(void)
&mAppleUserInterfaceThemeProtocol, &mAppleUserInterfaceThemeProtocol,
&gEfiFirmwareVolumeProtocolGuid, &gEfiFirmwareVolumeProtocolGuid,
&FirmwareVolume, &FirmwareVolume,
NULL &gAppleSMCProtocolGuid,
&SMCHelperProtocol,
&gAppleSMCStateProtocolGuid,
&SMCStateProtocol,
NULL
); );
// Status = SMCHelperInstall(&gImageHandle);
//obligatory protocol //obligatory protocol
Status = gBS->InstallProtocolInterface (&gImageHandle, Status = gBS->InstallProtocolInterface (&gImageHandle,

View File

@ -156,6 +156,7 @@
include/QuirksCodes.h include/QuirksCodes.h
include/remove_ref.h include/remove_ref.h
include/rename_helper.h include/rename_helper.h
include/SmcHelper.h
include/syslinux_mbr.h include/syslinux_mbr.h
include/TagTypes.h include/TagTypes.h
include/VolumeTypes.h include/VolumeTypes.h
@ -394,7 +395,7 @@
Settings/SelfOem.cpp Settings/SelfOem.cpp
Settings/SelfOem.h Settings/SelfOem.h
../Protocols/FirmwareVolume/FirmwareVolume.c ../Protocols/FirmwareVolume/FirmwareVolume.c
../Protocols/SMCHelper/SMCHelper.c
[Sources.IA32] [Sources.IA32]
PlatformIA32/ftol.asm | MSFT PlatformIA32/ftol.asm | MSFT
@ -531,6 +532,9 @@
gEfiKeyboardInfoProtocolGuid gEfiKeyboardInfoProtocolGuid
gAppleUserInterfaceThemeProtocolGuid gAppleUserInterfaceThemeProtocolGuid
gEfiFirmwareVolumeProtocolGuid gEfiFirmwareVolumeProtocolGuid
gAppleSMCProtocolGuid ## PRODUCES and CONSUMES
gAppleSMCStateProtocolGuid ## PRODUCES and CONSUMES
gFSInjectProtocolGuid gFSInjectProtocolGuid
gMsgLogProtocolGuid gMsgLogProtocolGuid
@ -550,13 +554,13 @@
[BuildOptions] [BuildOptions]
# -fno-rtti is only for C++ # -fno-rtti is only for C++
XCODE:*_*_*_CC_FLAGS = -fno-use-cxa-atexit -fno-omit-frame-pointer -fno-exceptions -DJCONST=CONST -Wno-incompatible-ms-struct #-Wunused-parameter XCODE:*_*_*_CC_FLAGS = -fno-use-cxa-atexit -fno-omit-frame-pointer -fno-exceptions -DJCONST=CONST -Wno-incompatible-ms-struct #-Wunused-parameter
XCODE:*_*_*_CXX_FLAGS = -fno-use-cxa-atexit -fno-omit-frame-pointer -fno-rtti -fno-exceptions -DJCONST=CONST -Wno-incompatible-ms-struct #-Wunused-parameter XCODE:*_*_*_CXX_FLAGS = -fno-use-cxa-atexit -fno-omit-frame-pointer -fno-rtti -fno-exceptions -DJCONST=CONST -Wno-incompatible-ms-struct #-Wunused-parameter
GCC:*_*_*_CC_FLAGS = -fno-omit-frame-pointer -DJCONST=CONST GCC:*_*_*_CC_FLAGS = -fno-omit-frame-pointer -DJCONST=CONST
GCC:*_*_*_CXX_FLAGS = -fno-omit-frame-pointer -fno-rtti -DJCONST=CONST GCC:*_*_*_CXX_FLAGS = -fno-omit-frame-pointer -fno-rtti -DJCONST=CONST
MSFT:*_*_*_CC_FLAGS = /wd4201 /D JCONST=const MSFT:*_*_*_CC_FLAGS = /wd4201 /D JCONST=const
#TODO re-enable warnings #TODO re-enable warnings
MSFT:*_*_*_CXX_FLAGS = /wd4201 /wd4244 /wd4267 /D JCONST=const MSFT:*_*_*_CXX_FLAGS = /wd4201 /wd4244 /wd4267 /D JCONST=const