Exemplo n.º 1
0
 /// <summary>
 /// Add a collection of registers under 'GroupName'. If the group has already been
 /// defined this generates an error unless the group ReferenceEquals() the existing
 /// group (in which case this method is a NOP).
 ///
 /// AddGroup will also create an instance of IDirtyBit and assign it to each register
 /// (all registers in the group share the same instance) which is useful for determining
 /// which groups of registers are dirty and need Apply() called.
 ///
 /// RegManager assumes that the register array may be sparse (i.e. some of the
 /// array elements may be null).  However, other parts of the system may assume
 /// non-sparse arrays -- be sure to check usage of a group if you are adding a
 /// sparse array.
 ///
 /// NOTE: if a register is added to the group *after* calling AddGroup() the dirty bit
 ///       needs to be "manually" added to the register.  For example:
 ///
 ///            IRegister[] group = new IRegister[4];
 ///            mRegManager.AddGroup( "MyGroup", group ); // group[*] is null!!!
 ///            group[0] = new Reg32(...);  // register is in group but no dirty bit!
 ///            group[0].GroupDirtyBit = mRegManager.GetGroupDirtyBit( "MyGroup" );
 ///
 /// NOTE: if a register belongs to multiple groups, it will only set the dirty bit for one of them!
 /// </summary>
 /// <param name="groupName">Name of group, must be non-null, unique, and not "*" (may be string.Empty)</param>
 /// <param name="group">collection of registers</param>
 /// <exception cref="InvalidParameterException">if the group already exists</exception>
 public virtual void AddGroup(string groupName, IRegister[] group)
 {
     lock ( mGroupLock )
     {
         if (mGroups.ContainsKey(groupName) ||
             mRegisterSets.ContainsKey(groupName) ||
             mSuperGroups.ContainsKey(groupName))
         {
             if (ReferenceEquals(group, mGroups[groupName]))
             {
                 // NOP
                 return;
             }
             throw new InvalidParameterException(string.Format("RegManager '{0}' already contains group '{1}'",
                                                               Name,
                                                               groupName));
         }
         IDirtyBit dirtyBit = new DirtyBit();
         foreach (var register in group)
         {
             if (register != null)
             {
                 register.GroupDirtyBit = dirtyBit;
             }
         }
         mGroups[groupName]    = group;
         mDirtyBits[groupName] = dirtyBit;
         // If we've already created the name lookup cache, refresh it
         if (mNameLookupReg.Count > 0)
         {
             UpdateRegisterDictionaries(true);
         }
     }
 }
Exemplo n.º 2
0
 private void SetDirtyBit(DirtyBit bit)
 {
     SetDirtyBit((uint)bit);
 }
Exemplo n.º 3
0
 private bool IsBitDirty(uint setBits, DirtyBit bitToTest)
 {
     return(((DirtyBit)setBits & bitToTest) != ~DirtyBit.All);
 }
Exemplo n.º 4
0
 // was empty
 public void MarkAsDirty(DirtyBit bit)
 {
     SetDirtyBit((uint)bit);
 }