Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inspector42 #18

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .gitIgnore
100644 → 100755
Empty file.
135 changes: 106 additions & 29 deletions README
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,12 +1,65 @@
Introduction
SYNOPSIS

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
freqVectorsEdit [-h] [-d <0|1>] [-b <BOARD-ID>] [-m <MODEL>] [-k <WORKINGDIR>] [-show [Haswell|Broadwell|SkyLake|KabyLake]]

The target plist (example: Mac-F60DEB81FF30ACF6.plist for the MacPro6,1) is selected based on the used board-id.

DESCRIPTION

1) Start script by entering:

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 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

The following options are available:

-h help, shows a list of available options


-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) 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
Broadwell
Skylake
KabyLake

-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.
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 (please use the -h option to show help and list of available further options as listed above):

./freqVectorsEdit.sh

Expand All @@ -17,38 +70,62 @@ Password: <enter root 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:

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 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.
35 changes: 29 additions & 6 deletions freqVectorsEdit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 (Inspector42)
#
# Updates:
# - v0.5 Show Mac model info (Pike R. Alpha, December 2013)
Expand Down Expand Up @@ -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 by SIP (Inspector42, August 2020)
#
#
# Known issues:
Expand All @@ -85,7 +86,7 @@
#
# Script version info.
#
gScriptVersion=3.2
gScriptVersion=3.3

#
# Path and filename setup.
Expand Down Expand Up @@ -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"
}
Expand Down Expand Up @@ -600,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"
Expand Down Expand Up @@ -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).
#
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 exist"
fi
fi
else
_invalidArgumentError "-k $1"
fi
;;

*) _invalidArgumentError "$1"
;;
Expand Down Expand Up @@ -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
#
Expand Down