public override void Visit(AmlParser.DefDevice defDevice) { AbsoluteNodePath oldPath = currentPath; Node node = acpiNamespace.LookupNode(defDevice.nameString.nodePath, currentPath); string[] segments = new string[currentPath.NameSegments.Length + defDevice.nameString.nodePath.NameSegments.Length]; int index = 0; foreach (string segment in currentPath.NameSegments) { segments[index++] = segment; } foreach (string segment in defDevice.nameString.nodePath.NameSegments) { segments[index++] = segment; } AbsoluteNodePath devPath = new AbsoluteNodePath(segments); node.Value = new AcpiObject.Device(devPath); currentPath = node.Path; foreach (AmlObject amlObject in defDevice.amlObjectList) { amlObject.Accept(this); } currentPath = oldPath; }
public override void Visit(AmlParser.DefAlias defAlias) { Node sourceNode = acpiNamespace.LookupNode(defAlias.sourceName.nodePath, currentPath); Node aliasNode = acpiNamespace.LookupNode(defAlias.aliasName.nodePath, currentPath); aliasNode.AliasTo(sourceNode); }
public Node CreateNodeAt(NodePath nodePath) { Node node = acpiNamespace.CreateNodeAt(nodePath, currentPath); frameStack.Peek().NotifyCreateNodeAt(nodePath, node); return(node); }
private void AddMethod(string name, byte numArgs, ReservedMethod.AcpiMethodImpl impl) { AbsoluteNodePath root = AbsoluteNodePath.CreateRoot(); Node node = acpiNamespace.CreateNodeAt(new AbsoluteNodePath(new string[] { name }), root); node.Value = new ReservedMethod(numArgs, SerializeFlag.NotSerialized, 0 /*syncLevel*/, impl);; }
public override void Visit(AmlParser.DefMethod defMethod) { Node node = acpiNamespace.LookupNode(defMethod.nameString.nodePath, currentPath); node.Value = new AcpiObject.BytecodeMethod(defMethod.methodFlags.argCount, defMethod.methodFlags.serializeFlag, defMethod.methodFlags.syncLevel, defMethod.unparsedTermList); }
public override void Visit(CreateField node) { AcpiObject.Buffer sourceBuff = thread.Pop().Read().GetAsBuffer(); ulong startBitIndex = thread.Pop().Read().GetAsInt().Value; ulong numBits = thread.Pop().Read().GetAsInt().Value; Node destinationNode = thread.CreateNodeAt(node.NodePath); destinationNode.Value = new BufferField(sourceBuff, startBitIndex, numBits); }
public override void Visit(PushNodePath node) { Node pathNode = thread.LookupNode(node.Value); thread.Push(new NodePathIoLocation(pathNode)); if (pathNode.Value is Method && pathNode.Value.GetAsMethod().ArgCount == 0) { Visit(new MethodCall()); } }
public override void Visit(StackIR.OperationRegion node) { ulong startIndex = thread.Pop().Read().GetAsInt().Value; ulong length = thread.Pop().Read().GetAsInt().Value; Node namespaceNode = thread.CreateNodeAt(node.NodePath); namespaceNode.Value = new AcpiObject.OperationRegion(thread.OperationRegionAccessor, node.OperationSpace, startIndex, length); }
public override void Visit(AmlParser.DefIndexField defIndexField) { Node indexNode = acpiNamespace.LookupNode(defIndexField.indexName.nodePath, currentPath); CheckObjectType(indexNode.Value, AcpiObjectType.FieldUnit); AcpiObject.FieldUnit indexField = (AcpiObject.FieldUnit)(indexNode.Value.GetTarget()); Node dataNode = acpiNamespace.LookupNode(defIndexField.dataName.nodePath, currentPath); CheckObjectType(dataNode.Value, AcpiObjectType.FieldUnit); AcpiObject.FieldUnit dataField = (AcpiObject.FieldUnit)(dataNode.Value.GetTarget()); OperationRegion indexFieldRegion = new OperationRegion(new IndexFieldOperationRegionAccessor(indexField, dataField), RegionSpace.SystemIO /*unused*/, 0, 256 /*index field never exceeds 8 bits*/); AccessType accessType = defIndexField.fieldFlags.accessType; AccessAttrib accessAttrib = AccessAttrib.SMBNone; int bitIndex = 0; foreach (FieldElement fieldElement in defIndexField.fieldList) { switch (fieldElement.Tag) { case FieldElement.TagValue.NamedField: AmlParser.NamedField namedField = fieldElement.GetAsNamedField(); Node node = acpiNamespace.LookupNode( new NodePath(false /*isAbsolute*/, 0, new string[] { namedField.nameSeg.data }), currentPath); node.Value = new FieldUnit(indexFieldRegion, bitIndex, namedField.bitWidth, accessType, accessAttrib, defIndexField.fieldFlags.lockRule, defIndexField.fieldFlags.updateRule); bitIndex += namedField.bitWidth; break; case FieldElement.TagValue.ReservedField: AmlParser.ReservedField reservedField = fieldElement.GetAsReservedField(); bitIndex += reservedField.bitWidth; break; case FieldElement.TagValue.AccessField: AmlParser.AccessField accessField = fieldElement.GetAsAccessField(); accessType = accessField.accessType; accessAttrib = accessField.accessAttrib; break; default: throw new LoadException("Unhandled alternative in switch over 'FieldElement'"); } } }
public override void Visit(AmlParser.DefOpRegion defOpRegion) { AcpiObject.AcpiObject startIndexObj = LoadTimeEvaluate(defOpRegion.regionOffset.integer); AcpiObject.AcpiObject lengthObj = LoadTimeEvaluate(defOpRegion.regionLen.integer); CheckObjectType(lengthObj, AcpiObjectType.Integer); Node node = acpiNamespace.LookupNode(defOpRegion.nameString.nodePath, currentPath); node.Value = new AcpiObject.OperationRegion(loader.OperationRegionAccessor, (RegionSpace)defOpRegion.regionSpace.byteData, startIndexObj.GetAsInt().Value, ((AcpiObject.Integer)(lengthObj.GetTarget())).Value); }
public override void Visit(AmlParser.DefBankField defBankField) { Node operationRegionNode = acpiNamespace.LookupNode(defBankField.regionName.nodePath, currentPath); CheckObjectType(operationRegionNode.Value, AcpiObjectType.OperationRegion); // TODO: BankFields are not used in the test files and appear to involve some kind of // "bank selection register". Need to understand this properly to implement it, but for // leaving unimplemented. Commented out below is some code to use as a starting point. throw new LoadException("BankField unimplemented"); #if false AccessType accessType = defBankField.fieldFlags.accessType; AccessAttrib accessAttrib = AccessAttrib.SMBNone; int bitIndex = 0; foreach (FieldElement fieldElement in defBankField.fieldList) { switch (fieldElement.Tag) { case FieldElement.TagValue.NamedField: AmlParser.NamedField namedField = fieldElement.GetAsNamedField(); Node node = acpiNamespace.LookupNode( new NodePath(false /*isAbsolute*/, 0, new string[] { namedField.nameSeg.data }), currentPath); node.Value = new FieldUnit((AcpiObject.OperationRegion)operationRegionNode.Value, bitIndex, namedField.bitWidth, accessType, accessAttrib, defBankField.fieldFlags.lockRule, defBankField.fieldFlags.updateRule); bitIndex += namedField.bitWidth; break; case FieldElement.TagValue.ReservedField: AmlParser.ReservedField reservedField = fieldElement.GetAsReservedField(); bitIndex += reservedField.bitWidth; break; case FieldElement.TagValue.AccessField: AmlParser.AccessField accessField = fieldElement.GetAsAccessField(); accessType = accessField.accessType; accessAttrib = accessField.accessAttrib; break; default: throw new LoadException("Unhandled alternative in switch over 'FieldElement'"); } } #endif }
public override void Visit(AmlParser.DefThermalZone defThermalZone) { AbsoluteNodePath oldPath = currentPath; Node node = acpiNamespace.CreateNodeAt(defThermalZone.nameString.nodePath, currentPath); currentPath = node.Path; foreach (AmlObject amlObject in defThermalZone.amlObjectList) { amlObject.Accept(this); } currentPath = oldPath; }
public override void Visit(Field node) { Node operationRegionNode = thread.LookupNode(node.NodePath); SortedList fields = FieldUnit.CreateFromFieldList((AcpiObject.OperationRegion)(operationRegionNode.Value.GetTarget()), node.FieldElements, node.FieldFlags.accessType, AccessAttrib.SMBNone, node.FieldFlags.lockRule, node.FieldFlags.updateRule); foreach (DictionaryEntry entry in fields) { Node namespaceNode = thread.CreateNodeAt( new NodePath(false /*isAbsolute*/, 0, new string[] { (string)entry.Key })); namespaceNode.Value = (FieldUnit)entry.Value; } }
public void InvokeMethod(AbsoluteNodePath nodePath, AcpiObject.AcpiObject[] parameters) { Node methodNode = acpiNamespace.LookupNode(nodePath); if (methodNode == null) { throw new MethodNotFoundInterpretException(); } if (!(methodNode.Value is AcpiObject.BytecodeMethod)) { throw new AmlTypeException(); } this.currentPath = methodNode.Path; ((AcpiObject.Method)(methodNode.Value)).Invoke(this, parameters, acpiNamespace); }
public override void Visit(AmlParser.DefPowerRes defPowerRes) { AbsoluteNodePath oldPath = currentPath; Node node = acpiNamespace.LookupNode(defPowerRes.nameString.nodePath, currentPath); node.Value = new AcpiObject.PowerResource(defPowerRes.systemLevel.byteData, defPowerRes.resourceOrder.wordData); currentPath = node.Path; foreach (AmlObject amlObject in defPowerRes.amlObjectList) { amlObject.Accept(this); } currentPath = oldPath; }
public void VisitField(AmlParser.SourceBuff sourceBuff, TermArg indexTermArg, ulong bitIndexMultiplier, ulong bitSize, NodePath fieldName) { AcpiObject.AcpiObject indexObj = LoadTimeEvaluate(indexTermArg); CheckObjectType(indexObj, AcpiObjectType.Integer); ulong index = ((AcpiObject.Integer)(indexObj.GetTarget())).Value; ulong bitIndex = index * bitIndexMultiplier; AcpiObject.AcpiObject bufferObj = LoadTimeEvaluate(sourceBuff.buffer); CheckObjectType(bufferObj, AcpiObjectType.Buffer); Node node = acpiNamespace.LookupNode(fieldName, currentPath); node.Value = new BufferField((AcpiObject.Buffer)(bufferObj.GetTarget()), bitIndex, bitSize); }
public override void Visit(AmlParser.DefField defField) { Node operationRegionNode = acpiNamespace.LookupNode(defField.nameString.nodePath, currentPath); CheckObjectType(operationRegionNode.Value, AcpiObjectType.OperationRegion); SortedList fields = FieldUnit.CreateFromFieldList((AcpiObject.OperationRegion)(operationRegionNode.Value.GetTarget()), defField.fieldList, defField.fieldFlags.accessType, AccessAttrib.SMBNone, defField.fieldFlags.lockRule, defField.fieldFlags.updateRule); foreach (DictionaryEntry entry in fields) { Node node = acpiNamespace.LookupNode( new NodePath(false /*isAbsolute*/, 0, new string[] { (string)entry.Key }), currentPath); node.Value = (FieldUnit)entry.Value; } }
public override void Visit(AmlParser.DefIndexField defIndexField) { foreach (FieldElement fieldElement in defIndexField.fieldList) { switch (fieldElement.Tag) { case FieldElement.TagValue.NamedField: AmlParser.NamedField namedField = fieldElement.GetAsNamedField(); Node node = acpiNamespace.CreateNodeAt( new NodePath(false /*isAbsolute*/, 0, new string[] { namedField.nameSeg.data }), currentPath); break; default: break; } } }
public override void Visit(AmlParser.DefProcessor defProcessor) { AbsoluteNodePath oldPath = currentPath; Node node = acpiNamespace.LookupNode(defProcessor.nameString.nodePath, currentPath); node.Value = new AcpiObject.Processor(defProcessor.procID.byteData, defProcessor.pblkAddr.dWordData, defProcessor.pblkLen.byteData); currentPath = node.Path; foreach (AmlObject amlObject in defProcessor.amlObjectList) { amlObject.Accept(this); } currentPath = oldPath; }
public override void Visit(AmlParser.DefName defName) { Node node = acpiNamespace.LookupNode(defName.nameString.nodePath, currentPath); node.Value = LoadTimeEvaluate(defName.dataRefObject); }
public override void Visit(DefName node) { Node namespaceNode = thread.CreateNodeAt(node.NodePath); namespaceNode.Value = thread.Pop().Read(); }
public override void Visit(AmlParser.DefMutex defMutex) { Node node = acpiNamespace.LookupNode(defMutex.nameString.nodePath, currentPath); node.Value = new AcpiObject.Mutex(defMutex.syncFlags.syncLevel); }
public void NotifyCreateNodeAt(NodePath nodePath, Node node) { methodTemporaryNamespaceObjectSet.Add(node); }
public override void Visit(AmlParser.DefEvent defEvent) { Node node = acpiNamespace.LookupNode(defEvent.nameString.nodePath, currentPath); node.Value = new AcpiObject.Event(); }