From 07212c59869db86463a8a2b4f61381caf322f517 Mon Sep 17 00:00:00 2001 From: rawhide kobayashi Date: Fri, 14 Mar 2025 14:31:45 -0500 Subject: [PATCH] why the heck didn't it grab these files --- .gitignore | 2 ++ .vscode/settings.json | 3 +++ ryzen-smu-cli.sln | 22 ++++++++++++++++ ryzen-smu-cli/Program.cs | 40 ++++++++++++++++++++++++++++++ ryzen-smu-cli/ryzen-smu-cli.csproj | 23 +++++++++++++++++ 5 files changed, 90 insertions(+) create mode 100644 .gitignore create mode 100644 .vscode/settings.json create mode 100644 ryzen-smu-cli.sln create mode 100644 ryzen-smu-cli/Program.cs create mode 100644 ryzen-smu-cli/ryzen-smu-cli.csproj diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cbbd0b5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +bin/ +obj/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..9f482ff --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "dotnet.defaultSolution": "ryzen-smu-cli.sln" +} \ No newline at end of file diff --git a/ryzen-smu-cli.sln b/ryzen-smu-cli.sln new file mode 100644 index 0000000..35c5ea6 --- /dev/null +++ b/ryzen-smu-cli.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ryzen-smu-cli", "ryzen-smu-cli\ryzen-smu-cli.csproj", "{F64F6F9E-E342-45AB-A064-92EE3DB730B6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F64F6F9E-E342-45AB-A064-92EE3DB730B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F64F6F9E-E342-45AB-A064-92EE3DB730B6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F64F6F9E-E342-45AB-A064-92EE3DB730B6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F64F6F9E-E342-45AB-A064-92EE3DB730B6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/ryzen-smu-cli/Program.cs b/ryzen-smu-cli/Program.cs new file mode 100644 index 0000000..f5598b3 --- /dev/null +++ b/ryzen-smu-cli/Program.cs @@ -0,0 +1,40 @@ +using System.CommandLine; +using ZenStates.Core; + +class Program +{ + private static readonly Cpu ryzen = new(); + + static int Main(string[] args) + { + + + var rootCommand = new RootCommand("A CLI for the Ryzen SMU."); + + var pboOffset = new Option("--offset", "Specify a core, or list of cores, and their PBO offset(s)."); + + rootCommand.AddOption(pboOffset); + // How to format this command and process it is to be decided. + rootCommand.SetHandler((core_values) => + { + Console.WriteLine(core_values); + }, pboOffset); + + // works + ApplySingleCorePBOOffset(0, -15); + + return rootCommand.Invoke(args); + } + + private static void ApplySingleCorePBOOffset(int coreNumber, int value) + { + // Magic numbers from SMUDebugTool + // This does some bitshifting calculations to get the mask for individual cores for chips with up to two CCDs + // I'm not sure if it would work with more, in theory. It's unclear to me based on the github issues. + int mapIndex = coreNumber < 8 ? 0 : 1; + if ((~ryzen.info.topology.coreDisableMap[mapIndex] >> coreNumber % 8 & 1) == 1) + { + ryzen.SetPsmMarginSingleCore((uint)(((mapIndex << 8) | coreNumber % 8 & 0xF) << 20), value); + } + } +} diff --git a/ryzen-smu-cli/ryzen-smu-cli.csproj b/ryzen-smu-cli/ryzen-smu-cli.csproj new file mode 100644 index 0000000..7de0400 --- /dev/null +++ b/ryzen-smu-cli/ryzen-smu-cli.csproj @@ -0,0 +1,23 @@ + + + + Exe + net8.0-windows + ryzen_smu_cli + enable + enable + 0.0.1 + + + + + + + + + + + + + +