diff --git a/Common/ZenStates-Core.dll b/Common/ZenStates-Core.dll index 0ee30ce..97e461f 100644 Binary files a/Common/ZenStates-Core.dll and b/Common/ZenStates-Core.dll differ diff --git a/WPF-no-themes/Properties/BuildNumberTemplate.cs b/WPF-no-themes/Properties/BuildNumberTemplate.cs index c90113d..4060fce 100644 --- a/WPF-no-themes/Properties/BuildNumberTemplate.cs +++ b/WPF-no-themes/Properties/BuildNumberTemplate.cs @@ -5,5 +5,5 @@ using System.Reflection; -[assembly: AssemblyVersion("1.30.1436")] -[assembly: AssemblyFileVersion("1.30.1436")] +[assembly: AssemblyVersion("1.30.1535")] +[assembly: AssemblyFileVersion("1.30.1535")] diff --git a/WPF/App.xaml.cs b/WPF/App.xaml.cs index d64709c..52d100a 100644 --- a/WPF/App.xaml.cs +++ b/WPF/App.xaml.cs @@ -1,6 +1,8 @@ using System; +using System.Globalization; using System.Threading; using System.Windows; +using System.Windows.Markup; using ZenStates.Core; using ZenTimings.Windows; @@ -30,6 +32,11 @@ protected override void OnStartup(StartupEventArgs e) Environment.Exit(0); } + Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); + Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); + FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata( + XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); + updater = new Updater(); GC.KeepAlive(instanceMutex); diff --git a/WPF/AppSettings.cs b/WPF/AppSettings.cs index 9d6c287..cab8b06 100644 --- a/WPF/AppSettings.cs +++ b/WPF/AppSettings.cs @@ -19,6 +19,7 @@ public enum Theme : int Light, Dark, DarkMint, + DarkMintGradient, DarkRed, Dracula, RetroWave, @@ -34,7 +35,7 @@ public enum ScreenshotType : int public AppSettings Create(bool save = true) { Version = $"{VersionMajor}.{VersionMinor}"; - AppTheme = Theme.Light; + AppTheme = Theme.DarkMintGradient; ScreenshotMode = ScreenshotType.Window; AutoRefresh = true; AutoRefreshInterval = 2000; @@ -112,6 +113,7 @@ public void ChangeTheme() new Uri("pack://application:,,,/ZenTimings;component/Themes/Light.xaml", UriKind.Absolute), new Uri("pack://application:,,,/ZenTimings;component/Themes/Dark.xaml", UriKind.Absolute), new Uri("pack://application:,,,/ZenTimings;component/Themes/DarkMint.xaml", UriKind.Absolute), + new Uri("pack://application:,,,/ZenTimings;component/Themes/DarkMintGradient.xaml", UriKind.Absolute), new Uri("pack://application:,,,/ZenTimings;component/Themes/DarkRed.xaml", UriKind.Absolute), new Uri("pack://application:,,,/ZenTimings;component/Themes/Dracula.xaml", UriKind.Absolute), new Uri("pack://application:,,,/ZenTimings;component/Themes/RetroWave.xaml", UriKind.Absolute), @@ -125,7 +127,7 @@ public void ChangeTheme() public bool AutoRefresh { get; set; } = true; public int AutoRefreshInterval { get; set; } = 2000; public bool AdvancedMode { get; set; } = true; - public Theme AppTheme { get; set; } = Theme.Light; + public Theme AppTheme { get; set; } = Theme.DarkMintGradient; public ScreenshotType ScreenshotMode { get; set; } = ScreenshotType.Window; public bool CheckForUpdates { get; set; } = true; public string UpdaterSkippedVersion { get; set; } = ""; diff --git a/WPF/CpuSingleton.cs b/WPF/CpuSingleton.cs new file mode 100644 index 0000000..a7b6190 --- /dev/null +++ b/WPF/CpuSingleton.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ZenStates.Core; + +namespace ZenTimings +{ + internal sealed class CpuSingleton + { + private static Cpu instance = null; + private CpuSingleton() { } + + public static Cpu Instance + { + get + { + if (instance == null) + instance = new Cpu(); + + return instance; + } + } + } +} diff --git a/WPF/MainWindow.xaml b/WPF/MainWindow.xaml index 8d3717c..7200c08 100644 --- a/WPF/MainWindow.xaml +++ b/WPF/MainWindow.xaml @@ -21,7 +21,12 @@ Loaded="AdonisWindow_Loaded" BorderThickness="1" UseLayoutRounding="True" - BorderBrush="{DynamicResource WindowBorderColor}" Closing="AdonisWindow_Closing" Height="538" SizeToContent="WidthAndHeight"> + BorderBrush="{DynamicResource WindowBorderColor}" + Style="{DynamicResource WindowStyles}" + Closing="AdonisWindow_Closing" + Height="538" + SizeToContent="WidthAndHeight" + Language="en-US"> + + diff --git a/WPF/MainWindow.xaml.cs b/WPF/MainWindow.xaml.cs index c2e3ab0..dde3f75 100644 --- a/WPF/MainWindow.xaml.cs +++ b/WPF/MainWindow.xaml.cs @@ -15,9 +15,10 @@ using System.Windows.Media.Imaging; using System.Windows.Threading; using ZenStates.Core; +using ZenStates.Core.DRAM; using ZenTimings.Plugin; using ZenTimings.Windows; -using static ZenTimings.MemoryConfig; +using static ZenStates.Core.DRAM.MemoryConfig; using Forms = System.Windows.Forms; using MessageBox = AdonisUI.Controls.MessageBox; using MessageBoxButton = AdonisUI.Controls.MessageBoxButton; @@ -59,7 +60,7 @@ public MainWindow() try { SplashWindow.Loading("CPU"); - cpu = new Cpu(); + cpu = CpuSingleton.Instance; if (cpu.info.family.Equals(Cpu.Family.UNSUPPORTED)) { @@ -98,14 +99,21 @@ public MainWindow() InitializeComponent(); SplashWindow.Loading("Memory modules"); + modules = cpu.GetMemoryConfig().Modules; ReadMemoryModulesInfo(); SplashWindow.Loading("Timings"); // Read from first enabled DCT if (modules.Count > 0) + { ReadTimings(modules[0].DctOffset); + } else + { ReadTimings(); + } + + MEMCFG.TotalCapacity = cpu.GetMemoryConfig().TotalCapacity.ToString(); if (cpu != null && settings.AdvancedMode) { @@ -155,9 +163,9 @@ public MainWindow() timings = MEMCFG, cpu.powerTable, cpu.info.codeName, - WMIPresent = !compatMode && MEMCFG.Type == MemType.DDR4, + WMIPresent = !compatMode && cpu.GetMemoryConfig().Type == MemType.DDR4, settings, - plugins + plugins, }; } catch (Exception ex) @@ -209,6 +217,9 @@ private void ExitApplication() //cpu?.io?.Close(settings.AutoUninstallDriver); cpu?.Dispose(); settings.Save(); + + //Driver.Cleanup(); + Application.Current.Shutdown(); } @@ -217,126 +228,15 @@ private BiosACPIFunction GetFunctionByIdString(string name) return biosFunctions.Find(x => x.IDString == name); } - private void ReadChannelsInfo() - { - int dimmIndex = 0; - uint channelsPerDimm = MEMCFG.Type >= MemType.DDR5 ? 2u : 1u; - - // Get the offset by probing the IMC0 to IMC7 - // It appears that offsets 0x80 and 0x84 are DIMM config registers - // When a DIMM is DR, bit 0 is set to 1 - // 0x50000 - // offset 0, bit 0 when set to 1 means DIMM1 is installed - // offset 8, bit 0 when set to 1 means DIMM2 is installed - for (uint i = 0; i < 8u * channelsPerDimm; i += channelsPerDimm) - { - uint channelOffset = i << 20; - bool channel = Utils.GetBits(cpu.ReadDword(channelOffset | 0x50DF0), 19, 1) == 0; - bool dimm1 = Utils.GetBits(cpu.ReadDword(channelOffset | 0x50000), 0, 1) == 1; - bool dimm2 = Utils.GetBits(cpu.ReadDword(channelOffset | 0x50008), 0, 1) == 1; - try - { - if (channel && (dimm1 || dimm2)) - { - if (dimm1) - { - MemoryModule module = modules[dimmIndex++]; - module.Slot = $"{Convert.ToChar(i / channelsPerDimm + 65)}1"; - module.DctOffset = channelOffset; - module.Rank = (MemRank)Utils.GetBits(cpu.ReadDword(channelOffset | 0x50080), 0, 1); - } - - if (dimm2) - { - MemoryModule module = modules[dimmIndex++]; - module.Slot = $"{Convert.ToChar(i / channelsPerDimm + 65)}2"; - module.DctOffset = channelOffset; - module.Rank = (MemRank)Utils.GetBits(cpu.ReadDword(channelOffset | 0x50084), 0, 1); - } - } - } - catch { } - } - } - private void ReadMemoryModulesInfo() { - using (ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from Win32_PhysicalMemory")) - { - bool connected = false; - try - { - WMI.Connect(@"root\cimv2"); - - connected = true; - - foreach (ManagementObject queryObject in searcher.Get().Cast()) - { - ulong capacity = 0UL; - uint clockSpeed = 0U; - string partNumber = "N/A"; - string bankLabel = ""; - string manufacturer = ""; - string deviceLocator = ""; - - object temp = WMI.TryGetProperty(queryObject, "Capacity"); - if (temp != null) capacity = (ulong)temp; - - temp = WMI.TryGetProperty(queryObject, "ConfiguredClockSpeed"); - if (temp != null) clockSpeed = (uint)temp; - - temp = WMI.TryGetProperty(queryObject, "partNumber"); - if (temp != null) partNumber = (string)temp; - - temp = WMI.TryGetProperty(queryObject, "BankLabel"); - if (temp != null) bankLabel = (string)temp; - - temp = WMI.TryGetProperty(queryObject, "Manufacturer"); - if (temp != null) manufacturer = (string)temp; - - temp = WMI.TryGetProperty(queryObject, "DeviceLocator"); - if (temp != null) deviceLocator = (string)temp; - - modules.Add(new MemoryModule(partNumber.Trim(), bankLabel.Trim(), manufacturer.Trim(), - deviceLocator, capacity, clockSpeed)); - - //string bl = bankLabel.Length > 0 ? new string(bankLabel.Where(char.IsDigit).ToArray()) : ""; - //string dl = deviceLocator.Length > 0 ? new string(deviceLocator.Where(char.IsDigit).ToArray()) : ""; - - //comboBoxPartNumber.Items.Add($"#{bl}: {partNumber}"); - //comboBoxPartNumber.SelectedIndex = 0; - } - } - catch (Exception ex) - { - string text = connected ? @"Failed to get installed memory parameters." : $@"{ex.Message}"; - MessageBox.Show( - text, - "Warning", - MessageBoxButton.OK, - MessageBoxImage.Warning); - } - } - if (modules.Count > 0) { - ReadChannelsInfo(); - - ulong totalCapacity = 0UL; - foreach (MemoryModule module in modules) { - totalCapacity += module.Capacity; - comboBoxPartNumber.Items.Add( - $"{module.Slot}: {module.PartNumber} ({module.Capacity / 1024 / (1024 * 1024)}GB, {module.Rank})"); + comboBoxPartNumber.Items.Add(module.ToString()); } - if (modules[0].ClockSpeed != 0) - MEMCFG.Frequency = modules[0].ClockSpeed; - - if (totalCapacity != 0) - MEMCFG.TotalCapacity = $"{totalCapacity / 1024 / (1024 * 1024)}GB"; - if (comboBoxPartNumber.Items.Count > 0) { comboBoxPartNumber.SelectedIndex = 0; @@ -418,7 +318,7 @@ private void ReadMemoryConfig() AOD aod = cpu.info.aod; - if (MEMCFG.Type == MemType.DDR4) + if (cpu.GetMemoryConfig().Type == MemType.DDR4) { // Get APCB config from BIOS. Holds memory parameters. @@ -539,7 +439,8 @@ private void ReadMemoryConfig() try { - if (cpu.info.codeName == Cpu.CodeName.Phoenix || cpu.info.codeName == Cpu.CodeName.Phoenix2 || cpu.info.codeName == Cpu.CodeName.HawkPoint) + Cpu.CodeName codeName = cpu.info.codeName; + if (codeName == Cpu.CodeName.Phoenix || codeName == Cpu.CodeName.Phoenix2 || codeName == Cpu.CodeName.HawkPoint) { labelProcCaOdt.IsEnabled = true; labelProcCkOdt.IsEnabled = true; @@ -550,6 +451,21 @@ private void ReadMemoryConfig() textBoxProcDqOdt.Text = Data.ProcDqOdt.ToString(); textBoxProcDqsOdt.Text = Data.ProcDqsOdt.ToString(); } + else if (cpu.info.family == Cpu.Family.FAMILY_1AH && Data.ProcOdtPullUp != null) + { + labelProcODT.Visibility = Visibility.Collapsed; + textBoxProcODT.Visibility = Visibility.Collapsed; + procOdtDivider1.Visibility = Visibility.Collapsed; + procOdtDivider2.Visibility = Visibility.Collapsed; + labelProcOdtPullUp.Visibility = Visibility.Visible; + labelProcOdtPullUp.IsEnabled = true; + labelProcOdtPullDown.Visibility = Visibility.Visible; + labelProcOdtPullDown.IsEnabled = true; + textBoxProcOdtPullUp.Visibility = Visibility.Visible; + textBoxProcOdtPullDown.Visibility = Visibility.Visible; + textBoxProcOdtPullUp.Text = Data.ProcOdtPullUp.ToString(); + textBoxProcOdtPullDown.Text = Data.ProcOdtPullDown.ToString(); + } else { labelProcODT.IsEnabled = true; @@ -588,7 +504,7 @@ private void ReadTimings(uint offset = 0) { uint config = cpu.ReadDword(offset | 0x50100); - MEMCFG.Type = (MemType)Utils.GetBits(config, 0, 2); + MEMCFG.Type = (MemoryConfig.MemType)(MemType)Utils.GetBits(config, 0, 2); uint powerDown = cpu.ReadDword(offset | 0x5012C); uint umcBase = cpu.ReadDword(offset | 0x50200); @@ -618,11 +534,11 @@ private void ReadTimings(uint offset = 0) uint timings22 = cpu.ReadDword(offset | 0x5028C); uint trfcRegValue = 0; - if (MEMCFG.Type == MemType.DDR4) + if (cpu.GetMemoryConfig().Type == MemType.DDR4) { trfcRegValue = trfcTimings0 != trfcTimings1 ? (trfcTimings0 != 0x21060138 ? trfcTimings0 : trfcTimings1) : trfcTimings0; } - else if (MEMCFG.Type >= MemType.DDR5) + else if (cpu.GetMemoryConfig().Type >= MemType.DDR5) { uint[] ddr5Regs = { trfcTimings0, trfcTimings1, trfcTimings2, trfcTimings3 }; foreach (uint reg in ddr5Regs) @@ -636,7 +552,7 @@ private void ReadTimings(uint offset = 0) } float configured = MEMCFG.Frequency; - float ratio = MEMCFG.Type == MemType.DDR4 ? Utils.GetBits(umcBase, 0, 7) / 3.0f : Utils.GetBits(umcBase, 0, 16) / 100.0f; + float ratio = cpu.GetMemoryConfig().Type == MemType.DDR4 ? Utils.GetBits(umcBase, 0, 7) / 3.0f : Utils.GetBits(umcBase, 0, 16) / 100.0f; float freqFromRatio = ratio * 200; MEMCFG.Ratio = ratio; @@ -652,9 +568,9 @@ private void ReadTimings(uint offset = 0) MEMCFG.BGSAlt = Utils.GetBits(bgsa0, 4, 7) > 0 || Utils.GetBits(bgsa1, 4, 7) > 0 ? "Enabled" : "Disabled"; - int GDM_BIT = MEMCFG.Type == MemType.DDR4 ? 11 : 18; + int GDM_BIT = cpu.GetMemoryConfig().Type == MemType.DDR4 ? 11 : 18; MEMCFG.GDM = Utils.GetBits(umcBase, GDM_BIT, 1) > 0 ? "Enabled" : "Disabled"; - int CMD2T_BIT = MEMCFG.Type == MemType.DDR4 ? 10 : 17; + int CMD2T_BIT = cpu.GetMemoryConfig().Type == MemType.DDR4 ? 10 : 17; MEMCFG.Cmd2T = Utils.GetBits(umcBase, CMD2T_BIT, 1) > 0 ? "2T" : "1T"; MEMCFG.CL = Utils.GetBits(timings5, 0, 6); @@ -708,14 +624,14 @@ private void ReadTimings(uint offset = 0) MEMCFG.PHYRDL = Utils.GetBits(timings19, 16, 8); MEMCFG.PHYWRD = Utils.GetBits(timings19, 24, 3); - if (MEMCFG.Type == MemType.DDR4) + if (cpu.GetMemoryConfig().Type == MemType.DDR4) { MEMCFG.RFC = Utils.GetBits(trfcRegValue, 0, 11); MEMCFG.RFC2 = Utils.GetBits(trfcRegValue, 11, 11); MEMCFG.RFC4 = Utils.GetBits(trfcRegValue, 22, 11); } - if (MEMCFG.Type >= MemType.DDR5) + if (cpu.GetMemoryConfig().Type >= MemType.DDR5) { MEMCFG.RFC = Utils.GetBits(trfcRegValue, 0, 16); MEMCFG.RFC2 = Utils.GetBits(trfcRegValue, 16, 16); @@ -1013,7 +929,7 @@ private void DebugToolstripItem_Click(object sender, RoutedEventArgs e) Window parent = Application.Current.MainWindow; if (parent != null) { - DebugDialog debugWnd = new DebugDialog(cpu, modules, MEMCFG, BMC, AsusWmi) + DebugDialog debugWnd = new DebugDialog(BMC, AsusWmi) { Owner = parent, Width = parent.Width, diff --git a/WPF/Plugin/SVI2Plugin.cs b/WPF/Plugin/SVI2Plugin.cs index e616a08..e8eb141 100644 --- a/WPF/Plugin/SVI2Plugin.cs +++ b/WPF/Plugin/SVI2Plugin.cs @@ -20,18 +20,18 @@ public class SVI2Plugin : IPlugin public List Sensors { get; private set; } - private Cpu _cpu; + private Cpu cpuInstance; public SVI2Plugin(Cpu cpu) { - InitializeSensors(cpu); + cpuInstance = cpu; + InitializeSensors(); } - private void InitializeSensors(Cpu cpu) + private void InitializeSensors() { - if (cpu != null && cpu.Status == IOModule.LibStatus.OK) + if (cpuInstance != null && cpuInstance.Status == IOModule.LibStatus.OK) { - _cpu = cpu; Sensors = new List { new Sensor("VSOC", 0), @@ -42,7 +42,7 @@ private void InitializeSensors(Cpu cpu) public bool Update() { - if (Sensors?.Count > 0 && _cpu != null) + if (Sensors?.Count > 0 && cpuInstance != null) { uint socPlaneValue; uint vcorePlaneValue; @@ -65,8 +65,8 @@ public bool Update() private void ReadSensorValues(out uint socPlaneValue, out uint vcorePlaneValue) { - socPlaneValue = _cpu.ReadDword(_cpu.info.svi2.socAddress); - vcorePlaneValue = _cpu.ReadDword(_cpu.info.svi2.coreAddress); + socPlaneValue = cpuInstance.ReadDword(cpuInstance.info.svi2.socAddress); + vcorePlaneValue = cpuInstance.ReadDword(cpuInstance.info.svi2.coreAddress); } private void UpdateSensorValue(uint planeValue, Sensor sensor) @@ -84,7 +84,7 @@ public void Open() public void Close() { - _cpu = null; + cpuInstance = null; Sensors = null; } } diff --git a/WPF/Properties/BuildNumberTemplate.cs b/WPF/Properties/BuildNumberTemplate.cs index 05293e4..742603c 100644 --- a/WPF/Properties/BuildNumberTemplate.cs +++ b/WPF/Properties/BuildNumberTemplate.cs @@ -5,5 +5,5 @@ using System.Reflection; -[assembly: AssemblyVersion("1.32.1436")] -[assembly: AssemblyFileVersion("1.32.1436")] +[assembly: AssemblyVersion("1.33.1535")] +[assembly: AssemblyFileVersion("1.33.1535")] diff --git a/WPF/Properties/BuildNumberTemplate.tt b/WPF/Properties/BuildNumberTemplate.tt index c445f21..8bf4518 100644 --- a/WPF/Properties/BuildNumberTemplate.tt +++ b/WPF/Properties/BuildNumberTemplate.tt @@ -6,8 +6,8 @@ using System.Reflection; -[assembly: AssemblyVersion("1.32.<#= this.RevisionNumber #>")] -[assembly: AssemblyFileVersion("1.32.<#= this.RevisionNumber #>")] +[assembly: AssemblyVersion("1.33.<#= this.RevisionNumber #>")] +[assembly: AssemblyFileVersion("1.33.<#= this.RevisionNumber #>")] <#+ int RevisionNumber = (int)(DateTime.UtcNow - new DateTime(2020,9,1)).TotalDays; #> \ No newline at end of file diff --git a/WPF/Resources/splash.png b/WPF/Resources/splash.png index 1d91674..a788c24 100644 Binary files a/WPF/Resources/splash.png and b/WPF/Resources/splash.png differ diff --git a/WPF/Resources/splash.psd b/WPF/Resources/splash.psd index bc86833..3229349 100644 Binary files a/WPF/Resources/splash.psd and b/WPF/Resources/splash.psd differ diff --git a/WPF/Themes/DarkMintGradient.xaml b/WPF/Themes/DarkMintGradient.xaml new file mode 100644 index 0000000..79bd9a8 --- /dev/null +++ b/WPF/Themes/DarkMintGradient.xaml @@ -0,0 +1,149 @@ + + + + + + + + + + + #D1D4C9 + + #161b37 + + #092237 + + #14151a + + #161b37 + + + #7ccaa2 + #1f2029 + + #60cd95 + + #5ad394 + #5ad394 + #5ad394 + + #0c2d4a + #0c2d4a + + #0e385c + #0e385c + + #092237 + + #092237 + #092237 + + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/WPF/Themes/DarkRed.xaml b/WPF/Themes/DarkRed.xaml index fcf6da5..7bd6458 100644 --- a/WPF/Themes/DarkRed.xaml +++ b/WPF/Themes/DarkRed.xaml @@ -14,10 +14,12 @@ #1A0302 - #0D0101 + #0B1215 #420704 + #0B1215 + #A71C1E #F3F3F3 @@ -44,7 +46,7 @@ - + @@ -56,6 +58,29 @@ + + + + + + + + + + - + - - - - + + - diff --git a/WPF/Windows/DebugDialog.xaml b/WPF/Windows/DebugDialog.xaml index 00c3eb8..bacff6a 100644 --- a/WPF/Windows/DebugDialog.xaml +++ b/WPF/Windows/DebugDialog.xaml @@ -16,7 +16,8 @@ WindowStartupLocation="CenterOwner" BorderThickness="1" UseLayoutRounding="True" - BorderBrush="{DynamicResource WindowBorderColor}"> + BorderBrush="{DynamicResource WindowBorderColor}" + Style="{DynamicResource WindowStyles}"> diff --git a/WPF/Windows/DebugDialog.xaml.cs b/WPF/Windows/DebugDialog.xaml.cs index f4a10b5..3032a06 100644 --- a/WPF/Windows/DebugDialog.xaml.cs +++ b/WPF/Windows/DebugDialog.xaml.cs @@ -8,7 +8,6 @@ using System.Windows; using ZenStates.Core; using ZenStates.Core.DRAM; -using static ZenTimings.MemoryConfig; using Application = System.Windows.Application; using MessageBox = AdonisUI.Controls.MessageBox; using SaveFileDialog = Microsoft.Win32.SaveFileDialog; @@ -22,14 +21,12 @@ public partial class DebugDialog { private readonly AsusWMI AWMI; private readonly BiosMemController BMC; - private readonly Cpu CPU; + private readonly Cpu cpu; - private readonly MemoryConfig MEMCFG; - private readonly List modules; - private readonly PowerTable PT; + private readonly ZenStates.Core.DRAM.MemoryConfig memoryConfig; + //private readonly List modules; //private readonly uint baseAddress; - private readonly SystemInfo SI; private readonly string wmiAMDACPI = "AMD_ACPI"; private readonly string wmiScope = "root\\wmi"; private ManagementObject classInstance; @@ -37,16 +34,13 @@ public partial class DebugDialog private ManagementBaseObject pack; private string result = ""; - public DebugDialog(Cpu cpu, List memModules, MemoryConfig memCfg, - BiosMemController biosMemCtrl, AsusWMI asusWmi) + public DebugDialog(BiosMemController biosMemCtrl, AsusWMI asusWmi) { InitializeComponent(); - modules = memModules; - SI = cpu.systemInfo; - MEMCFG = memCfg; - PT = cpu.powerTable; + cpu = CpuSingleton.Instance; + //modules = memModules; + memoryConfig = cpu.GetMemoryConfig(); BMC = biosMemCtrl; - CPU = cpu; AWMI = asusWmi; } @@ -145,17 +139,28 @@ private void AddLine(string row = "") private void PrintChannels() { - uint channelsPerDimm = MEMCFG.Type >= MemType.DDR5 ? 2u : 1u; + uint channelsPerDimm = 1; // memoryConfig.Type >= ZenStates.Core.DRAM.MemoryConfig.MemType.DDR5 ? 2u : 1u; AddHeading("Memory Channels Info"); - for (var i = 0u; i < 8u * channelsPerDimm; i += channelsPerDimm) + AddLine("-- UMC Configuration"); + + for (var i = 0u; i < 0xC; i += 1) + { + var offset = i << 20; + var reg = offset | 0x50100; + AddLine($"0x{reg:X8}: 0x{cpu.ReadDword(reg):X8}"); + } + + AddLine(); + + for (var i = 0u; i < 0xC * channelsPerDimm; i += channelsPerDimm) { try { var offset = i << 20; - var channel = Utils.GetBits(CPU.ReadDword(offset | 0x50DF0), 19, 1) == 0; - var dimm1 = Utils.GetBits(CPU.ReadDword(offset | 0x50000), 0, 1) == 1; - var dimm2 = Utils.GetBits(CPU.ReadDword(offset | 0x50008), 0, 1) == 1; + var channel = Utils.GetBits(cpu.ReadDword(offset | 0x50DF0), 19, 1) == 0; + var dimm1 = Utils.GetBits(cpu.ReadDword(offset | 0x50000), 0, 1) == 1; + var dimm2 = Utils.GetBits(cpu.ReadDword(offset | 0x50008), 0, 1) == 1; var enabled = channel && (dimm1 || dimm2); AddLine($"Channel{i / channelsPerDimm}: {enabled}"); @@ -166,7 +171,7 @@ private void PrintChannels() var endReg = offset | 0x50300; while (startReg <= endReg) { - var data = CPU.ReadDword(startReg); + var data = cpu.ReadDword(startReg); AddLine($" 0x{startReg:X8}: 0x{data:X8}"); startReg += 4; } @@ -187,11 +192,11 @@ private void Debug() result = $"{System.Windows.Forms.Application.ProductName} {System.Windows.Forms.Application.ProductVersion} Debug Report" + Environment.NewLine + - $"{"Core Version: "}{CPU.Version}" + + $"{"Core Version: "}{cpu.Version}" + Environment.NewLine + Environment.NewLine; - var type = SI.GetType(); + var type = cpu.systemInfo.GetType(); var properties = type.GetProperties(); AddHeading("System Info"); @@ -202,14 +207,14 @@ private void Debug() foreach (var property in properties) { if (property.Name == "CpuId" || property.Name == "PatchLevel" || property.Name == "SmuTableVersion") - AddLine($"{property.Name + ":",-19}{property.GetValue(SI, null):X8}"); + AddLine($"{property.Name + ":",-19}{property.GetValue(cpu.systemInfo, null):X8}"); else if (property.Name == "SmuVersion") - AddLine($"{property.Name + ":",-19}{SI.GetSmuVersionString()}"); + AddLine($"{property.Name + ":",-19}{cpu.systemInfo.GetSmuVersionString()}"); else - AddLine($"{property.Name + ":",-19}{property.GetValue(SI, null)}"); + AddLine($"{property.Name + ":",-19}{property.GetValue(cpu.systemInfo, null)}"); } - AddLine($"{"DRAM Base Address:",-19}{((long)CPU.powerTable.DramBaseAddressHi << 32) | CPU.powerTable.DramBaseAddress:X16}"); + AddLine($"{"DRAM Base Address:",-19}{((long)cpu.powerTable.DramBaseAddressHi << 32) | cpu.powerTable.DramBaseAddress:X16}"); } catch { @@ -221,17 +226,18 @@ private void Debug() // DRAM modules info AddHeading("Memory Modules"); - foreach (var module in modules) + foreach (var module in memoryConfig.Modules) { AddLine($"{module.BankLabel} | {module.DeviceLocator}"); AddLine($"-- Slot: {module.Slot}"); - if (module.Rank == MemRank.DR) + if (module.Rank == ZenStates.Core.DRAM.MemRank.DR) AddLine("-- Dual Rank"); else AddLine("-- Single Rank"); AddLine($"-- DCT Offset: 0x{module.DctOffset >> 20:X}"); AddLine($"-- Manufacturer: {module.Manufacturer}"); - AddLine($"-- {module.PartNumber} {module.Capacity / 1024 / (1024 * 1024)}GB {module.ClockSpeed}MHz"); + AddLine($"-- {module.PartNumber} {module.Capacity} {module.ClockSpeed}MHz"); + AddLine($"-- {module.AddressConfig}"); AddLine(); } @@ -239,21 +245,13 @@ private void Debug() // Memory timings info AddHeading("Memory Config"); - type = MEMCFG.GetType(); + type = memoryConfig.Timings[0].Value.GetType(); properties = type.GetProperties(); try { foreach (var property in properties) - AddLine($"{property.Name + ":",-18}{property.GetValue(MEMCFG, null)}"); - - if (MEMCFG.Type == MemoryConfig.MemType.DDR5) - { - List> timingsConfig = CPU.GetMemoryConfig().Timings; - Ddr5Timings timings = timingsConfig[0].Value as Ddr5Timings; - - AddLine($"{"Nitro Settings:",-18}{timings.Nitro}"); - } + AddLine($"{property.Name + ":",-18}{memoryConfig.Timings[0].Value[property.Name]}"); } catch { @@ -264,13 +262,13 @@ private void Debug() // AOD Table AddHeading("ACPI: AOD Table"); - type = CPU.info.aod.Table.GetType(); + type = cpu.info.aod.Table.GetType(); properties = type.GetProperties(); try { foreach (var property in properties) { - AddLine($"{property.Name + ":",-19}{property.GetValue(CPU.info.aod.Table, null)}"); + AddLine($"{property.Name + ":",-19}{property.GetValue(cpu.info.aod.Table, null)}"); } } catch @@ -283,13 +281,13 @@ private void Debug() AddHeading("ACPI: Raw AOD Table"); try { - for (var i = 0; i < CPU.info.aod.Table.RawAodTable.Length; ++i) - AddLine($"Index {i:D3}: {CPU.info.aod.Table.RawAodTable[i]:X2} ({CPU.info.aod.Table.RawAodTable[i]})"); + for (var i = 0; i < cpu.info.aod.Table.RawAodTable.Length; i++) + AddLine($"Index {i:D3}: {cpu.info.aod.Table.RawAodTable[i]:X2} ({cpu.info.aod.Table.RawAodTable[i]})"); } catch { AddLine(""); - } + } AddLine(); @@ -297,7 +295,7 @@ private void Debug() AddHeading("BIOS: Memory Controller Config"); try { - for (var i = 0; i < BMC.Table.Length; ++i) + for (var i = 0; i < BMC.Table.Length; i++) AddLine($"Index {i:D3}: {BMC.Table[i]:X2} ({BMC.Table[i]})"); } catch @@ -311,9 +309,9 @@ private void Debug() AddHeading("SMU: Power Table"); try { - for (var i = 0; i < PT.Table.Length; ++i) + for (var i = 0; i < cpu.powerTable.Table.Length; i++) { - var temp = BitConverter.GetBytes(PT.Table[i]); + var temp = BitConverter.GetBytes(cpu.powerTable.Table[i]); AddLine($"Offset {i * 0x4:X3}: {BitConverter.ToSingle(temp, 0):F8}"); } } @@ -328,15 +326,15 @@ private void Debug() AddHeading("SMU: Power Table Detected Values"); try { - type = PT.GetType(); + type = cpu.powerTable.GetType(); properties = type.GetProperties(); foreach (var property in properties) { if (property.Name == "TableVersion") - AddLine($"{property.Name + ":",-25}{property.GetValue(PT, null):X8}"); + AddLine($"{property.Name + ":",-25}{property.GetValue(cpu.powerTable, null):X8}"); else if (property.Name != "Table") - AddLine($"{property.Name + ":",-25}{property.GetValue(PT, null)}"); + AddLine($"{property.Name + ":",-25}{property.GetValue(cpu.powerTable, null)}"); } /*AddLine($"MCLK: {PT.MCLK}"); @@ -412,7 +410,7 @@ private void Debug() uint startAddress = 0x0005A000; uint endAddress = 0x0005A0FF; - if (CPU.smu.SMU_TYPE == SMU.SmuType.TYPE_APU1 || CPU.smu.SMU_TYPE == SMU.SmuType.TYPE_APU2) + if (cpu.smu.SMU_TYPE == SMU.SmuType.TYPE_APU1 || cpu.smu.SMU_TYPE == SMU.SmuType.TYPE_APU2) { startAddress = 0x0006F000; endAddress = 0x0006F0FF; @@ -421,7 +419,7 @@ private void Debug() while (startAddress <= endAddress) { uint data = 0xFFFFFFFF; - bool success = CPU.ReadDwordEx(startAddress, ref data); + bool success = cpu.ReadDwordEx(startAddress, ref data); if (success) { AddLine($"0x{startAddress:X8}: 0x{data:X8}"); @@ -442,7 +440,7 @@ private void Debug() while (startAddress <= endAddress) { - var data = CPU.ReadDword(startAddress); + var data = cpu.ReadDword(startAddress); // if (data != 0xFFFFFFFF) { AddLine($"0x{startAddress:X8}: 0x{data:X8}"); diff --git a/WPF/Windows/OptionsDialog.xaml b/WPF/Windows/OptionsDialog.xaml index 01a6da9..a2b2d97 100644 --- a/WPF/Windows/OptionsDialog.xaml +++ b/WPF/Windows/OptionsDialog.xaml @@ -20,7 +20,9 @@ ShowInTaskbar="False" BorderThickness="1" UseLayoutRounding="True" - BorderBrush="{DynamicResource WindowBorderColor}" Closing="OptionsWindow_Closing"> + BorderBrush="{DynamicResource WindowBorderColor}" + Style="{DynamicResource WindowStyles}" + Closing="OptionsWindow_Closing"> + diff --git a/WPF/Windows/SaveWindow.xaml b/WPF/Windows/SaveWindow.xaml index 4d9b22a..a9f9bc9 100644 --- a/WPF/Windows/SaveWindow.xaml +++ b/WPF/Windows/SaveWindow.xaml @@ -19,7 +19,9 @@ Icon="/Resources/ZenTimings2022.ico" BorderThickness="1" UseLayoutRounding="True" - BorderBrush="{DynamicResource WindowBorderColor}" ShowInTaskbar="False"> + BorderBrush="{DynamicResource WindowBorderColor}" + Style="{DynamicResource WindowStyles}" + ShowInTaskbar="False"> diff --git a/WPF/Windows/SystemInfoWindow.xaml b/WPF/Windows/SystemInfoWindow.xaml index 3753b81..fc89821 100644 --- a/WPF/Windows/SystemInfoWindow.xaml +++ b/WPF/Windows/SystemInfoWindow.xaml @@ -13,7 +13,11 @@ WindowStartupLocation="CenterOwner" BorderThickness="1" UseLayoutRounding="True" - BorderBrush="{DynamicResource WindowBorderColor}" Activated="AdonisWindow_Activated" Icon="/Resources/ZenTimings2022.ico" Closing="AdonisWindow_Closing"> + BorderBrush="{DynamicResource WindowBorderColor}" + Style="{DynamicResource WindowStyles}" + Activated="AdonisWindow_Activated" + Icon="/Resources/ZenTimings2022.ico" + Closing="AdonisWindow_Closing"> diff --git a/WPF/ZenTimings.csproj b/WPF/ZenTimings.csproj index 5f165ec..bd0929a 100644 --- a/WPF/ZenTimings.csproj +++ b/WPF/ZenTimings.csproj @@ -74,7 +74,7 @@ - + False ..\Common\ZenStates-Core.dll @@ -99,9 +99,6 @@ Common\MemoryConfig.cs - - Common\MemoryModule.cs - Common\Screenshot.cs @@ -120,6 +117,7 @@ + @@ -179,6 +177,10 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + MSBuild:Compile Designer