Exemplo n.º 1
0
 public UnderVoltor(Ols ols)
 {
     _ols        = ols;
     Support     = new bool[6];
     SettingFile = new UnderVoltSettings("Untilization");
     int[] tempsettings = new int[6];
     for (int i = 0; i < 6; i++)
     {
         if (GetVolta((Peripheral)i, out int origin))
         {
             SetVolta((Peripheral)i, origin + 5);
             GetVolta((Peripheral)i, out int tmp);
             if (tmp == origin + 5)
             {
                 tempsettings[i] = origin;
                 Support[i]      = true;
                 SetVolta((Peripheral)i, origin);
             }
             else
             {
                 Support[i] = false;
             }
         }
         else
         {
             Support[i] = false;
         }
     }
     AppliedSettings = tempsettings;
 }
Exemplo n.º 2
0
 public LogicalProcessor(Ols ols, int thread, int maxFreq)
 {
     MaxFrequency       = maxFreq;
     _ols               = ols;
     Thread             = thread;
     ThreadAffinityMask = 1UL << Thread;
     PThread            = new UIntPtr(ThreadAffinityMask);
 }
Exemplo n.º 3
0
 public void Dispose()
 {
     if (module != IntPtr.Zero)
     {
         DeinitializeOls();
         Ols.FreeLibrary(module);
         module = IntPtr.Zero;
     }
 }
Exemplo n.º 4
0
        public PMC(Ols ols, ManufacturerName Manufacturer, int thread, byte uMask, byte eventSelect)
        {
            _ols = ols;
            if (_ols.IsMsr() > 0)
            {
                switch (Manufacturer)
                {
                case ManufacturerName.GenuineIntel:
                    Thread      = thread;
                    pthread     = (UIntPtr)(1UL << Thread);
                    UMask       = uMask;
                    EventSelect = eventSelect;
                    uint eax = 0, edx = 0;
                    for (uint i = 0; i < 8; i++)
                    {
                        if (_ols.RdmsrTx(i + 0x186, ref eax, ref edx, (UIntPtr)(1UL << Thread)) > 0)
                        {
                            if (CPUinfo.BitsSlicer(eax, 22, 22) == 0)
                            {
                                PMC_num = i;
                                edx     = 0;
                                eax     = eventSelect + uMask * 256U + 0x43 * 256 * 256;
                                if (_ols.WrmsrTx(PMC_num + 0x186, eax, edx, (UIntPtr)(1UL << Thread)) == 0)
                                {
                                    ErrorMessage = "Wrmsr failed";
                                    Dispose();
                                    return;
                                }
                                PMC_num_msr = 0x0c1 + PMC_num;
                                break;
                            }
                        }
                        else
                        {
                            ErrorMessage = "No available PMC for this logical processor";
                            Dispose();
                        }
                    }
                    break;

                case ManufacturerName.AuthenticAMD:
                    Thread       = thread;
                    pthread      = (UIntPtr)(1UL << Thread);
                    ErrorMessage = "Unsupported cpu vendor";
                    Dispose();
                    break;

                default:
                    ErrorMessage = "Unsupported cpu vendor";
                    Dispose();
                    break;
                }
            }
        }
