public void Run()
 {
     while (threadsReadyToRun.Count > 0)
     {
         while (threadsReadyToRun.Count > 0)
         {
             AmlInterpreterThread currentThread = threadsReadyToRun.Dequeue();
             while (!currentThread.Blocked && !currentThread.Exited)
             {
                 currentThread.Step();
             }
             if (currentThread.Blocked)
             {
                 threadsBlocked.Enqueue(currentThread);
             }
         }
         foreach (AmlInterpreterThread thread in threadsBlocked)
         {
             if (!thread.Blocked)
             {
                 threadsReadyToRun.Enqueue(thread);
             }
         }
     }
     if (threadsBlocked.Count > 0)
     {
         throw new InterpretException("Deadlock between ACPI AML threads detected");
     }
 }
        public AmlInterpreterThread InvokeMethodOnNewThread(MethodResultCallback callback,
                                                            AbsoluteNodePath nodePath, AcpiObject.AcpiObject[] parameters)
        {
            AmlInterpreterThread thread = new AmlInterpreterThread(acpiNamespace, callback, operationRegionAccessor);

            thread.InvokeMethod(nodePath, parameters);
            threadsReadyToRun.Enqueue(thread);
            return(thread);
        }
Beispiel #3
0
        private static AcpiDevice[] GetDeviceInfo(AcpiObject.IOperationRegionAccessor operationRegionAccessor)
        {
            ArrayList deviceInfo = new ArrayList();

            AmlInterpreter interpreter = new AmlInterpreter(acpiNamespace, operationRegionAccessor);

            foreach (AcpiNamespace.Node crsNode in acpiNamespace.GetAllNodes())
            {
                if (crsNode.Name != "_CRS")
                {
                    continue;
                }

                VerboseOut.Write("Loading resource descriptors for ACPI device ");
                foreach (string segment in crsNode.Path.RemoveSegment().NameSegments)
                {
                    VerboseOut.Write(segment + "\\");
                }
                VerboseOut.WriteLine();

                AcpiNamespace.Node hidNode =
                    acpiNamespace.LookupNode(crsNode.Path.RemoveSegmentAbsolute().AddSegmentAbsolute("_HID"));
                if (hidNode == null)
                {
                    throw new Exception("Found device with _CRS property but no matching _HID property");
                }

                AcpiObject.AcpiObject hidObject = hidNode.Value;
                if (hidObject is AcpiObject.BytecodeMethod)
                {
                    AmlInterpreterThread thread =
                        interpreter.InvokeMethodOnNewThread(null, hidNode.Path, new AcpiObject.AcpiObject[] { });
                    interpreter.Run();
                    hidObject = thread.ExitValue;
                }
                string deviceId = HidObjectToDeviceId(hidObject);

                AcpiObject.AcpiObject crsObject = crsNode.Value;
                if (crsObject is AcpiObject.BytecodeMethod)
                {
                    AmlInterpreterThread thread =
                        interpreter.InvokeMethodOnNewThread(null, crsNode.Path, new AcpiObject.AcpiObject[] { });
                    interpreter.Run();
                    crsObject = thread.ExitValue;
                }

                if (crsObject is AcpiObject.Buffer)
                {
                    byte[] crsBuffer = crsObject.GetAsBuffer().Contents;
                    ResourceDescriptor[] resourceDescriptors = ResourceDescriptorParser.Parse(crsBuffer);

                    VerboseOut.WriteLine("Loaded resource descriptor for device " + deviceId);

                    deviceInfo.Add(new AcpiDevice(deviceId, resourceDescriptors));
                }
                else
                {
                    VerboseOut.WriteLine("No resource descriptor for device " + deviceId);
                }
            }

            return((AcpiDevice[])deviceInfo.ToArray(typeof(AcpiDevice)));
        }
 public void Enqueue(AmlInterpreterThread thread)
 {
     queue.Enqueue(thread);
 }
 public InterpretStepVisitor(AmlInterpreterThread thread)
 {
     this.thread = thread;
 }