private static void LoadDeviceInfo(AcpiNamespace acpiNamespace,
                                           AcpiObject.IOperationRegionAccessor operationRegionAccessor)
        {
            AmlInterpreter interpreter = new AmlInterpreter(acpiNamespace, operationRegionAccessor);

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

                Console.Write("Loading resource descriptors for ACPI device ");
                Console.WriteLine(crsNode.Path.RemoveSegment().ToString());

                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);

                    Console.WriteLine("Loaded resource descriptor for device " + deviceId);
                }
                else
                {
                    Console.WriteLine("No resource descriptor for device " + deviceId);
                }
            }
        }
Example #2
0
 public override void Invoke(AmlInterpreterThread thread, AcpiObject[] parameters, AcpiNamespace acpiNamespace)
 {
     if (body == null)
     {
         AcpiNamespace.Node node = acpiNamespace.FindValue(this);
         if (Parse(acpiNamespace, node.Path) == AmlParser.ParseSuccess.Failure)
         {
             throw new InterpretException("AML parser failure while just-in-time parsing AML method body");
         }
     }
     thread.PushFrame(new AmlStackFrame(body, parameters));
 }