Exemplo n.º 5
0
        public static Ols InitIO()
        {
            var ols = new Ols();

            // Check support library sutatus
            switch (ols.GetStatus()){
            case (uint) Ols.Status.NO_ERROR:
                break;
            case (uint) Ols.Status.DLL_NOT_FOUND:
                MessageBox.Show("Status Error!! DLL_NOT_FOUND");
                return null;
            case (uint) Ols.Status.DLL_INCORRECT_VERSION:
                MessageBox.Show("Status Error!! DLL_INCORRECT_VERSION");
                return null;
            case (uint) Ols.Status.DLL_INITIALIZE_ERROR:
                MessageBox.Show("Status Error!! DLL_INITIALIZE_ERROR");
                return null;
            }

            // Check WinRing0 status
            switch (ols.GetDllStatus()){
            case (uint) Ols.OlsDllStatus.OLS_DLL_NO_ERROR:
                break;
            case (uint) Ols.OlsDllStatus.OLS_DLL_DRIVER_NOT_LOADED:
                MessageBox.Show("DLL Status Error!! OLS_DRIVER_NOT_LOADED");
                return null;
            case (uint) Ols.OlsDllStatus.OLS_DLL_UNSUPPORTED_PLATFORM:
                MessageBox.Show("DLL Status Error!! OLS_UNSUPPORTED_PLATFORM");
                return null;
            case (uint) Ols.OlsDllStatus.OLS_DLL_DRIVER_NOT_FOUND:
                MessageBox.Show("DLL Status Error!! OLS_DLL_DRIVER_NOT_FOUND");
                return null;
            case (uint) Ols.OlsDllStatus.OLS_DLL_DRIVER_UNLOADED:
                MessageBox.Show("DLL Status Error!! OLS_DLL_DRIVER_UNLOADED");
                return null;
            case (uint) Ols.OlsDllStatus.OLS_DLL_DRIVER_NOT_LOADED_ON_NETWORK:
                MessageBox.Show("DLL Status Error!! DRIVER_NOT_LOADED_ON_NETWORK");
                return null;
            case (uint) Ols.OlsDllStatus.OLS_DLL_UNKNOWN_ERROR:
                MessageBox.Show("DLL Status Error!! OLS_DLL_UNKNOWN_ERROR");
                return null;
            }
            return ols;
        }
Exemplo n.º 6
0
 public PackageMonitor(Ols ols, string manufacturer)
 {
     Manufacturer = manufacturer;
     if (Manufacturer == "GenuineIntel")
     {
         _ols = ols;
         uint edx = 0, eax = 0;
         if (_ols.Rdmsr(0x606, ref eax, ref edx) > 0)
         {
             PU             = 1F / (float)Math.Pow(2, CPUinfo.BitsSlicer(eax, 3, 0));
             ESU            = 1F / (float)Math.Pow(2, CPUinfo.BitsSlicer(eax, 12, 8));
             TU             = 1F / (float)Math.Pow(2, CPUinfo.BitsSlicer(eax, 19, 16));
             RAPL_supported = true;
         }
         RAPL_supported = true;
     }
     else
     {
         RAPL_supported = false;
     }
 }
