📄 aploader.c
字号:
INFOFILTER_ResetDumpSectors(); INFOFILTER_DumpSectors(dwStartPos, 1, (BYTE *)&__AP_Info, sizeof(AP_INFO), 0); break; case SRC_FROM_DRAM: case SRC_FROM_FLASH: // Get AP_INFO structure content first HAL_CopyDRAM(dwStartPos, (DWORD)&__AP_Info, sizeof(AP_INFO)); break; }#ifdef DEBUG_AP_INFO DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "AP_INFO structure information\n"); DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "Identify [1]: %lx, Identify [2]: %lx, AP_Type: %lx, External Flag: %lx", __AP_Info.dwIdentify[0], __AP_Info.dwIdentify[1], __AP_Info.dwAP_Type, __AP_Info.dwExternalFlag); DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "Version AP: %lx, Chip Version: %lx", __AP_Info.dwVersionAP, __AP_Info.dwChipVersion); DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "AP Description: %lx, %lx, %lx, %lx\n", __AP_Info.dwDescription[0], __AP_Info.dwDescription[1], __AP_Info.dwDescription[2], __AP_Info.dwDescription[3]);#endif // #ifdef DEBUG_AP_INFO // STEP 2: Check support chip verion first -- LLY2.00 // if(__AP_Info.dwChipVersion != 1) // peteryu275, modified for IC check version, 2007/3/22 11:31AM if (_AP_IC_Version_Check(__AP_Info.dwChipVersion) == FALSE) { DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "Err: Not desired chip version auto-upgrade code: %lx,now: %lx\n", __AP_Info.dwChipVersion, IC_VERSION_ID); __OSDNDUpMsgAttr.wX -= GDI_GetStringWidth_909(aAP_IC_VERSION_ERROR); GDI_DrawString_909(0, &__OSDNDUpMsgAttr, aAP_IC_VERSION_ERROR); __OSDNDUpMsgAttr.wX += GDI_GetStringWidth_909(aAP_IC_VERSION_ERROR); OS_DelayTime(COUNT_3_SEC); return (NULL); } // STEP 3: Check the identify string "CT909-AP" if ((CT909AP_IDENTIFY1 != __AP_Info.dwIdentify[0]) || (CT909AP_IDENTIFY2 != __AP_Info.dwIdentify[1])) { DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "Err: ID is %lx, %lx\n", __AP_Info.dwIdentify[0], __AP_Info.dwIdentify[1]); return (NULL); } // STEP 4: Check the space is enough or not. // Calculate the AP code area base on DRAM type // ie. from AP_CODE_AREA ~ (DRAM end address - 4) // So, size = DRAM end address - AP_CODE_AREA dwAPCodeArea = HAL_GetDRAMSize(); if(dwAPCodeArea == HAL_DRAM_UNKNOWN) { DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "Err: Unknown DRAM type to calculate AP code area !\n"); return (NULL); } else { dwAPCodeArea -= DS_AP_CODE_AREA; } if(__AP_Info.dwAP_Size > dwAPCodeArea) { DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "Err: AP Size is %lx, larger than reserved space !\n", __AP_Info.dwAP_Size); return (NULL); } if(__AP_Info.dwVersionAP <= 4) { DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "Err: APPacker Version %lx is too old !\n", __AP_Info.dwVersionAP); return (NULL); } // Step 4: Return AP_INFO structure pointer if allow to switch return &__AP_Info;}// *********************************************************************// Function : AP_SwitchMode// Description : Switch to desired AP mode// Arguments : bAPID, specify the desired AP ID// Return : TRUE, the aciton is ok// FALSE, the action is failure// *********************************************************************// LLY2.15, modify the procedure since AP location method has updated.BYTE AP_SwitchMode(BYTE bAPID){ PAP_INFO pAP_Info; BYTE i=0; PSECTION_ENTRY pSec=NULL; // Step 1: Find if exist the desired AP ID while(1) { // Check if exist section name. // I0f zero, exit it. itmeans end of section. if(pSec[i].dwName == 0) { DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "Err: Can't find AP since end of section\n"); return (FALSE); } // Give section address to check if AP code pAP_Info=AP_Identify(SRC_FROM_FLASH, pSec[i].dwRMA); // Exit the loop directly if AP_Identify() return NULL // ie. don't support to switch AP if(pAP_Info == NULL) { i++; continue;// DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "Err: Switch AP fail since AP_Identify() return FALSE\n");// return FALSE; } // Exit the finding loop if find the desired AP if(pAP_Info->dwAP_Type == bAPID) { DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "Find the desired AP, location: %lx\n", pSec[i].dwRMA); break; } // increas sector index to check next section. i++; // exit the loop, if section index > supported number. if(i>=32) { DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "Err: Can't find AP since section > 32\n"); return (FALSE); } } DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "Switch to AP mode, ID: %lx\n", bAPID); // LLY2.00, stop decoder, parser, source before enter AP mode HAL_PlayCommand(COMMAND_STOP, 0); // wyc2.53-909P, SrcFilter_Stop(__dwSFStreamID); HAL_ControlParser(HAL_PARSER_STOP, 0); // Step 3: Remove all UI by following procedure. // Turn-off all UI, and related information, PIP ... OSD_RemoveAllUI(); // Micky0.72, must put after OSD_Remove UI, as OSD need to reference some info. OSD_NormalMode(); // Step 4: Start AP mode switch. __dwTemp=AP_Loader(SRC_FROM_FLASH, pSec[i].dwRMA, pSec[i].dwRSize); if(__dwTemp==FALSE) { BYTE bMode=0; DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "AP_Loader() fail. So, re-booting\n"); // Notice: need restore the AP mode to DVD mode HAL_WriteStorage(SETUP_ADDR_AP_MODE, &bMode, 1); // Re-booting. _AP_REBOOT(); } return TRUE;}// LLY1.50, add one parameter for this API since AP_INFO_ADDITIONAL structure need it.//VOID _AP_Prepare_AdditionalInfo(VOID)VOID _AP_Prepare_AdditionalInfo(DWORD dwAPSource){ PAP_INFO_ADDITIONAL AP_Info_Additional; DWORD dwIdx; DWORD dwPCB_Number; DWORD dwSaveInt; // LLY2.05, define a pointer to IR_INFO structure to get IR related information. PIR_INFO pIR_Info; // Get IR related information. pIR_Info = INPUT_GetIRInfo(); // Get PCB Number#ifdef SUPPORT_SERVO_SOURCE { extern BYTE SRVDBG_PCBNumber(void); dwPCB_Number = SRVDBG_PCBNumber(); }#else dwPCB_Number = 0x0;#endif // Disable all INT to write DRAM 0x40000000 ~ 0x40001000 Memory OS_DISABLE_INTERRUPTS( dwSaveInt ); // REG_PLAT_RESET_CONTROL_ENABLE = (PLAT_RESET_USB_ENABLE|PLAT_RESET_USBCLKCKT_ENABLE); // Chuan2.18, Can't reset Servo for GPB issue. REG_PLAT_RESET_CONTROL_ENABLE = (INT_SET_ALL& (~(PLAT_RESET_DSU1_ENABLE | PLAT_RESET_TIMER_ENABLE | PLAT_RESET_SERVO_ENABLE | PLAT_RESET_VOU_ENABLE | PLAT_RESET_VOU2_ENABLE | PLAT_RESET_PROM_ENABLE))); REG_PLAT_INT_MASK_PRIORITY = INT_CLEAR_ALL; REG_PLAT_INT_CLEAR = INT_SET_ALL; REG_PLAT_PROC1_1ST_INT_MASK_ENABLE = INT_SET_ALL; REG_PLAT_PROC1_1ST_INT_PENDING = INT_CLEAR_ALL; REG_PLAT_PROC1_2ND_INT_MASK_ENABLE = INT_SET_ALL; REG_PLAT_PROC1_2ND_INT_PENDING = INT_CLEAR_ALL; REG_PLAT_PROC1_1ST_INT_CLEAR = INT_SET_ALL; REG_PLAT_PROC1_2ND_INT_CLEAR = INT_SET_ALL; AP_Info_Additional = (PAP_INFO_ADDITIONAL)(0x40000000); AP_Info_Additional->pTableAddress = (PSECTION_ENTRY)(AP_TABLE_ADDRESS); AP_Info_Additional->dwVersionFAE = __dwVersionFAE; AP_Info_Additional->dwVersionServo = __dwVersionServo; AP_Info_Additional->dwPCB_Number = dwPCB_Number; AP_Info_Additional->dwVersionFlash = FLASH_SW_VERSION;// AP_Info_Additional->dwVersionTool = TOOLS_SW_VERSION; AP_Info_Additional->dwVersionAP_INFO_ADDITIONAL = 5; AP_Info_Additional->dwIRType = (DWORD) pIR_Info->bIR_Type; AP_Info_Additional->dwAP_Type = __AP_Info.dwAP_Type; AP_Info_Additional->dwExternalFlag = __AP_Info.dwExternalFlag; switch(__bMPEGVideoMode) { case MPEG_VIDEO_MODE_NTSC: if(__SetupInfo.bProgressiveScan == SETUP_PROGRESSIVE_SCAN_ON) { AP_Info_Additional->dwTVMode = MODE_NTSC_NORMAL | MODE_PSCAN; } else { AP_Info_Additional->dwTVMode = MODE_NTSC_NORMAL; } break; default: case MPEG_VIDEO_MODE_PAL: if(__SetupInfo.bProgressiveScan == SETUP_PROGRESSIVE_SCAN_ON) { AP_Info_Additional->dwTVMode = MODE_PAL_NORMAL | MODE_PSCAN; } else { AP_Info_Additional->dwTVMode = MODE_PAL_NORMAL; } break; } // LLY2.05, using IR reported information to prepare the IR map table and size directly AP_Info_Additional->bIRMapSize = pIR_Info->bIRMapSize; for(dwIdx=0; dwIdx<pIR_Info->bIRMapSize; dwIdx++) { AP_Info_Additional->bIRMap[dwIdx] = pIR_Info->aIRMap[dwIdx]; } // LLY2.05, using IR reported information to prepare IR customer code value AP_Info_Additional->bIR_Customer_Code[0] = pIR_Info->bCustomerCode; AP_Info_Additional->bIR_Customer_Code[1] = pIR_Info->bCustomerCode1; // LLY1.50, assign new elements value for AP_INFO_ADDITIONAL structure v4.0 AP_Info_Additional->wAPSource = (WORD)(dwAPSource); AP_Info_Additional->wAP_EEPROM_Addr = SETUP_ADDR_AP_MODE; // Append customer version string for Auto-Upgrade reference dwIdx = (DWORD)-1; do { dwIdx++; AP_Info_Additional->csVersionCustomer[dwIdx] = __csVersionCustomer[dwIdx]; } while((dwIdx<24) && (__csVersionCustomer[dwIdx] != 0x0)); ROMLD_MoveSectionTable((PSECTION_ENTRY)(DS_AP_CODE_AREA + sizeof(AP_INFO) + (DWORD)ROMLD_SECTION_TABLE_ADDR), (PSECTION_ENTRY)AP_TABLE_ADDRESS);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -