RET_CODE sys_get_host_key(UINT8 *key, UINT32 *len, UINT32 type) { unsigned long addr; CIPLUS_KEY_HDR hdr; UINT8 aes_key[16]; UINT8 *encryped_data; struct sto_device *dev = (struct sto_device *)dev_get_by_id(HLD_DEV_TYPE_STO, 0); libc_printf("%s - type %d\n",__FUNCTION__,type); if(RET_SUCCESS != find_key(CIPLUS_KEY_AES_KEY, &addr, &hdr)) return RET_FAILURE; sto_get_data(dev, aes_key, addr, 16); if(RET_SUCCESS != find_key(type, &addr, &hdr)) return RET_FAILURE; encryped_data = (UINT8 *)MALLOC(hdr.size); //encryped_data = g_ci_tmp_buff; sto_get_data(dev, encryped_data, addr, hdr.size); decrypt_key(encryped_data, key, aes_key, hdr.size); if(len) *len = hdr.size; FREE(encryped_data); return RET_SUCCESS; }
static UINT8 gyca_readmail_all_from_flash(UINT32 addr, UINT32 mail_head_size) { struct sto_device *flash_dev = NULL; UINT32 mailaddr; mailaddr=addr + mail_head_size; //flash_dev = (struct sto_device *)dev_get_by_type(NULL, HLD_DEV_TYPE_STO); flash_dev = (struct sto_device *)dev_get_by_id(HLD_DEV_TYPE_STO, 0); if(NULL == flash_dev) { GYCAS_PRINTF("gyca_readmail_all_from_flash: dev_get_by_name failed!\n"); return 1; } gyca_mutex_lock(); if ( sizeof(gycamail)*GYCA_EMAIL_MAX_CNT != sto_get_data(flash_dev, flashbuf, mailaddr, sizeof(gycamail)*GYCA_EMAIL_MAX_CNT)) { MEMSET(flashbuf, 0, sizeof(flashbuf)); gyca_mutex_unlock(); GYCAS_PRINTF("%s: sto_get_data failed!\n", __FUNCTION__); return 2; } gyca_mutex_unlock(); return 0; }
static UINT8 gyca_check_flash_mail_head(UINT32 addr) { struct sto_device *flash_dev = NULL; UINT32 mailaddr = addr; UINT8 mail_head[GYCA_MAIL_HEAD_SIZE]; //flash_dev = (struct sto_device *)dev_get_by_type(NULL, HLD_DEV_TYPE_STO); flash_dev = (struct sto_device *)dev_get_by_id(HLD_DEV_TYPE_STO, 0); if(NULL == flash_dev) { GYCAS_PRINTF("%s: dev_get_by_name failed!\n", __FUNCTION__); return 1; } //if (SUCCESS != flash_dev->get_data(flash_dev, mail_head, mailaddr, GYCA_MAIL_HEAD_SIZE)) if (GYCA_MAIL_HEAD_SIZE != sto_get_data(flash_dev, mail_head, mailaddr, GYCA_MAIL_HEAD_SIZE)) { GYCAS_PRINTF("%s: sto_get_data failed!\n", __FUNCTION__); return 2; } gyca_mutex_lock(); if(MEMCMP(mail_head,gyca_mail_head, GYCA_MAIL_HEAD_SIZE)) { gyca_mutex_unlock(); return 3; } gyca_mutex_unlock(); return 0; }
static INT8 stb_hwinfo_load(STB_HWINFO *hwinfo) { INT8 ret = 0, i; UINT32 check_data; UINT8 data[STB_HWINFO_LEN]; BOOL old2new = FALSE; struct sto_device *sto = (struct sto_device *)dev_get_by_id(HLD_DEV_TYPE_STO, 0); if(NULL == sto) { ret = -1; goto RETURN; } MEMSET(data,0,STB_HWINFO_LEN); sto_get_data(sto, data, STB_HWINFO_BASE_ADDR, sizeof(STB_HWINFO)); #if 0 check_data = ((data[0]<<24) |(data[1]<<16) |(data[2]<<8) |(data[3])); if(check_data == 0xffffffff) { ret = -1; goto RETURN; } #endif MEMCPY(hwinfo, data, sizeof(STB_HWINFO)); //libc_printf("load oui = %d, hwmode = %d, hwversion = %d\n", hwinfo->stb_oui, hwinfo->stb_hw_model, hwinfo->stb_hw_version); RETURN: return ret; }
static UINT8 find_ota_loader(UINT32 *ota_loader_addr) { #define C_SECTOR_SIZE 0x10000 UINT8 *buffer; UINT32 data_id; UINT32 data_len; UINT32 data_off; UINT32 data_crc; UINT32 crc; UINT32 pointer = 0; struct sto_device *flash_dev = (struct sto_device *)dev_get_by_type(NULL, HLD_DEV_TYPE_STO); while(pointer < (UINT32)flash_dev->totol_size) { data_id = sto_fetch_long((UINT32)pointer + CHUNK_ID); data_len = sto_fetch_long((UINT32)pointer + CHUNK_LENGTH); data_off = sto_fetch_long((UINT32)pointer + CHUNK_OFFSET); data_crc = sto_fetch_long((UINT32)pointer + CHUNK_CRC); if(data_len && (data_len < data_off) && (data_crc != NO_CRC) && ((data_id & CHUNKID_SECLOADER_MASK) == CHUNKID_SECLOADER)) { buffer = (UINT8 *)MALLOC(data_len); if(buffer != NULL) { sto_get_data(flash_dev, buffer, pointer + 16, data_len); crc = MG_Table_Driven_CRC(0xFFFFFFFF, buffer, data_len); FREE(buffer); if(data_crc == crc) { *ota_loader_addr = pointer; return 1; } } } pointer += C_SECTOR_SIZE; } return 0; }
static void win_stb_info_load_data() { UINT8 styleidx; UINT32 ret; char str[100]={0}; UINT16 uni_str[100]; OSD_RECT rect; CHUNK_HEADER blk_header; UINT8 i; UINT32 id, mask; BYTE info_block_number; STB_INFO_DATA *stb_data; HW_SW_INFO hwswInfo; api_hwsw_Info_get(&hwswInfo); //load serail number #if 0 UINT32 stb_id = 0; UINT16 platform_id = 0; CDSTBCA_GetSTBID(&platform_id, &stb_id); sprintf((UINT8 *)items_value_str[0], "%.4x%.8x",platform_id,stb_id); #else api_sn_get(str); // serial number sprintf((UINT8 *)items_value_str[0], "%s", str); #endif //load hw_ver & sw_ver api_hwsw_Info_get(&hwswInfo); sprintf((UINT8 *)items_value_str[1], "0x%.6x", hwswInfo.oui); // factory id); sprintf((UINT8 *)items_value_str[2], "0x%.4x", hwswInfo.hw_version); // hw version sprintf((UINT8 *)items_value_str[3], "0x%.4x", hwswInfo.sw_version); // sw version //load loader_ver sto_get_data(g_sto_dev, str, 0+CHUNK_VERSION, 0x4); str[4] = 0; sprintf((UINT8 *)items_value_str[4], "0x%s", str); // loader version items_value_str[4][8] = 0; //load download date stb_data = stb_info_data_get(); sprintf((UINT8 *)items_value_str[5], "%s", stb_data->download_date); //download data styleidx = TXT_ITEM_IDX; rect.uWidth = TXT_NEME_W; rect.uHeight = TXT_H; id = 0; for (id = 0; id < ITERM_COUNT; id++) { rect.uLeft = TXT_NEME_L; rect.uTop = TXT_T + id *(TXT_H + TXT_VERTICAL_GAP); win_draw_text_content(&rect, NULL, NULL, (UINT32)items_name_string_id[id], styleidx); rect.uWidth = TXT_VALUE_W; rect.uLeft += TXT_HORIZONTAL_GAP; win_draw_text_content(&rect, (char*)items_value_str[id], NULL, 0, styleidx); } /* show libcore info */ memset(str, 0, sizeof(str)); memcpy(str, libcore_banner, strlen(libcore_banner)-2); #ifdef SFU_AUTO_TEST strcat(str, "[SFU]"); #endif ComAscStr2Uni(str,uni_str); libcore_content->text.pString = uni_str; OSD_DrawObject((POBJECT_HEAD)&libcore_info,C_UPDATE_ALL); //OSD_UpdateVscr(apVscr); return ; }