示例#1
0
文件: EntryPoint.cs 项目: ufwt/whoop
        public EntryPoint(string name, string api, string kernelFunc, Module module,
                          bool whoopInit, bool isClone = false)
        {
            this.Id = kernelFunc.Equals("") ? name : name + "$" + kernelFunc;

            this.Name       = name;
            this.API        = api;
            this.KernelFunc = kernelFunc;

            this.Module = module;

            if ((api.Equals("probe") || api.Equals("port_probe")) &&
                ((whoopInit && module.API.Equals("whoop_driver_ops")) ||
                 module.API.Equals("test_driver") ||
                 module.API.Equals("pci_driver") ||
                 module.API.Equals("usb_driver") ||
                 module.API.Equals("usb_serial_driver") ||
                 module.API.Equals("platform_driver") ||
                 module.API.Equals("ps3_system_bus_driver") ||
                 module.API.Equals("cx_drv")))
            {
                this.IsInit = true;
                DeviceDriver.SetInitEntryPoint(name);
            }
            else
            {
                this.IsInit = false;
            }

            if ((api.Equals("remove") || api.Equals("port_remove")) &&
                ((whoopInit && module.API.Equals("whoop_driver_ops")) ||
                 module.API.Equals("test_driver") ||
                 module.API.Equals("pci_driver") ||
                 module.API.Equals("usb_driver") ||
                 module.API.Equals("usb_serial_driver") ||
                 module.API.Equals("platform_driver") ||
                 module.API.Equals("ps3_system_bus_driver") ||
                 module.API.Equals("cx_drv")))
            {
                this.IsExit = true;
            }
            else
            {
                this.IsExit = false;
            }

            this.IsClone = isClone;

            if (DeviceDriver.HasKernelImposedDeviceLock(api, module))
            {
                this.IsDeviceLocked = true;
            }
            else
            {
                this.IsDeviceLocked = false;
            }

            if (DeviceDriver.HasKernelImposedPowerLock(api))
            {
                this.IsPowerLocked = true;
            }
            else
            {
                this.IsPowerLocked = false;
            }

            if (DeviceDriver.HasKernelImposedRTNL(api))
            {
                this.IsRtnlLocked = true;
            }
            else
            {
                this.IsRtnlLocked = false;
            }

            if (DeviceDriver.IsNetworkAPI(api))
            {
                this.IsNetLocked = true;
            }
            else
            {
                this.IsNetLocked = false;
            }

            if (DeviceDriver.HasKernelImposedTxLock(api))
            {
                this.IsTxLocked = true;
            }
            else
            {
                this.IsTxLocked = false;
            }

            if (DeviceDriver.IsGoingToDisableNetwork(api))
            {
                this.IsGoingToDisableNetwork = true;
            }
            else
            {
                this.IsGoingToDisableNetwork = false;
            }

            if (DeviceDriver.IsCalledWithNetworkDisabled(api))
            {
                this.IsCalledWithNetworkDisabled = true;
            }
            else
            {
                this.IsCalledWithNetworkDisabled = false;
            }

            this.IsInlined          = false;
            this.IsCallingPowerLock = false;
            this.IsCallingRtnlLock  = false;
            this.IsCallingNetLock   = false;
            this.IsCallingTxLock    = false;

            this.HasWriteAccess = new Dictionary <string, int>();
            this.HasReadAccess  = new Dictionary <string, int>();

            this.ForceWriteResource = new HashSet <string>();
            this.ForceReadResource  = new HashSet <string>();

            this.IsHoldingLock     = false;
            this.IsEnablingDevice  = false;
            this.IsDisablingDevice = false;
        }
示例#2
0
        /// <summary>
        /// Checks if the given entry points can run concurrently.
        /// </summary>
        /// <returns>Boolean value</returns>
        /// <param name="ep1">First entry point</param>
        /// <param name="ep2">Second entry point</param>
        private static bool CanRunConcurrently(EntryPoint ep1, EntryPoint ep2)
        {
            if (ep1.IsInit && ep2.IsInit)
            {
                return(false);
            }
            if (ep1.IsExit || ep2.IsExit)
            {
                return(false);
            }

            if (DeviceDriver.HasKernelImposedDeviceLock(ep1.API, ep1.Module) &&
                DeviceDriver.HasKernelImposedDeviceLock(ep2.API, ep2.Module))
            {
                return(false);
            }
            if (DeviceDriver.HasKernelImposedPowerLock(ep1.API) &&
                DeviceDriver.HasKernelImposedPowerLock(ep2.API))
            {
                return(false);
            }
            if (DeviceDriver.HasKernelImposedRTNL(ep1.API) &&
                DeviceDriver.HasKernelImposedRTNL(ep2.API))
            {
                return(false);
            }
            if (DeviceDriver.HasKernelImposedTxLock(ep1.API) &&
                DeviceDriver.HasKernelImposedTxLock(ep2.API))
            {
                return(false);
            }

            if (DeviceDriver.IsPowerManagementAPI(ep1.API) &&
                DeviceDriver.IsPowerManagementAPI(ep2.API))
            {
                return(false);
            }
            if (DeviceDriver.IsCalledWithNetpollDisabled(ep1.API) &&
                DeviceDriver.IsCalledWithNetpollDisabled(ep2.API))
            {
                return(false);
            }

            if (DeviceDriver.IsFileOperationsSerialised(ep1, ep2))
            {
                return(false);
            }
            if (DeviceDriver.IsBlockOperationsSerialised(ep1, ep2))
            {
                return(false);
            }
            if (DeviceDriver.IsUSBOperationsSerialised(ep1, ep2))
            {
                return(false);
            }
            if (DeviceDriver.IsNFCOperationsSerialised(ep1, ep2))
            {
                return(false);
            }

            return(true);
        }