示例#1
0
        public new static IRegister ConstructReg(string name,
                                                 RegDef regDef,
                                                 IRegDriver driver,
                                                 int baseAddr,
                                                 object[] args)
        {
            var newRegister = new SimulatedReg(name, regDef.BARoffset + baseAddr, regDef.BFenum, driver,
                                               regDef.RegType);

            return(newRegister);
        }
示例#2
0
 public static IRegister ConstructReg(string name,
                                      RegDef regDef,
                                      IRegDriver driver,
                                      int baseAddr,
                                      object[] args)
 {
     return(new Reg32(name,
                      regDef.BARoffset + baseAddr,
                      regDef.BFenum,
                      driver,
                      regDef.RegType));
 }
示例#3
0
 /// <summary>
 /// Remove the register definition(s) identified by 'id' (e.g. (int)eCommonReg.Trig10) from
 /// 'registerDefinitions'.
 /// </summary>
 /// <param name="registerDefinitions">The register definitions to filter</param>
 /// <param name="id">List of the registers's enum value (e.g. (int)eCommonReg.Trig10) of the definition to remove</param>
 public static void RemoveRegisters(IList <RegDef> registerDefinitions, ICollection <int> id)
 {
     // Index backwards so deletions don't affect where we need to check next
     for (int j = registerDefinitions.Count - 1; j >= 0; j--)
     {
         RegDef register = registerDefinitions[j];
         if (id.Contains(register.nameEnum))
         {
             registerDefinitions.RemoveAt(j);
         }
     }
 }
示例#4
0
 /// <summary>
 /// Remove the register definition identified by 'id' (e.g. (int)eCommonReg.Trig10) from
 /// 'registerDefinitions'.
 /// </summary>
 /// <param name="registerDefinitions">The register definitions to filter</param>
 /// <param name="id">The register's enum value (e.g. (int)eCommonReg.Trig10) of the definition to remove</param>
 public static void RemoveRegister(IList <RegDef> registerDefinitions, int id)
 {
     for (int j = registerDefinitions.Count - 1; j >= 0; j--)
     {
         RegDef register = registerDefinitions[j];
         if (register.nameEnum == id)
         {
             registerDefinitions.RemoveAt(j);
             // There should only be 1 entry per register ... so we're done
             break;
         }
     }
 }
示例#5
0
 /// <summary>
 /// Delegate method used to construct a register.  This method will be passed to a
 /// register factory such as RegFactory to create registers from definitions.
 /// </summary>
 /// <param name="name">register name</param>
 /// <param name="regDef">reference to RegDef struct.</param>
 /// <param name="driver">driver to read this type of Treg register.</param>
 /// <param name="baseAddr">typically 0, but this additional base address can be
 /// used to add to the register address specified in the RegDef struct.
 /// Currently only used for CannotReadDirectly registers, so is typically 0.</param>
 /// <param name="args">arbitrary array of objects for use by the delegate ... normally
 /// used to specify register-type specific arguments</param>
 /// <returns>a reference to the register Treg created.</returns>
 public static IRegister ConstructNonMemoryMappedControlReg(string name,
                                                            RegDef regDef,
                                                            IRegDriver driver,
                                                            int baseAddr,
                                                            object[] args)
 {
     return(new Reg32(name,
                      regDef.BARoffset + baseAddr,
                      regDef.BFenum,
                      driver,
                      regDef.RegType)
     {
         IsMemoryMapped = false
     });
 }
示例#6
0
        /// <summary>
        /// Delegate method used to construct a register.  This method will be passed to a
        /// register factory such as RegFactory to create registers from definitions.
        /// </summary>
        /// <param name="name">register name</param>
        /// <param name="regDef">reference to RegDeg struct.</param>
        /// <param name="driver">driver to read this type of Treg register.</param>
        /// <param name="baseAddr">typically 0, but this additional base address can be
        /// used to add to the register address specified in the RegDef struct.
        /// Currently only used for CannotReadDirectly registers, so is typically 0.</param>
        /// <param name="args">arbitrary array of objects for use by the delegate ... For
        /// AddrDataReg32 this must contain (in order):
        ///    Address Field (RegField32)
        ///    Data Field (RegField32)
        ///    Control Field (RegField32)
        /// </param>
        /// <returns>a reference to the register Treg created.</returns>
        public static IRegister ConstructReg(string name,
                                             RegDef regDef,
                                             IRegDriver driver,
                                             int baseAddr,
                                             object[] args)
        {
            if (args == null ||
                args.Length < 3)
            {
                throw new InvalidParameterException(
                          "Expected 'args' to contain 3 RegField32 values [address, data, control].");
            }
            switch (args.Length)
            {
            case 3:
                return(new AddrDataReg32(name,
                                         regDef.BARoffset + baseAddr,
                                         regDef.BFenum,
                                         driver,
                                         regDef.RegType,
                                         (IBitField)args[0],
                                         (IBitField)args[1],
                                         (IBitField)args[2]));

            case 5:
                return(new AddrDataReg32(name,
                                         regDef.BARoffset + baseAddr,
                                         regDef.BFenum,
                                         driver,
                                         regDef.RegType,
                                         (IBitField)args[0],
                                         (IBitField)args[1],
                                         (IBitField)args[2],
                                         (int)args[3],
                                         (int)args[4]));

            default:
                throw new InvalidParameterException(
                          "Expected 'args' to contain 3 or 5 values: 3 RegField32 values [address, data, control] and, optionally, read control value and write control value.");
            }
        }
示例#7
0
 /// <summary>
 /// Replace the BitField type defined in supplied the register and bit field definitions.
 /// This allows a derived class to customize a RegisterSet (e.g. use SlugCarrierEventBF
 /// instead of EventBF).
 /// </summary>
 /// <param name="registerDefinitions">The register definitions to filter</param>
 /// <param name="bitFieldDefinitions">The bit field definitions to filter</param>
 /// <param name="oldType">the old/original Type of the bit field</param>
 /// <param name="newType">the new Type of the bit field</param>
 protected static void ReplaceType(IList <RegDef> registerDefinitions,
                                   IList <BitFieldDef> bitFieldDefinitions,
                                   Type oldType,
                                   Type newType)
 {
     // Replace the bit field type for any register definitions using 'oldType'
     for (int j = registerDefinitions.Count - 1; j >= 0; j--)
     {
         RegDef definition = registerDefinitions[j];
         if (ReferenceEquals(oldType, definition.BFenum))
         {
             definition.BFenum = newType;
         }
     }
     // Replace the bit field type for and bit field definitions using 'oldType'
     for (int j = bitFieldDefinitions.Count - 1; j >= 0; j--)
     {
         BitFieldDef definition = bitFieldDefinitions[j];
         if (ReferenceEquals(oldType, definition.BFType))
         {
             definition.BFType = newType;
         }
     }
 }