From 735987a8b1db74b76419f09809e3f3791fcffa93 Mon Sep 17 00:00:00 2001 From: SergeySlice Date: Tue, 26 Jul 2022 19:57:36 +0300 Subject: [PATCH] exclude SMCHelper as the service is embedded Signed-off-by: SergeySlice --- CloverPackage/package/buildpkg.sh | 24 ++++++++++++------------ Include/Protocol/AppleSMC.h | 6 +----- Protocols/SMCHelper/SMCHelper.c | 6 +----- ebuild.sh | 4 ++-- hebuild.sh | 4 ++-- rEFIt_UEFI/refit/menu.cpp | 24 +++++++++++++++++++++++- 6 files changed, 41 insertions(+), 27 deletions(-) diff --git a/CloverPackage/package/buildpkg.sh b/CloverPackage/package/buildpkg.sh index c6dc57ac2..568e74fea 100755 --- a/CloverPackage/package/buildpkg.sh +++ b/CloverPackage/package/buildpkg.sh @@ -843,12 +843,12 @@ if [[ -d "${SRCROOT}/CloverV2/EFI/CLOVER/drivers/$DRIVERS_LEGACY" && ${NOEXTRAS} --subst="INSTALLER_CHOICE=$packageRefId" MarkChoice # Add postinstall script for SMCHelper drivers to remove it if VirtualSMC driver exists - if [[ "$driver" == SMCHelper* ]]; then - addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${driverChoice}" \ - --subst="DRIVER_NAME=$driver" \ - --subst="DRIVER_DIR=$(basename $driverDestDir)" \ - "VirtualSMC" - fi + # if [[ "$driver" == SMCHelper* ]]; then + # addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${driverChoice}" \ + # --subst="DRIVER_NAME=$driver" \ + # --subst="DRIVER_DIR=$(basename $driverDestDir)" \ + # "VirtualSMC" + # fi # mandatory drivers starts all selected only if /Library/Preferences/com.projectosx.clover.installer.plist does not exist # (i.e. Clover package never run on that target partition). # Otherwise each single choice start selected only for legacy Clover and only if you previously selected it @@ -1011,12 +1011,12 @@ if [[ -d "${SRCROOT}/CloverV2/EFI/CLOVER/drivers/$DRIVERS_UEFI" ]]; then --subst="INSTALLER_CHOICE=$packageRefId" MarkChoice # Add postinstall script for SMCHelper drivers to remove it if VirtualSMC driver exists - if [[ "$driver" == SMCHelper* ]]; then - addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${driverChoice}" \ - --subst="DRIVER_NAME=$driver" \ - --subst="DRIVER_DIR=$(basename $driverDestDir)" \ - "VirtualSMC" - fi +# if [[ "$driver" == SMCHelper* ]]; then +# addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${driverChoice}" \ +# --subst="DRIVER_NAME=$driver" \ +# --subst="DRIVER_DIR=$(basename $driverDestDir)" \ +# "VirtualSMC" +# fi buildpackage "$packageRefId" "${driverChoice}" "${PKG_BUILD_DIR}/${driverChoice}" "${driverDestDir}" addChoice --group="Recommended64UEFI" \ diff --git a/Include/Protocol/AppleSMC.h b/Include/Protocol/AppleSMC.h index f025fef08..cb84026c0 100644 --- a/Include/Protocol/AppleSMC.h +++ b/Include/Protocol/AppleSMC.h @@ -282,11 +282,7 @@ struct _APPLE_SMC_IO_PROTOCOL { SMC_INDEX Index; ///< SMC_ADDRESS Address; ///< BOOLEAN Mmio; ///< -/* SMC_IO_SMC_UNKNOWN_1 SmcUnknown1; ///< - SMC_IO_SMC_UNKNOWN_2 SmcUnknown2; ///< - SMC_IO_SMC_UNKNOWN_3 SmcUnknown3; ///< - SMC_IO_SMC_UNKNOWN_4 SmcUnknown4; ///< - SMC_IO_SMC_UNKNOWN_5 SmcUnknown5; ///< */ + }; diff --git a/Protocols/SMCHelper/SMCHelper.c b/Protocols/SMCHelper/SMCHelper.c index 840d82226..c698e78b2 100644 --- a/Protocols/SMCHelper/SMCHelper.c +++ b/Protocols/SMCHelper/SMCHelper.c @@ -481,11 +481,7 @@ APPLE_SMC_IO_PROTOCOL SMCHelperProtocol = { 0, SMC_PORT_BASE, FALSE, -/* SmcUnknown1Impl, - SmcUnknown2Impl, - SmcUnknown3Impl, - SmcUnknown4Impl, - SmcUnknown5Impl */ + }; APPLE_SMC_STATE_PROTOCOL SMCStateProtocol = { diff --git a/ebuild.sh b/ebuild.sh index 32a7511ff..be61ef20f 100755 --- a/ebuild.sh +++ b/ebuild.sh @@ -799,7 +799,7 @@ MainPostBuildScript() { # Mandatory drivers echo "Copy Mandatory drivers:" - binArray=( XhciDxe SMCHelper EnglishDxe ) + binArray=( XhciDxe EnglishDxe ) for efi in "${binArray[@]}" do copyBin "$BUILD_DIR_ARCH"/$efi.efi "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_LEGACY/$efi.efi @@ -823,7 +823,7 @@ MainPostBuildScript() { # fi - binArray=( SMCHelper EnglishDxe ) + binArray=( EnglishDxe ) for efi in "${binArray[@]}" do copyBin "$BUILD_DIR_ARCH"/$efi.efi "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_UEFI/$efi.efi diff --git a/hebuild.sh b/hebuild.sh index 09edca86a..cf8d3f3cb 100755 --- a/hebuild.sh +++ b/hebuild.sh @@ -775,7 +775,7 @@ MainPostBuildScript() { # Mandatory drivers echo "Copy Mandatory drivers:" - binArray=( FSInject XhciDxe SMCHelper AudioDxe ) + binArray=( FSInject XhciDxe AudioDxe ) for efi in "${binArray[@]}" do copyBin "$BUILD_DIR_ARCH"/$efi.efi "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_LEGACY/$efi.efi @@ -798,7 +798,7 @@ MainPostBuildScript() { fi - binArray=( FSInject SMCHelper AudioDxe ) + binArray=( FSInject AudioDxe ) for efi in "${binArray[@]}" do copyBin "$BUILD_DIR_ARCH"/$efi.efi "$CLOVER_PKG_DIR"/EFI/CLOVER/drivers/$DRIVERS_UEFI/$efi.efi diff --git a/rEFIt_UEFI/refit/menu.cpp b/rEFIt_UEFI/refit/menu.cpp index 874bb77d4..32c70d981 100644 --- a/rEFIt_UEFI/refit/menu.cpp +++ b/rEFIt_UEFI/refit/menu.cpp @@ -128,6 +128,9 @@ REFIT_MENU_SCREEN AboutMenu(2, L"About"_XSW, L""_XSW); REFIT_MENU_SCREEN HelpMenu(3, L"Help"_XSW, L""_XSW); REFIT_MENU_SCREEN OptionMenu(4, L"Options"_XSW, L""_XSW); +XBool gResetSMC = false; +extern APPLE_SMC_IO_PROTOCOL *gAppleSmc; + void FillInputs(XBool New) { @@ -461,6 +464,9 @@ void FillInputs(XBool New) InputItems[InputItemsCount].ItemType = BoolValue; //128 InputItems[InputItemsCount++].BValue = gSettings.Quirks.OcKernelQuirks.ProvideCurrentCpuInfo; + InputItems[InputItemsCount].ItemType = BoolValue; //129 + InputItems[InputItemsCount++].BValue = gResetSMC; + //menu for drop table @@ -929,7 +935,7 @@ void ApplyInputs(void) gSettings.Quirks.OcBooterQuirks.DisableSingleUser = ((gSettings.Quirks.QuirksMask & QUIRK_SU) != 0); //0 gSettings.Quirks.OcBooterQuirks.DisableVariableWrite = ((gSettings.Quirks.QuirksMask & QUIRK_VAR) != 0); //0 gSettings.Quirks.OcBooterQuirks.DiscardHibernateMap = ((gSettings.Quirks.QuirksMask & QUIRK_HIBER) != 0); //0 - gSettings.Quirks.OcBooterQuirks.EnableSafeModeSlide = ((gSettings.Quirks.QuirksMask & QUIRK_SAFE) != 0); //1 + gSettings.Quirks.OcBooterQuirks.EnableSafeModeSlide = ((gSettings.Quirks.QuirksMask & QUIRK_SAFE) != 0); //0 gSettings.Quirks.OcBooterQuirks.EnableWriteUnprotector = ((gSettings.Quirks.QuirksMask & QUIRK_UNPROT) != 0); //1 gSettings.Quirks.OcBooterQuirks.ForceExitBootServices = ((gSettings.Quirks.QuirksMask & QUIRK_EXIT) != 0); //0 gSettings.Quirks.OcBooterQuirks.ProtectMemoryRegions = ((gSettings.Quirks.QuirksMask & QUIRK_REGION) != 0); //0 @@ -1112,6 +1118,21 @@ void ApplyInputs(void) gSettings.Quirks.OcKernelQuirks.ProvideCurrentCpuInfo = InputItems[i].BValue != 0; DBG("applied ProvideCurrentCpuInfo=%s\n", gSettings.Quirks.OcKernelQuirks.ProvideCurrentCpuInfo ? "Y" : "N" ); } + i++; //129 + if (InputItems[i].Valid) { + gResetSMC = InputItems[i].BValue != 0; + if (gResetSMC) { + // reset controller + if (gAppleSmc && (gAppleSmc->Signature == NON_APPLE_SMC_SIGNATURE)) { + gAppleSmc->SmcReset(gAppleSmc, 1); + DBG("SMC store is resetted\n"); + } else { + DBG("SMC protocol not found\n"); + } + gResetSMC = false; + } + } + if (NeedSave) { ApplySettings(); @@ -2489,6 +2510,7 @@ REFIT_ABSTRACT_MENU_ENTRY* SubMenuSystem() SubScreen->AddMenuItemInput(2, "Block kext:", true); SubScreen->AddMenuItemInput(51, "Set OS version if not detected:", true); SubScreen->AddMenuItemInput(118, "Booter Cfg Command:", true); + SubScreen->AddMenuItemInput(129, "Reset SMC", false); SubScreen->AddMenuEntry(SubMenuCSR(), true); SubScreen->AddMenuEntry(SubMenuBLC(), true);