Beispiel #1
0
        /// <summary>
        /// Perform a write of the register using the register's software copy of its
        /// value without performing any of the normal checks (such as "is this register
        /// writable?").  This method is intended for advanced operations such as
        /// used by RegSet -- please consider using Write( IRegDriver, T ) instead.
        ///
        /// For AddrDataReg32 this is a "device register" write operation.  This is composed of
        /// 1) Optionally, a write mWriteValue to mRwField (if non-null)
        /// 2) A write to mAddrField (value == Offset)
        /// 3) A write to mAddrField
        /// If all the fields are part of the same register, all the fields are written at the same time.
        /// </summary>
        /// <param name="driver">IRegDriver used for memory mapped register operation (forwarded to BitField.Apply)</param>
        public override void DriverWrite(IRegDriver driver)
        {
            // REVISIT: should put lock around these otherwise in a multi threaded environment
            // you can't be sure the value logged was actually the value written!!!
            // ACTUALLY, we could just get a thread safe, stack copy of mValue at start of this
            // method and use it internally.  This would fix 1 problem.  It wouldn't however fix
            // the problem of really not being sure the write took place when it was supposed to!

            if (mLogger.IsLoggingEnabledFor(LogLevel.Fine))
            {
                mLogger.LogAppend(new RegisterLoggingEvent(LogLevel.Fine, mValue, this)
                {
                    Operation = RegisterLoggingEvent.OperationType.RegWrDR
                });
            }

            // Make sure control and address fields are set...
            if (mRwField != null)
            {
                mRwField.Value = mWriteValue;
            }
            mAddrField.Value = Offset;
            mDataField.Value = mValue;
            // *** THIS IMPLEMENTATION ASSUMES ALL IBitField OBJECTS BELONG TO THE SAME REGISTER ***
            // NOTE: DriverWrite() always writes to the HW ... so set Force=true
            mDataField.Apply(driver, true);
        }
Beispiel #2
0
        /// <summary>
        /// Perform a read of the register WITHOUT updating the register's software
        /// copy or performing any of the normal checks (such as "is this register
        /// readable?").  This method is intended for advanced operations such as
        /// used by RegSet -- please consider using Read() instead.
        ///
        /// For AddrDataReg32 this is a "device register" read operation.  This is composed of
        /// 1) Optionally, a write mReadValue to mRwField (if non-null)
        /// 2) A write to mAddrField (value == Offset)
        /// 3) A read from mDataField
        /// </summary>
        /// <returns></returns>
        public override int DriverRead()
        {
            // Make sure control and address fields are set...
            if (mRwField != null)
            {
                mRwField.Value = mReadValue;
            }
            mAddrField.Value = Offset;

            // *** THIS IMPLEMENTATION ASSUMES ALL IBitField OBJECTS BELONG TO THE SAME REGISTER ***
            mAddrField.Apply(false);

            // Delegate actual read to the Field (instead of the normal IRegDriver)
            int regVal = mDataField.Read();

            if (mLogger.IsLoggingEnabledFor(LogLevel.Fine))
            {
                mLogger.LogAppend(new RegisterLoggingEvent(LogLevel.Fine, regVal, this)
                {
                    Operation = RegisterLoggingEvent.OperationType.RegRdDR
                });
            }
            return(regVal);
        }