Пример #1
0
    /// <summary>
    /// Load registry file.
    /// </summary>
    /// <param name="sender">Sender.</param>
    /// <param name="e">E.</param>
    protected void OnLoad(object sender, EventArgs e)
    {
        Gtk.FileChooserDialog filechooser =
            new Gtk.FileChooserDialog("Choose the file to open",
                                      this,
                                      FileChooserAction.Open,
                                      "Cancel", ResponseType.Cancel,
                                      "Open", ResponseType.Accept);
        if (filechooser.Run() == (int)ResponseType.Accept)
        {
            this._spt = Vega64SoftPowerTableEditor.SoftPowerTable.OpenRegFile(filechooser.Filename);
            this.setupWidgets();
        }

        filechooser.Destroy();
    }
Пример #2
0
        /// <summary>
        /// Opens the reg file.
        /// </summary>
        /// <returns>SoftPowerTable</returns>
        public static SoftPowerTable OpenRegFile(string filename)
        {
            SoftPowerTable spt = new SoftPowerTable();

            // Parse out the hex data
            spt._originalText  = File.ReadAllText(filename);
            spt._hexStartIndex = spt._originalText.IndexOf(STR_HEX_START, StringComparison.Ordinal) + STR_HEX_START.Length;
            String hexData = spt._originalText.Substring(spt._hexStartIndex, spt._originalText.Length - spt._hexStartIndex);

            // store newlines for later
            for (int i = spt._hexStartIndex; i < spt._originalText.Length; i++)
            {
                if (spt._originalText[i] == '\n')
                {
                    spt._hexBlobNewLineIndices.Add(i);
                }
            }

            // clean up the hex data
            hexData = Regex.Replace(hexData, @"\t|\n|\r|\s+|\\|,", "");

            // convert to byte array
            byte[] byteArray = StringToByteArray(hexData);
            spt._originalData = byteArray;

            // parse main table
            spt.atom_powerplay_table = FromBytes <ATOM_POWERPLAY_TABLE>(byteArray);

            // parse state array
            int offset = spt.atom_powerplay_table.usStateArrayOffset;

            spt.atom_vega10_state_array = FromBytes <ATOM_Vega10_State_Array>(byteArray.Skip(offset).ToArray());

            // parse gfx clk states (hurray!)
            offset = spt.atom_powerplay_table.usGfxclkDependencyTableOffset;
            spt.atom_vega10_gfxclk_table = FromBytes <ATOM_Vega10_GFXCLK_Dependency_Table>(byteArray.Skip(offset).ToArray());
            offset += Marshal.SizeOf(spt.atom_vega10_gfxclk_table);
            spt.atom_vega10_gfxclk_entries = ArrFromBytes <ATOM_Vega10_GFXCLK_Dependency_Record>(byteArray, offset, spt.atom_vega10_gfxclk_table.ucNumEntries);

            // parse mem clk states
            offset = spt.atom_powerplay_table.usMclkDependencyTableOffset;
            spt.atom_vega10_memclk_table = FromBytes <ATOM_Vega10_MCLK_Dependency_Table>(byteArray.Skip(offset).ToArray());
            offset += Marshal.SizeOf(spt.atom_vega10_memclk_table);
            spt.atom_vega10_memclk_entries = ArrFromBytes <ATOM_Vega10_MCLK_Dependency_Record>(byteArray, offset, spt.atom_vega10_memclk_table.ucNumEntries);

            // parse gfx voltages
            offset = spt.atom_powerplay_table.usVddcLookupTableOffset;
            spt.atom_vega10_gfxvdd_table = FromBytes <ATOM_Vega10_Voltage_Lookup_Table>(byteArray.Skip(offset).ToArray());
            offset += Marshal.SizeOf(spt.atom_vega10_gfxvdd_table);
            spt.atom_vega10_gfxvdd_record = ArrFromBytes <ATOM_Vega10_Voltage_Lookup_Record>(byteArray, offset, spt.atom_vega10_gfxvdd_table.ucNumEntries);

            // parse mem voltages
            offset = spt.atom_powerplay_table.usVddmemLookupTableOffset;
            spt.atom_vega10_memvdd_table = FromBytes <ATOM_Vega10_Voltage_Lookup_Table>(byteArray.Skip(offset).ToArray());
            offset += Marshal.SizeOf(spt.atom_vega10_gfxvdd_table);
            spt.atom_vega10_memvdd_record = ArrFromBytes <ATOM_Vega10_Voltage_Lookup_Record>(byteArray, offset, spt.atom_vega10_memvdd_table.ucNumEntries);

            // parse fan table
            spt.atom_vega10_fan_table = FromBytes <ATOM_Vega10_Fan_Table>(byteArray.Skip(spt.atom_powerplay_table.usFanTableOffset).ToArray());

            // parse powertune table
            spt.atom_vega10_powertune_table = FromBytes <ATOM_Vega10_PowerTune_Table_V3>(byteArray.Skip(spt.atom_powerplay_table.usPowerTuneTableOffset).ToArray());

            // debug
            Console.WriteLine(spt._originalText);

            return(spt);
        }