Exemplo n.º 7
0
        public Ols()
        {
            string fileName;

            if (System.IntPtr.Size == 8)
            {
                fileName = dllNameX64;
            }
            else
            {
                fileName = dllName;
            }

            module = Ols.LoadLibrary(fileName);
            if (module == IntPtr.Zero)
            {
                status = (uint)Status.DLL_NOT_FOUND;
            }
            else
            {
                GetDllStatus     = (_GetDllStatus)GetDelegate("GetDllStatus", typeof(_GetDllStatus));
                GetDllVersion    = (_GetDllVersion)GetDelegate("GetDllVersion", typeof(_GetDllVersion));
                GetDriverVersion = (_GetDriverVersion)GetDelegate("GetDriverVersion", typeof(_GetDriverVersion));
                GetDriverType    = (_GetDriverType)GetDelegate("GetDriverType", typeof(_GetDriverType));

                InitializeOls   = (_InitializeOls)GetDelegate("InitializeOls", typeof(_InitializeOls));
                DeinitializeOls = (_DeinitializeOls)GetDelegate("DeinitializeOls", typeof(_DeinitializeOls));

                IsCpuid = (_IsCpuid)GetDelegate("IsCpuid", typeof(_IsCpuid));
                IsMsr   = (_IsMsr)GetDelegate("IsMsr", typeof(_IsMsr));
                IsTsc   = (_IsTsc)GetDelegate("IsTsc", typeof(_IsTsc));
                Hlt     = (_Hlt)GetDelegate("Hlt", typeof(_Hlt));
                HltTx   = (_HltTx)GetDelegate("HltTx", typeof(_HltTx));
                HltPx   = (_HltPx)GetDelegate("HltPx", typeof(_HltPx));
                Rdmsr   = (_Rdmsr)GetDelegate("Rdmsr", typeof(_Rdmsr));
                RdmsrTx = (_RdmsrTx)GetDelegate("RdmsrTx", typeof(_RdmsrTx));
                RdmsrPx = (_RdmsrPx)GetDelegate("RdmsrPx", typeof(_RdmsrPx));
                Wrmsr   = (_Wrmsr)GetDelegate("Wrmsr", typeof(_Wrmsr));
                WrmsrTx = (_WrmsrTx)GetDelegate("WrmsrTx", typeof(_WrmsrTx));
                WrmsrPx = (_WrmsrPx)GetDelegate("WrmsrPx", typeof(_WrmsrPx));
                Rdpmc   = (_Rdpmc)GetDelegate("Rdpmc", typeof(_Rdpmc));
                RdpmcTx = (_RdpmcTx)GetDelegate("RdpmcTx", typeof(_RdpmcTx));
                RdpmcPx = (_RdpmcPx)GetDelegate("RdpmcPx", typeof(_RdpmcPx));
                Cpuid   = (_Cpuid)GetDelegate("Cpuid", typeof(_Cpuid));
                CpuidTx = (_CpuidTx)GetDelegate("CpuidTx", typeof(_CpuidTx));
                CpuidPx = (_CpuidPx)GetDelegate("CpuidPx", typeof(_CpuidPx));
                Rdtsc   = (_Rdtsc)GetDelegate("Rdtsc", typeof(_Rdtsc));
                RdtscTx = (_RdtscTx)GetDelegate("RdtscTx", typeof(_RdtscTx));
                RdtscPx = (_RdtscPx)GetDelegate("RdtscPx", typeof(_RdtscPx));

                ReadIoPortByte    = (_ReadIoPortByte)GetDelegate("ReadIoPortByte", typeof(_ReadIoPortByte));
                ReadIoPortWord    = (_ReadIoPortWord)GetDelegate("ReadIoPortWord", typeof(_ReadIoPortWord));
                ReadIoPortDword   = (_ReadIoPortDword)GetDelegate("ReadIoPortDword", typeof(_ReadIoPortDword));
                ReadIoPortByteEx  = (_ReadIoPortByteEx)GetDelegate("ReadIoPortByteEx", typeof(_ReadIoPortByteEx));
                ReadIoPortWordEx  = (_ReadIoPortWordEx)GetDelegate("ReadIoPortWordEx", typeof(_ReadIoPortWordEx));
                ReadIoPortDwordEx = (_ReadIoPortDwordEx)GetDelegate("ReadIoPortDwordEx", typeof(_ReadIoPortDwordEx));

                WriteIoPortByte    = (_WriteIoPortByte)GetDelegate("WriteIoPortByte", typeof(_WriteIoPortByte));
                WriteIoPortWord    = (_WriteIoPortWord)GetDelegate("WriteIoPortWord", typeof(_WriteIoPortWord));
                WriteIoPortDword   = (_WriteIoPortDword)GetDelegate("WriteIoPortDword", typeof(_WriteIoPortDword));
                WriteIoPortByteEx  = (_WriteIoPortByteEx)GetDelegate("WriteIoPortByteEx", typeof(_WriteIoPortByteEx));
                WriteIoPortWordEx  = (_WriteIoPortWordEx)GetDelegate("WriteIoPortWordEx", typeof(_WriteIoPortWordEx));
                WriteIoPortDwordEx = (_WriteIoPortDwordEx)GetDelegate("WriteIoPortDwordEx", typeof(_WriteIoPortDwordEx));

                SetPciMaxBusIndex     = (_SetPciMaxBusIndex)GetDelegate("SetPciMaxBusIndex", typeof(_SetPciMaxBusIndex));
                ReadPciConfigByte     = (_ReadPciConfigByte)GetDelegate("ReadPciConfigByte", typeof(_ReadPciConfigByte));
                ReadPciConfigWord     = (_ReadPciConfigWord)GetDelegate("ReadPciConfigWord", typeof(_ReadPciConfigWord));
                ReadPciConfigDword    = (_ReadPciConfigDword)GetDelegate("ReadPciConfigDword", typeof(_ReadPciConfigDword));
                ReadPciConfigByteEx   = (_ReadPciConfigByteEx)GetDelegate("ReadPciConfigByteEx", typeof(_ReadPciConfigByteEx));
                ReadPciConfigWordEx   = (_ReadPciConfigWordEx)GetDelegate("ReadPciConfigWordEx", typeof(_ReadPciConfigWordEx));
                ReadPciConfigDwordEx  = (_ReadPciConfigDwordEx)GetDelegate("ReadPciConfigDwordEx", typeof(_ReadPciConfigDwordEx));
                WritePciConfigByte    = (_WritePciConfigByte)GetDelegate("WritePciConfigByte", typeof(_WritePciConfigByte));
                WritePciConfigWord    = (_WritePciConfigWord)GetDelegate("WritePciConfigWord", typeof(_WritePciConfigWord));
                WritePciConfigDword   = (_WritePciConfigDword)GetDelegate("WritePciConfigDword", typeof(_WritePciConfigDword));
                WritePciConfigByteEx  = (_WritePciConfigByteEx)GetDelegate("WritePciConfigByteEx", typeof(_WritePciConfigByteEx));
                WritePciConfigWordEx  = (_WritePciConfigWordEx)GetDelegate("WritePciConfigWordEx", typeof(_WritePciConfigWordEx));
                WritePciConfigDwordEx = (_WritePciConfigDwordEx)GetDelegate("WritePciConfigDwordEx", typeof(_WritePciConfigDwordEx));
                FindPciDeviceById     = (_FindPciDeviceById)GetDelegate("FindPciDeviceById", typeof(_FindPciDeviceById));
                FindPciDeviceByClass  = (_FindPciDeviceByClass)GetDelegate("FindPciDeviceByClass", typeof(_FindPciDeviceByClass));

                /*
                 * ReadDmiMemory = (_ReadDmiMemory)GetDelegate("ReadDmiMemory", typeof(_ReadDmiMemory));
                 * ReadPhysicalMemory = (_ReadPhysicalMemory)GetDelegate("ReadPhysicalMemory", typeof(_ReadPhysicalMemory));
                 * WritePhysicalMemory = (_WritePhysicalMemory)GetDelegate("WritePhysicalMemory", typeof(_WritePhysicalMemory));
                 */

                if (!(
                        GetDllStatus != null &&
                        GetDllVersion != null &&
                        GetDriverVersion != null &&
                        GetDriverType != null &&
                        InitializeOls != null &&
                        DeinitializeOls != null &&
                        IsCpuid != null &&
                        IsMsr != null &&
                        IsTsc != null &&
                        Hlt != null &&
                        HltTx != null &&
                        HltPx != null &&
                        Rdmsr != null &&
                        RdmsrTx != null &&
                        RdmsrPx != null &&
                        Wrmsr != null &&
                        WrmsrTx != null &&
                        WrmsrPx != null &&
                        Rdpmc != null &&
                        RdpmcTx != null &&
                        RdpmcPx != null &&
                        Cpuid != null &&
                        CpuidTx != null &&
                        CpuidPx != null &&
                        Rdtsc != null &&
                        RdtscTx != null &&
                        RdtscPx != null &&
                        ReadIoPortByte != null &&
                        ReadIoPortWord != null &&
                        ReadIoPortDword != null &&
                        ReadIoPortByteEx != null &&
                        ReadIoPortWordEx != null &&
                        ReadIoPortDwordEx != null &&
                        WriteIoPortByte != null &&
                        WriteIoPortWord != null &&
                        WriteIoPortDword != null &&
                        WriteIoPortByteEx != null &&
                        WriteIoPortWordEx != null &&
                        WriteIoPortDwordEx != null &&
                        SetPciMaxBusIndex != null &&
                        ReadPciConfigByte != null &&
                        ReadPciConfigWord != null &&
                        ReadPciConfigDword != null &&
                        ReadPciConfigByteEx != null &&
                        ReadPciConfigWordEx != null &&
                        ReadPciConfigDwordEx != null &&
                        WritePciConfigByte != null &&
                        WritePciConfigWord != null &&
                        WritePciConfigDword != null &&
                        WritePciConfigByteEx != null &&
                        WritePciConfigWordEx != null &&
                        WritePciConfigDwordEx != null &&
                        FindPciDeviceById != null &&
                        FindPciDeviceByClass != null

                        /*&& ReadDmiMemory != null
                         * && ReadPhysicalMemory != null
                         * && WritePhysicalMemory != null
                         */
                        ))
                {
                    status = (uint)Status.DLL_INCORRECT_VERSION;
                }

                if (InitializeOls() == 0)
                {
                    status = (uint)Status.DLL_INITIALIZE_ERROR;
                }
            }
        }
