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.

1113 lines
40 KiB

  1. //***************************************************************************
  2. //
  3. // FileName:
  4. // $Workfile: ZIVACHIP.CPP $
  5. //
  6. // Author:
  7. // TOSHIBA [PCS](PSY) Seiichi Nakamura
  8. // Copyright (c) 1997 TOSHIBA CORPORATION
  9. //
  10. // Description:
  11. //
  12. //***************************************************************************
  13. // $Header: /DVD Drivers/ZiVA.WDM/ZIVACHIP.CPP 26 99/02/12 4:44p Yagi $
  14. // $Modtime: 99/02/10 1:24p $
  15. // $Nokeywords:$
  16. //***************************************************************************
  17. // for ziva debug
  18. //#define DEBUG_ZIVA
  19. // for ziva command print out
  20. //#define DEBUG_ZIVA_COMMAND
  21. //---------------------------------------------------------------------------
  22. // INCLUDES
  23. //---------------------------------------------------------------------------
  24. #include "includes.h"
  25. #include "ioif.h"
  26. #include "timeout.h"
  27. #include "zivachip.h"
  28. #include "dvd1cmd.h" // from C-CUBE
  29. #include "dramcfg.h" // from C-CUBE
  30. // Ziva Command time out setting. 1000 is 1 sec
  31. #define COMMAND_TIMEOUT (1000)
  32. //---------------------------------------------------------------------------
  33. // Constructor for CViZAMemory
  34. //---------------------------------------------------------------------------
  35. CZiVA::CZiVAMemory::CZiVAMemory(void):Address(0),m_ziva(NULL)
  36. {
  37. };
  38. //---------------------------------------------------------------------------
  39. // CZiVAMemory::Init
  40. //---------------------------------------------------------------------------
  41. void CZiVA::CZiVAMemory::Init( CZiVA *pziva, DWORD addr )
  42. {
  43. Address = addr;
  44. m_ziva = pziva;
  45. };
  46. //---------------------------------------------------------------------------
  47. // CZiVAMemory::Get
  48. //---------------------------------------------------------------------------
  49. DWORD CZiVA::CZiVAMemory::Get( DWORD *pData )
  50. {
  51. ASSERT( m_ziva != NULL );
  52. #ifdef ZIVA_DEBUG
  53. DBG_PRINTF( ("CZiVAMemory::Get Addr = 0x%x\n", Address ) );
  54. #endif
  55. return m_ziva->ZiVAReadMemory( Address, pData );
  56. };
  57. //---------------------------------------------------------------------------
  58. // CZiVAMemory::Set
  59. //---------------------------------------------------------------------------
  60. DWORD CZiVA::CZiVAMemory::Set( DWORD Data )
  61. {
  62. ASSERT( m_ziva != NULL );
  63. #ifdef ZIVA_DEBUG
  64. DBG_PRINTF( ("CZiVAMemory::Set Addr = 0x%x Data = 0x%x\n", Address, Data) );
  65. #endif
  66. return m_ziva->ZiVAWriteMemory( Address, Data );
  67. };
  68. //---------------------------------------------------------------------------
  69. // CZiVAMemory::GetAndSet
  70. //---------------------------------------------------------------------------
  71. DWORD CZiVA::CZiVAMemory::GetAndSet( DWORD Mask, DWORD Data )
  72. {
  73. ASSERT( m_ziva != NULL );
  74. DWORD GetData = 0;
  75. m_ziva->ZiVAReadMemory( Address, &GetData );
  76. GetData = GetData & Mask;
  77. GetData = GetData | Data;
  78. #ifdef ZIVA_DEBUG
  79. // DBG_PRINTF( ("CZiVAMemory::GetAndSet Addr = 0x%x Mask = 0x%x Data = 0x%x WriteData = 0x%x \n", Address, Mask, Data,GetData ) );
  80. #endif
  81. return m_ziva->ZiVAWriteMemory( Address, GetData );
  82. };
  83. //---------------------------------------------------------------------------
  84. // CZiVAMemory::operator&=
  85. //---------------------------------------------------------------------------
  86. CZiVA::CZiVAMemory& CZiVA::CZiVAMemory::operator&=(const DWORD &Data )
  87. {
  88. ASSERT( m_ziva != NULL );
  89. DWORD GetData = 0;
  90. m_ziva->ZiVAReadMemory( Address, &GetData );
  91. GetData = GetData & Data;
  92. #ifdef ZIVA_DEBUG
  93. // DBG_PRINTF( ("CZiVAMemory::operator &= Addr = 0x%x Data = 0x%x WriteData = 0x%x \n", Address, Data,GetData ) );
  94. #endif
  95. m_ziva->ZiVAWriteMemory( Address, GetData );
  96. return *this;
  97. };
  98. //---------------------------------------------------------------------------
  99. // CZiVAMemory::operator|=
  100. //---------------------------------------------------------------------------
  101. CZiVA::CZiVAMemory& CZiVA::CZiVAMemory::operator|=(const DWORD &Data )
  102. {
  103. ASSERT( m_ziva != NULL );
  104. DWORD GetData = 0;
  105. m_ziva->ZiVAReadMemory( Address, &GetData );
  106. GetData = GetData | Data;
  107. #ifdef ZIVA_DEBUG
  108. // DBG_PRINTF( ("CZiVAMemory::operator |= Addr = 0x%x Data = 0x%x WriteData = 0x%x \n", Address, Data,GetData ) );
  109. #endif
  110. m_ziva->ZiVAWriteMemory( Address, GetData );
  111. return *this;
  112. };
  113. //---------------------------------------------------------------------------
  114. // CZiVA constructor
  115. //---------------------------------------------------------------------------
  116. CZiVA::CZiVA( void ): m_pioif(NULL),m_pKernelObj( NULL )
  117. {
  118. };
  119. //---------------------------------------------------------------------------
  120. // CZiVA::ZiVAWriteMemory
  121. //---------------------------------------------------------------------------
  122. DWORD CZiVA::ZiVAWriteMemory( DWORD Addr, DWORD Data )
  123. {
  124. ASSERT( m_pKernelObj != NULL );
  125. ASSERT( m_pioif != NULL );
  126. m_pKernelObj->DisableHwInt();
  127. #ifdef ZIVA_DEBUG
  128. // DBG_PRINTF(( "ZiVAWriteMemory Addr = 0x%x Data = 0x%x\n", Addr,Data ));
  129. #endif
  130. // set auto increment off
  131. m_pioif->zivaio.HIO[7] &= (BYTE)(~0x08);
  132. m_pioif->zivaio.HIO[4] = (BYTE)( Addr & 0xff );
  133. m_pioif->zivaio.HIO[5] = (BYTE)( ( Addr >> 8 ) & 0xff );
  134. m_pioif->zivaio.HIO[6] = (BYTE)( ( Addr >> 16 ) & 0xff );
  135. m_pioif->zivaio.HIO[3] = (BYTE)( (Data >> 24 ) & 0xff );
  136. m_pioif->zivaio.HIO[2] = (BYTE)( (Data >> 16 ) & 0xff );
  137. m_pioif->zivaio.HIO[1] = (BYTE)( (Data >> 8 ) & 0xff );
  138. m_pioif->zivaio.HIO[0] = (BYTE)( Data & 0xff );
  139. m_pKernelObj->EnableHwInt();
  140. return 0;
  141. };
  142. //---------------------------------------------------------------------------
  143. // CZiVA::ZiVAReadMemory
  144. //---------------------------------------------------------------------------
  145. DWORD CZiVA::ZiVAReadMemory( DWORD Addr, DWORD *Data )
  146. {
  147. ASSERT( m_pioif != NULL );
  148. ASSERT( m_pKernelObj != NULL );
  149. m_pKernelObj->DisableHwInt();
  150. DWORD rcData = 0;
  151. // set auto increment off
  152. m_pioif->zivaio.HIO[7] &= (BYTE)(~0x08);
  153. m_pioif->zivaio.HIO[4] = (BYTE)( Addr & 0xff );
  154. m_pioif->zivaio.HIO[5] = (BYTE)( ( Addr >> 8 ) & 0xff );
  155. m_pioif->zivaio.HIO[6] = (BYTE)( ( Addr >> 16 ) & 0xff );
  156. rcData = (BYTE)m_pioif->zivaio.HIO[3]; rcData = rcData << 8;
  157. rcData += (BYTE)m_pioif->zivaio.HIO[2]; rcData = rcData << 8;
  158. rcData += (BYTE)m_pioif->zivaio.HIO[1]; rcData = rcData << 8;
  159. rcData += (BYTE)m_pioif->zivaio.HIO[0];
  160. *Data = rcData;
  161. #ifdef ZIVA_DEBUG
  162. DBG_PRINTF(( "ZiVAReadMemory Addr = 0x%x Ret = 0x%x\n", Addr, *Data ));
  163. #endif
  164. m_pKernelObj->EnableHwInt();
  165. return 0;
  166. };
  167. //---------------------------------------------------------------------------
  168. // CZiVA::Init
  169. //---------------------------------------------------------------------------
  170. void CZiVA::Init( IKernelService *pKernelObj, CIOIF *pioif )
  171. {
  172. m_pioif = pioif;
  173. m_pKernelObj = pKernelObj;
  174. Host_Control.Init( this , 0x00 | 0x800000 );
  175. ROM_INFO.Init( this, ADDR_ROM_INFO );
  176. DRAM_INFO.Init( this, ADDR_DRAM_INFO );
  177. UCODE_MEMORY.Init( this, ADDR_UCODE_MEMORY );
  178. VIDEO_MODE.Init( this, ADDR_VIDEO_MODE );
  179. DISPLAY_ASPECT_RATIO.Init( this, ADDR_DISPLAY_ASPECT_RATIO );
  180. ASPECT_RATIO_MODE.Init( this, ADDR_ASPECT_RATIO_MODE );
  181. PAN_SCAN_SOURCE.Init( this, ADDR_PAN_SCAN_SOURCE );
  182. PAN_SCAN_HORIZONTAL_OFFSET.Init( this, ADDR_PAN_SCAN_HORIZONTAL_OFFSET );
  183. TOP_BORDER.Init( this, ADDR_TOP_BORDER );
  184. BORDER_COLOR.Init( this, ADDR_BORDER_COLOR );
  185. BACKGROUND_COLOR.Init( this, ADDR_BACKGROUND_COLOR );
  186. OSD_EVEN_FIELD.Init( this, ADDR_OSD_EVEN_FIELD );
  187. OSD_ODD_FIELD.Init( this, ADDR_OSD_ODD_FIELD );
  188. IC_TYPE.Init( this, ADDR_IC_TYPE );
  189. ERR_CONCEALMENT_LEVEL.Init( this, ADDR_ERR_CONCEALMENT_LEVEL );
  190. ERR_HORIZONTAL_SIZE.Init( this, ADDR_ERR_HORIZONTAL_SIZE );
  191. ERR_VERTICAL_SIZE.Init( this, ADDR_ERR_VERTICAL_SIZE );
  192. ERR_ASPECT_RATIO_INFORMATION.Init( this, ADDR_ERR_ASPECT_RATIO_INFORMATION );
  193. ERR_FRAME_RATE_CODE.Init( this, ADDR_ERR_FRAME_RATE_CODE );
  194. FORCE_CODED_ASPECT_RATIO.Init( this, ADDR_FORCE_CODED_ASPECT_RATIO );
  195. AUDIO_CONFIG.Init( this, ADDR_AUDIO_CONFIG );
  196. AUDIO_DAC_MODE.Init( this, ADDR_AUDIO_DAC_MODE );
  197. AUDIO_CLOCK_SELECTION.Init( this, ADDR_AUDIO_CLOCK_SELECTION );
  198. IEC_958_DELAY.Init( this, ADDR_IEC_958_DELAY );
  199. AUDIO_ATTENUATION.Init( this, ADDR_AUDIO_ATTENUATION );
  200. IEC_958_CHANNEL_STATUS_BITS.Init( this, ADDR_IEC_958_CHANNEL_STATUS_BITS );
  201. AC3_OUTPUT_MODE.Init( this, ADDR_AC3_OUTPUT_MODE );
  202. AC3_OPERATIONAL_MODE.Init( this, ADDR_AC3_OPERATIONAL_MODE );
  203. AC3_LOW_BOOST.Init( this, ADDR_AC3_LOW_BOOST );
  204. AC3_HIGH_CUT.Init( this, ADDR_AC3_HIGH_CUT );
  205. AC3_PCM_SCALE_FACTOR.Init( this, ADDR_AC3_PCM_SCALE_FACTOR );
  206. AC3_LFE_OUTPUT_ENABLE.Init( this, ADDR_AC3_LFE_OUTPUT_ENABLE );
  207. AC3_VOICE_SELECT.Init( this, ADDR_AC3_VOICE_SELECT );
  208. AC3_L_LEVEL.Init( this, ADDR_AC3_L_LEVEL );
  209. AC3_C_LEVEL.Init( this, ADDR_AC3_C_LEVEL );
  210. AC3_R_LEVEL.Init( this, ADDR_AC3_R_LEVEL );
  211. AC3_SL_LEVEL.Init( this, ADDR_AC3_SL_LEVEL );
  212. AC3_SR_LEVEL.Init( this, ADDR_AC3_SR_LEVEL );
  213. AC3_CENTER_DELAY.Init( this, ADDR_AC3_CENTER_DELAY );
  214. AC3_SURROUND_DELAY.Init( this, ADDR_AC3_SURROUND_DELAY );
  215. BITSTREAM_TYPE.Init( this, ADDR_BITSTREAM_TYPE );
  216. BITSTREAM_SOURCE.Init( this, ADDR_BITSTREAM_SOURCE );
  217. SD_MODE.Init( this, ADDR_SD_MODE );
  218. CD_MODE.Init( this, ADDR_CD_MODE );
  219. AV_SYNC_MODE.Init( this, ADDR_AV_SYNC_MODE );
  220. VIDEO_PTS_SKIP_INTERVAL.Init( this, ADDR_VIDEO_PTS_SKIP_INTERVAL );
  221. VIDEO_PTS_REPEAT_INTERVAL.Init( this, ADDR_VIDEO_PTS_REPEAT_INTERVAL );
  222. AUTOPAUSE_ENABLE.Init( this, ADDR_AUTOPAUSE_ENABLE );
  223. VIDEO_ENV_CHANGE.Init( this, ADDR_VIDEO_ENV_CHANGE );
  224. MEMCOPY_XFER_BLOCKSIZE.Init( this, ADDR_MEMCOPY_XFER_BLOCKSIZE );
  225. INT_MASK.Init( this, ADDR_INT_MASK );
  226. AUTO_FLUSH_INTERVAL.Init( this, ADDR_AUTO_FLUSH_INTERVAL );
  227. RDY_S_THRESHOLD_LOW.Init( this, ADDR_RDY_S_THRESHOLD_LOW );
  228. MEMORY_MAP.Init( this, ADDR_MEMORY_MAP );
  229. PCI_BUFFER_START.Init( this, ADDR_PCI_BUFFER_START );
  230. PCI_BUFFER_END.Init( this, ADDR_PCI_BUFFER_END );
  231. DSI_BUFFER_START.Init( this, ADDR_DSI_BUFFER_START );
  232. DSI_BUFFER_END.Init( this, ADDR_DSI_BUFFER_END );
  233. OSD_BUFFER_START.Init( this, ADDR_OSD_BUFFER_START );
  234. OSD_BUFFER_END.Init( this, ADDR_OSD_BUFFER_END );
  235. OSD_BUFFER_IDLE_START.Init( this, ADDR_OSD_BUFFER_IDLE_START );
  236. USER_DATA_BUFFER_START.Init( this, ADDR_USER_DATA_BUFFER_START );
  237. USER_DATA_BUFFER_END.Init( this, ADDR_USER_DATA_BUFFER_END );
  238. USER_DATA_READ.Init( this, ADDR_USER_DATA_READ );
  239. USER_DATA_WRITE.Init( this, ADDR_USER_DATA_WRITE );
  240. DUMP_DATA_BUFFER_START.Init( this, ADDR_DUMP_DATA_BUFFER_START );
  241. DUMP_DATA_BUFFER_END.Init( this, ADDR_DUMP_DATA_BUFFER_END );
  242. SUB_PICTURE_PALETTE_START.Init( this, ADDR_SUB_PICTURE_PALETTE_START );
  243. SUB_PICTURE_PALETTE_END.Init( this, ADDR_SUB_PICTURE_PALETTE_END );
  244. PROC_STATE.Init( this, ADDR_PROC_STATE );
  245. MRC_ID.Init( this, ADDR_MRC_ID );
  246. MRC_STATUS.Init( this, ADDR_MRC_STATUS );
  247. INT_STATUS.Init( this, ADDR_INT_STATUS );
  248. HLI_INT_SRC.Init( this, ADDR_HLI_INT_SRC );
  249. BUFF_INT_SRC.Init( this, ADDR_BUFF_INT_SRC );
  250. UND_INT_SRC.Init( this, ADDR_UND_INT_SRC );
  251. PBT_INT_SRC.Init( this, ADDR_PBT_INT_SRC );
  252. AOR_INT_SRC.Init( this, ADDR_AOR_INT_SRC );
  253. AEE_INT_SRC.Init( this, ADDR_AEE_INT_SRC );
  254. ERR_INT_SRC.Init( this, ADDR_ERR_INT_SRC );
  255. VIDEO_EMPTINESS.Init( this, ADDR_VIDEO_EMPTINESS );
  256. AUDIO_EMPTINESS.Init( this, ADDR_AUDIO_EMPTINESS );
  257. CURR_PIC_DISPLAYED.Init( this, ADDR_CURR_PIC_DISPLAYED );
  258. NEXT_PIC_DISPLAYED.Init( this, ADDR_NEXT_PIC_DISPLAYED );
  259. VIDEO_FIELD.Init( this, ADDR_VIDEO_FIELD );
  260. OSD_VALID.Init( this, ADDR_OSD_VALID );
  261. NUM_DECODED.Init( this, ADDR_NUM_DECODED );
  262. NUM_SKIPPED.Init( this, ADDR_NUM_SKIPPED );
  263. NUM_REPEATED.Init( this, ADDR_NUM_REPEATED );
  264. MRC_PIC_PTS.Init( this, ADDR_MRC_PIC_PTS );
  265. MRC_PIC_STC.Init( this, ADDR_MRC_PIC_STC );
  266. N_AUD_DECODED.Init( this, ADDR_N_AUD_DECODED );
  267. NEXT_SECTOR_ADDR.Init( this, ADDR_NEXT_SECTOR_ADDR );
  268. N_SYS_ERRORS.Init( this, ADDR_N_SYS_ERRORS );
  269. N_VID_ERRORS.Init( this, ADDR_N_VID_ERRORS );
  270. N_AUD_ERRORS.Init( this, ADDR_N_AUD_ERRORS );
  271. DATE_TIME.Init( this, ADDR_DATE_TIME );
  272. VERSION.Init( this, ADDR_VERSION );
  273. EXTENDED_VERSION.Init( this, ADDR_EXTENDED_VERSION );
  274. PIC1_BUFFER_START.Init( this, ADDR_PIC1_BUFFER_START );
  275. PIC1_PTS.Init( this, ADDR_PIC1_PTS );
  276. PIC1_PAN_SCAN.Init( this, ADDR_PIC1_PAN_SCAN );
  277. PIC1_USER_DATA.Init( this, ADDR_PIC1_USER_DATA );
  278. PIC1_TREF_PTYP_FLGS.Init( this, ADDR_PIC1_TREF_PTYP_FLGS );
  279. PIC2_BUFFER_START.Init( this, ADDR_PIC2_BUFFER_START );
  280. PIC2_PTS.Init( this, ADDR_PIC2_PTS );
  281. PIC2_PAN_SCAN.Init( this, ADDR_PIC2_PAN_SCAN );
  282. PIC2_USER_DATA.Init( this, ADDR_PIC2_USER_DATA );
  283. PIC2_TREF_PTYP_FLGS.Init( this, ADDR_PIC2_TREF_PTYP_FLGS );
  284. PIC3_BUFFER_START.Init( this, ADDR_PIC3_BUFFER_START );
  285. PIC3_PTS.Init( this, ADDR_PIC3_PTS );
  286. PIC3_PAN_SCAN.Init( this, ADDR_PIC3_PAN_SCAN );
  287. PIC3_USER_DATA.Init( this, ADDR_PIC3_USER_DATA );
  288. PIC3_TREF_PTYP_FLGS.Init( this, ADDR_PIC3_TREF_PTYP_FLGS );
  289. STREAM_ID.Init( this, ADDR_STREAM_ID );
  290. PACKET_LEN.Init( this, ADDR_PACKET_LEN );
  291. PES_HEADER.Init( this, ADDR_PES_HEADER );
  292. SUBPIC_EMPTINESS.Init( this, ADDR_SUBPIC_EMPTINESS );
  293. H_SIZE.Init( this, ADDR_H_SIZE );
  294. V_SIZE.Init( this, ADDR_V_SIZE );
  295. APSECT_RATIO.Init( this, ADDR_APSECT_RATIO );
  296. FRAME_RATE.Init( this, ADDR_FRAME_RATE );
  297. BIT_RATE.Init( this, ADDR_BIT_RATE );
  298. VBV_SIZE.Init( this, ADDR_VBV_SIZE );
  299. SEQ_FLAGS.Init( this, ADDR_SEQ_FLAGS );
  300. DISP_SIZE_H_V.Init( this, ADDR_DISP_SIZE_H_V );
  301. TIME_CODE.Init( this, ADDR_TIME_CODE );
  302. GOP_FLAGS.Init( this, ADDR_GOP_FLAGS );
  303. TEMP_REF.Init( this, ADDR_TEMP_REF );
  304. PIC_TYPE.Init( this, ADDR_PIC_TYPE );
  305. VBV_DELAY.Init( this, ADDR_VBV_DELAY );
  306. PIC_HEADER.Init( this, ADDR_PIC_HEADER );
  307. AUDIO_TYPE.Init( this, ADDR_AUDIO_TYPE );
  308. MPEG_AUDIO_HEADER1.Init( this, ADDR_MPEG_AUDIO_HEADER1 );
  309. AC3_FRAME_NUMBER.Init( this, ADDR_AC3_FRAME_NUMBER );
  310. LPCM_AUDIO_EMPHASIS_FLAG.Init( this, ADDR_LPCM_AUDIO_EMPHASIS_FLAG );
  311. MPEG_AUDIO_HEADER2.Init( this, ADDR_MPEG_AUDIO_HEADER2 );
  312. LPCM_AUDIO_MUTE_FLAG.Init( this, ADDR_LPCM_AUDIO_MUTE_FLAG );
  313. AC3_BSI_IS_BEING_READ.Init( this, ADDR_AC3_BSI_IS_BEING_READ );
  314. LPCM_AUDIO_FRAME_NUMBER.Init( this, ADDR_LPCM_AUDIO_FRAME_NUMBER );
  315. AC3_BSI_VALID.Init( this, ADDR_AC3_BSI_VALID );
  316. LPCM_AUDIO_QUANTIZATION_WORD_LENGTH.Init( this, ADDR_LPCM_AUDIO_QUANTIZATION_WORD_LENGTH );
  317. AC3_BSI_FRAME.Init( this, ADDR_AC3_BSI_FRAME );
  318. LPCM_AUDIO_SAMPLING_FREQUENCY.Init( this, ADDR_LPCM_AUDIO_SAMPLING_FREQUENCY );
  319. AC3_FSCOD_FRMSIZECOD.Init( this, ADDR_AC3_FSCOD_FRMSIZECOD );
  320. LPCM_AUDIO_NUMBER_OF_AUDIO_CHANNELS.Init( this, ADDR_LPCM_AUDIO_NUMBER_OF_AUDIO_CHANNELS );
  321. AC3_BSID_BSMOD.Init( this, ADDR_AC3_BSID_BSMOD );
  322. LPCM_AUDIO_DYNAMIC_RANGE_CONTROL.Init( this, ADDR_LPCM_AUDIO_DYNAMIC_RANGE_CONTROL );
  323. AC3_ACMOD_CMIXLEV.Init( this, ADDR_AC3_ACMOD_CMIXLEV );
  324. AC3_SURMIXLEV_DSURMOD.Init( this, ADDR_AC3_SURMIXLEV_DSURMOD );
  325. AC3_LFEON_DIALNORM.Init( this, ADDR_AC3_LFEON_DIALNORM );
  326. AC3_COMPR_LANGCOD.Init( this, ADDR_AC3_COMPR_LANGCOD );
  327. AC3_MIXLEV_ROOMTYP.Init( this, ADDR_AC3_MIXLEV_ROOMTYP );
  328. AC3_DIALNORM2_COMPR2.Init( this, ADDR_AC3_DIALNORM2_COMPR2 );
  329. AC3_LANGCOD2_MIXLEV2.Init( this, ADDR_AC3_LANGCOD2_MIXLEV2 );
  330. AC3_ROOMTYP2_COPYRIGHTB.Init( this, ADDR_AC3_ROOMTYP2_COPYRIGHTB );
  331. AC3_ORIGBS_TIMECOD1.Init( this, ADDR_AC3_ORIGBS_TIMECOD1 );
  332. // AC3_TIMECOD2.Init( this, ADDR_AC3_TIMECOD2 ); // 98.04.02 H.Yagi
  333. AC3_TIMECOD2.Init( this, ADDR_AC3_TIMECOD2_EBITS ); // 98.04.02 H.Yagi
  334. SE_STATUS.Init( this, ADDR_SE_STATUS );
  335. NEW_AUDIO_MODE.Init( this, ADDR_NEW_AUDIO_MODE );
  336. NEW_SUBPICTURE_PALETTE.Init( this, ADDR_NEW_SUBPICTURE_PALETTE );
  337. NEW_AUDIO_CONFIG.Init( this, ADDR_NEW_AUDIO_CONFIG );
  338. VSYNC_HEARTBEAT.Init( this, ADDR_VSYNC_HEARTBEAT );
  339. ML_HEARTBEAT.Init( this, ADDR_ML_HEARTBEAT );
  340. SUBPICTURE_ENABLE.Init( this, ADDR_SUBPICTURE_ENABLE );
  341. HIGHLIGHT_ENABLE.Init( this, ADDR_HIGHLIGHT_ENABLE );
  342. CURRENT_BUTTON.Init( this, ADDR_CURRENT_BUTTON );
  343. ERR_MPEG_VERSION.Init( this, ADDR_ERR_MPEG_VERSION ); // 98.04.02 H.Yagi
  344. VERTICAL_DISPLAYMODE.Init( this, ADDR_VERTICAL_DISPLAYMODE ); // 98.04.02 H.Yagi
  345. AC3_ENGINE_VERSION.Init( this, ADDR_AC3_ENGINE_VERSION ); // 98.04.02 H.Yagi
  346. ROM_END_POINTER.Init( this, ADDR_ROM_END_POINTER ); // 98.04.02 H.Yagi
  347. CURRENT_VOB_CELL_ID.Init( this, ADDR_CURRENT_VOB_CELL_ID ); // 98.04.02 H.Yagi
  348. PREV_VOBU_VIDEO_RLBN.Init( this, ADDR_PREV_VOBU_VIDEO_RLBN ); // 98.04.02 H.Yagi
  349. // Authentication for only ZiVA1.1 or later // Yagi
  350. KEY_ADDRESS.Init( this, 0x480 );
  351. KEY_LENGTH.Init( this, 0x484 );
  352. // toshiba special
  353. AU_CLK_INOUT.Init( this, 0xf8 );
  354. IDLE_DELAY.Init( this, ADDR_IDLE_DELAY );
  355. // 98.05.29 H.Yagi
  356. HOST_OPTIONS.Init( this, ADDR_HOST_OPTIONS );
  357. };
  358. void CZiVA::CppInit( DWORD gKeyAddress )
  359. {
  360. KEY_COMMAND.Init( this, gKeyAddress );
  361. KEY_STATUS.Init( this, gKeyAddress+1*4 );
  362. DRIVE_CHALLENGE_0.Init( this, gKeyAddress+2*4 );
  363. DRIVE_CHALLENGE_1.Init( this, gKeyAddress+3*4 );
  364. DRIVE_CHALLENGE_2.Init( this, gKeyAddress+4*4 );
  365. DRIVE_CHALLENGE_3.Init( this, gKeyAddress+5*4 );
  366. DRIVE_CHALLENGE_4.Init( this, gKeyAddress+6*4 );
  367. DRIVE_CHALLENGE_5.Init( this, gKeyAddress+7*4 );
  368. DRIVE_CHALLENGE_6.Init( this, gKeyAddress+8*4 );
  369. DRIVE_CHALLENGE_7.Init( this, gKeyAddress+9*4 );
  370. DRIVE_CHALLENGE_8.Init( this, gKeyAddress+10*4 );
  371. DRIVE_CHALLENGE_9.Init( this, gKeyAddress+11*4 );
  372. DECODER_CHALLENGE_0.Init( this, gKeyAddress+12*4 );
  373. DECODER_CHALLENGE_1.Init( this, gKeyAddress+13*4 );
  374. DECODER_CHALLENGE_2.Init( this, gKeyAddress+14*4 );
  375. DECODER_CHALLENGE_3.Init( this, gKeyAddress+15*4 );
  376. DECODER_CHALLENGE_4.Init( this, gKeyAddress+16*4 );
  377. DECODER_CHALLENGE_5.Init( this, gKeyAddress+17*4 );
  378. DECODER_CHALLENGE_6.Init( this, gKeyAddress+18*4 );
  379. DECODER_CHALLENGE_7.Init( this, gKeyAddress+19*4 );
  380. DECODER_CHALLENGE_8.Init( this, gKeyAddress+20*4 );
  381. DECODER_CHALLENGE_9.Init( this, gKeyAddress+21*4 );
  382. DRIVE_RESULT_0.Init( this, gKeyAddress+22*4 );
  383. DRIVE_RESULT_1.Init( this, gKeyAddress+23*4 );
  384. DRIVE_RESULT_2.Init( this, gKeyAddress+24*4 );
  385. DRIVE_RESULT_3.Init( this, gKeyAddress+25*4 );
  386. DRIVE_RESULT_4.Init( this, gKeyAddress+26*4 );
  387. DECODER_RESULT_0.Init( this, gKeyAddress+27*4 );
  388. DECODER_RESULT_1.Init( this, gKeyAddress+28*4 );
  389. DECODER_RESULT_2.Init( this, gKeyAddress+29*4 );
  390. DECODER_RESULT_3.Init( this, gKeyAddress+30*4 );
  391. DECODER_RESULT_4.Init( this, gKeyAddress+31*4 );
  392. TITLE_KEY_0.Init( this, gKeyAddress+32*4 );
  393. TITLE_KEY_1.Init( this, gKeyAddress+33*4 );
  394. TITLE_KEY_2.Init( this, gKeyAddress+34*4 );
  395. TITLE_KEY_3.Init( this, gKeyAddress+35*4 );
  396. TITLE_KEY_4.Init( this, gKeyAddress+36*4 );
  397. };
  398. //---------------------------------------------------------------------------
  399. // CZiVA::ZiVACommand
  400. //---------------------------------------------------------------------------
  401. ZIVARESULT CZiVA::ZiVACommand( DWORD CommandID, DWORD d1, DWORD d2, DWORD d3, DWORD d4, DWORD d5, DWORD d6 )
  402. {
  403. ASSERT( m_pioif != NULL );
  404. DWORD StatusPointer = 0;
  405. DWORD ZiVAStatus = 0;
  406. CTimeOut TimeOut( COMMAND_TIMEOUT, 1 , m_pKernelObj );
  407. // status pointer check?
  408. while( TRUE )
  409. {
  410. ZiVAReadMemory(ADDR_STATUS_ADDRESS, &StatusPointer);
  411. if( StatusPointer != 0 )
  412. {
  413. ZiVAReadMemory( StatusPointer, &ZiVAStatus );
  414. // DBG_PRINTF( ("ZiVA Status = 0x%x\n", ZiVAStatus ));
  415. break;
  416. };
  417. // Sleep
  418. TimeOut.Sleep();
  419. // check Time out....... 1 sec
  420. if( TimeOut.CheckTimeOut() == TRUE )
  421. return ZIVARESULT_TIMEOUT;
  422. };
  423. m_pKernelObj->DisableHwInt();
  424. ZiVAWriteMemory( ADDR_COMMAND, CommandID );
  425. ZiVAWriteMemory( ADDR_PARAMETER_1, d1 );
  426. ZiVAWriteMemory( ADDR_PARAMETER_2, d2 );
  427. ZiVAWriteMemory( ADDR_PARAMETER_3, d3 );
  428. ZiVAWriteMemory( ADDR_PARAMETER_4, d4 );
  429. ZiVAWriteMemory( ADDR_PARAMETER_5, d5 );
  430. ZiVAWriteMemory( ADDR_PARAMETER_6, d6 );
  431. ZiVAWriteMemory( ADDR_STATUS_ADDRESS, 0x00 ); // zero the status pointer
  432. // interrupt
  433. // Host_Control |= 0x10C2;
  434. m_pKernelObj->EnableHwInt();
  435. CTimeOut TimeOut2( COMMAND_TIMEOUT, 1, m_pKernelObj );
  436. // status pointer check?
  437. while( TRUE )
  438. {
  439. ZiVAReadMemory(ADDR_STATUS_ADDRESS, &StatusPointer);
  440. if( StatusPointer != 0 )
  441. {
  442. ZiVAReadMemory( StatusPointer, &ZiVAStatus );
  443. DBG_PRINTF( ("ZiVA Status = 0x%x\n", ZiVAStatus ));
  444. break;
  445. };
  446. // Sleep
  447. TimeOut2.Sleep();
  448. // check Time out....... 1 sec
  449. if( TimeOut2.CheckTimeOut() == TRUE )
  450. return ZIVARESULT_TIMEOUT;
  451. };
  452. return ZIVARESULT_NOERROR;
  453. };
  454. //---------------------------------------------------------------------------
  455. // CZiVA::ZiVACommandNoWait
  456. //---------------------------------------------------------------------------
  457. ZIVARESULT CZiVA::ZiVACommandNoWait( DWORD CommandID, DWORD d1, DWORD d2, DWORD d3, DWORD d4, DWORD d5, DWORD d6 )
  458. {
  459. ASSERT( m_pioif != NULL );
  460. DWORD StatusPointer = 0;
  461. // DWORD ZiVAStatus = 0;
  462. // status pointer check?
  463. ZiVAReadMemory(ADDR_STATUS_ADDRESS, &StatusPointer);
  464. if( StatusPointer == 0 )
  465. return ZIVARESULT_TIMEOUT;
  466. m_pKernelObj->DisableHwInt();
  467. ZiVAWriteMemory( ADDR_COMMAND, CommandID );
  468. ZiVAWriteMemory( ADDR_PARAMETER_1, d1 );
  469. ZiVAWriteMemory( ADDR_PARAMETER_2, d2 );
  470. ZiVAWriteMemory( ADDR_PARAMETER_3, d3 );
  471. ZiVAWriteMemory( ADDR_PARAMETER_4, d4 );
  472. ZiVAWriteMemory( ADDR_PARAMETER_5, d5 );
  473. ZiVAWriteMemory( ADDR_PARAMETER_6, d6 );
  474. ZiVAWriteMemory( ADDR_STATUS_ADDRESS, 0x00 ); // zero the status pointer
  475. // interrupt
  476. // Host_Control |= 0x10C2;
  477. m_pKernelObj->EnableHwInt();
  478. ZiVAReadMemory(ADDR_STATUS_ADDRESS, &StatusPointer);
  479. if( StatusPointer == 0 )
  480. return ZIVARESULT_TIMEOUT;
  481. return ZIVARESULT_NOERROR;
  482. };
  483. //---------------------------------------------------------------------------
  484. // CZiVA::Abort
  485. //---------------------------------------------------------------------------
  486. ZIVARESULT CZiVA::Abort( DWORD Flush )
  487. {
  488. #ifdef DEBUG_ZIVA_COMMAND
  489. DBG_PRINTF( ("CZiVA::Abort 0x%x\n",Flush ));
  490. #endif
  491. return ZiVACommand( ABORT , Flush );
  492. };
  493. //---------------------------------------------------------------------------
  494. // CZiVA::Digest
  495. //---------------------------------------------------------------------------
  496. ZIVARESULT CZiVA::Digest( DWORD x, DWORD y, DWORD decimation, DWORD threshold, DWORD start )
  497. {
  498. #ifdef DEBUG_ZIVA_COMMAND
  499. DBG_PRINTF( ("CZiVA::Digest 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", x, y, decimation, threshold, start ));
  500. #endif
  501. return ZiVACommand( DIGEST , x, y, decimation, threshold, start );
  502. };
  503. //---------------------------------------------------------------------------
  504. // CZiVA::DumpDumpData_VCD
  505. //---------------------------------------------------------------------------
  506. ZIVARESULT CZiVA::DumpData_VCD( DWORD start, DWORD length, DWORD address )
  507. {
  508. #ifdef DEBUG_ZIVA_COMMAND
  509. DBG_PRINTF( ("CZiVA::DumpData_VCD 0x%x, 0x%x, 0x%x\n", start, length, address ));
  510. #endif
  511. return ZiVACommand( DUMPDATA_VCD , start, length, address );
  512. };
  513. //---------------------------------------------------------------------------
  514. // CZiVA::DumpData_DVD
  515. //---------------------------------------------------------------------------
  516. ZIVARESULT CZiVA::DumpData_DVD( DWORD numberOfBytes )
  517. {
  518. #ifdef DEBUG_ZIVA_COMMAND
  519. DBG_PRINTF( (" CZiVA::DumpData_DVD 0x%x\n", numberOfBytes ));
  520. #endif
  521. return ZiVACommand( DUMPDATA_DVD , numberOfBytes );
  522. };
  523. //---------------------------------------------------------------------------
  524. // CZiVA::Fade
  525. //---------------------------------------------------------------------------
  526. ZIVARESULT CZiVA::Fade( DWORD level, DWORD fadetime )
  527. {
  528. #ifdef DEBUG_ZIVA_COMMAND
  529. DBG_PRINTF( ("CZiVA::Fade 0x%x, 0x%x\n", level, fadetime ));
  530. #endif
  531. return ZiVACommand( FADE , level, fadetime );
  532. };
  533. //---------------------------------------------------------------------------
  534. // CZiVA::Freeze
  535. //---------------------------------------------------------------------------
  536. ZIVARESULT CZiVA::Freeze( DWORD displayMode )
  537. {
  538. #ifdef DEBUG_ZIVA_COMMAND
  539. DBG_PRINTF( ("CZiVA::Freeze 0x%x\n", displayMode ));
  540. #endif
  541. return ZiVACommand( FREEZE , displayMode );
  542. };
  543. //---------------------------------------------------------------------------
  544. // CZiVA::HighLight
  545. //---------------------------------------------------------------------------
  546. // by oka
  547. ZIVARESULT CZiVA::HighLight( DWORD button, DWORD action )
  548. {
  549. #ifdef DEBUG_ZIVA_COMMAND
  550. DBG_PRINTF( ("CZiVA::HighLight 0x%x, 0x%x, 0x%x\n", button, group, action ));
  551. #endif
  552. // by oka
  553. return ZiVACommand( HIGHLIGHT , button, action );
  554. };
  555. //---------------------------------------------------------------------------
  556. // CZiVA::HighLight2
  557. //---------------------------------------------------------------------------
  558. ZIVARESULT CZiVA::HighLight2( DWORD Contrast, DWORD Color, DWORD YGeom, DWORD XGeom )
  559. {
  560. #ifdef DEBUG_ZIVA_COMMAND
  561. DBG_PRINTF( ("CZiVA::HighLight2 0x%x, 0x%x, 0x%x, 0x%x\n", Contrast, Color, YGeom, XGeom ));
  562. #endif
  563. return ZiVACommand( HIGHLIGHT2,Contrast, Color, YGeom, XGeom );
  564. };
  565. /*
  566. //---------------------------------------------------------------------------
  567. // CZiVA::NewAudioMode
  568. //---------------------------------------------------------------------------
  569. ZIVARESULT CZiVA::NewAudioMode( void )
  570. {
  571. #ifdef DEBUG_ZIVA_COMMAND
  572. DBG_PRINTF( ("CZiVA::NewAudioMode\n" ));
  573. #endif
  574. return ZiVACommand( 0x0027 );
  575. };
  576. */
  577. //---------------------------------------------------------------------------
  578. // CZiVA::NewPlayMode
  579. //---------------------------------------------------------------------------
  580. ZIVARESULT CZiVA::NewPlayMode( void )
  581. {
  582. #ifdef DEBUG_ZIVA_COMMAND
  583. DBG_PRINTF( ("CZiVA::NewPlayMode\n" ));
  584. #endif
  585. return ZiVACommand( NEWPLAYMODE );
  586. };
  587. //---------------------------------------------------------------------------
  588. // CZiVA::Pause
  589. //---------------------------------------------------------------------------
  590. ZIVARESULT CZiVA::Pause( DWORD displaymode )
  591. {
  592. #ifdef DEBUG_ZIVA_COMMAND
  593. DBG_PRINTF( ("CZiVA::Pause 0x%x\n" , displaymode ));
  594. #endif
  595. return ZiVACommand( PAUSE , displaymode );
  596. };
  597. //---------------------------------------------------------------------------
  598. // CZiVA::Play
  599. //---------------------------------------------------------------------------
  600. ZIVARESULT CZiVA::Play( DWORD playmode, DWORD fadetime, DWORD start, DWORD stop )
  601. {
  602. #ifdef DEBUG_ZIVA_COMMAND
  603. DBG_PRINTF( ("CZiVA::Play 0x%x, 0x%x, 0x%x, 0x%x\n" , playmode, fadetime, start, stop ));
  604. #endif
  605. return ZiVACommand( PLAY , playmode, fadetime, start, stop );
  606. };
  607. //---------------------------------------------------------------------------
  608. // CZiVA::MemCopy(ROMtoDRAM)
  609. //---------------------------------------------------------------------------
  610. ZIVARESULT CZiVA::MemCopy( DWORD romAddr, DWORD dramAddr, DWORD Length )
  611. {
  612. #ifdef DEBUG_ZIVA_COMMAND
  613. DBG_PRINTF( ("CZiVA::MemCopy 0x%x, 0x%x, 0x%x\n", romAddr, dramAddr, Length ));
  614. #endif
  615. return ZiVACommand( MEMCOPY , romAddr, dramAddr, Length );
  616. };
  617. //---------------------------------------------------------------------------
  618. // CZiVA::Reset
  619. //---------------------------------------------------------------------------
  620. ZIVARESULT CZiVA::Reset( void )
  621. {
  622. #ifdef DEBUG_ZIVA_COMMAND
  623. DBG_PRINTF( ("CZiVA::Reset\n" ));
  624. #endif
  625. return ZiVACommand( RESET );
  626. };
  627. //---------------------------------------------------------------------------
  628. //
  629. //---------------------------------------------------------------------------
  630. //ZIVARESULT CZiVA::Resume( DWORD playmode )
  631. //{
  632. // return ZiVACommand( 0x012e , playmode );
  633. //};
  634. //---------------------------------------------------------------------------
  635. // CZiVA::Resume
  636. //---------------------------------------------------------------------------
  637. ZIVARESULT CZiVA::Resume( void )
  638. {
  639. #ifdef DEBUG_ZIVA_COMMAND
  640. DBG_PRINTF( ("CZiVA::Resume\n" ));
  641. #endif
  642. return ZiVACommand( RESUME );
  643. };
  644. //---------------------------------------------------------------------------
  645. // CZiVA::Scan
  646. //---------------------------------------------------------------------------
  647. ZIVARESULT CZiVA::Scan( DWORD skip, DWORD scanmode, DWORD displaymode )
  648. {
  649. #ifdef DEBUG_ZIVA_COMMAND
  650. DBG_PRINTF( ("CZiVA::Scan 0x%x, 0x%x, 0x%x\n", skip, scanmode, displaymode ));
  651. #endif
  652. return ZiVACommand( SCAN , skip, scanmode, displaymode );
  653. };
  654. //---------------------------------------------------------------------------
  655. // CZiVA::ScreenLoad
  656. //---------------------------------------------------------------------------
  657. ZIVARESULT CZiVA::ScreenLoad( DWORD address, DWORD length, DWORD displaymode )
  658. {
  659. #ifdef DEBUG_ZIVA_COMMAND
  660. DBG_PRINTF( ("CZiVA::ScreenLoad 0x%x0, 0x%x, 0x%x\n", address, length, displaymode ));
  661. #endif
  662. return ZiVACommand( SCREENLOAD , address, length, displaymode );
  663. };
  664. //---------------------------------------------------------------------------
  665. // CZiVA::SelectStream
  666. //---------------------------------------------------------------------------
  667. ZIVARESULT CZiVA::SelectStream( DWORD streamtype, DWORD streamnumber )
  668. {
  669. #ifdef DEBUG_ZIVA_COMMAND
  670. DBG_PRINTF( ("CZiVA::SelectStream 0x%x, 0x%x\n", streamtype, streamnumber ));
  671. #endif
  672. return ZiVACommand( SELECTSTREAM , streamtype, streamnumber );
  673. };
  674. //---------------------------------------------------------------------------
  675. // CZiVA::SetFill
  676. //---------------------------------------------------------------------------
  677. ZIVARESULT CZiVA::SetFill( DWORD x, DWORD y, DWORD length, DWORD height, DWORD color )
  678. {
  679. #ifdef DEBUG_ZIVA_COMMAND
  680. DBG_PRINTF( ("CZiVA::SetFill 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", x, y, length, height, color ));
  681. #endif
  682. return ZiVACommand( SETFILL , x, y, length, height, color );
  683. };
  684. //---------------------------------------------------------------------------
  685. // CZiVA::SetStreams
  686. //---------------------------------------------------------------------------
  687. ZIVARESULT CZiVA::SetStreams( DWORD videoID, DWORD audioID )
  688. {
  689. #ifdef DEBUG_ZIVA_COMMAND
  690. DBG_PRINTF( ("CZiVA::SetStreams 0x%x, 0x%x\n", videoID, audioID ));
  691. #endif
  692. return ZiVACommand( SETSTREAMS , videoID, audioID );
  693. };
  694. //---------------------------------------------------------------------------
  695. // CZiVA::SingleStep
  696. //---------------------------------------------------------------------------
  697. ZIVARESULT CZiVA::SingleStep( DWORD displaymode )
  698. {
  699. #ifdef DEBUG_ZIVA_COMMAND
  700. DBG_PRINTF( ("CZiVA::SingleStep 0x%x\n", displaymode ));
  701. #endif
  702. return ZiVACommand( SINGLESTEP , displaymode );
  703. };
  704. //---------------------------------------------------------------------------
  705. // CZiVA::SlowMotion
  706. //---------------------------------------------------------------------------
  707. ZIVARESULT CZiVA::SlowMotion( DWORD N, DWORD displaymode )
  708. {
  709. #ifdef DEBUG_ZIVA_COMMAND
  710. DBG_PRINTF( ("CZiVA::SlowMotion 0x%x, 0x%x\n", N, displaymode ));
  711. #endif
  712. return ZiVACommand( SLOWMOTION , N, displaymode );
  713. };
  714. // by oka
  715. //---------------------------------------------------------------------------
  716. // CZiVA::Magnify
  717. //---------------------------------------------------------------------------
  718. ZIVARESULT CZiVA::Magnify( DWORD x, DWORD y, DWORD factor )
  719. {
  720. #ifdef DEBUG_ZIVA_COMMAND
  721. DBG_PRINTF( ("CZiVA::Magnify 0x%x, 0x%x\n", x,y,factor ));
  722. #endif
  723. return ZiVACommand( MAGNIFY , x, y, factor );
  724. };
  725. /*
  726. //---------------------------------------------------------------------------
  727. // CZiVA::SwitchOSDBuffer
  728. //---------------------------------------------------------------------------
  729. ZIVARESULT CZiVA::SwitchOSDBuffer( DWORD evenfield, DWORD oddfield )
  730. {
  731. return ZiVACommand( 0x8254 , evenfield, oddfield );
  732. }
  733. */
  734. ZIVARESULT CZiVA::TransferKey( DWORD KeyType, DWORD Authenticate )
  735. {
  736. #ifdef DEBUG_ZIVA_COMMAND
  737. DBG_PRINTF( (" CZiVA::TransferKey 0x%x, 0x%x\n", KeyType, Authenticate ));
  738. #endif
  739. return ZiVACommand( 0x0137 , KeyType, Authenticate );
  740. }
  741. //===================================================
  742. // ZiVA register ACCESS functions.
  743. //===================================================
  744. // CL6100 GBUS map
  745. #define CF_read1 0x2d
  746. #define CF_intrpt 0x1c // all the CFIFO registers changed
  747. #define CF_command 0x1f
  748. #define CPU_imdt 0x34 // IMEM data register
  749. #define CPU_imadr 0x36 // IMEM read/write pointer
  750. #define CPU_index 0x3a // index register for indirect regs
  751. #define CPU_idxdt 0x3b // data port for indirect regs
  752. #define HOST_control 0x00
  753. #define DMA_adr 0x22 // DMA Indirect Index registe
  754. #define DMA_MODE 0x0f // DMA Mode Setting register
  755. #define DMA_data 0x23 // DMA Indirect Data register
  756. #define DMA_CYCLE 0x11 // DMA Cycle register to define rom cycle/size
  757. #define CPU_PC 0x9 // IMEM instruction pointer register
  758. #define CPU_DIR 0xA // instruction register
  759. //---------------------------------------------------------------------------
  760. // CZiVA::ZiVAWriteReg
  761. //---------------------------------------------------------------------------
  762. DWORD CZiVA::ZiVAWriteReg(DWORD Addr, DWORD Data )
  763. {
  764. return ZiVAWriteMemory( Addr | 0x800000 , Data );
  765. };
  766. //---------------------------------------------------------------------------
  767. // CZiVA::ZiVAReadReg
  768. //---------------------------------------------------------------------------
  769. DWORD CZiVA::ZiVAReadReg(DWORD Addr, DWORD *Data )
  770. {
  771. return ZiVAReadMemory( Addr | 0x800000 , Data );
  772. };
  773. //---------------------------------------------------------------------------
  774. // ZiVA::ZiVAWriteIMEM
  775. //---------------------------------------------------------------------------
  776. DWORD CZiVA::ZiVAWriteIMEM(DWORD Addr, DWORD Data )
  777. {
  778. ZiVAWriteReg( CPU_imadr, Addr );
  779. return ZiVAWriteReg( CPU_imdt, Data );
  780. };
  781. //---------------------------------------------------------------------------
  782. // ZiVA::ZiVAReadIMEM
  783. //---------------------------------------------------------------------------
  784. DWORD CZiVA::ZiVAReadIMEM(DWORD Addr, DWORD *Data )
  785. {
  786. ZiVAWriteReg( CPU_index, 0x0b );
  787. ZiVAWriteReg( CPU_idxdt, Addr );
  788. ZiVAWriteReg( CPU_index, 0x0e );
  789. return ZiVAReadReg( CPU_idxdt , Data );
  790. };
  791. //---------------------------------------------------------------------------
  792. // CZiVA::load_GetDWORD
  793. //---------------------------------------------------------------------------
  794. DWORD CZiVA::load_GetDWORD()
  795. {
  796. DWORD dwResult = gpbRead[0] + (gpbRead[1] << 8) + (gpbRead[2] << 16) + (gpbRead[3] << 24);
  797. gpbRead += 4;
  798. return dwResult;
  799. };
  800. //---------------------------------------------------------------------------
  801. // CZiVA::load_GetDWORDSwap
  802. //---------------------------------------------------------------------------
  803. DWORD CZiVA::load_GetDWORDSwap()
  804. {
  805. DWORD dwResult = gpbRead[3] + (gpbRead[2] << 8) + (gpbRead[1] << 16) + (gpbRead[0] << 24);
  806. gpbRead += 4;
  807. return dwResult;
  808. };
  809. //---------------------------------------------------------------------------
  810. // CZiVA::load_GetDWORDSwapBackward
  811. //---------------------------------------------------------------------------
  812. DWORD CZiVA::load_GetDWORDSwapBackward()
  813. {
  814. DWORD dwResult = gpbRead[3] + (gpbRead[2] << 8) + (gpbRead[1] << 16) + (gpbRead[0] << 24);
  815. gpbRead -= 4;
  816. return dwResult;
  817. };
  818. #define IMEM_START_OFFSET 0x800 // byte offset
  819. #define IMEM_LENGTH 0xFF // in 32-bit words
  820. #define DRAM_IMAGE_LENGTH 0x7FF // in bytes
  821. #define GBUS_TABLE_OFFSET 0xBFC // byte offset
  822. #define STREAM_SOURCE 0x0 // SD Interface
  823. #define SD_MODE 0xD // For SD Interface
  824. //===================================================
  825. // ZiVA Microcode Downloading
  826. //===================================================
  827. //---------------------------------------------------------------------------
  828. // CZiVA::WriteMicrocode
  829. //---------------------------------------------------------------------------
  830. // Type 0:NTSC , 1:PAL
  831. BOOL CZiVA::WriteMicrocode( DWORD Type )
  832. {
  833. DWORD dwSectionLength; // Section length in bytes
  834. DWORD dwSectionAddress; // Start address in DRAM (WORD address)
  835. DWORD dwSectionChecksum; // Section check sum value
  836. DWORD dwCnt; // Counter of the bytes written to the DVD chip
  837. DWORD dwAddress; // Current DRAM address (byte address)
  838. BYTE * pbUCodeStart; // Sarting point of the UCode in the buffer (file)
  839. BYTE * pbFinalGBUSStart; // Sarting point of the final GBUS writes.
  840. DWORD dwTmp;
  841. BYTE TmpTmp;
  842. gpbRead = UXData; // Set pointer to the beginning of the buffer
  843. // I-MODE SETING!!!
  844. TmpTmp = m_pioif->zivaio.HIO[7];
  845. // A. Skip the initial header of the file (12 bytes)
  846. gpbRead += 12;
  847. // B. Skip data_type, section flags and unused (4 bytes)
  848. gpbRead += 4;
  849. dwSectionLength = load_GetDWORD();
  850. dwSectionAddress = load_GetDWORD();
  851. dwSectionChecksum = load_GetDWORD();
  852. // Remember the start of the UCode.
  853. pbUCodeStart = gpbRead;
  854. // C.1. Configuration-specific GBUS writes
  855. // Issue "Host Run" command
  856. Host_Control = 0x1000;
  857. // C.1.1 Set up the DRAM.
  858. ZiVAWriteReg( DMA_adr, DMA_MODE );
  859. //ZiVAWriteReg( DMA_data, 0x4EC ); // 16 Mbits DRAM
  860. ZiVAWriteReg( DMA_data, 0x14EC ); // 20 Mbits DRAM
  861. // C.1.2 Set up the ROM and SRAM (if any).
  862. ZiVAWriteReg( DMA_adr, DMA_CYCLE );
  863. ZiVAWriteReg( DMA_data, 0 ); // No ROM or SRAM present
  864. // C.2. Initial GBUS writes:
  865. gpbRead = pbUCodeStart + GBUS_TABLE_OFFSET;
  866. for ( dwCnt = load_GetDWORDSwapBackward(); dwCnt; dwCnt-- )
  867. {
  868. dwAddress = load_GetDWORDSwapBackward();
  869. ZiVAWriteReg( dwAddress, load_GetDWORDSwapBackward() );
  870. }
  871. // Remember the start of the Final GBUS writes table.
  872. pbFinalGBUSStart = gpbRead;
  873. // C.3. Copy bootstrap code into IMEM
  874. gpbRead = pbUCodeStart + IMEM_START_OFFSET;
  875. for ( dwAddress=0; dwAddress < IMEM_LENGTH; dwAddress ++ )
  876. {
  877. DWORD dwValue = load_GetDWORDSwap();
  878. ZiVAWriteIMEM( dwAddress, dwValue );
  879. }
  880. //return TRUE;
  881. // C.4. Copy default DVD1 configuration data into DRAM
  882. gpbRead = pbUCodeStart;
  883. for ( dwAddress=0; dwAddress < dwSectionLength/*DRAM_IMAGE_LENGTH*/; )
  884. {
  885. ZiVAWriteMemory( dwAddress, load_GetDWORDSwap() );
  886. dwAddress += 4; // Next 32-bit-WORD byte address in DRAM
  887. }
  888. // Check DRAM 12345
  889. ZiVAReadMemory( 0x128, &dwTmp );
  890. DBG_PRINTF( ("check DRAM 12345 ? Data = 0x%x\n", dwTmp ) );
  891. /*
  892. // C.5. Update configuration data in DRAM for the specific system.
  893. DVD_WriteDRAM( DRAM_Stream_Source, STREAM_SOURCE );
  894. DVD_WriteDRAM( DRAM_SD_Mode, SD_MODE );
  895. DVD_WriteDRAM( DRAM_CFifo_Level, CFIFO_THRESHOLD );
  896. DVD_WriteDRAM( DRAM_INFO, 1 ); // one 4Mbits DRAM increment
  897. DVD_WriteDRAM( UCODE_MEMORY, 0 ); // Microcode is in DRAM
  898. DVD_WriteDRAM( MEMORY_MAP, 3 ); // for 20 Mbits DRAM
  899. DVD_WriteDRAM( AC3_OUTPUT_MODE, 7 ); // 6 channels audio
  900. */
  901. DRAM_INFO = 0x01; // one 4Mbits DRAM increment
  902. UCODE_MEMORY = 0x00; // microcode is in DRAM
  903. VIDEO_MODE = 0x03; // VCLK slave, HSYNC and VSYNC master, CCIR-656 output
  904. switch( Type )
  905. {
  906. case 0:
  907. MEMORY_MAP = 0x03; // for 20 Mbits DRAM And NTSC
  908. break;
  909. case 1:
  910. MEMORY_MAP = 0x06; // for 20 Mbits DRAM And PAL
  911. break;
  912. default:
  913. DBG_BREAK();
  914. return FALSE;
  915. };
  916. // C.6. Perform final GBUS writes.
  917. gpbRead = pbFinalGBUSStart;
  918. for ( dwCnt = load_GetDWORDSwapBackward(); dwCnt; dwCnt-- )
  919. {
  920. dwAddress = load_GetDWORDSwapBackward();
  921. ZiVAWriteReg( dwAddress, load_GetDWORDSwapBackward() );
  922. }
  923. // Extend watchdog timer threashold. by H.Yagi 99.02.10
  924. HOST_OPTIONS |= 0x0400;
  925. //ZiVAWriteReg( CPU_cntl, 0x900000 ); // Run CPU.
  926. // D. Wait for the DVD1 to enter the Idle state
  927. // gets current time.
  928. CTimeOut TimeOut( COMMAND_TIMEOUT, 1, m_pKernelObj );
  929. // status pointer check?
  930. DWORD State;
  931. while( TRUE )
  932. {
  933. State = (DWORD)PROC_STATE;
  934. DBG_PRINTF(( " Load UCode PROCSTATE = 0x%x\n" , State));
  935. if( State == ZIVA_STATE_IDLE )
  936. break;
  937. // Sleep
  938. TimeOut.Sleep();
  939. // check Time out....... 1 sec
  940. if( TimeOut.CheckTimeOut() == TRUE )
  941. {
  942. DBG_PRINTF(( " Load UCode failed: State = 0x%x\n" , (DWORD)PROC_STATE ));
  943. DBG_BREAK();
  944. return FALSE;
  945. };
  946. };
  947. IDLE_DELAY = 0x10; // Power saving value
  948. HOST_OPTIONS |= 0x20; // for NV interrupt correctly
  949. DBG_PRINTF( (" LOAD UCODE completed. State = 0x%x\n", (DWORD)PROC_STATE ));
  950. // _Debug_Printf_Service(" LOAD UCODE completed. State = 0x%x\n", (DWORD)PROC_STATE );
  951. return TRUE;
  952. };
  953. //***************************************************************************
  954. // End of
  955. //***************************************************************************