sysmain_inc.h
上传用户:poi891205
上传日期:2013-07-15
资源大小:9745k
文件大小:8k
源码类别:

DVD

开发平台:

C/C++

  1. /*
  2. *  Terry,2004/2/6 01:09PM
  3. *  1.chg dvd code download mode
  4. */
  5. #ifdef SERVO_TEST 
  6. #include "mpegsys.h"
  7. #include "cd.h"
  8. #endif
  9. #include "mpegsys.h"
  10. #ifdef ROM_ATA_SHARE_BUS
  11. void atapi_share_rom_bus(void)
  12. {
  13.        UINT16 status;
  14.        //rom1234 => 2,4
  15.        // rom1/2 bases       
  16.        regs0->rom1_base = 0x100;       // rom2 n*64k-base ,pcmcia
  17.        regs0->rom2_base = 0x160;       // rom2 n*64k-base ,pcmcia
  18.        regs0->rom3_base = 0x200;       // rom3 n*64k-base ,pcmcia
  19.        
  20.        //regs0->rom_config = 0x50a0;     // pcmcia,rom2,4       
  21.        regs0->rom_config = 0x5060;     // pcmcia,rom2,3
  22.        //regs0->wait_cyc3_2 = 0x0404;
  23.        regs0->pcmcia_ctrl = 0x0018;
  24.        
  25.        
  26.        regs0->pcmcia_iorw_wait =0x2222;
  27.        //regs0->iochrdy_wait_cyc =0x;
  28.        //regs0->oe_wait_cyc3_2 = ;
  29.        //regs0->we_wait_cyc3_2 = ;
  30.        
  31.        /*atapi_reg_read(0x10);
  32.        atapi_reg_read(0x11);
  33.        atapi_reg_read(0x12);
  34.        atapi_reg_read(0x13);
  35.        atapi_reg_read(0x14);
  36.        atapi_reg_read(0x15);
  37.        atapi_reg_read(0x16);
  38.        atapi_reg_read(0x17);
  39.        atapi_reg_write(0x11,0xa5a5);
  40.        atapi_reg_write(0x12,0xa2a2);
  41.        atapi_reg_write(0x14,0xa4a4);
  42.        
  43.        
  44.        printf("okn");
  45.        while(1);
  46.        */
  47.        /*
  48.        atapi_init();  
  49.        atapi_open_tray();
  50.        
  51.        delay(1000);
  52.        status = atapi_reg_read(IDE_STATUS);    
  53.    printf("status:%xn",status);       
  54.        printf("............n");
  55.        
  56.        while(1);*/
  57. }
  58. #ifndef DVD_SERVO
  59. #define CS0 (ROM_BASE_UNCACHED+0x1000000)
  60. #define CS1 (ROM_BASE_UNCACHED+0x2000000)
  61. #define DA0 (1<<0)
  62. #define DA1 (1<<1)
  63. #define DA2 (1<<2)
  64. UINT16
  65. atapi_reg_read(UINT8 addr)
  66. {
  67. //UINT8 *p;
  68. UINT16 *q,res;
  69. UINT32 r;
  70. int cs=0;
  71. cpu_intr_disable();     
  72. r=(addr&0x7)<<1;
  73. if(addr&(1<<3))
  74. {
  75.  r|=CS1;
  76.  cs=1;
  77.         }
  78. else r|=CS0;
  79. //p=(UINT8 *)r;
  80. q=(UINT16 *)r;
  81. res=*q;
  82.     if(addr!=IDE_DATA)
  83.       res=res&0xff;
  84.     
  85.     cpu_intr_enable();            // enable CPU-level intr_enable
  86.     //printf("<r,cs:%x,r:%x q:%x addr:%x>n",cs,r,res,addr);
  87. return res;
  88. }
  89. void
  90. atapi_reg_write(UINT8 addr, UINT16 data)
  91. {
  92. UINT16 *p;
  93. UINT32 r;
  94. int cs=0;
  95. cpu_intr_disable();     
  96. r=(addr&0x7)<<1;
  97. if(addr&(1<<3))
  98. { r|=CS1;cs=1;}
  99. else r|=CS0;
  100. p=(UINT16 *)r;
  101. *p = data;
  102. cpu_intr_enable();            // enable CPU-level intr_enable
  103. //printf("<w,cs:%x r:%x p:%x data%x addr:%x>n",cs,r,p,data,addr);
  104. }
  105. #endif //#ifndef DVD_SERVO
  106. #else
  107. #define atapi_share_rom_bus() {}
  108. #endif
  109. #ifdef USE_HDD //cyue: Add Test 2002-06-14 04:45PM
  110. void hdd_init()
  111. {
  112.   play_state=VCD_STATE_NORMAL;
  113.   //play_state=VCD_STATE_IDLE;
  114.   system_state=SYSTEM_BROWSE;
  115.   cd_type_loaded=CDDVD;
  116.   //osd_init();
  117.   ClearOsdMsg(0);//kenny add it 2001/5/8
  118.   InitVar();  
  119.   HDD_Test();
  120.   play_state=VCD_STATE_IDLE;
  121. }
  122. #else
  123. #define hdd_init() {}
  124. #endif
  125. #ifdef SERVO_TEST  
  126. void TestRomY()
  127. {
  128.   int i;
  129.   UINT32 ssstate;
  130.   
  131.   AVD_ResetMediaStatus();
  132.   stream_video = 0xe0;
  133.   stream_audio = 0xff;
  134.   restart_video_engine();
  135.   restart_cdlayer();
  136.   regs0->dvddsp_vx = 0;
  137.   regs0->dvddsp_vy = 0;
  138.   regs0->dvddsp_ry = CBV_H-1; // at least this value
  139.   regs0->dvddsp_rx= 0;
  140.   cbv_y= 0;
  141.  
  142.   while (1)
  143.   {
  144.     // get current cbv pointer   
  145.     polling();    
  146.     if (DISC_DUMP_Y==cbv_y) {
  147.     ssstate = 0; continue;
  148.     }
  149.     ssstate = 1;
  150.     stream_ptr = get_cbv_ptr(0,cbv_y);
  151.     DISC_BARRIER_Y = cbv_y;
  152.      regs0->dvddsp_ry = cbv_y;
  153.     if (++cbv_y>=CBV_H) cbv_y = 0;
  154.     i++;
  155.     //printf("%x", i);
  156. // if (decoded_pic>0x30) dump_content("nSRV ", stream_ptr, 1024);
  157. //dump_content("nSRV ", stream_ptr, 1024);
  158.     dma_iptr = 0;
  159.     dma_ilen = 1024;
  160.     if (is_svo_dvd())
  161.     {
  162.       do {
  163.         polling();
  164.         if (IsAVDMediaInterrupt()) break;
  165.       } while (do_system());
  166.     }
  167.     else
  168.     {
  169.       do {
  170.         polling();
  171.         if (IsAVDMediaInterrupt()) break;
  172.       } while (do_cd());
  173.     }
  174.     if (IsAVDMediaInterrupt()) break;
  175.   }
  176. }
  177. void servo_test(void)
  178. {
  179.   while (1)
  180.   {
  181.   printf("MMMAINn");
  182.   TestRomY();
  183.   }
  184.   
  185.   while (1)
  186.   {
  187. //   extern UINT32 disc_dump_y;
  188. //   extern UINT32 disc_barrier_y;
  189.     io_write("ttMMMAINn");
  190.     cd_type=CDDVD;
  191.     bDiscType=CDDVD;
  192.     PlayLBA(0,100000);    
  193.     setup_dvd_motion_ntsc();
  194.     setup_decode_service(SERVICE_CD);
  195.     DISC_DUMP_Y = 0;
  196.     DISC_BARRIER_Y = 30;
  197.     do {
  198.         srv_kernel();   //doing kernel routine.
  199.         polling();      //polling system status for pending-job
  200.     } while (1); //!IsAVDMediaInterrupt());
  201.   }
  202. }
  203. #else
  204. #define servo_test() {}
  205. #endif
  206. #if 1 
  207. extern char _stextf[];
  208. extern char _text_drv[], _text_drv_dvd[], _text_drv_ap[], _text_drv_iop[], _text_other[], _text_drv_cdrom[];
  209. #ifdef DVD_SERVO
  210. extern char _text_drv_srvdp[], _text_drv_ap2[], _text_drv_free[], _text_drv_mp4[], _text_drv_wma[];
  211. #else
  212. extern char _text_drv_ap2[], _text_drv_free[], _text_drv_mp4[], _text_drv_wma[];
  213. #endif
  214. #ifdef SPHE1000
  215. extern char _text_lwip[];
  216. #endif
  217. UINT16 modual_loaded = 0;
  218. #ifdef SYSMAIN_DBG
  219. #ifdef SPHE1000
  220. const char dbg[16][20]={"DVD","MPEG","JPEG","AP","CDROM","IOP","IOPRESET","OTHER","SRVDSP","AP2","AP3","FREE","","MP4","WMA","LWIP"};
  221. #else
  222. const char dbg[15][20]={"DVD","MPEG","JPEG","AP","CDROM","IOP","IOPRESET","OTHER","SRVDSP","AP2","AP3","FREE","","MP4","WMA"};
  223. #endif
  224. #endif
  225. void download_text_code(UINT16 iModuleIndex,BYTE *pDestAddr)
  226. {
  227.   BYTE *p;
  228.   UINT32 unOffset;
  229.   int v;
  230.   unOffset = ((UINT32 *)_stextf)[iModuleIndex];
  231.   p = (BYTE *)(_stextf + unOffset + (MODUAL_Ns * 4));
  232.   v = dsp3_decompress(p, pDestAddr);
  233.   invalidate_dcache();
  234.   
  235. #ifdef SYSMAIN_DBG
  236.   printf("load:%s v:%xn",dbg[iModuleIndex],v);
  237. #endif
  238. }
  239. void LoadModual(UINT16 iModuleIndex)
  240. {
  241.     BYTE *pDestAddr;
  242.     UINT16 index = (1 << (iModuleIndex & 0xf));
  243. /*
  244. if(iModuleIndex&RESET_MODE)
  245. {
  246. modual_loaded&=(~index);
  247. }
  248. else
  249. */
  250. if ((modual_loaded & index) == 0)
  251. {
  252. if ((iModuleIndex != MODUAL_CDROM) && (iModuleIndex != MODUAL_MP4) && (iModuleIndex != MODUAL_WMA)) // load CDROM ,MP4 and WMA module always
  253. //if ((iModuleIndex != MODUAL_CDROM)) // load CDROM ,MP4 and WMA module always
  254. modual_loaded |= index;
  255. switch(iModuleIndex)
  256. {
  257. case MODUAL_OTHER:
  258. default:
  259. pDestAddr = _text_other;
  260. break;
  261. case MODUAL_IOP:
  262. case MODUAL_IOP_RESET:
  263. pDestAddr = _text_drv_iop;
  264. break;
  265. case MODUAL_MPEG:
  266.         download_text_code(MODUAL_DVD,_text_drv_dvd);//download dvd
  267.         
  268. modual_loaded &= (~(1<<MODUAL_JPEG));
  269. pDestAddr = _text_drv;
  270. break;
  271. case MODUAL_JPEG:
  272. modual_loaded &= (~(1<<MODUAL_MPEG));
  273. modual_loaded &= (~(1<<MODUAL_DVD));
  274. pDestAddr = _text_drv;
  275. break;
  276. case MODUAL_AP:
  277. pDestAddr = _text_drv_ap;
  278. break;
  279. //case MODUAL_DVD:
  280. //modual_loaded &= (~(1 << MODUAL_CDROM));
  281. //pDestAddr = _text_drv_dvd;
  282. //break;
  283. case MODUAL_CDROM:
  284. pDestAddr = _text_drv_cdrom;
  285. break;
  286. #ifdef DVD_SERVO
  287. case MODUAL_SRVDSP:
  288. pDestAddr = _text_drv_srvdp;
  289. break;
  290. #endif
  291. case MODUAL_AP2:
  292. modual_loaded &= (~(1<<MODUAL_AP3));
  293. pDestAddr = _text_drv_ap2;
  294. break;
  295. case MODUAL_AP3:
  296. modual_loaded &= (~(1<<MODUAL_AP2));
  297. pDestAddr = _text_drv_ap2;
  298. break;
  299. case MODUAL_FREE:
  300. pDestAddr = _text_drv_free;
  301. break;
  302. case MODUAL_MP4:
  303. pDestAddr = _text_drv_mp4;
  304. break;
  305. case MODUAL_WMA:
  306. pDestAddr = _text_drv_wma;
  307. break;
  308. #ifdef SPHE1000
  309. case MODUAL_LWIP:
  310. pDestAddr = _text_lwip;
  311. break;
  312. #endif
  313. }
  314.         download_text_code(iModuleIndex,pDestAddr);//download dvd
  315. }
  316. #ifdef SYSMAIN_DBG
  317. else
  318. {
  319. printf("[%s] module is already loaded.n",dbg[iModuleIndex]);
  320. io_write("------------------------n");
  321. return;
  322. }
  323. {
  324. UINT16 i;
  325. io_write("loaded:");
  326. for(i=0;i<MODUAL_Ns;i++)
  327. {
  328.             if(modual_loaded&(1<<i))
  329. printf("[%s] ",dbg[i]);
  330. }
  331. io_write("n");
  332. }
  333. io_write("------------------------n");
  334. #endif
  335. }
  336. #else
  337. void  LoadModual(UINT16 iModuleIndex) {}
  338. #endif