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.

106 lines
3.4 KiB

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