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); } } }
public AmlParser.ParseSuccess Parse(AcpiNamespace acpiNamespace, AcpiNamespace.AbsoluteNodePath initialNodePath) { int offset = 0; TermObj[] termList; if (new AmlParser(new ByteBufferAmlStreamAdapter(unparsedTermList), acpiNamespace, initialNodePath). ParseTermList(out termList, ref offset, unparsedTermList.Length) == AmlParser.ParseSuccess.Failure) { return(AmlParser.ParseSuccess.Failure); } Debug.Assert(offset == unparsedTermList.Length, "offset == unparsedTermList.Length"); AmlToStackIRVisitor amlToStackIRVisitor = new AmlToStackIRVisitor(); amlToStackIRVisitor.VisitSequence(termList); body = amlToStackIRVisitor.Result; return(AmlParser.ParseSuccess.Success); }
public static void Main(string[] args) { if (args.Length < 1) { Usage(); Environment.Exit(1); } try { AcpiNamespace acpiNamespace = new AcpiNamespace(); ReservedObjects reservedObjects = new ReservedObjects(acpiNamespace); reservedObjects.CreateReservedObjects(); AcpiObject.IOperationRegionAccessor operationRegionAccessor = new TestOperationRegionAccessor(); AmlInterpreter interpreter = new AmlInterpreter(acpiNamespace, operationRegionAccessor); foreach (string flag in args) { if (flag.StartsWith("/tracefile=")) { operationRegionAccessor = new TraceOperationRegionAccessor(new FileStream(flag.Substring("/tracefile=".Length), FileMode.Open, FileAccess.Read)); } else if (flag.StartsWith("/")) { Console.WriteLine("Unrecognized flag '" + flag + "'"); Environment.Exit(1); } } AmlParser.ParseSuccess parseSuccess = AmlParser.ParseSuccess.Success; foreach (string dumpFilename in args) { if (dumpFilename.StartsWith("/")) { continue; } using (FileStream reader = new FileStream(dumpFilename, FileMode.Open, FileAccess.Read)) { AmlParser.AMLCode result; int offset = 0x24; // Skip header AmlParser parser = new AmlParser(new FileStreamAmlStreamAdapter(reader), null, null); parseSuccess = parser.ParseAMLCode(out result, ref offset, (int)(new FileInfo(dumpFilename).Length)); if (parseSuccess == AmlParser.ParseSuccess.Success) { AmlLoader loader = new AmlLoader(acpiNamespace, operationRegionAccessor); loader.Load(result); } else { break; } } } if (parseSuccess == AmlParser.ParseSuccess.Success) { parseSuccess = interpreter.ParseMethodBodies(); } if (parseSuccess == AmlParser.ParseSuccess.Success) { LoadDeviceInfo(acpiNamespace, operationRegionAccessor); } if (parseSuccess == AmlParser.ParseSuccess.Success) { Console.WriteLine("Parsed successfully"); Environment.Exit(0); } else { Console.WriteLine("Encountered error during parse"); Environment.Exit(1); } } catch (Exception e) { Console.WriteLine("Encountered exception: " + e.Message); Console.WriteLine(e.StackTrace); Environment.Exit(1); } }
public override void Invoke(AmlInterpreterThread thread, AcpiObject[] parameters, AcpiNamespace acpiNamespace) { thread.Push(new ValueIoLocation(impl(parameters))); }
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)); }
public abstract void Invoke(AmlInterpreterThread thread, AcpiObject[] parameters, AcpiNamespace acpiNamespace);
public NodePathReference(AcpiNamespace acpiNamespace, AcpiNamespace.AbsoluteNodePath nodePath) { this.acpiNamespace = acpiNamespace; this.nodePath = nodePath; }