⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ucode.c

📁 车载电子影音系统dvd播放系统原程序代码
💻 C
📖 第 1 页 / 共 4 页
字号:
        dwTemp = 0x01000000 | ((DWORD)(ERAM_END_ADDR>>8)<<12) | ERAM_ADDR>>8;
        W99AV_WriteRegDW( UCPR1, LOWORD(dwTemp), HIWORD(dwTemp));
#endif  

        // Chuan 278 2002/10/28: Release A_RST
        W99AV_WriteRegDW (PCR, __wW99AVPCRLow, __wW99AVPCRHigh) ;
        break ;
    }

#ifndef SYSTEM_8051
    if (pdwUcode)
    {
        _hfree(pdwUcode);
        pdwUcode = NULL;
    }
#endif

    return bRet ;
}

// ********************************************************************
//  Function    :   UCODE_CheckCode
//  Description :   Check 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_CheckCode (BYTE bRam, BYTE bCode)
{
    bRet = TRUE ;
// Chuan1.05, define it to check ucode
#ifdef  CHECK_UCODE_LOAD

    switch (bRam)
    {
    case    UCODE_CRAM :
        break;
        
    case UCODE_IRAM :
        if (bCode==UCODE_IRAM_GZIP) 
        { 
#ifdef SYSTEM_8051
        dwRAM = _dwIRAMGZIP;
#else
        bRet = _OpenUCODE ("iramgzip.inc"); 
#endif 
        }
#ifdef SYSTEM_8051        
        else
        {
            break;
        }
#else
        else
        {
            bRet = _OpenUCODE ("iram.inc");   
        }
#endif

        for (_UCODEIndex=0; _UCODEIndex<dwRAM[1]; _UCODEIndex++)
        {
            W99AV_ReadDRAMData (IRAM_ADDR+_UCODEIndex, &dwData);
            if (dwData != dwRAM[_UCODEIndex+START])
            {
#ifdef SUPPORT_PRINTF
                printf ("\nCheck IRAM code %d error, [0x%lx]--[0x%lx]", _UCODEIndex, dwData, dwRAM[_UCODEIndex+START]) ;
#endif
                bRet = FALSE ;
                break ;
            }
        }
        break;

    case UCODE_PRAM :
        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 to play 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 ;
        }

        ////////////////////////////////////////
        // Check download PRAM procedure
        __wW99AVPCRLow &= 0xDFFF ;  //(Bit 13, Parser Disable)
        W99AV_WriteRegDW (PCR, __wW99AVPCRLow, __wW99AVPCRHigh) ;
        // Soft Reset Parser
        __wW99AVPCRLow |= 0x1000 ;  //(Bit 12, Parser Reset)
        W99AV_WriteRegDW (PCR, __wW99AVPCRLow, __wW99AVPCRHigh) ;
        // LLY.043 end ...

        for(_UCODEIndex=0; _UCODEIndex<dwRAM[1];_UCODEIndex++)
        {
            W99AV_OutIndex(W99AV_AIRID_PARRAM | _UCODEIndex) ;
            W99AV_InData();
            W99AV_OutIndex(W99AV_AIRID_PARRAM | _UCODEIndex) ;
            dwData=W99AV_InData()&0xfffff;
            if(dwData!=dwRAM[_UCODEIndex+START])
            {
#ifdef SUPPORT_PRINTF
                printf ("\nCheck PRAM %d Error [0x%lx] != [0x%lx]", _UCODEIndex, dwData, dwRAM[_UCODEIndex+START]) ;
#endif
                bRet = FALSE ;
                break ;
            }
        }
        // LLY.043, fix recursive call -- expand HAL_ControlParser(HAL_PARSER_ENABLE) procedure
        // Restore previous state
        __wW99AVPCRLow &= 0xEFFF ;  //(Bit 12, Parser Reset)
        W99AV_WriteRegDW (PCR, __wW99AVPCRLow, __wW99AVPCRHigh) ;
        //DVD016MICKY
        __wW99AVPCRLow |= 0x2000 ;  //(Bit 13, Parser Enable)
        W99AV_WriteRegDW (PCR, __wW99AVPCRLow, __wW99AVPCRHigh) ;
        // LLY.043 end ...
        break ;
        
    case UCODE_URAM :
#ifdef SYSTEM_8051
        dwRAM = _dwURAM;
#else
        bRet = _OpenUCODE ("uram.inc");
#endif
        wptr=(WORD code *)& dwRAM[START];

        // Step 2 : set URAM write enable
        _WriteInternalRegW_IO(CFR,0x0060);    // CF, to stall CPU
        _WriteInternalRegW_IO(RMADRR,0x00c0);    // rm_adr
        __wW99AVPCRHigh |= 0x0004;  // PCR[18]:URAM_EN
        W99AV_WriteRegDW(PCR,(WORD)__wW99AVPCRLow, __wW99AVPCRHigh);
        
        // Step 3 : load nonzero URAM data to register

        for(_UCODEIndex=0; _UCODEIndex<dwRAM[1];_UCODEIndex++)
        {
            _WriteInternalRegW_IO(PCRR,(WORD)(_UCODEIndex+0x800));
            _WriteInternalRegW_IO(RMADRR,(WORD)(0x00c4|((_UCODEIndex&0x00FF)<<8)));
            dwData = _ReadInternalRegW_IO (DIR0R) ;
            dwTemp = _ReadInternalRegW_IO (DIR1R) ;
            dwData = MAKELONG(dwData,dwTemp);
            if(dwData!=dwRAM[_UCODEIndex+START])
            {
#ifdef SUPPORT_PRINTF
                printf ("\nCheck URAM %d Error [0x%lx] != [0x%lx]", _UCODEIndex, dwData, dwRAM[_UCODEIndex+START]) ;
#endif
                bRet = FALSE ;
                break ;
            }
        }

        // Step 4 : set URAM write disable
        _WriteInternalRegW_IO(RMADRR,0x0000);
        _WriteInternalRegW_IO(CFR,0x0000);
        W99AV_WriteRegDW(PCR,(WORD)(__wW99AVPCRLow|0x10), __wW99AVPCRHigh);
        W99AV_WriteRegDW(PCR,(WORD)(__wW99AVPCRLow), __wW99AVPCRHigh);
        break ;
        
    case UCODE_DSPRAM :
#ifndef SYSTEM_8051
        // Chuan 278 2002/10/28: Check DSP PRAM first.
        switch (bCode)
        {
        case UCODE_DSPRAM_GZIP:  
            bRet = _OpenUCODE ( "gzippram.inc" );
            break ;
            
        case UCODE_DSPRAM_AC3:
            bRet = _OpenUCODE ( "ac3pram.inc" );
            break ;
        case UCODE_DSPRAM_DTS:
            bRet = _OpenUCODE ( "dtspram.inc" );
            break ;
        case UCODE_DSPRAM_MPG:
            bRet = _OpenUCODE ( "mpgpram.inc" );
            break ;
        case UCODE_DSPRAM_MP3:
            bRet = _OpenUCODE ( "mp3pram.inc" );
            break ;
        case UCODE_DSPRAM_PCM:
            bRet = _OpenUCODE ( "pcmpram.inc" );
            break ;
#ifdef SUPPORT_WMA //Kevin1.23, add
        case UCODE_DSPRAM_WMA:
            bRet = _OpenUCODE ( "wmapram.inc" );
            break ;
#endif
        }
        dwData = W99AV_AIRID_DSPMEM | 0x00010000L ;
        // Chuan 278 2002/10/28: Keep A_RST high        
        W99AV_WriteRegDW (PCR,(WORD) (__wW99AVPCRLow|0x0020), __wW99AVPCRHigh) ;
        for (_UCODEIndex=0; _UCODEIndex<dwRAM[1]; _UCODEIndex++)
        {
            W99AV_OutIndex(dwData | _UCODEIndex) ;
            W99AV_InData();
            W99AV_OutIndex(dwData | _UCODEIndex) ;
            dwTemp=W99AV_InData() & 0x0fffffff;
            if(dwTemp!=dwRAM[_UCODEIndex+START])
            {
#ifdef SUPPORT_PRINTF
                printf ("\nCheck DSP PM RAM %d Error [0x%lx] != [0x%lx]", _UCODEIndex, dwTemp, dwRAM[_UCODEIndex+START]) ;
#endif
                bRet = FALSE ;
                break ;
            }
        }
        if (pdwUcode)
        {
            _hfree(pdwUcode);
            pdwUcode = NULL;
        }
        // Chuan 278 2002/10/28: Check DSP ERAM
        switch (bCode)
        {
        case UCODE_DSPRAM_GZIP:
            W99AV_WriteRegDW (PCR, __wW99AVPCRLow, __wW99AVPCRHigh) ;
            return bRet;
            break;
            
        case UCODE_DSPRAM_AC3:
            bRet = _OpenUCODE ( "ac3eram.inc" );
            break ;
        case UCODE_DSPRAM_DTS:
            bRet = _OpenUCODE ( "dtseram.inc" );
            break ;
        case UCODE_DSPRAM_MPG:
            bRet = _OpenUCODE ( "mpgeram.inc" );
            break ;
        case UCODE_DSPRAM_MP3:
            bRet = _OpenUCODE ( "mp3eram.inc" );
            break ;
        case UCODE_DSPRAM_PCM:
            bRet = _OpenUCODE ( "pcmeram.inc" );
            break ;
#ifdef SUPPORT_WMA //Kevin1.23, add
        case UCODE_DSPRAM_WMA:
            bRet = _OpenUCODE ( "wmaeram.inc" );
            break ;
#endif
        }
        for (_UCODEIndex=0; _UCODEIndex<dwRAM[1]; _UCODEIndex++)
        {
            W99AV_ReadDRAMData (ERAM_ADDR+_UCODEIndex, &dwTemp) ;
            if(dwTemp!=dwRAM[_UCODEIndex+START])
            {
#ifdef SUPPORT_PRINTF
                printf ("\nCheck ERAM %d Error [0x%lx] != [0x%lx]", _UCODEIndex, dwTemp, dwRAM[_UCODEIndex+START]) ;
#endif
                bRet = FALSE ;
                break ;
            }
        }
        W99AV_WriteRegDW (PCR, __wW99AVPCRLow, __wW99AVPCRHigh) ;
#endif
        break ;
    }

#ifndef SYSTEM_8051
    if (pdwUcode)
    {
        _hfree(pdwUcode);
        pdwUcode = NULL;
    }
#endif

#endif // #ifdef  CHECK_UCODE_LOAD
    return bRet ;
}
#else
//////////////////////////////////////////////////////////////////
// Chuan1.20, For Non-compress UCODE Part

#ifdef SYSTEM_8051
// include the micro-code of RISC IRAM
DWORD code _dwIRAM[]=
{
#include "iram.inc"
};

// include the micro-code of CSS IRAM
#ifdef INPUT_PATH_ATAPIIF
DWORD code _dwCSS[] =
{
#if !defined(SUPPORT_DVDIF) && !defined(SUPPORT_CDIF)
#include "css.inc"
#else   //  #if !defined(SUPPORT_DVDIF) && !defined(SUPPORT_CDIF)
0, 0
#endif  //  #if !defined(SUPPORT_DVDIF) && !defined(SUPPORT_CDIF)
} ;
#endif  // #ifdef INPUT_PATH_ATAPIIF

/*
// include the micro-code of RISC URAM
DWORD code _dwCRAM[]=
{
#include "cram.inc"
};
*/
#endif  // #ifdef SYSTEM_8051

// ********************************************************************
//  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
    // LLY.273, rename it.
    // need to reload pram any time here
    _bPramCur=UCODE_NONE; // UCODE_PRAM_NONE ;
    //force reload dsp code
    _bDSPramCur=UCODE_NONE; // UCODE_PMRAM_NONE ;
    _bDSPBackup = 0; // Brian1.00
    // Chuan0.83, CT908 no need to load IRAMEXT
    //_bIRAMExtCur=UCODE_NONE;
    // TCC028, since protect dsp code will make write pixel fail. HCT will check this
    // TCC029, UPR can protect only iram range
    // Chuan2.80a, _PreLoadRetCode will unprotect IRAM range. Thereafter, here don't need to unprotect again.

    // Write IRAM Code
    if (!UCODE_LoadCode (UCODE_IRAM, (BYTE)NULL))
        return FALSE ;

    // Chuan0.83, CT908 no need to load IRAMEXT
    // Download IRAM's extension code -- CSS/ OGT ...
    // LLY.273, It's unnecessary to check condition
    // Because, there is protection for _dwCSS[] array
    // wyc2.80, load OGT code to avoid RISC enter CSS code and not return.
    //if( !UCODE_LoadCode(UCODE_IRAMEXT, UCODE_IRAMEXT_OGT/*UCODE_IRAMEXT_CSS*/) ) 
    // return FALSE ;

    ////////////////////////////////////////
    // Download URAM continue
    ////////////////////////////////////////
    //LLY.103-2, move loading URAM.INC action to _PrepareLoadCode()
    //because URAM code must load first

    //////////////////////////////////////////////
    // Download parser ram
    /////////////////////////////////////////////
    if (!UCODE_LoadCode (UCODE_PRAM, UCODE_PRAM_VCD))
        return FALSE ;

    // TCC0411, should load dsp code according to setup's setting.
    // Or next power-on will still load normal one.
    // TCC2.78b-2, fix setup as spdif_raw, start up as CDDA mode, it will hang problem, reported by Paragon/Mustek(IC issue).
    // The solution is to load normal set of dsp code first, then load iec part. Don't know why.
    // Chuan 178 2002/10/28: Load DSP PRAM/ERAM together
    // Chuan0.8x, Move DSP Code to UCODE 2
    if (!UCODE2_LoadCode (UCODE_DSPRAM, (BYTE)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 :
// ********************************************************************

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -