Source code of Windows XP (NT5)
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.

212 lines
5.4 KiB

  1. //***************************************************************************
  2. //
  3. // FileName:
  4. // $Workfile: ioif.h $
  5. //
  6. // Author:
  7. // TOSHIBA [PCS](PSY) Seiichi Nakamura
  8. // Copyright (c) 1997 TOSHIBA CORPORATION
  9. //
  10. // Description:
  11. //
  12. //***************************************************************************
  13. // $Header: /DVD Drivers/Sources/ZiVAHAL/ioif.h 1 97/06/27 23:22 Seichan $
  14. // $Modtime: 97/06/23 19:37 $
  15. // $Nokeywords:$
  16. //***************************************************************************
  17. #ifndef _IOIF_H_
  18. #define _IOIF_H_
  19. //---------------------------------------------------------------------------
  20. // IO Template Class
  21. //---------------------------------------------------------------------------
  22. template<class T> class CIOTemplate
  23. {
  24. private:
  25. IKernelService *m_pKernelObj;
  26. DWORD m_dwAddr;
  27. public:
  28. CIOTemplate( void ): m_pKernelObj(NULL)
  29. {
  30. };
  31. inline void Init( IKernelService *m_pObj, DWORD Addr )
  32. {
  33. m_pKernelObj = m_pObj;
  34. m_dwAddr = Addr;
  35. };
  36. inline BYTE Get( DWORD offset )
  37. {
  38. ASSERT( offset < sizeof( T ) );
  39. BYTE Data;
  40. m_pKernelObj->GetPortData(m_dwAddr+offset, &Data);
  41. return Data;
  42. };
  43. // Data Write by offset.
  44. inline void Set( DWORD offset, BYTE Data )
  45. {
  46. ASSERT( 0 <= offset && offset < sizeof( T ) );
  47. m_pKernelObj->SetPortData( m_dwAddr + offset, Data );
  48. };
  49. CIOTemplate& operator=(const T &Data )
  50. {
  51. ASSERT( m_pKernelObj != NULL );
  52. m_pKernelObj->SetPortData( m_dwAddr, Data );
  53. return *this;
  54. };
  55. operator T()
  56. {
  57. ASSERT( m_pKernelObj != NULL );
  58. T Ret;
  59. m_pKernelObj->GetPortData( m_dwAddr, &Ret );
  60. return Ret;
  61. };
  62. CIOTemplate& operator&=(const T &Data )
  63. {
  64. ASSERT( m_pKernelObj != NULL );
  65. T GetData;
  66. m_pKernelObj->GetPortData(m_dwAddr, &GetData);
  67. GetData &= Data;
  68. m_pKernelObj->SetPortData(m_dwAddr, GetData );
  69. return *this;
  70. };
  71. CIOTemplate& operator|=(const T &Data )
  72. {
  73. ASSERT( m_pKernelObj != NULL );
  74. T GetData;
  75. m_pKernelObj->GetPortData(m_dwAddr, &GetData);
  76. GetData |= Data;
  77. m_pKernelObj->SetPortData(m_dwAddr, GetData );
  78. return *this;
  79. };
  80. };
  81. //---------------------------------------------------------------------------
  82. // IO Class definition
  83. //---------------------------------------------------------------------------
  84. typedef CIOTemplate< DWORD > CDWORDIO;
  85. typedef CIOTemplate< WORD > CWORDIO;
  86. typedef CIOTemplate< BYTE > CBYTEIO;
  87. //---------------------------------------------------------------------------
  88. // PCI interface control class
  89. //---------------------------------------------------------------------------
  90. class CIOIF
  91. {
  92. // Luke register class
  93. class CLuke2
  94. {
  95. public:
  96. CDWORDIO IO_CONT; // control register
  97. CWORDIO IO_INTF; // interrupt flag register
  98. CDWORDIO IO_MADR; // master address register
  99. CDWORDIO IO_MTC; // master transfer counter register
  100. CBYTEIO IO_CPLT; // color pallet data register
  101. CBYTEIO IO_CPCNT; // color paller control register
  102. CWORDIO AVCONT; // AV control register
  103. CBYTEIO IO_VMODE; // digital video output mode register
  104. CBYTEIO IO_HSCNT; // digital video h-sync count register
  105. CBYTEIO IO_VPCNT; // digital video V-sync count register
  106. CBYTEIO IO_POL; // digital video V/H-sync. Polarity register
  107. CDWORDIO I2C_CONT; // IIC access register
  108. CBYTEIO I2C_ERR; // IIC error register
  109. CBYTEIO IO_EEPROM; // EEPROM access register
  110. CBYTEIO IO_PSCNT; // program steram control register
  111. CBYTEIO IO_TEST; // TEST control register
  112. CBYTEIO RST_CONT; // reset control register
  113. CDWORDIO STCCUNT; // STC counter register
  114. CWORDIO STCCONT; // STC control register
  115. CDWORDIO DMA_Start_Address; //
  116. CDWORDIO DMA_Byte_Count; //
  117. CDWORDIO Counter_Test; //
  118. CDWORDIO STCREF; // STC interrupt reference
  119. public:
  120. void Init( IKernelService *pKernelObj )
  121. {
  122. IO_CONT.Init( pKernelObj , 0x00 );
  123. IO_INTF.Init( pKernelObj , 0x04 );
  124. IO_MADR.Init( pKernelObj , 0x08 );
  125. IO_MTC.Init( pKernelObj , 0x0c );
  126. IO_CPLT.Init( pKernelObj , 0x10 );
  127. IO_CPCNT.Init( pKernelObj , 0x11 );
  128. AVCONT.Init( pKernelObj , 0x12 );
  129. IO_VMODE.Init( pKernelObj , 0x14 );
  130. IO_HSCNT.Init( pKernelObj , 0x15 );
  131. IO_VPCNT.Init( pKernelObj , 0x16 );
  132. IO_POL.Init( pKernelObj , 0x17 );
  133. I2C_CONT.Init( pKernelObj , 0x18 );
  134. I2C_ERR.Init( pKernelObj , 0x1c );
  135. IO_EEPROM.Init( pKernelObj , 0x20 );
  136. IO_PSCNT.Init( pKernelObj , 0x22 );
  137. IO_TEST.Init( pKernelObj , 0x23 );
  138. RST_CONT.Init( pKernelObj , 0x27 );
  139. STCCUNT.Init( pKernelObj , 0x28 );
  140. STCCONT.Init( pKernelObj , 0x2c );
  141. DMA_Start_Address.Init( pKernelObj , 0x30 );
  142. DMA_Byte_Count.Init( pKernelObj , 0x34 );
  143. Counter_Test.Init( pKernelObj , 0x38 );
  144. STCREF.Init( pKernelObj , 0x3c );
  145. };
  146. };
  147. //----------------------
  148. // ZiVA Register class
  149. //----------------------
  150. class CZiVAIO
  151. {
  152. public:
  153. CBYTEIO HIO[ 8 ];
  154. public:
  155. void Init( IKernelService *pKernelObj )
  156. {
  157. for( int i = 0 ; i < 8 ; i ++ )
  158. HIO[i].Init( pKernelObj , i + 0x40 );
  159. };
  160. };
  161. public:
  162. CLuke2 luke2; // Luke2 instance
  163. CZiVAIO zivaio; // DVD1 instance
  164. inline void Init( IKernelService *pKernelObj )
  165. {
  166. luke2.Init( pKernelObj );
  167. zivaio.Init( pKernelObj );
  168. return;
  169. };
  170. };
  171. #endif // _IOIF_H_
  172. //***************************************************************************
  173. // End of
  174. //***************************************************************************