?? ucode.c
字號:
#include "winav.h"
#include "w99av.h"
#include "ucode.h"
#include "setup.h"
#include "hal.h"
#include "cc.h"
#include "chips.h" //Kevin1.11a
/////////////////////////////////////////////////////////////////////
// ***** Big Modification History Area *****
// LLY.273, some modification
// [1] Remove "OFFSET" becasue it's unnecessary any more
// [2] Use "START" to replace "2" while accessing *.inc
// [3] Rename "ADDR" to "IRAM_ADDR"
// [4] Different ERAM_ADDR value -- because IRAM space is bigger
// 0x1a00 : use for F/W version >= 37
// 0x1900 : use for F/W version < 37
// [5] Different CSS_ADDR value -- because IRAM space is bigger
// IRAM_ADDR+5632-512 : use for F/W version >= 40
// IRAM_ADDR+5406-512 : use for F/W version < 40
// [6] Re-arrange the UCODE usage ID
/////////////////////////////////////////////////////////////////////
// ***** Big Modification History Area *****
// Chuan 278 2002/10/28: The PRAM/ERAM must download together, else DSP will run at wrong
// code after release audio. For example: The first instruction is jump to ERAM for JPGPRAM.
// But at that time, JPGERAM is not ready. If it jump to critical point, it may make DSP crash.
// UCODE_PMRAM_XXX / UCODE_ERAM_XXX -> UCODE_DSPRAM_XXX
// Related to CSS key management in DVDPRAM.INC has been moved out as keypar.INC.
// UCODE_PRAM_KEY to load keypar.INC
/*
/////////////////////////////////////////////////////////////////////////
// ***** Common Define For UCODE LOAD Area *****
#define START 2 // 0:date , 1:count number, 2:real data start point
#define IRAM_ADDR 0x0200 // the start address of iram.inc
#define ERAM_ADDR 0x1a00 // dsp eram's dram address
// 0x1600 = IRAM_ADDR+5632-512
// 512: the 512n '0' in the IRAM start address, ie 0x200 ~ 0x400 must fill with '0'
#define IRAMEXT_ADDR 0x1600 // the start address of IRAM extension ucode
#define CSS_ADDR IRAMEXT_ADDR // the start address of css.inc
#define OGT_ADDR IRAMEXT_ADDR // the start address of ogt.inc
*/
//////////////////////////////////////////////////////////////////
// ***** Internal Global Variables Define Area *****
// LLY.273, It's unnecessary because UCODE_Load will initialize them
BYTE _bPramCur; // = UCODE_PRAM_NONE ;
BYTE _bDSPramCur;
// Chuan0.83, CT908 no need to load IRAMEXT
// BYTE _bIRAMExtCur; // Keep current IRAM extension code
// Chuan DVD_171 12/11/2001: Declare as code *. If want know in detail, please refer to tracernote 100
DWORD code *dwRAM;
#ifndef SYSTEM_8051
DWORD *pdwUcode = NULL;
char cFile[20] = "\0";
#endif // #ifndef SYSTEM_8051
//For internal function usage.
// TCC161, UCODE_Load/UCODE_LoadCode and UCODE_Check/UCODE_CheckCode can't use same global variable for return value.
BYTE bRet ;
DWORD dwData; // Chuan 278 2002/10/28: No need initial value.
WORD _UCODEIndex; // Chuan 278 2002/10/28: No need initial value.
DWORD dwTemp;
WORD code *wptr; // pointer to WORD
//alex1.24a Scan Dram ok or not at Power on
#ifdef SUPPORT_DRAM_SCAN_POWERON
DWORD code _dwURAMTest[]=
{
#include "uramtest.inc"
};
DWORD code _dwCRAMTest[]=
{
#include "cramtest.inc"
};
#endif //#ifdef SUPPORT_DRAM_SCAN_POWERON
// include the micro-code of RISC URAM
DWORD code _dwURAM[]=
{
#include "uram.inc"
};
//////////////////////////////////////////////////////////////////
// Chuan1.20, For UCode Reduce Part
#ifdef SUPPORT_GZIP_COMPRESSION
// include the micro-code of PRAM
DWORD code _dwDVDPAR[]=
{
#include "dvdpar.inc"
};
// Chuan 278 2002/10/30: The code related to CSS key management in DVDPRAM.INC has been moved out.
DWORD code _dwKEYPAR[]=
{
#include "keypar.inc"
};
DWORD code _dwALLPAR[] =
{
#include "allpar.inc"
};
// wyc1.10, new parser code.
DWORD code _dwDATPAR[] =
{
#include "datpar.inc"
};
// include the micro-code of MP3's PRAM
DWORD code _dwCDROMPAR[]=
{
#include "cdrompar.inc"
};
DWORD code _dwIRAMGZIP[]=
{
#include "iramgzip.inc"
};
DWORD code _dwGZIPPRAM[]=
{
#include "gzippram.inc"
};
// ********************************************************************
// Function : UCODE_Load
// Description : Download micro-code to IRAM and PRAM
// Arguments : none
// Return : TRUE or FALSE
// Side Effect :
// ********************************************************************
BIT UCODE_Load(void)
{
// Step 1: Initialize all current code as none,
// because this API will be called to re-load all code
_bPramCur = UCODE_NONE;
_bDSPramCur = UCODE_NONE;
//Kevin2.31, comment
//if (!UCODE_LoadCode (UCODE_PRAM, UCODE_PRAM_VCD))
// return FALSE ;
//Kevin2.31, comment
//if (!UCODE_LoadCode (UCODE_DSPRAM, UCODE_DSPRAM_NORMAL))
// return FALSE ;
return TRUE;
}
// ********************************************************************
// Function : UCODE_Check
// Description : Check the procedure of download micro-code
// Arguments :
// Return : TRUE or FALSE
// Side Effect :
// ********************************************************************
BIT UCODE_Check(void)
{
// Chuan1.05, define it to check ucode
#ifdef CHECK_UCODE_LOAD
if (!UCODE_CheckCode (UCODE_IRAM, (BYTE)NULL))
return FALSE ;
//Kevin2.31, comment
//if (!UCODE_CheckCode (UCODE_PRAM, UCODE_PRAM_VCD))
// return FALSE ;
//Kevin2.31, comment
//if (!UCODE_CheckCode (UCODE_DSPRAM, UCODE_DSPRAM_NORMAL))
// return FALSE ;
#endif
return TRUE;
}
// ********************************************************************
// Function : UCODE_LoadCode
// Description : Download the desired micro-code
// Arguments : bRam, the desired ucode;
// bCode, the subtype of the desired code
// Return : TRUE or FALSE
// Side Effect :
// ********************************************************************
#pragma DISABLE
BYTE UCODE_LoadCode(BYTE bRam, BYTE bCode)
{
extern void _WriteInternalRegW_IO(BYTE bReg, WORD wLo);
bRet = TRUE ;
switch (bRam)
{
//////////////////////////////////////////////////////////////////
// ***** Load IRAM Code *****
case UCODE_IRAM :
if (bCode==NULL)
{
bRet = FALSE;
break;
}
#ifdef SYSTEM_8051
dwRAM = _dwIRAMGZIP;
#else
bRet = _OpenUCODE ("iramgzip.inc");
#endif
#ifdef SUPPORT_DRAM_PROTECTION
//Kevin1.01, unprotect IRAM
W99AV_WriteRegDW( UPR, 0x0000, 0x1E00);
#endif
// First 17 DW IRAM.INC must download in last time.
// So must re-adjust the download procedure.
// [1] download 15 ~ end first
// Chuan2.80a, Now 28AF has 16 ret code. CT908 has 17 ret code.
if ( ! W99AV_WriteDRAMBurst( (IRAM_ADDR+17), &dwRAM[START+17], (WORD)(dwRAM[1]-17)))
{
#ifdef SUPPORT_PRINTF
printf ( "\n **** DownLoad IRAM Failure...." );
#endif
bRet = FALSE ;
}
// [2] Download 1 ~ 17 last
if ( ! W99AV_WriteDRAMBurst (IRAM_ADDR, &dwRAM[START], (WORD)(17)))
{
#ifdef SUPPORT_PRINTF
printf ( "\n **** DownLoad IRAM Failure...." );
#endif
bRet = FALSE ;
}
#ifdef SUPPORT_DRAM_PROTECTION
//Kevin1.01, protect IRAM form IRAM_ADDR to IRAM_END_ADDR
dwTemp = 0x1F000000 | ((DWORD)(IRAM_END_ADDR>>8)<<12) | IRAM_ADDR>>8;
W99AV_WriteRegDW( UPR, LOWORD(dwTemp), HIWORD(dwTemp));
#endif
break ;
//////////////////////////////////////////////////////////////////
// ***** Load Parser Code *****
case UCODE_PRAM :
if (bCode == _bPramCur)
{
// TCC040, let upper level know that code not changed
bRet = UCODE_LOAD_NONE ;
break ;
}
// Keep the desired subtype code in current variable
_bPramCur = bCode ;
// Depending on the desired subtype to load ucode
switch (bCode)
{
case UCODE_DVDPRAM :
#ifdef SYSTEM_8051
dwRAM = _dwDVDPAR ;
#else
bRet = _OpenUCODE ("dvdpar.inc");
#endif
break ;
// Chuan 278 2002/10/30: The code related to CSS key management in DVDPRAM.INC has been moved out.
case UCODE_KEYPRAM :
#ifdef SYSTEM_8051
dwRAM = _dwKEYPAR ;
#else
bRet = _OpenUCODE ("keypar.inc");
#endif
break ;
case UCODE_CDROMPRAM :
#ifdef SYSTEM_8051
dwRAM = _dwCDROMPAR ;
#elif defined(BITSTREAM_WITHOUT_SYNC)
bRet = _OpenUCODE ( "dosall.inc" ); // Chuan2.80p, DosTest - Host path w/o SYNC
#else
bRet = _OpenUCODE ( "cdrompar.inc" ); // Chuan2.80p, Emulator ATAPIIF/CDIF only
#endif
break ;
case UCODE_ALLPRAM :
#ifdef SYSTEM_8051
dwRAM = _dwALLPAR ;
#elif defined(BITSTREAM_WITHOUT_SYNC)
bRet = _OpenUCODE ( "dosall.inc" ); // Chuan2.80p, DosTest - Host path w/o SYNC
#else
bRet = _OpenUCODE ( "allpar.inc" ); // Chuan2.80p, Emulator ATAPIIF/CDIF only
#endif
break ;
// wyc1.10, new parser code for playing DVD-DAT / CD-DAT files.
case UCODE_DATPRAM:
#ifdef SYSTEM_8051
dwRAM = _dwDATPAR ;
#else
bRet = _OpenUCODE ( "datpar.inc" ); // Chuan2.80p, Emulator ATAPIIF/CDIF only
#endif
break;
#ifdef BITSTREAM_WITHOUT_SYNC
case UCODE_DOSJPEG:
bRet = _OpenUCODE ( "dosjpeg.inc" ); // Chuan2.80p, DosTest - Host path w/o SYNC
break ;
#endif
default :
#ifdef SUPPORT_PRINTF
printf ("\nWrong Parser Ramcode specified !") ;
#endif
return FALSE ;
}
// LLY.0411, using HAL_Reset(HAL_RESET_PARSER), becasue it will
// issue disable parser and parser reset.
// Must call HAL_ControlParser(HAL_PARSER_ENABLE, NULL)
// LLY.043, fix recursive call -- expand HAL_Reset(HAL_RESET_PARSER) procedure
// LLY.050-1, push 16 DWORD zero to vcfifo before parser reset
__dwW99AVCmdArg[0]=2;
__dwW99AVCmdArg[1]=0xFFFF; // don't care commnad argument
__dwW99AVCmdArg[2]=0x00102000; // [31:16]: data cnt; [15:0] specify fifo
W99AV_CommandN(COMMAND_FFIFO); // Chuan2.80p, Use define instead of number
__wW99AVPCRLow &= 0xDFFF ; //(Bit 13, Parser Disable)
// LLY.041-3 begin ....
W99AV_WriteRegDW (PCR, __wW99AVPCRLow, __wW99AVPCRHigh) ;
// LLY.041-3 end ...
// Soft Reset Parser
__wW99AVPCRLow |= 0x1000 ; //(Bit 12, Parser Reset)
W99AV_WriteRegDW (PCR, __wW99AVPCRLow, __wW99AVPCRHigh) ;
// LLY.043 end ...
// download parser ram
for (_UCODEIndex=0; _UCODEIndex<dwRAM[1]; _UCODEIndex++)
{
// Chuan DVD_171 12/11/2001: use simple way
W99AV_OutIndex (W99AV_AIRID_PARRAM | _UCODEIndex) ;
W99AV_OutData (dwRAM [_UCODEIndex+START]) ;
}
// LLY.043, fix recursive call -- expand HAL_ControlParser(HAL_PARSER_ENABLE, NULL) procedure
// Restore previous state
__wW99AVPCRLow &= 0xEFFF ; //(Bit 12, Parser Reset)
// LLY.0411 begin ....
W99AV_WriteRegDW (PCR, __wW99AVPCRLow, __wW99AVPCRHigh) ;
// LLY.0411 end ...
// DVD016, not enable parser
//DVD016MICKY
__wW99AVPCRLow |= 0x2000 ; //(Bit 13, Parser Enable)
W99AV_WriteRegDW (PCR, __wW99AVPCRLow, __wW99AVPCRHigh) ;
// LLY.043 end ...
break ;
//////////////////////////////////////////////////////////////////
// ***** Load URAM Code *****
case UCODE_URAM :
#ifdef SUPPORT_DRAM_SCAN_POWERON //alex1.24a, Scan Dram
case UCODE_URAM_DRAMTEST :
if (bRam == UCODE_URAM_DRAMTEST)
{
#ifdef SYSTEM_8051
dwRAM = _dwURAMTest;
#else
bRet = _OpenUCODE ("uramtest.inc");
#endif
}
else
#endif //#ifdef SUPPORT_DRAM_SCAN_POWERON
{
#ifdef SYSTEM_8051
dwRAM = _dwURAM;
#else
bRet = _OpenUCODE ("uram.inc");
#endif
}
wptr=(WORD code *)& dwRAM[START];
// Step 1 : Reset URAM
__dwW99AVCmdArg[0]=1;
__dwW99AVCmdArg[1]=CMDARG_URAMRST;
if(!W99AV_CommandN(COMMAND_URAMRST)) // Chuan2.80p, Use define instead of number
bRet =FALSE;
// Step 2 : set URAM write enable
_WriteInternalRegW_IO(CFR,0x0060); // CF, to stall CPU
_WriteInternalRegW_IO(RMADRR,0x0080); // rm_adr
_WriteInternalRegDW_IO(DCCTLR,0x0,0x1); // Chuan-Test0.01
// Step 3 : load nonzero URAM data to register
for(_UCODEIndex=0; _UCODEIndex<dwRAM[1];_UCODEIndex++)
{
if(dwRAM[_UCODEIndex+START]!=0)
{
_WriteInternalRegW_IO(RMADRR,(WORD)(0x0080|((_UCODEIndex&0x00FF)<<8)));
#ifdef USE_LITTLE_ENDIAN
_WriteInternalRegW_IO (DIR0R, (*wptr)) ;
_WriteInternalRegW_IO (DIR1R, (*(wptr+1))) ;
#else
_WriteInternalRegW_IO (DIR0R, (*(wptr+1))) ;
_WriteInternalRegW_IO (DIR1R, (*wptr)) ;
#endif
}
wptr+=2;
}
// Step 4 : set URAM write disable
_WriteInternalRegW_IO(RMADRR,0x0000);
_WriteInternalRegW_IO(CFR,0x0000);
// Chuan-Test0.01, Enable URAM_EN
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -