Пример #1
0
        public FieldUnit(OperationRegion operationRegion, int startBitIndex, int numBits,
                         AccessType accessType, AccessAttrib accessAttrib,
                         LockRule lockRule, UpdateRule updateRule)
        {
            if (startBitIndex < 0 || (startBitIndex + numBits + 7) / 8 > (int)operationRegion.Length)
            {
                throw new ArgumentException("Field unit not in bounds of operation region");
            }

            this.operationRegion = operationRegion;
            this.startBitIndex   = startBitIndex;
            this.numBits         = numBits;
            this.accessType      = accessType;
            this.accessAttrib    = accessAttrib;
            this.lockRule        = lockRule;
            this.updateRule      = updateRule;
        }
Пример #2
0
        // SortedList will be Dictionary<string, FieldUnit> when generics are available
        public static SortedList CreateFromFieldList(OperationRegion operationRegionNode,
                                                     FieldElement[] fieldList,
                                                     AccessType initialAccessType,
                                                     AccessAttrib initialAccessAttrib,
                                                     LockRule lockRule,
                                                     UpdateRule updateRule
                                                     )
        {
            SortedList   result       = new SortedList(); // = new Dictionary<string, FieldUnit>();
            AccessType   accessType   = initialAccessType;
            AccessAttrib accessAttrib = initialAccessAttrib;
            int          bitIndex     = 0;

            foreach (FieldElement fieldElement in fieldList)
            {
                switch (fieldElement.Tag)
                {
                case FieldElement.TagValue.NamedField:
                    AmlParser.NamedField namedField = fieldElement.GetAsNamedField();
                    result.Add(namedField.nameSeg.data,
                               new FieldUnit(operationRegionNode,
                                             bitIndex, namedField.bitWidth,
                                             accessType, accessAttrib, lockRule, 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'");
                }
            }

            return(result);
        }