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

📄 aploader.c

📁 ct952 source code use for Digital Frame Photo
💻 C
📖 第 1 页 / 共 2 页
字号:
#include "winav.h"#include "ctkav.h"#include "infofilter.h"#include "srcfilter.h"#include "aploader.h"#include "hal.h"#include "disp.h"#include "utl.h"#include "input.h"#include "cc.h"#include "setup.h"#include "media.h"#include "initial.h"#include "usbwrap.h"////////////////////////////////////////////////////////////////////////  Big modification Area//  LLY2.10, Remove CT909A related code./////////////////////////////////////////////////////////////////////// Global Variable Area - Global use/////////////////////////////////////////////////////////////////////AP_INFO     __AP_Info;VOID    _AP_Prepare_AdditionalInfo(DWORD dwAPSource);VOID    _AP_ExternalStart(DWORD dwInfoAddr, DWORD dwCodeAddr, DWORD dwLen);BYTE    _AP_CheckSum(void);// Check IC Version// peteryu275, add for IC check version, 2007/3/22 11:31AMBYTE _AP_IC_Version_Check(DWORD apVersion);extern PARM_DRAW_STRING __OSDNDUpMsgAttr;// peteryu275, add for IC check version, 2007/3/22 11:31AM end // LLY2.00, add function to re-booting while AP switch procedure fail.void _AP_REBOOT(void){    DWORD dwSaveInt;        OS_DISABLE_INTERRUPTS(dwSaveInt);    REG_PLAT_WATCHDOG = 0;    REG_PLAT_SYSTEM_CONFIGURATION1 |= (1L<<28);    while(1);}//***************************************************************************//  Function    :   AP_Loader//  Abstract    ://  Arguments   :   dwStartPos : Indicates the start sector//              :   dwEndPos : Indicates the end sector//              :   dwType : Indicates the source from CD/ USB/ DRAM/ Flash//  Return      :   None//  Side Effect ://  Notes       ://***************************************************************************DWORD   AP_Loader(DWORD dwType, DWORD dwStartPos, DWORD dwSize){    GDI_REGION_INFO RegionInfo;#ifndef NO_DISC_MODE    DWORD   dwTime;#endif  // #ifndef NO_DISC_MODE    // Chuan1.08, Turn on PROM#ifdef  SUPPORT_PROM_DISABLE    DWORD dwSaveInt;    OS_DISABLE_INTERRUPTS( dwSaveInt );    REG_PLAT_CLK_GENERATOR_CONTROL &= ~(PLAT_MCLK_PROM_DISABLE);    OS_RESTORE_INTERRUPTS( dwSaveInt );    //UTL_DelayTime(COUNT_50_MSEC, FALSE); //CoCo1.20, reduce code size    OS_DelayTime(COUNT_50_MSEC); //CoCo1.20, reduce code size#endif  // #ifdef  SUPPORT_PROM_DISABLE    // STEP1: Identify the AP to check validity    // If validity, __AP_Info will be assign the right value    if(AP_Identify(dwType, dwStartPos)==NULL)    {        // Chuan2.77, for AP on DRAM checksum error display, 2007/4/11 06:23PM            if (__AP_Info.dwAP_Type ==  AP_AUTO_UPGRADE)        {            DWORD dwSaveInt;                          OS_DelayTime(COUNT_1_SEC);                        HAL_WatchDog_Enable(FALSE);            OS_DISABLE_INTERRUPTS(dwSaveInt);            while(1);        }        else        {            return FALSE;        }    }    // Disable Information for DBG    DBG_Disable();    // Can't call GDI Function @ Non CHEERDVD Thread because CHEERDVD Thread has been suspended!!. It may be cause deadlock.    // Therefore, release Mutex of GDI Function    OS_TryLockMutex( &__mutexGDIIdle );    OS_UnlockMutex(&__mutexGDIIdle);    // STEP2: Turn off MainVideo/ PIP/ SP1/ SP2.#ifdef SUPPORT_TFT_DIGITAL_MODE    HAL_AdjustTFT_DigitalMode(FALSE);#endif        DISP_DisplayCtrl(DISP_MAINVIDEO, FALSE);    DISP_DisplayCtrl(DISP_PIP, FALSE);    DISP_DisplayCtrl(DISP_SP1, FALSE);    DISP_DisplayCtrl(DISP_SP2, FALSE);    DISP_DisplayCtrl(DISP_OSD, FALSE);    DISP_DelayVSYNC(1);        // LLY2.20, rename it as UTL_Config_BufferMode()    UTL_Config_BufferMode(DUMP_BUFF_AP_MODE);    // Chuan2.38a, Can't call GDI Function @ Non CHEERDVD Thread. It may be cause deadlock.    GDI_DeactivateRegion();    RegionInfo.wWidth = 616;    RegionInfo.wHeight = 78;    RegionInfo.bColorMode = GDI_OSD_4B_MODE;    RegionInfo.dwTAddr = DS_OSDFRAME_ST_AP;    GDI_ConfigRegionInfo(0, &RegionInfo);    GDI_InitialRegion(0);    GDI_ClearRegion(0);    GDI_ActivateRegion(0);    DISP_DelayVSYNC(1);    // STEP3: Load AP to DRAM    // Chuan2.77, add for unprotection with loverlap DS_OSD_FONTTABLE_ST,2007/4/11 04:29PM    MACRO_MCU_WRITE_PROTECTION_ENABLE(MCU_WRITE_PROTECTION_DISABLE_ALL);        switch(dwType)    {        case SRC_FROM_USB:        case SRC_FROM_SERVO:            INFOFILTER_ResetDumpSectors();            INFOFILTER_DumpSectors(dwStartPos, dwSize, (BYTE *)DS_AP_CODE_AREA, __AP_Info.dwAP_Size, 0);            HAL_PowerControl(HAL_POWER_USB, HAL_POWER_SAVE);            USB_HCExit();#ifndef NO_DISC_MODE            // Chuan1.20, Open tray after AP_Loader(). (For Auto-Upgrade)            if ((__AP_Info.dwAP_Type ==  AP_AUTO_UPGRADE) && (dwType == SRC_FROM_SERVO))            {                SrcFilter_OpenTray();                dwTime = OS_GetSysTimer() ;                while (OS_GetSysTimer() - dwTime < COUNT_10_SEC)                {                    if (SrcFilter_CheckTrayStatus () == SRC_TRAY_OPENED)                        break;                }            }                        if (dwType == SRC_FROM_SERVO)            {                // Chuan1.21, Force Servo enter power down mode, else it can't                // stop for COBY platform (Can't be eject                SrcFilter_PowerMode(SERVO_POWER_STOP);            }            // LLY2.37, using procedure to check servo real stop            // Otherwiss, sometime servo pick-up maybe still running while upgrade from USB mode            // Notice: Servo power down command has been issued while switching to USB mode            // **** Will be removed while SrcFilter_GetStatus() w/ desired source index is ok            //OS_DelayTime(COUNT_100_MSEC);	// Chuan2.18, wait 100 msec for Servo power down            dwTime = OS_GetSysTimer() ;            while(OS_GetSysTimer() - dwTime < COUNT_10_SEC)            {                if(SrcFilter_GetStatus(SOURCE_DISC) != SRC_SPINDLE_STATUS_SPINNING)                {                    break;                }                else                {                    OS_YieldThread();                }            }#endif  // #ifndef NO_DISC_MODE            break;        case SRC_FROM_FLASH:        case SRC_FROM_DRAM:            if (dwStartPos != DS_AP_CODE_AREA)            {                HAL_CopyDRAM(dwStartPos, DS_AP_CODE_AREA, dwSize);            }            break;    }    // STEP4: Do checksum & Prepare AP Additional Information    if (__AP_Info.dwExternalFlag == TRUE)    {        WORD  wCheckSum;        // Do Checksum ..        wCheckSum = HAL_CheckSum((DS_AP_CODE_AREA+sizeof(AP_INFO)), (DS_AP_CODE_AREA+__AP_Info.dwAP_Size));        if ((WORD)__AP_Info.dwCheckSum != wCheckSum)        {            // DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "CheckSum Error: %x ->%x", (WORD)__AP_Info.dwCheckSum, wCheckSum);            // Chuan2.77, for AP on DRAM checksum error display, 2007/4/11 06:23PM            MainBGColor.Color.bY = 0x4C;            MainBGColor.Color.bU = 0x54;            MainBGColor.Color.bV = 0xFF;            DISP_BGColorSet(MainBGColor, DISP_MAIN_BG);            OS_DelayTime(COUNT_3_SEC);            if (__AP_Info.dwAP_Type ==  AP_AUTO_UPGRADE)            {                DWORD dwSaveInt;                                HAL_WatchDog_Enable(FALSE);                OS_DISABLE_INTERRUPTS(dwSaveInt);                while(1);            }            else            {                _AP_REBOOT();            }            //peteryu dmp117dvb, for AP on DRAM checksum error display, 2007/4/11 06:23PM end                        return FALSE;        }        // STEP4: Prepare Additional Information to prepare area.        // LLY1.50, need pass AP source while prepare AP_INFO_ADDITIONAL structure        _AP_Prepare_AdditionalInfo(dwType);    }    // STEP6: Jump to 0x40001000 or prepare area to run the AP.    ROMLD_BOOT_LoadSectionAndRun((PSECTION_ENTRY)AP_TABLE_ADDRESS, __AP_Info.dwAP_UNZIP_BUF, __AP_Info.dwAP_SP);    return TRUE;}//  *********************************************************************//  Function    :   APCode_Version_Check//  Description :   Check the version of AP//  Arguments   :   apVersion, version of AP//  Return      :   TRUE, Version is ok//                  FALSE, Version is wrong//  *********************************************************************//  peteryu275, add for IC check version, 2007/3/22 11:31AMBYTE    _AP_IC_Version_Check(DWORD dwAPVersion){    BYTE bAPCheckStatus = FALSE;        if (dwAPVersion == IC_VERSION_RESERVED || dwAPVersion == IC_VERSION_ID)    {        bAPCheckStatus = TRUE;    }    return bAPCheckStatus;}   // BYTE _AP_IC_Version_Check(DWORD dwAPVersion)// LLY1.50 create, base on _AP_Identify() to build a new API// Then, it can get AP_INFO structure, and return the AP ID//  *******************************************************************************//  Function    :   AP_Identify//  Description :   Parsing AP_INFO structure, and return the structure pointer//  Argument    :   dwSource, specify the AP source, ex. USB/ Servo/ DRAM/ Flash//                  dwStartPos, specify the AP start address//  Return      :   AP_INFO structure pointer if allow to switch it, or//                  NULL if dis-allow to switch it.//  *******************************************************************************//#define DEBUG_AP_INFOPAP_INFO   AP_Identify(BYTE bSource, DWORD dwStartPos){    DWORD   dwAPCodeArea=0;    // Step 1: Dump AP_INFO structure content    switch(bSource)    {    case    SRC_FROM_USB:    case    SRC_FROM_SERVO:

⌨️ 快捷键说明

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