Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
3.0 KiB

  1. // $Header: G:/SwDev/WDM/Video/bt848/rcs/Regbase.h 1.5 1998/05/08 00:11:02 tomz Exp $
  2. #ifndef __REGBASE_H
  3. #define __REGBASE_H
  4. #include "mytypes.h"
  5. /* Type: AllFs
  6. * Purpose: To be used as an error return value from register accessing
  7. * functions. All bits are set to 1.
  8. */
  9. const DWORD AllFs = (DWORD) ~0L;
  10. /* Function: ReturnAllFs
  11. * Purpose: This function is used in the register access methods to indicate
  12. * that some sort of error has occured. Used for easing the debugging, as
  13. * it contains a macro to print the error if DEBUG is #defined
  14. */
  15. inline DWORD ReturnAllFs()
  16. {
  17. // OUTPUT_MESS( ALLFS );
  18. return AllFs;
  19. }
  20. /*
  21. * Type: RegisterType
  22. * Purpose: A type to differentiate between diferent kinds of registers.
  23. * Depending on the type register may not peforms certain operations
  24. * RW - read/write, RO - read-only, WO - write-only
  25. */
  26. typedef enum { RW, RO, WO, RR } RegisterType;
  27. /* Class: RegBase
  28. * Purpose:
  29. * Defines the interface and encapsulates the register access.
  30. * Attributes:
  31. * pBaseAddress_: DWORD, static. Holds the base address of the registers. On the
  32. * PCI bus it is a 32 bit memory address. On the ISA bus it is a 16 bit I/O address.
  33. * type_: RegisterType - defines the access permission for the register.
  34. * dwShadow_: DWORD - a local copy of the register. Used for returning a value
  35. * of write-only registers
  36. * Operations:
  37. * operator DWORD(): data access method. Pure virtual
  38. * DWORD operator=( DWORD ): assignment operator. Pure virtual. This assignment
  39. * operator does not return a reference to the class because of the performance reasons
  40. * void SetBaseAddress( DWORD )
  41. * DWORD GetBaseAddress()
  42. * RegisterType GetRegisterType()
  43. * void SetShadow( DWORD ): assigns a value of a register to a shadow
  44. * DWORD GetShadow( void ): retrieves a value from a shadow
  45. */
  46. class RegBase
  47. {
  48. private:
  49. RegisterType type_;
  50. DWORD dwShadow_;
  51. RegBase();
  52. protected:
  53. void SetShadow( DWORD dwValue );
  54. DWORD GetShadow();
  55. public:
  56. RegBase( RegisterType aType ) :
  57. type_( aType ), dwShadow_( 0 )
  58. {}
  59. static LPBYTE GetBaseAddress() {
  60. extern BYTE *GetBase();
  61. return GetBase();
  62. }
  63. RegisterType GetRegisterType() { return type_; }
  64. virtual operator DWORD() = 0;
  65. virtual DWORD operator=( DWORD dwValue ) = 0;
  66. virtual ~RegBase() {}
  67. };
  68. /* Method: RegBase::SetShadow
  69. * Purpose: Used to store the value of a register in the shadow
  70. * Input: dwValue: DWORD - new value of a register
  71. * Output: None
  72. * Note: inline
  73. */
  74. inline void RegBase::SetShadow( DWORD dwValue ) { dwShadow_ = dwValue; }
  75. /* Method: RegBase::GetShadow
  76. * Purpose: Used to obtain the last value written to a write-only register
  77. * from the shadow
  78. * Input: None
  79. * Output: DWORD
  80. * Note: inline
  81. */
  82. inline DWORD RegBase::GetShadow() { return dwShadow_; }
  83. #endif __REGBASE_H