From ea51d3694489f7fe4e6dfc8ca4d99202c98178cd Mon Sep 17 00:00:00 2001 From: Inspector42 Date: Fri, 28 Aug 2020 15:19:55 +0200 Subject: [PATCH 1/5] Added -k option to change path to kext For users that do not intend to change IOPlatformPfluginFamiliy.kext in System of would like to keep SIP enabled, it is now possible to use a copy in an unprotecxted location. This comes in handy if resultig plist is further processes for use with CPUFriend --- .gitIgnore | 0 README | 42 ++++++++++++++++++++++++++++++++++++++---- freqVectorsEdit.sh | 33 ++++++++++++++++++++++++++++----- 3 files changed, 66 insertions(+), 9 deletions(-) mode change 100644 => 100755 .gitIgnore mode change 100644 => 100755 README diff --git a/.gitIgnore b/.gitIgnore old mode 100644 new mode 100755 diff --git a/README b/README old mode 100644 new mode 100755 index 1dbbe9d..a3c6eca --- a/README +++ b/README @@ -1,9 +1,43 @@ -Introduction +SYNOPSIS + +freqVectorsEdit [ -bhmk ] [ -show ] + + +DESCRIPTION + + + freqVectorsEdit.sh is a bash script to add/replace FrequencyVectors in plists in X86PlatformPlugin.kext/Contents/Resources/ + This kext can be found in: /System/Library/Extensions/IOPlatformPluginFamily.kext/Contents/PlugIns + + The target plist (example: Mac-F60DEB81FF30ACF6.plist for the MacPro6,1) is selected based on the used board-id. + + In the current version, the following options are available + + The following options are available: + + + -b board-id (example: Mac-F60DEB81FF30ACF6) + Overrides the board-id obtained from the system settings in case the editing it performed on a 3rd computer + default: board-id of current running systems specified in SMBIOS settings + + -d debug + 0 = no debug output (default) + 1 = debug output (very verbose) + + -m model (example: MacPro6,1) + Overrides the model obtained from the system settings + + -show show supported board-id and model combinations + Haswell + Broadwell + Skylake + KabyLake + + -k kext path (example: /System/Library/Extensions) + Overrides path to kernel extension to allow editing of frequency vectors with SIP enabled + This will of course require further processing but comes in handy if resulting patched plist is used for CPUFriend -freqVectorsEdit.sh is a bash script to add/replace FrequencyVectors in plists in X86PlatformPlugin.kext/Contents/Resources/ -This kext can be found in: /System/Library/Extensions/IOPlatformPluginFamily.kext/Contents/PlugIns -The target plist (example: Mac-F60DEB81FF30ACF6.plist for the MacPro6,1) is selected based on the used board-id. 1) Start script by entering: diff --git a/freqVectorsEdit.sh b/freqVectorsEdit.sh index a591759..8c62f34 100755 --- a/freqVectorsEdit.sh +++ b/freqVectorsEdit.sh @@ -3,7 +3,7 @@ # # Script (freqVectorsEdit.sh) to add 'FrequencyVectors' from a source plist to Mac-F60DEB81FF30ACF6.plist # -# Version 3.2 - Copyright (c) 2013-2017 by Pike R. Alpha +# Version 3.3 - Copyright (c) 2013-2017 by Pike R. Alpha and 2020 by Jens S. Wondrak # # Updates: # - v0.5 Show Mac model info (Pike R. Alpha, December 2013) @@ -67,6 +67,7 @@ # - Show matching board-id in bold. # - Show Frequencies and HWP setting. # - v3.2 Renamed _listmatchingFiles to _selectSourceResourceFile() +# - v3.3 Added option -k to override path to Extension folder to enable use in directories not locked bz SIP # # # Known issues: @@ -85,7 +86,7 @@ # # Script version info. # -gScriptVersion=3.2 +gScriptVersion=3.3 # # Path and filename setup. @@ -314,7 +315,7 @@ function _toLowerCase() function _showHeader() { - printf "${STYLE_BOLD}freqVectorsEdit.sh${STYLE_RESET} v${gScriptVersion} Copyright (c) 2013-$(date "+%Y") by Pike R. Alpha.\n" + printf "${STYLE_BOLD}freqVectorsEdit.sh${STYLE_RESET} v${gScriptVersion} Copyright (c) 2013-$(date "+%Y") by Pike R. Alpha and 2020 by Jens S. Wondrak.\n" echo '-----------------------------------------------------------------' printf "${STYLE_BOLD}Bugs${STYLE_RESET} > ${STYLE_BLUE_FG}https://github.com/Piker-Alpha/freqVectorsEdit.sh/issues${STYLE_RESET} <\n\n" } @@ -1415,6 +1416,7 @@ function _getScriptArguments() printf " Broadwell\n" printf " Skylake\n" printf " KabyLake\n" + printf " -${STYLE_BOLD}k${STYLE_RESET}ext path (example: /System/Library/Extensions)\n" # # Stop script (success). # @@ -1468,7 +1470,7 @@ function _getScriptArguments() # # Is this a valid flag? # - if [[ "${flag}" =~ ^[-bdm]+$ ]]; + if [[ "${flag}" =~ ^[-bdmk]+$ ]]; then # # Yes. Figure out what flag it is. @@ -1515,6 +1517,26 @@ function _getScriptArguments() _invalidArgumentError "-m $1" fi ;; + + -k) shift + + if [ -a "$1" ]; + then + if [[ $gExtensionsDirectory != "$1" ]]; + then + gExtensionsDirectory="$1" + gResourcePath="${gExtensionsDirectory}/IOPlatformPluginFamily.kext/Contents/PlugIns/X86PlatformPlugin.kext/Contents/Resources" + if [ -a "$gResourcePath" ]; + then + _PRINT_MSG "Override value: (-k) kext path, now using: ${gExtensionsDirectory}!" + else + _invalidArgumentError "-k resource does not exists" + fi + fi + else + _invalidArgumentError "-k $1" + fi + ;; *) _invalidArgumentError "$1" ;; @@ -1563,7 +1585,8 @@ function main() fi _DEBUG_PRINT "Used board-id: ${gBoardID}" - _DEBUG_PRINT "Used model...: ${gModelID}\n" + _DEBUG_PRINT "Used model...: ${gModelID}" + _DEBUG_PRINT "Used path....: ${gExtensionsDirectory}\n" _selectSourceResourceFile # From e8fbc4988449377ebe631e2a7ed869424c36f604 Mon Sep 17 00:00:00 2001 From: Inspector42 Date: Fri, 28 Aug 2020 16:45:57 +0200 Subject: [PATCH 2/5] Corrected some typos --- README | 6 ++++-- freqVectorsEdit.sh | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README b/README index a3c6eca..f0d858a 100755 --- a/README +++ b/README @@ -6,7 +6,8 @@ freqVectorsEdit [ -bhmk ] [ -show ] DESCRIPTION - freqVectorsEdit.sh is a bash script to add/replace FrequencyVectors in plists in X86PlatformPlugin.kext/Contents/Resources/ + freqVectorsEdit.sh is a bash script to add/replace FrequencyVectors in plists in + X86PlatformPlugin.kext/Contents/Resources/ This kext can be found in: /System/Library/Extensions/IOPlatformPluginFamily.kext/Contents/PlugIns The target plist (example: Mac-F60DEB81FF30ACF6.plist for the MacPro6,1) is selected based on the used board-id. @@ -35,7 +36,8 @@ DESCRIPTION -k kext path (example: /System/Library/Extensions) Overrides path to kernel extension to allow editing of frequency vectors with SIP enabled - This will of course require further processing but comes in handy if resulting patched plist is used for CPUFriend + This will of course require further processing but comes in handy if resulting patched plist is used + for CPUFriend diff --git a/freqVectorsEdit.sh b/freqVectorsEdit.sh index 8c62f34..1285fe6 100755 --- a/freqVectorsEdit.sh +++ b/freqVectorsEdit.sh @@ -3,7 +3,7 @@ # # Script (freqVectorsEdit.sh) to add 'FrequencyVectors' from a source plist to Mac-F60DEB81FF30ACF6.plist # -# Version 3.3 - Copyright (c) 2013-2017 by Pike R. Alpha and 2020 by Jens S. Wondrak +# Version 3.3 - Copyright (c) 2013-2017 by Pike R. Alpha and 2020 by Jens S. Wondrak (Inspector42) # # Updates: # - v0.5 Show Mac model info (Pike R. Alpha, December 2013) @@ -67,7 +67,7 @@ # - Show matching board-id in bold. # - Show Frequencies and HWP setting. # - v3.2 Renamed _listmatchingFiles to _selectSourceResourceFile() -# - v3.3 Added option -k to override path to Extension folder to enable use in directories not locked bz SIP +# - v3.3 Added option -k to override path to Extension folder to enable use in directories not locked by SIP (Insepctor42, August 2020) # # # Known issues: From bc6a91e4b71250bd0f5b6464822abb2f20feb9ed Mon Sep 17 00:00:00 2001 From: Inspector42 Date: Sun, 30 Aug 2020 14:26:13 +0200 Subject: [PATCH 3/5] Complete rework of README Added man page style use as well as specific instructions for use of kext in a working directory rather than the original system location --- README | 86 +++++++++++++++++++++++++++++++--------------- freqVectorsEdit.sh | 6 ++-- 2 files changed, 62 insertions(+), 30 deletions(-) diff --git a/README b/README index f0d858a..fbfa1e7 100755 --- a/README +++ b/README @@ -1,6 +1,6 @@ SYNOPSIS -freqVectorsEdit [ -bhmk ] [ -show ] +freqVectorsEdit [-h] [-d <0|1>] [-b ] [-m ] [-k ] [-show [Haswell|Broadwell|SkyLake|KabyLake]] DESCRIPTION @@ -16,9 +16,12 @@ DESCRIPTION The following options are available: + -h help, shows a list of available options + -b board-id (example: Mac-F60DEB81FF30ACF6) - Overrides the board-id obtained from the system settings in case the editing it performed on a 3rd computer + Overrides the board-id obtained from the system settings in case the editing it performed on a + 3rd computer default: board-id of current running systems specified in SMBIOS settings -d debug @@ -36,13 +39,20 @@ DESCRIPTION -k kext path (example: /System/Library/Extensions) Overrides path to kernel extension to allow editing of frequency vectors with SIP enabled - This will of course require further processing but comes in handy if resulting patched plist is used - for CPUFriend + in the specified working directory. This requires a copy of IOPlatformPluginFamily.kext to reside in the + specified directory . This will of course require further processing but comes + in handy if resulting patched plist is used for CPUFriend + +In order to use freqVectorsEdit.sh with enabled SIP, you need to first copy "IOPlatformPluginFamily.kext" from "/System/Library/Extensions". +Let's assume you are using /Users/Documents/Hackintosh as your working directory. +The you can then use + cp -a /System/Library/Extensions/IOPlatformPluginFamily.kext /Users/Documents/Hackintosh/IOPlatformPluginFamily.kext +Now you continue as laid out below using ./freqVectorsEdit.sh -k /Users/Documents/Hackintosh. -1) Start script by entering: +1) Start script by entering (please use the -h option to show help and list of available further options as listed above): ./freqVectorsEdit.sh @@ -53,27 +63,49 @@ Password: 3) Now you see something like this: -freqVectorsEdit.sh v1.3 Copyright (c) 2013-2014 by Pike R. Alpha. ------------------------------------------------------------------ -Bugs > https://github.com/Piker-Alpha/freqVectorsEdit.sh/issues < - -Available resource files (plists) with FrequencyVectors: - - [ 1 ] Mac-031B6874CF7F642A.plist / iMac14,1 - [ 2 ] Mac-189A3D4F975D5FFC.plist / MacBookPro11,1 - [ 3 ] Mac-27ADBB7B4CEE8E61.plist / iMac14,2 - [ 4 ] Mac-2BD1B31983FE1663.plist / MacBookPro11,3 - [ 5 ] Mac-35C1E88140C3E6CF.plist / MacBookAir6,1 - [ 6 ] Mac-35C5E08120C7EEAF.plist / Macmini7,1 - [ 7 ] Mac-3CBD00234E554E41.plist / MacBookPro11,2 - [ 8 ] Mac-42FD25EABCABB274.plist / iMac15,1 - [ 9 ] Mac-77EB7D7DAF985301.plist / iMac14,3 - [ 10 ] Mac-7DF21CB3ED6977E5.plist / MacBookAir6,2 - [ 11 ] Mac-81E3E92DD6088272.plist / iMac14,4 - [ 12 ] Mac-F60DEB81FF30ACF6.plist / MacPro6,1 - [ 13 ] Mac-FA842E06C61E91C5.plist / iMac15,2 - -Please choose the desired plist for your hardware (Exit/1-13) ? + freqVectorsEdit.sh v3.3 Copyright (c) 2013-2020 by Pike R. Alpha and 2020 by Jens S. Wondrak. + ----------------------------------------------------------------- + Bugs > https://github.com/Piker-Alpha/freqVectorsEdit.sh/issues < + + Available resource files (plists) with FrequencyVectors: + + [ 1 ] Mac-EE2EBD4B90B839A8.plist (MacBook10,1 @ 3000 HWP/3200 HWP/3600 HWP) + [ 2 ] Mac-BE0E8AC46FE800CC.plist (MacBook8,1 @ 2400/2600/2900) + [ 3 ] Mac-42FD25EABCABB274.plist (iMac15,1) + [ 4 ] Mac-189A3D4F975D5FFC.plist (MacBookPro11,1) + [ 5 ] Mac-90BE64C3CB5A9AEB.plist (Unknown Model @ 3000/3200/3600) + [ 6 ] Mac-BE088AF8C5EB4FA2.plist (iMac18,3) + [ 7 ] Mac-65CE76090165799A.plist (iMac17,1) + [ 8 ] Mac-6FEBD60817C77D8A.plist (Unknown Model @ 3800 HWP/4100 HWP) + [ 9 ] Mac-E43C1C25D4880AD6.plist (MacBookPro12,1) + [ 10 ] Mac-FA842E06C61E91C5.plist (iMac15,1) + [ 11 ] Mac-FFE5EF870D7BA81A.plist (iMac16,2) + [ 12 ] Mac-CAD6701F7CEA0921.plist (MacBookPro14,2 @ 3500 HWP/3700 HWP/4000 HWP) + [ 13 ] Mac-226CB3C6A851A671.plist (Unknown Model @ 3600 HWP) + [ 14 ] Mac-747B1AEFF11738BE.plist (Unknown Model @ 3000/3200/3600) + [ 15 ] Mac-7DF21CB3ED6977E5.plist (MacBookAir6,2) + [ 16 ] Mac-4B682C642B45593E.plist (iMac18,1) + [ 17 ] Mac-27AD2F918AE68F61.plist (Unknown Model HWP) + [ 18 ] Mac-F305150B0C7DEEEF.plist (Unknown Model @ 2400/2600/2900) + [ 19 ] Mac-7BA5B2DFE22DDD8C.plist (Unknown Model @ 3600 HWP/4000 HWP/4100 HWP/4500 HWP) + [ 20 ] Mac-E7203C0F68AA0004.plist (Unknown Model @ 3900 HWP/4500 HWP) + [ 21 ] Mac-63001698E7A34814.plist (Unknown Model @ 3600 HWP/4100 HWP/4600 HWP) + [ 22 ] Mac-9F18E312C5C2BF0B.plist (MacBookAir7,1 @ 2700/3200) + [ 23 ] Mac-112818653D3AABFC.plist (Unknown Model @ 3000/3200/3600) + [ 24 ] Mac-031B6874CF7F642A.plist (iMac14,1) + + Please choose the desired plist for your hardware (Exit/1-24) ? + +Note that the model names in brackets rely on the models.cfg file that is part of https://github.com/Piker-Alpha/ssdtPRGen.sh. +It only receives infrequent updates and hence the newest Macs may show up as "Unknown Model". + +Unknown Models are liste in red font, those that match your system's max turbo frequency will show up in green font. + +Currently multiple entries for the same board-id are also not supported. The script creates individual temporary files for each entries +with a filename boardid-tttt.bin, in which tttt represents the maximum turbo frequency. However, the other routines can only utilise +temporary files boardid.bin and therefore results from selecting a boardid with multiple entries is not defined. + +LFM patch is applied based on current system setting using "sysctl -nx machdep.xcpm.hard_plimit_min_100mhz_ratio" 4) Let's use '4' for this run and press enter. After this you see this: @@ -87,4 +119,4 @@ Do you want to reboot now? (y/n) n 6) Let's use 'n' for this run and press enter. You normally would select 'y'. - +7) If you used diff --git a/freqVectorsEdit.sh b/freqVectorsEdit.sh index 1285fe6..ae37215 100755 --- a/freqVectorsEdit.sh +++ b/freqVectorsEdit.sh @@ -67,7 +67,7 @@ # - Show matching board-id in bold. # - Show Frequencies and HWP setting. # - v3.2 Renamed _listmatchingFiles to _selectSourceResourceFile() -# - v3.3 Added option -k to override path to Extension folder to enable use in directories not locked by SIP (Insepctor42, August 2020) +# - v3.3 Added option -k to override path to Extension folder to enable use in directories not locked by SIP (Inspector42, August 2020) # # # Known issues: @@ -601,7 +601,7 @@ function _getResourceFiles() if [[ "${#gTargetFileNames[@]}" -eq 0 ]]; then - _PRINT_MSG 'Error: FrequencyVector data found in X86PlatformPlugin.kext!' + _PRINT_MSG 'Error: No FrequencyVector data found in X86PlatformPlugin.kext!' _ABORT else _DEBUG_PRINT "${#gTargetFileNames[@]} plists found with FrequencyVectors" @@ -1530,7 +1530,7 @@ function _getScriptArguments() then _PRINT_MSG "Override value: (-k) kext path, now using: ${gExtensionsDirectory}!" else - _invalidArgumentError "-k resource does not exists" + _invalidArgumentError "-k resource does not exist" fi fi else From e41460f690d4283628e2fa26acfbce93618cbe9b Mon Sep 17 00:00:00 2001 From: Inspector42 Date: Sun, 30 Aug 2020 14:31:49 +0200 Subject: [PATCH 4/5] Update README Minor ammendments at the end of the README (Step 7) --- README | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README b/README index fbfa1e7..7a61fef 100755 --- a/README +++ b/README @@ -111,12 +111,14 @@ LFM patch is applied based on current system setting using "sysctl -nx machdep.x Triggering a kernelcache refresh ... -Do you want to open Mac-F60DEB81FF30ACF6.plist (y/n)? n + Do you want to open Mac-F60DEB81FF30ACF6.plist (y/n)? n 5) Let's use 'n' for this run and press enter. Now it asks you if you want to reboot: -Do you want to reboot now? (y/n) n + Do you want to reboot now? (y/n) n 6) Let's use 'n' for this run and press enter. You normally would select 'y'. -7) If you used +7) If you used the -k option then of course the modified IOPlatformPluginFamily.kext will require further processin. + When manually copying it back into the system SIP must be disabled and an update of the pre-linked kernel needs to be triggered manually using @touch /System/Library/Extensions" before reboot. + Else the modified plists residing within the IOPlatformPluginFamily.kext can be used to create the necessary resource files for CPUFriend. From 420c17d759092f9b975aa6e66f8a167c6946f19e Mon Sep 17 00:00:00 2001 From: Lord of the Mac Date: Sun, 6 Sep 2020 13:28:16 +0200 Subject: [PATCH 5/5] Clarified options -b and -m in README Clarified that -b and -m modify the target plist to be modified/copied to. Added hint that modification of kext invalidates signature --- README | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/README b/README index 7a61fef..241aa8e 100755 --- a/README +++ b/README @@ -10,7 +10,11 @@ DESCRIPTION X86PlatformPlugin.kext/Contents/Resources/ This kext can be found in: /System/Library/Extensions/IOPlatformPluginFamily.kext/Contents/PlugIns - The target plist (example: Mac-F60DEB81FF30ACF6.plist for the MacPro6,1) is selected based on the used board-id. + The target plist (example: Mac-F60DEB81FF30ACF6.plist for the MacPro6,1) is selected based on the board-id that is specified in the + SMBIOS settings of the system on which this script is launched. + + It should be noted that modifying the kext with this script invalidates the signature of the kext and requires at + least partially disabled SIP to be loaded on newer versions of macOS. In the current version, the following options are available @@ -19,17 +23,19 @@ DESCRIPTION -h help, shows a list of available options - -b board-id (example: Mac-F60DEB81FF30ACF6) - Overrides the board-id obtained from the system settings in case the editing it performed on a - 3rd computer + -b board-id (example: Mac-F60DEB81FF30ACF6) identifying matching plist to be overwritten by the script in the kext + Overrides the board-id obtained from the system settings that determines, which plist within the kext is overwritten + Useful in case the editing it performed on a 3rd computer different from the target system default: board-id of current running systems specified in SMBIOS settings -d debug 0 = no debug output (default) 1 = debug output (very verbose) - -m model (example: MacPro6,1) - Overrides the model obtained from the system settings + -m model (example: MacPro6,1) identifying matching plist to be overwritten by the script in the kext + Overrides the model obtained from the system settings that determines, which plist within the kext is overwritten + Useful in case the editing it performed on a 3rd computer different from the target system + default: model of current running systems specified in SMBIOS settings -show show supported board-id and model combinations Haswell @@ -37,11 +43,12 @@ DESCRIPTION Skylake KabyLake - -k kext path (example: /System/Library/Extensions) + -k kext path (example: ~/Documents) Overrides path to kernel extension to allow editing of frequency vectors with SIP enabled in the specified working directory. This requires a copy of IOPlatformPluginFamily.kext to reside in the specified directory . This will of course require further processing but comes in handy if resulting patched plist is used for CPUFriend + default: /System/Library/Extensions In order to use freqVectorsEdit.sh with enabled SIP, you need to first copy "IOPlatformPluginFamily.kext" from "/System/Library/Extensions". Let's assume you are using /Users/Documents/Hackintosh as your working directory.