Exemplo n.º 1
0
        private static AmlParser.ParseSuccess ParseAndLoadRegion(IoMemory region, AcpiObject.IOperationRegionAccessor operationRegionAccessor)
        {
            AmlParser.AMLCode result;
            int       offset = 0;
            AmlParser parser = new AmlParser(new IoMemoryAmlStreamAdapter(region), null, null);

            AmlParser.ParseSuccess parseSuccess =
                parser.ParseAMLCode(out result, ref offset, region.Length);

            if (parseSuccess == AmlParser.ParseSuccess.Success)
            {
                AmlLoader loader = new AmlLoader(acpiNamespace, operationRegionAccessor);
                loader.Load(result);
            }
            return(parseSuccess);
        }
Exemplo n.º 2
0
 public AmlLoader(AcpiNamespace acpiNamespace,
                  AcpiObject.IOperationRegionAccessor operationRegionAccessor)
 {
     this.acpiNamespace           = acpiNamespace;
     this.operationRegionAccessor = operationRegionAccessor;
 }
Exemplo n.º 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)));
        }