Esempio n. 1
0
        public bool Find(bool bMainController, out IT87XX pEnvironmentController)
        {
            pEnvironmentController = null;
            lock (m_findLock)
            {
                try
                {
                    ChipID = Chip.Unknown;
                    if (bMainController)
                    {
                        FindMainEnvironmentController(out pEnvironmentController);
                    }

                    return((pEnvironmentController != null) ? true : false);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
Esempio n. 2
0
        private bool FindMainEnvironmentController(ushort registerPort, ushort valuePort, out IT87XX pEnvironmentController)
        {
            bool  result = false;
            bool  flag   = false;
            Mutex mutex  = null;

            pEnvironmentController = null;
            if (registerPort != 46)
            {
                return(result);
            }
            try
            {
                bool createdNew;
                mutex = new Mutex(initiallyOwned: true, MutexName4MBPnPMode, out createdNew);
                if (!createdNew)
                {
                    mutex.WaitOne(MutexTimeout4MBPnPMode);
                }
                IT87Enter(registerPort);
                flag = true;
                ushort num5 = ReadWord(registerPort, valuePort, 32);
                Chip   chip;
                switch (num5)
                {
                case 34336:
                    chip = Chip.IT8620E;
                    break;

                case 34344:
                    chip = Chip.IT8626;
                    break;

                case 34438:
                    chip = Chip.IT8686E;
                    break;

                case 34440:
                    chip = Chip.IT8688;
                    break;

                case 34600:
                    chip = Chip.IT8728F;
                    break;

                default:
                    chip = Chip.Unknown;
                    break;
                }

                ChipID = chip;
                if (chip == Chip.Unknown && num5 != 0 && num5 != ushort.MaxValue)
                {
                    IT87Exit(registerPort, valuePort);
                    return(result);
                }

                Select(registerPort, valuePort, 4);
                ushort num = ReadWord(registerPort, valuePort, 96);

                Thread.Sleep(1);

                ushort num2 = ReadWord(registerPort, valuePort, 96);
                byte   b    = (byte)(ReadByte(registerPort, valuePort, 34) & 0xF);
                Select(registerPort, valuePort, 7);
                ushort num3 = ReadWord(registerPort, valuePort, 98);

                Thread.Sleep(1);

                ushort num4 = ReadWord(registerPort, valuePort, 98);
                IT87Exit(registerPort, valuePort);
                flag = false;

                if (num != num2 || num < 256 || (num & 0xF007) != 0)
                {
                    return(result);
                }

                if (num3 != num4 || num3 < 256 || (num3 & 0xF007) != 0)
                {
                    return(result);
                }

                result = true;
                switch (chip)
                {
                case Chip.IT8620E:
                case Chip.IT8626:
                case Chip.IT8686E:
                case Chip.IT8688:
                    pEnvironmentController = new IT8620(ChipID, num, num3, b);
                    return(result);

                case Chip.IT8728F:
                    pEnvironmentController = new IT8728(ChipID, num, num3, b);
                    return(result);

                default:
                    result = false;
                    return(result);
                }
            }
            catch (Exception)
            {
                return(result);
            }
            finally
            {
                if (flag)
                {
                    IT87Exit(registerPort, valuePort);
                }
                mutex?.ReleaseMutex();
            }
        }
Esempio n. 3
0
 private bool FindMainEnvironmentController(out IT87XX pEnvironmentController)
 {
     RegisterPort = REGISTER_PORTS[0];
     ValuePort    = VALUE_PORTS[0];
     return(FindMainEnvironmentController(REGISTER_PORTS[0], VALUE_PORTS[0], out pEnvironmentController));
 }