Exemplo n.º 8
0
 static HardwareAccess()
 {
     Ols = new Ols();
 }
Exemplo n.º 9
0
        private unsafe void Init()
        {
            this.textBox.Text = "";
            this.textBox.Refresh();

            Cursor.Current = Cursors.WaitCursor;

            try
            {
                //-----------------------------------------------------------------------------
                // Initialize
                //-----------------------------------------------------------------------------
                Ols ols = new Ols();

                // Check support library sutatus
                switch (ols.GetStatus())
                {
                    case (uint)Ols.Status.NO_ERROR:
                        break;
                    case (uint)Ols.Status.DLL_NOT_FOUND:
                        MessageBox.Show("Status Error!! DLL_NOT_FOUND");
                        Environment.Exit(0);
                        break;
                    case (uint)Ols.Status.DLL_INCORRECT_VERSION:
                        MessageBox.Show("Status Error!! DLL_INCORRECT_VERSION");
                        Environment.Exit(0);
                        break;
                    case (uint)Ols.Status.DLL_INITIALIZE_ERROR:
                        MessageBox.Show("Status Error!! DLL_INITIALIZE_ERROR");
                        Environment.Exit(0);
                        break;
                }

                // Check WinRing0 status
                switch (ols.GetDllStatus())
                {
                    case (uint)Ols.OlsDllStatus.OLS_DLL_NO_ERROR:
                        break;
                    case (uint)Ols.OlsDllStatus.OLS_DLL_DRIVER_NOT_LOADED:
                        MessageBox.Show("DLL Status Error!! OLS_DRIVER_NOT_LOADED");
                        Environment.Exit(0);
                        break;
                    case (uint)Ols.OlsDllStatus.OLS_DLL_UNSUPPORTED_PLATFORM:
                        MessageBox.Show("DLL Status Error!! OLS_UNSUPPORTED_PLATFORM");
                        Environment.Exit(0);
                        break;
                    case (uint)Ols.OlsDllStatus.OLS_DLL_DRIVER_NOT_FOUND:
                        MessageBox.Show("DLL Status Error!! OLS_DLL_DRIVER_NOT_FOUND");
                        Environment.Exit(0);
                        break;
                    case (uint)Ols.OlsDllStatus.OLS_DLL_DRIVER_UNLOADED:
                        MessageBox.Show("DLL Status Error!! OLS_DLL_DRIVER_UNLOADED");
                        Environment.Exit(0);
                        break;
                    case (uint)Ols.OlsDllStatus.OLS_DLL_DRIVER_NOT_LOADED_ON_NETWORK:
                        MessageBox.Show("DLL Status Error!! DRIVER_NOT_LOADED_ON_NETWORK");
                        Environment.Exit(0);
                        break;
                    case (uint)Ols.OlsDllStatus.OLS_DLL_UNKNOWN_ERROR:
                        MessageBox.Show("DLL Status Error!! OLS_DLL_UNKNOWN_ERROR");
                        Environment.Exit(0);
                        break;
                }

                String str = "";
                //-----------------------------------------------------------------------------
                // DLL Information
                //-----------------------------------------------------------------------------
                byte major = 0, minor = 0, revision = 0, release = 0;

                str += "[DLL Version]\r\n";
                ols.GetDllVersion(ref major, ref minor, ref revision, ref release);
                str += major.ToString()
                    + "." + minor.ToString()
                    + "." + revision.ToString()
                    + "." + release.ToString()
                    + "\r\n";

                str += "[Device Driver Version]\r\n";
                ols.GetDriverVersion(ref major, ref minor, ref revision, ref release);
                str += major.ToString()
                    + "." + minor.ToString()
                    + "." + revision.ToString()
                    + "." + release.ToString()
                    + "\r\n";

                str += "[Device Driver Type]\r\n";
                switch (ols.GetDriverType())
                {
                    case (uint)Ols.OlsDriverType.OLS_DRIVER_TYPE_WIN_9X:
                        str += "OLS_DRIVER_TYPE_WIN_9X\r\n";
                        break;
                    case (uint)Ols.OlsDriverType.OLS_DRIVER_TYPE_WIN_NT:
                        str += "OLS_DRIVER_TYPE_WIN_NT\r\n";
                        break;
                    case (uint)Ols.OlsDriverType.OLS_DRIVER_TYPE_WIN_NT_X64:
                        str += "OLS_DRIVER_TYPE_WIN_NT_X64\r\n";
                        break;
                    case (uint)Ols.OlsDriverType.OLS_DRIVER_TYPE_WIN_NT_IA64:
                        str += "OLS_DRIVER_TYPE_WIN_NT_IA64\r\n";
                        break;
                    default:
                        str += "OLS_DRIVER_TYPE_UNKNOWN\r\n";
                        break;
                }

                //-----------------------------------------------------------------------------
                // TSC
                //-----------------------------------------------------------------------------
                uint index = 0, eax = 0, ebx = 0, ecx = 0, edx = 0;

                str += "[TSC]\r\n";
                if (ols.RdtscPx(ref eax, ref edx, (UIntPtr)1) != 0)
                {
                    str += "index     63-32    31-0\r\n";
                    str += index.ToString("X8") + ": " + edx.ToString("X8")
                        + " " + eax.ToString("X8") + "\r\n";
                }
                else
                {
                    str += "Failure : Change Process Affinity Mask\r\n";
                }

                //-----------------------------------------------------------------------------
                // MSR
                //-----------------------------------------------------------------------------
                str += "[MSR]\r\n";
                index = 0x00000010; // Time Stamp Counter
                if (ols.RdmsrTx(index, ref eax, ref edx, (UIntPtr)1) != 0)
                {
                    str += "index     63-32    31-0\r\n";
                    str += index.ToString("X8") + ": " + edx.ToString("X8")
                        + " " + eax.ToString("X8") + "\r\n";
                }
                else
                {
                    str += "Failure : Change Thread Affinity Mask\r\n";
                }

                //-----------------------------------------------------------------------------
                // CPUID (Standard/Extended)
                //-----------------------------------------------------------------------------
                uint maxCpuid = 0, maxCpuidEx = 0;

                str += "[CPUID]\r\n";
                str += "index     EAX      EBX      ECX      EDX  \r\n";

                // Standard
                ols.CpuidPx(0x00000000, ref maxCpuid, ref ebx, ref ecx, ref edx, (UIntPtr)1);
                for (index = 0x00000000; index <= maxCpuid; index++)
                {
                    ols.CpuidPx(index, ref eax, ref ebx, ref ecx, ref edx, (UIntPtr)1);
                    str += index.ToString("X8") + ": "
                        + eax.ToString("X8") + " " + ebx.ToString("X8") + " "
                        + ecx.ToString("X8") + " " + edx.ToString("X8") + "\r\n";
                }
                // Extended
                ols.CpuidPx(0x80000000, ref maxCpuidEx, ref ebx, ref ecx, ref edx, (UIntPtr)1);
                for (index = 0x80000000; index <= maxCpuidEx; index++)
                {
                    ols.CpuidPx(index, ref eax, ref ebx, ref ecx, ref edx, (UIntPtr)1);
                    str += index.ToString("X8") + ": "
                        + eax.ToString("X8") + " " + ebx.ToString("X8") + " "
                        + ecx.ToString("X8") + " " + edx.ToString("X8") + "\r\n";
                }

                //-----------------------------------------------------------------------------
                // I/O (Beep)
                //-----------------------------------------------------------------------------

                var port = new IndexedIOPort
                {
                  BaseAddress = 0x290,
                  AddressPortOffset = 5,
                  DataPortOffset = 6,
                  BankSelect = 0x4e
                };

                port.Select(1);
                var cputin = port.Read(0x50) + (port.Read(0x51) >> 7) * 0.5;

                port.Select(2);
                var auxtin = port.Read(0x50) + (port.Read(0x51) >> 7) * 0.5;

                port.Select(0);
                var systin = port.Read(0x27);

                var cpufanout0 = port.Read(0x29);
                var cpufanout0div = ((port.Read(0x47) >> 6) & 3) | (((port.Read(0x5d) >> 6) & 1) << 2);

                var cpufanout0rpm = 1.35e6 / (cpufanout0 * (1 << cpufanout0div));

                var sysfanout = port.Read(0x28);
                var sysfanoutdiv = ((port.Read(0x47) >> 4) & 3) | (((port.Read(0x5d) >> 5) & 1) << 2); ;

                var sysfanoutrpm = 1.35e6 / (sysfanout * (1 << sysfanoutdiv));

                var auxfanout0 = port.Read(0x2a);
                var auxfanout0div = ((port.Read(0x4b) >> 6) & 3) | (((port.Read(0x5d) >> 7) & 1) << 2); ;

                var auxfanout0rpm = 1.35e6 / (auxfanout0 * (1 << auxfanout0div));

                var cpufanout1 = port.Read(0x3f);
                var cpufanout1div = ((port.Read(0x59) >> 0) & 3) | (((port.Read(0x4c) >> 7) & 1) << 2);

                var cpufanout1rpm = 1.35e6 / (cpufanout1 * (1 << cpufanout1div));

                port.Select(5);
                var auxfanout1 = port.Read(0x53);
                port.Select(0);
                var auxfanout1div = (port.Read(0x59) >> 2) & 3;

                var vcore = port.Read(0x20) * 0.008;
                var vin0_12v = port.Read(0x21) * 0.008 * 7;
                var avcc = port.Read(0x22) * 0.008;
                var vcc_3_3v = port.Read(0x23) * 0.008 * 2;
                var vin1_5v = port.Read(0x24) * 0.008 * 3;
                var vin2_2_5v = port.Read(0x25) * 0.008;
                var vin3 = port.Read(0x26) * 0.008;

                //ols.WriteIoPortByte(LPCINDEX, 0xFE);
                //var dts = ols.ReadIoPortByte(LPCDATA);

                //uint freq = 1193180000 / 440000; // 440Hz

                //ols.WriteIoPortByte(0x43, 0xB6);
                //ols.WriteIoPortByte(0x42, (byte)(freq & 0xFF));
                //ols.WriteIoPortByte(0x42, (byte)(freq >> 9));

                //System.Threading.Thread.Sleep(100);

                //ols.WriteIoPortByte(0x61, (byte)(ols.ReadIoPortByte(0x61) | 0x03));

                //System.Threading.Thread.Sleep(1000);

                //ols.WriteIoPortByte(0x61, (byte)(ols.ReadIoPortByte(0x61) & 0xFC));

                //str += "[I/O]\r\nBeep 440Hz\r\n";

                //-----------------------------------------------------------------------------
                // PCI
                //-----------------------------------------------------------------------------
                uint address, value;

                str += "[PCI]\r\n";

                // All Device
                str += "Bus Dev Fnc VendorDevice\r\n";
                for (uint bus = 0; bus <= 128; bus++)
                {
                    for (uint dev = 0; dev < 32; dev++)
                    {
                        for (uint func = 0; func < 8; func++)
                        {
                            address = ols.PciBusDevFunc(bus, dev, func);
                            value = ols.ReadPciConfigDword(address, 0x00);
                            if ((value & 0xFFFF) != 0xFFFF && (value & 0xFFFF) != 0x0000)
                            {
                                str += ols.PciGetBus(address).ToString("X2") + "h "
                                    + ols.PciGetDev(address).ToString("X2") + "h "
                                    + ols.PciGetFunc(address).ToString("X2") + "h "
                                    + ((uint)(value & 0x0000FFFF)).ToString("X04") + "h "
                                    + ((uint)((value >> 16) & 0x0000FFFF)).ToString("X04") + "h\r\n";
                            }
                        }
                    }
                }

                // Host Bridge
                address = ols.FindPciDeviceByClass( 0x06, 0x00, 0x00, 0);
                if (address != 0xFFFFFFFF)
                {
                    str += "[PCI Confguration Space Dump] HostBridge\r\n";
                    str += "    00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F\r\n";
                    str += "---------------------------------------------------\r\n";

                    for (int i = 0; i < 256; i += 16)
                    {
                        str += i.ToString("X2") + "|";
                        for (int j = 0; j < 16; j++)
                        {
                            str += " " + (ols.ReadPciConfigByte(address, (byte)(i + j))).ToString("X2");
                        }
                        str += "\r\n";
                    }
                }

                this.textBox.Text = str;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
                Environment.Exit(0);
            }

            Cursor.Current = Cursors.Default;
        }
Exemplo n.º 10
0
 public FreqPMC(Ols ols, ManufacturerName manufacturer, int thread, byte uMask, byte eventSelect) : base(ols, manufacturer, thread, uMask, eventSelect)
 {
 }
Exemplo n.º 11
0
 public smBus(Ols openLibSys)
 {
     ols = openLibSys;
 }