From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ben Elliston To: sid@sources.redhat.com Subject: New ro_value_control_register class Date: Sun, 02 Dec 2001 14:04:00 -0000 Message-ID: <15370.42327.275439.742878@scooby.brisbane.redhat.com> X-SW-Source: 2001-q4/msg00045.html Message-ID: <20011202140400.VRtJRBuFD1Wlv831zoWOOzClpOgW5PbGTkMP_rkwK5A@z> The following patch adds a new sidutil:: "ro_value_control_register" class which can be used to implement proper read-only registers where the underlying value may be changed programmatically, but not via bus accesses. Does this look okay to commit? 2001-11-30 Ben Elliston * sidbusutil.h (class ro_value_control_register): New class. (value_control_register::shift_amount): Make protected. Index: sidbusutil.h =================================================================== RCS file: /cvs/src/sid/include/sidbusutil.h,v retrieving revision 1.53 diff -u -c -r1.53 sidbusutil.h *** sidbusutil.h 2001/09/20 17:15:18 1.53 --- sidbusutil.h 2001/12/02 22:00:24 *************** *** 788,806 **** const value_control_register& it); friend std::istream& operator >> <> (std::istream& i, value_control_register& it); - - private: - DataType field_value; // return index of mask LSB unsigned shift_amount() const { ! DataType mask = this->get_mask (); ! for (unsigned i=0; i& it); friend std::istream& operator >> <> (std::istream& i, value_control_register& it); + protected: // return index of mask LSB unsigned shift_amount() const + { + DataType mask = this->get_mask (); + for (unsigned i=0; i + class ro_value_control_register: public value_control_register + { + public: + ro_value_control_register(control_register_bank* b, + sid::host_int_4 o, + DataType m, + DataType v): + value_control_register(b,o,m,true,true,v) + {} + + ro_value_control_register(control_register_bank* b, + sid::host_int_4 o, + DataType m): + value_control_register(b,o,m,true,true,0) + {} + + // Some convenience operators for accessing register fields + void operator = (const DataType& v) { ! DataType shifted_v = v << this->shift_amount(); ! value_control_register::set (shifted_v, this->get_mask()); } + + protected: + void set (DataType set_value, DataType set_mask) + { + // do nothing + } }; // This is a type of control register whose value never changes.