示例#1
0
            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'");
                    }
                }
            }
示例#2
0
 public IndexFieldOperationRegionAccessor(FieldUnit index, FieldUnit data)
 {
     this.index = index;
     this.data  = data;
 }