/*---------------------------------------------------------- * * func name: get_system_version_info() * function : 得到当前系统的软件相关版本信息. 存放于systemversion * calllist : sto_chunk_count() * sto_chunk_goto() * sto_get_chunk_header() * * calledlist: * input : * output : * parameter: 无 * * return : 0 获取内存失败 * block_number 版本信息数目 * * * * notice : systemversion内存要注意释放 *--------------------------------------------------------*/ unsigned int get_system_version_info(void) { int i = 0; UINT32 id; UINT32 mask; block_number = sto_chunk_count(0,0); if(0 == block_number) return 0; systemversion = (CHUNK_HEADER*)MALLOC(sizeof(CHUNK_HEADER)*block_number); if(NULL == systemversion) { libc_printf("Get Memorey fialed!!\n"); return -1; } //bootloader, maincode,seecode,Radioback,Radiobg,cccam_prio,softcamkey //cccam_newcamd,defaultdb,userdb for(i = 0; i<block_number; i++) { id = mask = 0; sto_chunk_goto(&id,mask,i+1); sto_get_chunk_header(id, systemversion+i); } return block_number; }
static void win_rs232upg_clear() { UINT8 i,chunk_number; chunk_number = sto_chunk_count(0,0); #ifdef HDCP_IN_FLASH chunk_number--; #endif #ifdef DIVX_CERT_ENABLE chunk_number--; #endif if(rs232upg_upgtype_chars != NULL) { for(i=0;i<chunk_number;i++) FREE(rs232upg_upgtype_chars[i]); FREE(rs232upg_upgtype_chars); rs232upg_upgtype_chars = NULL; } }
INT32 InitBlockList() { #if (defined HDCP_IN_FLASH ||defined DIVX_CERT_ENABLE) UINT8 i=0; CHUNK_LIST *temp_pblock_list; INT32 temp_block_number=0,temp_block_number2=0; UINT32 Block_id=0,HDCP_key_ID=0,divx_key_id=0; #ifdef HDCP_IN_FLASH HDCP_key_ID=HDCPKEY_CHUNK_ID; #endif #ifdef DIVX_CERT_ENABLE divx_key_id = DIVX_CHUCK_ID; #endif #endif sto_chunk_init(0, 0); // block_number = chunk_count(0,0); block_number = sto_chunk_count(0,0); if(block_number <= 0 ) return !SUCCESS; FreeBlockList(); // P2PUPG_DBG("p2p: alloc block list!!!\n"); pblock_list = (CHUNK_LIST *)MALLOC(sizeof(CHUNK_LIST)*block_number); if(pblock_list == NULL) return !SUCCESS; // if(!get_chunk_list(pblock_list)) if(!sto_get_chunk_list(pblock_list)) { FREE(pblock_list); pblock_list = NULL; return !SUCCESS; } #ifdef HDCP_IN_FLASH if(m_allcode_include_bootloader==1) return SUCCESS; (temp_pblock_list)= (CHUNK_LIST *)MALLOC(sizeof(CHUNK_LIST)*block_number); for(i=0;i<block_number;i++) { if(((UINT32 )pblock_list[i].id)!=HDCP_key_ID) { MEMCPY((temp_pblock_list+temp_block_number),(pblock_list+i),sizeof(CHUNK_LIST)); temp_block_number++; } } FREE(pblock_list); block_number=temp_block_number; pblock_list = (CHUNK_LIST *)MALLOC(sizeof(CHUNK_LIST)*block_number); MEMCPY(pblock_list,temp_pblock_list,sizeof(CHUNK_LIST)*block_number); FREE(temp_pblock_list); #endif #ifdef DIVX_CERT_ENABLE (temp_pblock_list)= (CHUNK_LIST *)MALLOC(sizeof(CHUNK_LIST)*block_number); for(i=0;i<block_number;i++) { if(((UINT32 )pblock_list[i].id)!=divx_key_id) { MEMCPY((temp_pblock_list+temp_block_number),(pblock_list+i),sizeof(CHUNK_LIST)); temp_block_number++; } } FREE(pblock_list); block_number=temp_block_number; pblock_list = (CHUNK_LIST *)MALLOC(sizeof(CHUNK_LIST)*block_number); MEMCPY(pblock_list,temp_pblock_list,sizeof(CHUNK_LIST)*block_number); FREE(temp_pblock_list); #endif return SUCCESS; }
static void display_sys_infomation(UINT8 flag) { CHUNK_HEADER blk_header; UINT8 i; UINT32 id,mask; char str[30]; BYTE info_block_number; info_block_number = sto_chunk_count(0,0); for(i=0;i<info_block_number;i++) { id = mask = 0; sto_chunk_goto(&id,mask,i + 1); sto_get_chunk_header(id, &blk_header); set_info_con_rect(CON_L, CON_T + (CON_H + CON_GAP)*i,CON_W,CON_H); /* Name */ OSD_SetTextFieldContent(&info_txt_name,STRING_ANSI, (UINT32)blk_header.name); if(flag == 0) {//show version & time /* Version */ if(i==0) OSD_SetTextFieldContent(&info_txt1,STRING_ANSI, (UINT32)&blk_header.version[8]); #ifdef UPGRADE_BY_CUSTOMER_ID else if(i == 1)/*main code version*/ { if(blk_header.version[1] != '.') { OSD_SetTextFieldContent(&info_txt1,STRING_ANSI, (UINT32)&blk_header.version[CUSTOMER_ID_LENGTH]); } else { OSD_SetTextFieldContent(&info_txt1,STRING_ANSI, (UINT32)blk_header.version); } } #endif else OSD_SetTextFieldContent(&info_txt1,STRING_ANSI, (UINT32)blk_header.version); /* Time */ OSD_SetTextFieldContent(&info_txt2,STRING_ANSI, (UINT32)blk_header.time); } else {//show length & offset /*length*/ sprintf(str,"0x%x",blk_header.len); OSD_SetTextFieldContent(&info_txt1,STRING_ANSI, (UINT32)str); /* Offset */ sprintf(str,"0x%x",blk_header.offset); OSD_SetTextFieldContent(&info_txt2,STRING_ANSI, (UINT32)str); } OSD_DrawObject((POBJECT_HEAD )&info_item_con,C_UPDATE_ALL); } }
static void win_rs232upg_load_chunk_info() { CHUNK_HEADER blk_header; UINT32 id,mask; UINT8 chunk_number; UINT8 i; char strTmp[30]; char strTmp1[30]; char strTmp2[30]; char strTmp3[30]; char strTmp4[30]; char strTmp5[30]; char strTmp6[30]; char strTmp7[30]; char strTmp8[30]; #if (defined HDCP_IN_FLASH ||defined DIVX_CERT_ENABLE) UINT32 Block_id = 0, HDCP_key_ID = 0,divx_key_ID = 0,ciplus_key_ID = 0; UINT8 hdcp_chunk_index = 0; UINT8 cipluskey_chunk_index = 0; BOOL has_hdcp_chunk = FALSE; BOOL has_cipluskey_chunk = FALSE; UINT8 divx_chunk_index = 0; BOOL has_divx_chunk = FALSE; UINT32 special_type =0; #endif //-a by wangyang del seecode upgrade {{ UINT32 seecode_key_ID = 0; UINT8 seecode_chunk_index = 0; BOOL has_seecodekey_chunk = FALSE; //-a by wangyang del seecode upgrade }} chunk_number = sto_chunk_count(0,0); if(chunk_number == 0) return; if(InitBlockList() != SUCCESS) return; if(rs232upg_upgtype_chars != NULL) FREE(rs232upg_upgtype_chars); rs232upg_upgtype_chars = (UINT16**)MALLOC(sizeof(UINT16*)*chunk_number); if(rs232upg_upgtype_chars == NULL) ASSERT(0); for(i=0; i<chunk_number; i++) { rs232upg_upgtype_chars[i] = (UINT16*)MALLOC(16*sizeof(UINT16)); if(rs232upg_upgtype_chars[i] == NULL) ASSERT(0); } // STRCPY(rs232upg_upgtype_chars[0],"allcode"); { UINT16 *unistr=NULL; unistr=OSD_GetUnicodeString(RS_TOTAL_FLASH); ComUniStrCopyChar(rs232upg_upgtype_chars[0],(UINT16 *)unistr); //ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_TOTAL_FLASH),strTmp); //STRCPY(rs232upg_upgtype_chars[0],strTmp); } for(i=1; i<chunk_number; i++) { id = mask = 0; sto_chunk_goto(&id,mask,i + 1); sto_get_chunk_header(id, &blk_header); #if (defined HDCP_IN_FLASH ||defined DIVX_CERT_ENABLE || defined CI_PLUS_SUPPORT ) special_type = 0; #ifdef HDCP_IN_FLASH HDCP_key_ID = HDCPKEY_CHUNK_ID; if(((UINT32)blk_header.id) == HDCP_key_ID) { hdcp_chunk_index = i; has_hdcp_chunk = TRUE; special_type = 1; } #endif #ifdef DIVX_CERT_ENABLE divx_key_ID = DIVX_CHUCK_ID; if(((UINT32)blk_header.id) == divx_key_ID) { divx_chunk_index = i; has_divx_chunk = TRUE; special_type = 1; } #endif #ifdef CI_PLUS_SUPPORT ciplus_key_ID = CIPLUSKEY_CHUNK_ID; if(((UINT32)blk_header.id) == ciplus_key_ID) { cipluskey_chunk_index = i; has_cipluskey_chunk = TRUE; special_type = 1; } #endif //-a by wangyang del seecode upgrade {{ seecode_key_ID =SEECODE_CHUNK_ID if(((UINT32)blk_header.id) == ciplus_key_ID) { seecode_chunk_index = i; has_seecodekey_chunk = TRUE; special_type = 1; } //-a by wangyang del seecode upgrade }} if(special_type != 1) { STRCPY(rs232upg_upgtype_chars[i], blk_header.name); //-a by wangyang del seecode upgrade {{ if(i==1) { ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_FIRMWARE),strTmp1); STRCPY(rs232upg_upgtype_chars[i], strTmp1); } else if (i == 2) { ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_SEECODE),strTmp2); STRCPY(rs232upg_upgtype_chars[i],strTmp2); } else if (i == 3) { ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_LOGO),strTmp3); STRCPY(rs232upg_upgtype_chars[i], strTmp3); } else if (i == 4) { ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_CCCAM_PRIO),strTmp4); STRCPY(rs232upg_upgtype_chars[i], strTmp4); } else if (i == 5) { ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_CCCAM_NEWCAM),strTmp5); STRCPY(rs232upg_upgtype_chars[i], strTmp5); } else if (i == 6) { ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_DEFAULT_DATA),strTmp6); STRCPY(rs232upg_upgtype_chars[i], strTmp6); } else if (i == 7) { ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_USER_DATA),strTmp7); STRCPY(rs232upg_upgtype_chars[i], strTmp7); } //-a by wangyang del seecode upgrade }} } #else STRCPY(rs232upg_upgtype_chars[i],blk_header.name); //-a by wangyang del seecode upgrade {{ seecode_key_ID =SEECODE_CHUNK_ID; if(((UINT32)blk_header.id) == seecode_key_ID) { seecode_chunk_index = i; has_seecodekey_chunk = TRUE; //special_type = 1; } if(i==1) { UINT16 *unistr=NULL; unistr=OSD_GetUnicodeString(RS_FIRMWARE); ComUniStrCopyChar(rs232upg_upgtype_chars[1],(UINT16 *)unistr); //ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_FIRMWARE),strTmp1); //STRCPY(rs232upg_upgtype_chars[1], strTmp1); } else if (i == 2) { // ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_SEECODE),strTmp2); // STRCPY(rs232upg_upgtype_chars[i], strTmp2); } else if (i == 3) { // ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_LOGO),strTmp3); // STRCPY(rs232upg_upgtype_chars[i],strTmp3); } else if (i == 4) { // ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_CCCAM_PRIO),strTmp4); // STRCPY(rs232upg_upgtype_chars[i], strTmp4); } else if (i == 5) { // ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_CCCAM_NEWCAM),strTmp5); // STRCPY(rs232upg_upgtype_chars[i], strTmp5); } else if (i == 6) { // ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_DEFAULT_DATA),strTmp6); // STRCPY(rs232upg_upgtype_chars[i], strTmp6); } else if (i == 9) { // ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_USER_DATA),strTmp7); // STRCPY(rs232upg_upgtype_chars[2],strTmp7); } //-a by wangyang del seecode upgrade }} #endif } //-a by wangyang del seecode upgrade {{ if(has_seecodekey_chunk == TRUE) { FREE(rs232upg_upgtype_chars[seecode_chunk_index]); for(i=seecode_chunk_index; i<chunk_number;i++) rs232upg_upgtype_chars[i] = rs232upg_upgtype_chars[i+1]; chunk_number--; #ifdef HDCP_IN_FLASH if( (has_seecodekey_chunk == TRUE) && seecode_chunk_index < hdcp_chunk_index) hdcp_chunk_index --; if( (has_divx_chunk == TRUE) && seecode_chunk_index < cipluskey_chunk_index) cipluskey_chunk_index --; if( (has_divx_chunk == TRUE) && seecode_chunk_index < divx_chunk_index) divx_chunk_index --; #endif } //-a by wangyang del seecode upgrade }} #ifdef HDCP_IN_FLASH if(has_hdcp_chunk == TRUE) { FREE(rs232upg_upgtype_chars[hdcp_chunk_index]); for(i=hdcp_chunk_index; i<chunk_number;i++) rs232upg_upgtype_chars[i] = rs232upg_upgtype_chars[i+1]; chunk_number--; if( (has_cipluskey_chunk == TRUE) && hdcp_chunk_index < cipluskey_chunk_index) cipluskey_chunk_index --; if( (has_divx_chunk == TRUE) && hdcp_chunk_index < divx_chunk_index) divx_chunk_index --; } #endif #ifdef DIVX_CERT_ENABLE if(has_divx_chunk == TRUE) { FREE(rs232upg_upgtype_chars[divx_chunk_index]); for(i=divx_chunk_index; i<chunk_number;i++) rs232upg_upgtype_chars[i] = rs232upg_upgtype_chars[i+1]; chunk_number--; if( (has_cipluskey_chunk == TRUE) && divx_chunk_index < cipluskey_chunk_index) cipluskey_chunk_index --; } #endif #ifdef CI_PLUS_SUPPORT if(has_cipluskey_chunk == TRUE) { FREE(rs232upg_upgtype_chars[cipluskey_chunk_index]); for(i=cipluskey_chunk_index; i<chunk_number;i++) rs232upg_upgtype_chars[i] = rs232upg_upgtype_chars[i+1]; chunk_number--; } #endif #if (defined HDCP_IN_FLASH ||defined DIVX_CERT_ENABLE || defined CI_PLUS_SUPPORT ) OSD_SetMultiselSelTable(&rs232upg_sel_upgrade_type,rs232upg_upgtype_chars); OSD_SetMultiselCount(&rs232upg_sel_upgrade_type, chunk_number); #else OSD_SetMultiselSelTable(&rs232upg_sel_upgrade_type,rs232upg_upgtype_chars); OSD_SetMultiselCount(&rs232upg_sel_upgrade_type, 2); #endif }
unsigned int nVersion = 0xb722; //LIB_ASH_OC(argc & 0xFF); //LIB_ASH_OC(argv[1][0]); //LIB_ASH_OC(argv[1][1]); if( argc >= 2 && argv[1][0] == 0x2d && argv[1][1] == 0x72)//"-r" { #ifdef TRANSFER_FORMAT2_SUPPORT LIB_ASH_OC((nVersion >> 8) & 0xFF); LIB_ASH_OC( nVersion & 0xFF); #endif } /* collect information */ n = sto_chunk_count(0, 0); of = sto_chunk_goto(&chid, 0, n); len = sto_fetch_long(of + CHUNK_LENGTH); /* send Length */ data_len = n * CHUNK_HEADER_SIZE + 2; LIB_ASH_OC((data_len >> 8) & 0xFF); LIB_ASH_OC(data_len & 0xFF); crc = 0xFFFFFFFF; /* send Flash ID */ LIB_ASH_OC(flash_id_val); crc = MG_Table_Driven_CRC(crc, &flash_id_val, 1); /* send Chunk Status */ LIB_ASH_OC(g_crc_bad); crc = MG_Table_Driven_CRC(crc, &g_crc_bad, 1);