### Set CPU Frequency Levels (C#) Source: https://context7.com/irusanov/zenstates-core/llms.txt Demonstrates how to control CPU frequencies at different levels, including setting the maximum boost frequency (FMax), all-core frequency, and single-core frequency using a core mask or direct core/CCD/CCX specification. It also covers getting the current core multiplier and setting the CPU VID for overclocking. Requires the ZenStates.Core library and OC mode for some operations. ```csharp using ZenStates.Core; using (var cpu = new Cpu()) { // Get current maximum frequency uint fmax = cpu.GetFMax(); Console.WriteLine($"Current FMax: {fmax} MHz"); // Set boost limit for all cores bool fmaxSet = cpu.SetFMax(4800); // 4800 MHz Console.WriteLine($"FMax Set: {fmaxSet}"); // Set frequency for all cores (requires OC mode) bool allCoreSet = cpu.SetFrequencyAllCore(4500); // 4500 MHz Console.WriteLine($"All-Core Frequency Set: {allCoreSet}"); // Set frequency for a single core using core mask uint coreMask = cpu.MakeCoreMask(core: 0, ccd: 0, ccx: 0); bool singleCoreSet = cpu.SetFrequencySingleCore(coreMask, 4700); Console.WriteLine($"Single Core Frequency Set: {singleCoreSet}"); // Alternative: Set frequency for specific core/ccd/ccx directly bool coreSet = cpu.SetFrequencySingleCore( core: 2, ccd: 0, ccx: 0, frequency: 4600 ); // Get current core multiplier double multi = cpu.GetCoreMulti(index: 0); Console.WriteLine($"Core 0 Multiplier: {multi}x"); // Set CPU VID for overclocking SMU.Status vidStatus = cpu.SetOverclockCpuVid(0x28); // Lower VID = higher voltage } ``` -------------------------------- ### Read and Control CPU Power Limits (C#) Source: https://context7.com/irusanov/zenstates-core/llms.txt Shows how to read and modify CPU power limits including Package Power Tracking (PPT), Thermal Design Current (TDC), and Electrical Design Current (EDC). It also covers getting and setting the Precision Boost Overdrive (PBO) Scalar and enabling/disabling manual Overclocking (OC) mode. Requires the ZenStates.Core library. ```csharp using ZenStates.Core; using (var cpu = new Cpu()) { // Set Package Power Tracking (PPT) limit in milliwatts SMU.Status pptStatus = cpu.SetPPTLimit(142000); // 142W Console.WriteLine($"PPT Set: {GetSMUStatus.GetByType(pptStatus)}"); // Set Thermal Design Current (TDC) limits SMU.Status tdcVddStatus = cpu.SetTDCVDDLimit(95000); // 95A VDD SMU.Status tdcSocStatus = cpu.SetTDCSOCLimit(25000); // 25A SoC // Set Electrical Design Current (EDC) limits SMU.Status edcVddStatus = cpu.SetEDCVDDLimit(140000); // 140A VDD SMU.Status edcSocStatus = cpu.SetEDCSOCLimit(30000); // 30A SoC // Get and set PBO Scalar (0.0 to 10.0) float currentScalar = cpu.GetPBOScalar(); Console.WriteLine($"Current PBO Scalar: {currentScalar}x"); SMU.Status scalarStatus = cpu.SetPBOScalar(2); // Set to 2x Console.WriteLine($"PBO Scalar Set: {GetSMUStatus.GetByType(scalarStatus)}"); // Enable/Disable Manual OC Mode bool isOcMode = cpu.GetOcMode(); Console.WriteLine($"OC Mode Active: {isOcMode}"); SMU.Status enableOc = cpu.EnableOcMode(); SMU.Status disableOc = cpu.DisableOcMode(); } ``` -------------------------------- ### Set Per-Core Voltage Margins (C#) Source: https://context7.com/irusanov/zenstates-core/llms.txt Adjust per-core voltage margins for Curve Optimizer functionality using the ZenStates.Core library. This allows for undervolting or overvolting specific cores. It includes functions to get and set PSM margins for single cores or all cores, and retrieve core performance data. ```csharp using ZenStates.Core; using (var cpu = new Cpu()) { // Get current PSM margin for a specific core uint coreMask = cpu.MakeCoreMask(core: 0, ccd: 0, ccx: 0); uint? margin = cpu.GetPsmMarginSingleCore(coreMask); if (margin.HasValue) { Console.WriteLine($"Core 0 PSM Margin: {margin.Value}"); } // Set PSM margin for all cores (-30 to +30 range typically) bool allCoresSet = cpu.SetPsmMarginAllCores(-15); // Negative = undervolt Console.WriteLine($"All Cores Margin Set: {allCoresSet}"); // Set PSM margin for a single core bool singleSet = cpu.SetPsmMarginSingleCore( core: 0, ccd: 0, ccx: 0, margin: -20 ); Console.WriteLine($"Single Core Margin Set: {singleSet}"); // Get core performance ranking data int perfData = cpu.GetCorePerformanceData(index: 0); Console.WriteLine($"Core 0 Performance Data: {perfData}"); } ``` -------------------------------- ### Read SMU Power Table Data in C# Source: https://context7.com/irusanov/zenstates-core/llms.txt Accesses the SMU power table to retrieve real-time clock and voltage information for the CPU. This involves refreshing the power table from the SMU and then accessing its properties like table size, DRAM base address, clock frequencies (FCLK, MCLK, UCLK), and various voltage readings. It also demonstrates how to get DRAM base addresses and transfer the table to DRAM. ```csharp using ZenStates.Core; using (var cpu = new Cpu()) { // Refresh power table from SMU SMU.Status refreshStatus = cpu.RefreshPowerTable(); if (refreshStatus == SMU.Status.OK) { PowerTable pt = cpu.powerTable; Console.WriteLine($"Table Size: {pt.TableSize} bytes"); Console.WriteLine($"DRAM Base Address: 0x{pt.DramBaseAddress:X}"); // Clock frequencies Console.WriteLine($"FCLK: {pt.FCLK:F0} MHz"); Console.WriteLine($"MCLK: {pt.MCLK:F0} MHz"); Console.WriteLine($"UCLK: {pt.UCLK:F0} MHz"); // Voltages Console.WriteLine($"VDDCR_SOC: {pt.VDDCR_SOC:F4}V"); Console.WriteLine($"CLDO_VDDP: {pt.CLDO_VDDP:F4}V"); Console.WriteLine($"CLDO_VDDG_IOD: {pt.CLDO_VDDG_IOD:F4}V"); Console.WriteLine($"CLDO_VDDG_CCD: {pt.CLDO_VDDG_CCD:F4}V"); Console.WriteLine($"VDD_MISC: {pt.VDD_MISC:F4}V"); // Raw table data access float[] rawTable = pt.Table; Console.WriteLine($"Raw table entries: {rawTable?.Length ?? 0}"); } // Get DRAM base address uint dramAddr = cpu.GetDramBaseAddress(); long dramAddr64 = cpu.GetDramBaseAddress64(); Console.WriteLine($"DRAM Address: 0x{dramAddr:X8}"); Console.WriteLine($"DRAM Address (64-bit): 0x{dramAddr64:X16}"); // Transfer table to DRAM SMU.Status transferStatus = cpu.TransferTableToDram(); } ``` -------------------------------- ### Send SMU Commands via Mailboxes (C#) Source: https://context7.com/irusanov/zenstates-core/llms.txt Demonstrates how to send commands to the System Management Unit (SMU) using different mailboxes like RSMU, MP1, and HSMP. It includes testing SMU communication, retrieving the SMU version, and sending custom commands with arguments. Requires the ZenStates.Core library. ```csharp using ZenStates.Core; using (var cpu = new Cpu()) { // Test SMU communication bool smuResponding = cpu.SendTestMessage(); Console.WriteLine($"SMU Responding: {smuResponding}"); // Get SMU version uint smuVersion = cpu.GetSmuVersion(); Console.WriteLine($"SMU Version: 0x{smuVersion:X8}"); // Send custom RSMU command with arguments uint[] args = new uint[6] { 0, 0, 0, 0, 0, 0 }; SMU.Status status = cpu.smu.SendRsmuCommand( cpu.smu.Rsmu.SMU_MSG_TestMessage, ref args ); Console.WriteLine($"Command Status: {GetSMUStatus.GetByType(status)}"); // Send MP1 mailbox command uint[] mp1Args = new uint[6]; SMU.Status mp1Status = cpu.smu.SendMp1Command(0x1, ref mp1Args); // Send HSMP command (if supported) uint[] hsmpArgs = new uint[8]; SMU.Status hsmpStatus = cpu.smu.SendHsmpCommand(0x1, ref hsmpArgs); } ``` -------------------------------- ### Initialize Cpu Module in C# Source: https://github.com/irusanov/zenstates-core/blob/master/README.md Demonstrates the initialization of the `Cpu` module from the ZenStates.Core library. The `Cpu` module is the primary interface for accessing CPU information and control. ```csharp private readonly Cpu cpu = new Cpu(); ``` -------------------------------- ### Initialize CPU Module in C# Source: https://context7.com/irusanov/zenstates-core/llms.txt Initializes the main entry point for ZenStates-Core functionality, the `Cpu` class. It checks the initialization status and retrieves the library version. Remember to dispose of the `Cpu` object when done. ```csharp using ZenStates.Core; // Initialize the CPU module - this is the main entry point private readonly Cpu cpu = new Cpu(); // Check initialization status if (cpu.Status == IOModule.LibStatus.OK) { Console.WriteLine("ZenStates-Core initialized successfully"); } else if (cpu.Status == IOModule.LibStatus.PARTIALLY_OK) { Console.WriteLine($"Partial initialization: {cpu.LastError?.Message}"); } // Access library version Console.WriteLine($"Library Version: {cpu.Version}"); // Always dispose when done cpu.Dispose(); ``` -------------------------------- ### Import ZenStates.Core Library in C# Source: https://github.com/irusanov/zenstates-core/blob/master/README.md This snippet shows how to reference and import the ZenStates.Core library in a .NET project. It's the first step to utilizing the library's functionalities. ```csharp using ZenStates.Core; ``` -------------------------------- ### Read CPU Temperature Data (C#) Source: https://context7.com/irusanov/zenstates-core/llms.txt Provides methods to read CPU temperature, including the main CPU temperature (Tctl) and per-Core Complex Die (CCD) temperatures. It also shows how to check if PROCHOT (Processor Hot) is enabled. Requires the ZenStates.Core library. ```csharp using ZenStates.Core; using (var cpu = new Cpu()) { // Read main CPU temperature (Tctl) float? temperature = cpu.GetCpuTemperature(); if (temperature.HasValue) { Console.WriteLine($"CPU Temperature: {temperature.Value:F1}°C"); } // Read per-CCD temperatures for (uint ccd = 0; ccd < cpu.info.topology.ccds; ccd++) { float? ccdTemp = cpu.GetSingleCcdTemperature(ccd); if (ccdTemp.HasValue && ccdTemp.Value > 0) { Console.WriteLine($"CCD{ccd} Temperature: {ccdTemp.Value:F1}°C"); } } // Check PROCHOT status bool prochotEnabled = cpu.IsProchotEnabled(); Console.WriteLine($"PROCHOT Enabled: {prochotEnabled}"); } ``` -------------------------------- ### Read System Information in C# Source: https://context7.com/irusanov/zenstates-core/llms.txt Retrieves comprehensive system information by combining CPU data with motherboard details obtained via WMI. This includes CPU name, codename, core counts, SMU version, AGESA version, and motherboard vendor and name. ```csharp using ZenStates.Core; using (var cpu = new Cpu()) { var sysInfo = cpu.systemInfo; // CPU info Console.WriteLine($"CPU: {sysInfo.CpuName}"); Console.WriteLine($"Code Name: {sysInfo.CodeName}"); Console.WriteLine($"CPUID: {sysInfo.GetCpuIdString()}"); Console.WriteLine($"Cores: {sysInfo.FusedCoreCount}"); Console.WriteLine($"Threads: {sysInfo.Threads}"); Console.WriteLine($"SMT: {sysInfo.SMT}"); // SMU info Console.WriteLine($"SMU Version: {sysInfo.GetSmuVersionString()}"); Console.WriteLine($"SMU Table Version: 0x{sysInfo.SmuTableVersion:X}"); Console.WriteLine($"AGESA Version: {sysInfo.AgesaVersion}"); // Motherboard info Console.WriteLine($"Motherboard: {sysInfo.MbVendor} {sysInfo.MbName}"); Console.WriteLine($"BIOS Version: {sysInfo.BiosVersion}"); } ``` -------------------------------- ### Read CPU Identification and Topology in C# Source: https://context7.com/irusanov/zenstates-core/llms.txt Accesses detailed CPU information, including identification, core counts, and topology, through the `Cpu.info` structure. This allows retrieval of CPU name, vendor, codename, model, stepping, and package type, as well as physical and logical core counts, CCDs, CCXs, and SVI2 power plane addresses. ```csharp using ZenStates.Core; using (var cpu = new Cpu()) { // Basic CPU identification Console.WriteLine($"CPU Name: {cpu.info.cpuName}"); Console.WriteLine($"Vendor: {cpu.info.vendor}"); Console.WriteLine($"CPUID: 0x{cpu.info.cpuid:X8}"); Console.WriteLine($"Family: {cpu.info.family}"); Console.WriteLine($"Code Name: {cpu.info.codeName}"); Console.WriteLine($"Model: 0x{cpu.info.model:X2}"); Console.WriteLine($"Stepping: {cpu.info.stepping}"); Console.WriteLine($"Package Type: {cpu.info.packageType}"); Console.WriteLine($"Patch Level: 0x{cpu.info.patchLevel:X8}"); // Topology information Console.WriteLine($"Physical Cores: {cpu.info.topology.physicalCores}"); Console.WriteLine($"Logical Cores: {cpu.info.topology.logicalCores}"); Console.WriteLine($"Threads Per Core: {cpu.info.topology.threadsPerCore}"); Console.WriteLine($"CCDs: {cpu.info.topology.ccds}"); Console.WriteLine($"CCXs: {cpu.info.topology.ccxs}"); Console.WriteLine($"Cores Per CCX: {cpu.info.topology.coresPerCcx}"); // SVI2 power plane addresses Console.WriteLine($"Core SVI2 Address: 0x{cpu.info.svi2.coreAddress:X8}"); Console.WriteLine($"SoC SVI2 Address: 0x{cpu.info.svi2.socAddress:X8}"); } ``` -------------------------------- ### Control System Base Clock (BCLK) in C# Source: https://context7.com/irusanov/zenstates-core/llms.txt Provides functionality to read and modify the system's base clock (BCLK) via the MMIO interface. It demonstrates how to retrieve the current BCLK frequency, check the clock generator strap status, and set a new BCLK value. Use the SetBclk function with caution as incorrect values can impact system stability. ```csharp using ZenStates.Core; using (var cpu = new Cpu()) { // Get current BCLK double? bclk = cpu.GetBclk(); if (bclk.HasValue) { Console.WriteLine($"Current BCLK: {bclk.Value:F2} MHz"); } // Get strap status AMD_MMIO.ClkGen strapStatus = cpu.GetStrapStatus(); Console.WriteLine($"Strap Status: {strapStatus}"); // Set new BCLK (use with caution!) bool bclkSet = cpu.SetBclk(100.5); // 100.5 MHz Console.WriteLine($"BCLK Set: {bclkSet}"); } ``` -------------------------------- ### Read Memory Timings and Configuration (C#) Source: https://context7.com/irusanov/zenstates-core/llms.txt Access detailed DDR4/DDR5 memory timings and module information using the ZenStates.Core.DRAM namespace. This code retrieves the overall memory configuration, including type and capacity, then iterates through each memory module to display its specifications. Finally, it reads and prints detailed timings for the first memory module if available. ```csharp using ZenStates.Core; using ZenStates.Core.DRAM; using (var cpu = new Cpu()) { MemoryConfig memConfig = cpu.GetMemoryConfig(); // Memory type and capacity Console.WriteLine($"Memory Type: {memConfig.Type}"); Console.WriteLine($"Total Capacity: {memConfig.TotalCapacity}"); // Module information foreach (var module in memConfig.Modules) { Console.WriteLine($"Slot: {module.Slot}"); Console.WriteLine($"Part Number: {module.PartNumber}"); Console.WriteLine($"Manufacturer: {module.Manufacturer}"); Console.WriteLine($"Capacity: {module.Capacity}"); Console.WriteLine($"Clock Speed: {module.ClockSpeed} MHz"); Console.WriteLine($"Rank: {module.Rank}"); } // Read timings for first module if (memConfig.Timings.Count > 0) { var timings = memConfig.Timings[0].Value; Console.WriteLine($"Frequency: {timings.Frequency} MHz"); Console.WriteLine($"CL: {timings.CL}"); Console.WriteLine($"RCD-RD: {timings.RCDRD}"); Console.WriteLine($"RCD-WR: {timings.RCDWR}"); Console.WriteLine($"RP: {timings.RP}"); Console.WriteLine($"RAS: {timings.RAS}"); Console.WriteLine($"RC: {timings.RC}"); Console.WriteLine($"RFC: {timings.RFC} ({timings.RFCns:F1}ns)"); Console.WriteLine($"REFI: {timings.REFI} ({timings.REFIns:F1}ns)"); Console.WriteLine($"WR: {timings.WR}"); Console.WriteLine($"RTP: {timings.RTP}"); Console.WriteLine($"RRDS: {timings.RRDS}"); Console.WriteLine($"RRDL: {timings.RRDL}"); Console.WriteLine($"FAW: {timings.FAW}"); Console.WriteLine($"WTRS: {timings.WTRS}"); Console.WriteLine($"WTRL: {timings.WTRL}"); Console.WriteLine($"CWL: {timings.CWL}"); Console.WriteLine($"RDWR: {timings.RDWR}"); Console.WriteLine($"WRRD: {timings.WRRD}"); Console.WriteLine($"RDRDSCL: {timings.RDRDSCL}"); Console.WriteLine($"WRWRSCL: {timings.WRWRSCL}"); Console.WriteLine($"Command Rate: {timings.Cmd2T}"); Console.WriteLine($"Gear Down Mode: {timings.GDM}"); Console.WriteLine($"Bank Group Swap: {timings.BGS}"); Console.WriteLine($"BGS Alt: {timings.BGSAlt}"); Console.WriteLine($"Power Down: {timings.PowerDown}"); } } ``` -------------------------------- ### Check Advanced CPU Features in C# Source: https://context7.com/irusanov/zenstates-core/llms.txt Queries advanced CPU capabilities and special modes, including checking for LN2 mode, the status of EXPO profiles for DDR5 memory, and retrieving table version information. It also demonstrates direct register access (MMIO) and Model-Specific Register (MSR) reads, as well as executing CPUID instructions. ```csharp using ZenStates.Core; using (var cpu = new Cpu()) { // Check LN2 mode bool ln2Mode = cpu.GetLN2Mode(); Console.WriteLine($"LN2 Mode: {ln2Mode}"); // Check EXPO profile status (DDR5) bool? expoActive = cpu.IsExpoProfileActive(); if (expoActive.HasValue) { Console.WriteLine($"EXPO Profile Active: {expoActive.Value}"); } // Get table version info Cpu.TableVersionResult tableInfo = cpu.GetTableVersion(); Console.WriteLine($"Table Version: 0x{tableInfo.TableVersion:X}"); Console.WriteLine($"Table Size: {tableInfo.TableSize} bytes"); // Direct register access uint regValue = 0; bool readSuccess = cpu.ReadDword(0x50100, ref regValue); if (readSuccess) { Console.WriteLine($"Register 0x50100: 0x{regValue:X8}"); } // MSR access uint eax = 0, edx = 0; bool msrRead = cpu.ReadMsr(0xC0010293, ref eax, ref edx); if (msrRead) { Console.WriteLine($"MSR 0xC0010293: EAX=0x{eax:X8}, EDX=0x{edx:X8}"); } // CPUID access uint cpuEax = 0, cpuEbx = 0, cpuEcx = 0, cpuEdx = 0; bool cpuidSuccess = cpu.Cpuid(0x80000001, ref cpuEax, ref cpuEbx, ref cpuEcx, ref cpuEdx); if (cpuidSuccess) { Console.WriteLine($"CPUID 0x80000001: EBX=0x{cpuEbx:X8}"); } } ``` -------------------------------- ### Access AMD Overclocking Data (AOD) in C# Source: https://context7.com/irusanov/zenstates-core/llms.txt Enables reading AMD Overclocking Data (AOD) from ACPI tables to obtain memory timings and voltage information. This snippet shows how to access the AOD table's base address and length, extract specific data fields like memory clock and timings (Tcl, Trcd, Trp, Tras, Trc, Trfc), and retrieve voltage settings (MemVddio, MemVpp). It also includes fetching WMI AMD ACPI functions. ```csharp using ZenStates.Core; using (var cpu = new Cpu()) { AOD aod = cpu.info.aod; if (aod.Table?.Data != null) { Console.WriteLine($"AOD Table Base Address: 0x{aod.Table.BaseAddress:X}"); Console.WriteLine($"AOD Table Length: {aod.Table.Length} bytes"); // Access AOD data fields var data = aod.Table.Data; if (data != null) { // Memory clock and timings from AOD Console.WriteLine($"Memory Clock: {data["MemClk"]}"); Console.WriteLine($"CL: {data["Tcl"]}"); Console.WriteLine($"tRCD: {data["Trcd"]}"); Console.WriteLine($"tRP: {data["Trp"]}"); Console.WriteLine($"tRAS: {data["Tras"]}"); Console.WriteLine($"tRC: {data["Trc"]}"); Console.WriteLine($"tRFC: {data["Trfc"]}"); // Voltages Console.WriteLine($"VDDIO: {data["MemVddio"]}"); Console.WriteLine($"VPP: {data["MemVpp"]}"); } } // Get WMI AMD ACPI functions var wmiFunctions = AOD.GetWmiFunctions(); foreach (var func in wmiFunctions) { Console.WriteLine($"WMI Function: {func.Key} = 0x{func.Value:X}"); } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.