コード例 #1
0
        /// <summary>
        /// Parses and initializes device driver specific information.
        /// </summary>
        /// <param name="files">List of file names</param>
        public static void ParseAndInitialize(List <string> files)
        {
            string driverInfoFile = files[files.Count - 1].Substring(0,
                                                                     files[files.Count - 1].LastIndexOf(".")) + ".info";

            DeviceDriver.EntryPoints = new List <EntryPoint>();
            DeviceDriver.Modules     = new List <Module>();
            DeviceDriver.SharedStructInitialiseFunc = "";

            bool whoopInit = true;

            using (StreamReader file = new StreamReader(driverInfoFile))
            {
                string line;

                while ((line = file.ReadLine()) != null)
                {
                    string type       = line.Trim(new char[] { '<', '>' });
                    string api        = "";
                    string kernelFunc = "";

                    if (type.Contains("$"))
                    {
                        var moduleSplit = type.Split(new string[] { "$" }, StringSplitOptions.None);
                        api        = moduleSplit[0];
                        kernelFunc = moduleSplit[1];
                    }
                    else
                    {
                        api = type;
                    }

                    Module module = new Module(api, kernelFunc);
                    DeviceDriver.Modules.Add(module);

                    if (api.Equals("test_driver") ||
                        api.Equals("pci_driver") ||
                        api.Equals("usb_driver") ||
                        api.Equals("usb_serial_driver") ||
                        api.Equals("platform_driver") ||
                        api.Equals("ps3_system_bus_driver") ||
                        api.Equals("cx_drv"))
                    {
                        whoopInit = false;
                    }

                    while ((line = file.ReadLine()) != null)
                    {
                        if (line.Equals("</>"))
                        {
                            break;
                        }
                    }
                }
            }

            using (StreamReader file = new StreamReader(driverInfoFile))
            {
                string line;

                while ((line = file.ReadLine()) != null)
                {
                    string type       = line.Trim(new char[] { '<', '>' });
                    string api        = "";
                    string kernelFunc = "";

                    if (type.Contains("$"))
                    {
                        var moduleSplit = type.Split(new string[] { "$" }, StringSplitOptions.None);
                        api        = moduleSplit[0];
                        kernelFunc = moduleSplit[1];
                    }
                    else
                    {
                        api = type;
                    }

                    if (api.Equals("whoop_network_shared_struct"))
                    {
                        var info = file.ReadLine();
                        DeviceDriver.SharedStructInitialiseFunc = info.Remove(0, 2);
                    }

                    Module module = DeviceDriver.Modules.First(val => val.API.Equals(api));

                    while ((line = file.ReadLine()) != null)
                    {
                        if (line.Equals("</>"))
                        {
                            break;
                        }
                        string[] pair = line.Split(new string[] { "::" }, StringSplitOptions.None);

                        var ep = new EntryPoint(pair[1], pair[0], kernelFunc, module, whoopInit);
                        module.EntryPoints.Add(ep);

                        if (DeviceDriver.EntryPoints.Any(val => val.Name.Equals(ep.Name)))
                        {
                            continue;
                        }

                        DeviceDriver.EntryPoints.Add(ep);

                        if (ep.IsCalledWithNetworkDisabled || ep.IsGoingToDisableNetwork)
                        {
                            var epClone = new EntryPoint(pair[1] + "#net", pair[0], kernelFunc, module, whoopInit, true);
                            module.EntryPoints.Add(epClone);
                            DeviceDriver.EntryPoints.Add(epClone);
                        }
                    }
                }
            }

            DeviceDriver.EntryPointPairs = new List <EntryPointPair>();

            foreach (var ep1 in DeviceDriver.EntryPoints)
            {
                foreach (var ep2 in DeviceDriver.EntryPoints)
                {
                    if (!DeviceDriver.CanBePaired(ep1, ep2))
                    {
                        continue;
                    }
                    if (!DeviceDriver.IsNewPair(ep1.Name, ep2.Name))
                    {
                        continue;
                    }
                    if (!DeviceDriver.CanRunConcurrently(ep1, ep2))
                    {
                        continue;
                    }
                    DeviceDriver.EntryPointPairs.Add(new EntryPointPair(ep1, ep2));
                }
            }
        }
コード例 #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);
        }