static void win_tplist_tuner_frontend(void) { S_NODE s_node; T_NODE t_node; #ifdef NEW_DEMO_FRAME struct ft_antenna antenna; union ft_xpond xpond_info; struct nim_device *nim = NULL; #else struct cc_antenna_info antenna; struct cc_xpond_info xpond_info; #endif OBJLIST* ol; UINT32 tp_idx; UINT16 pre_sat_id,cur_sat_id; UINT8 back_saved; BOOL old_get_key; nim_io_control(g_nim_dev, NIM_DRIVER_STOP_CHANSCAN, 0); ap_set_key_notify_proc(win_tplist_key_notify_proc); old_get_key = ap_enable_key_task_get_key(TRUE); win_signal_set_level_quality(0, 0, 0); win_signal_update(); OSD_UpdateVscr(OSD_GetTaskVscr(osal_task_get_current_id())); ol = &tplst_olist; tp_idx = OSD_GetObjListCurPoint(ol); get_tuner_sat(TUNER_EITHER, cur_tp_sat_idx,&s_node); get_tp_at(s_node.sat_id,tp_idx,&t_node); #ifdef SUPPORT_TWO_TUNER #ifdef SUPPORT_SELECT_SAME_SAT cur_tuner_idx = s_node.reserve_1; //antset_cur_tuner;//s_node.tuner1_valid? 0 : 1; #else cur_tuner_idx = s_node.tuner1_valid? 0 : 1; #endif #endif #ifndef NEW_DEMO_FRAME struct cc_antenna_info antenna; struct cc_xpond_info xpond_info; sat2antenna_ext(&s_node, &antenna,cur_tuner_idx); xpond_info.frq = t_node.frq; xpond_info.sym = t_node.sym; xpond_info.pol = t_node.pol; set_antenna(&antenna); set_xpond(&xpond_info); #else MEMSET(&antenna, 0, sizeof(struct ft_antenna)); MEMSET(&xpond_info, 0, sizeof(union ft_xpond)); sat2antenna(&s_node, &antenna); xpond_info.s_info.type = FRONTEND_TYPE_S; xpond_info.s_info.frq = t_node.frq; xpond_info.s_info.sym = t_node.sym; xpond_info.s_info.pol = t_node.pol; xpond_info.s_info.tp_id = t_node.tp_id; #ifdef SUPPORT_SELECT_SAME_SAT nim = (struct nim_device *)dev_get_by_id(HLD_DEV_TYPE_NIM, ((s_node.reserve_1 == 0)? 0 : ((s_node.reserve_1 == 1) ? 1 : 0))); #else nim = (struct nim_device *)dev_get_by_id(HLD_DEV_TYPE_NIM, (s_node.tuner1_valid ? 0 : (s_node.tuner2_valid ? 1 : 0))); #endif frontend_tuning(nim, &antenna, &xpond_info, 1); #endif if(pre_tp_sat_idx != cur_tp_sat_idx) { get_tuner_sat(TUNER_EITHER, pre_tp_sat_idx, &s_node); pre_sat_id = s_node.sat_id; get_tuner_sat(TUNER_EITHER, cur_tp_sat_idx, &s_node); cur_sat_id = s_node.sat_id; wincom_dish_move_popup_open(/*pre_sat_id*/0xFFFF,cur_sat_id,cur_tuner_idx,&back_saved); pre_tp_sat_idx = cur_tp_sat_idx; } ap_enable_key_task_get_key(old_get_key); ap_set_key_notify_proc(NULL); nim_io_control(g_nim_dev, NIM_DRIVER_STOP_CHANSCAN, 0); }
acpi_status bm_initialize (void) { acpi_status status = AE_OK; u32 start = 0; u32 stop = 0; u32 elapsed = 0; FUNCTION_TRACE("bm_initialize"); MEMSET(&node_list, 0, sizeof(BM_NODE_LIST)); status = acpi_get_timer(&start); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Building device hierarchy.\n")); /* * Enumerate ACPI fixed-feature devices. */ status = bm_enumerate_fixed_features(); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } /* * Enumerate the ACPI namespace. */ status = bm_enumerate_namespace(); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } acpi_get_timer(&stop); acpi_get_timer_duration(start, stop, &elapsed); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Building device hierarchy took [%d] microseconds.\n", elapsed)); /* * Display hierarchy. */ bm_print_hierarchy(); /* * Register for all standard and device-specific notifications. */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Registering for all device notifications.\n")); status = acpi_install_notify_handler(ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY, &bm_notify, NULL); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unable to register for standard notifications.\n")); return_ACPI_STATUS(status); } status = acpi_install_notify_handler(ACPI_ROOT_OBJECT, ACPI_DEVICE_NOTIFY, &bm_notify, NULL); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unable to register for device-specific notifications.\n")); return_ACPI_STATUS(status); } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Bus Manager enabled.\n")); /* * Initialize built-in power resource driver. */ bm_pr_initialize(); return_ACPI_STATUS(status); }
/* XBQuickWindow - Create an X window Input parameters: . mywindow - A pointer to an XBWindow structure that will be used to hold information on the window. This should be acquired with XBWinCreate. . host - name of the display . name - title (name) of the window . x,y - coordinates of the upper left corner of the window. If <0, use user-positioning (normally, the window manager will ask the user where to put the window) . nx,ny - width and height of the window Note: This creates a window with various defaults (visual, colormap, etc) A small modification to this routine would allow Black and White windows to be used on color displays; this would be useful for testing codes. */ int XBQuickWindow( XBWindow *mywindow, char *host, char *name, int x, int y, int nx, int ny ){ /* Just to be careful, clear mywindow */ MEMSET( mywindow, 0, sizeof(XBWindow) ); return XBiQuickWindow( mywindow, host, name, x, y, nx, ny, 0 ); }
/*! * * \par Description: * This function copy valuable data from datablk to logblk,then change datablk to freeblk ,change logblk to datablk. * * \param [in] LogNum,serial number within log block space * \return sucess or failed. * \note this function was called when log block is in order,that is to say physical * page number is same with logical page number. **/ __s32 _log2data_swap_merge(__u32 nlogical) { __u16 LastUsedPage,SuperPage; struct __SuperPhyBlkType_t DataBlk; struct __LogBlkType_t LogBlk; struct __PhysicOpPara_t SrcParam,DstParam; /* init info of data block and log block*/ BMM_GetDataBlk(nlogical, &DataBlk); BMM_GetLogBlk(nlogical, &LogBlk); LastUsedPage = LogBlk.LastUsedPage; if((SUPPORT_LOG_BLOCK_MANAGE)&&(LogBlk.LogBlkType == LSB_TYPE)) { LOGICCTL_ERR("swap merge : LSB type not support swap merge\n"); return NAND_OP_FALSE; } /*copy data from data block to log block*/ for (SuperPage = LastUsedPage + 1; SuperPage < PAGE_CNT_OF_SUPER_BLK; SuperPage++){ /*set source and destinate address*/ LML_CalculatePhyOpPar(&SrcParam,CUR_MAP_ZONE, DataBlk.PhyBlkNum, SuperPage); LML_CalculatePhyOpPar(&DstParam,CUR_MAP_ZONE, LogBlk.PhyBlk.PhyBlkNum, SuperPage); if (NAND_OP_TRUE != PHY_PageCopyback(&SrcParam,&DstParam)){ LOGICCTL_ERR("swap merge : copy back err\n"); return NAND_OP_FALSE; } if (NAND_OP_TRUE != PHY_SynchBank(DstParam.BankNum, SYNC_BANK_MODE)){ struct __SuperPhyBlkType_t SubBlk; if (NAND_OP_TRUE != LML_BadBlkManage(&LogBlk.PhyBlk,CUR_MAP_ZONE,SuperPage,&SubBlk)){ LOGICCTL_ERR("swap merge : bad block manage err after copy back\n"); return NAND_OP_FALSE; } LogBlk.PhyBlk = SubBlk; SuperPage -= 1; } } /*move log block to data block*/ BMM_SetDataBlk(nlogical, &LogBlk.PhyBlk); /*clear log block item*/ MEMSET(&LogBlk, 0xff, sizeof(struct __LogBlkType_t)); LogBlk.LogBlkType = 0; LogBlk.WriteBlkIndex = 0; LogBlk.ReadBlkIndex = 0; BMM_SetLogBlk(nlogical, &LogBlk); /*erase data block*/ if ( NAND_OP_TRUE != LML_VirtualBlkErase(CUR_MAP_ZONE, DataBlk.PhyBlkNum)){ if (NAND_OP_TRUE != LML_BadBlkManage(&DataBlk,CUR_MAP_ZONE,0,NULL)){ LOGICCTL_ERR("swap merge : bad block manage err erase data block\n"); return NAND_OP_FALSE; } } /*move erased data block to free block*/ if (DataBlk.BlkEraseCnt < 0xffff) DataBlk.BlkEraseCnt ++; BMM_SetFreeBlk(&DataBlk); /*clear page map table*/ PMM_ClearCurMapTbl(); return NAND_OP_TRUE; }
static PRESULT factoryset_sel_callback(POBJECT_HEAD pObj, VEVENT event, UINT32 param1, UINT32 param2) { PRESULT ret = PROC_PASS; VACTION unact; UINT32 sel; UINT8 bID; char str[10]; UINT16 * Uni_str; UINT8* pstr; UINT16 cur_idx; COM_POP_LIST_TYPE_T list_type; OSD_RECT rect; COM_POP_LIST_PARAM_T param; UINT16 i,n = 0; S_NODE s_node; UINT32 flag; bID = OSD_GetObjID(pObj); switch(event) { case EVN_PRE_CHANGE: sel = *((UINT32*)param1); break; case EVN_POST_CHANGE: sel = param1; if(bID == IDC_CON5) { get_sat_at(sel,SET_SELECTED,&s_node); #if 0 #ifdef SUPPORT_TWO_TUNER //guop modify #ifdef SUPPORT_SELECT_SAME_SAT OSD_SetTextFieldContent(&satsrch_txt6_note , STRING_ID, ((s_node.reserve_1 == 0) ? RS_LNB1 : RS_LNB2)); #else OSD_SetTextFieldContent(&satsrch_txt6_note , STRING_ID, (s_node.tuner1_valid ? RS_LNB1 : RS_LNB2)); #endif OSD_DrawObject((POBJECT_HEAD)&satsrch_txt6_note, C_UPDATE_ALL); #endif #endif } break; case EVN_REQUEST_STRING: sel = param1; Uni_str= (UINT16*)param2; if(bID == IDC_CON5) { get_sat_name_factory(2,sel,Uni_str); sys_data_set_cur_satidx(sel); } break; #if 0 case EVN_UNKNOWN_ACTION: unact = (VACTION)(param1>>16); if(unact == VACT_POP_UP) { OSD_SetRect2(&rect,&pObj->frame); switch(bID) { case SAT_ID: rect.uLeft -= 80; rect.uWidth += 80; list_type = POP_LIST_TYPE_SAT; rect.uHeight = 300; param.id = TUNER_EITHER; param.cur = SATSRCH_SAT_IDX; if(single_multi_srch_flag == 0) param.selecttype = POP_LIST_SINGLESELECT; else { MEMSET(sat_select,0,sizeof(sat_select)); n = get_tuner_sat_cnt(TUNER_EITHER); if(n == 0) { list_type = 0xFF; break; } for(i=0;i<n;i++) { get_tuner_sat(TUNER_EITHER,i,&s_node); if(s_node.selected_flag) sat_select[i] = 1; } #if (defined(SUPPORT_TWO_TUNER) || !defined(SELECT_SAT_ONLY)) param.selecttype = POP_LIST_MULTISELECT; #else param.selecttype = POP_LIST_SINGLESELECT; #endif param.select_array = sat_select; } break; default: list_type = 0xFF; } if(list_type == 0xFF) break; cur_idx = win_com_open_sub_list(list_type,&rect,¶m); if(single_multi_srch_flag == 0) { if(cur_idx == LIST_INVALID_SEL_IDX || cur_idx == param.cur) break; } else { /* Check the select satellite */ #if (defined(SUPPORT_TWO_TUNER) || !defined(SELECT_SAT_ONLY)) for(i=0;i<n;i++) { if(win_comlist_ext_check_item_sel(i)) flag = 1; else flag = 0; get_tuner_sat(TUNER_EITHER,i,&s_node); if(s_node.selected_flag != flag) { s_node.selected_flag = flag; modify_sat(s_node.sat_id, &s_node); } } update_data(TYPE_SAT_NODE); #endif } if(single_multi_srch_flag == 0) SATSRCH_SAT_IDX = cur_idx; get_sat_at(cur_idx,SET_SELECTED,&s_node); #ifdef SUPPORT_SELECT_SAME_SAT OSD_SetTextFieldContent(&satsrch_txt6_note , STRING_ID, ((s_node.reserve_1 == 0) ? RS_LNB1 : RS_LNB2)); #else OSD_SetTextFieldContent(&satsrch_txt6_note , STRING_ID, (s_node.tuner1_valid ? RS_LNB1 : RS_LNB2)); #endif OSD_DrawObject((POBJECT_HEAD)&satsrch_txt6_note, C_UPDATE_ALL); OSD_TrackObject((POBJECT_HEAD)&satsrch_item1, C_DRAW_SIGN_EVN_FLG | C_UPDATE_ALL); if(single_multi_srch_flag) { /* TODO : Draw the select satellites name */ //win_satsrch_set_drawselectsats(); UINT16 sat_cnt = get_tuner_sat_cnt(TUNER_EITHER_SELECT); if(sat_cnt <=(SELSAT_ROW_CNT*2)) win_satsrch_set_fix_drawselectsats(); else { start_scroll_sat_id=0; api_stop_timer(&sat_display_scroll); sat_display_scroll = api_start_timer("SATDISP",500,(OSAL_T_TIMER_FUNC_PTR)sat_search_scroll_disp_handler); } } } break; #endif } return ret; }
static int default_int2char(SCR *sp, const CHAR_T * str, ssize_t len, CONVWIN *cw, size_t *tolen, const char **pdst, const char *enc) { size_t i, j; int offset = 0; char **tostr = (char **)(void *)&cw->bp1; size_t *blen = &cw->blen1; mbstate_t mbs; size_t n; ssize_t nlen = len + MB_CUR_MAX; char *dst; size_t buflen; char buffer[CONV_BUFFER_SIZE]; iconv_t id = (iconv_t)-1; /* convert first len bytes of buffer and append it to cw->bp * len is adjusted => 0 * offset contains the offset in cw->bp and is adjusted * cw->bp is grown as required */ #ifdef USE_ICONV #define CONVERT2(len, cw, offset) \ do { \ const char *bp = buffer; \ while (len != 0) { \ size_t outleft = cw->blen1 - offset; \ char *obp = (char *)cw->bp1 + offset; \ if (cw->blen1 < offset + MB_CUR_MAX) { \ nlen += 256; \ BINC_RETC(NULL, cw->bp1, cw->blen1, nlen); \ } \ errno = 0; \ if (iconv(id, &bp, &len, &obp, &outleft) == (size_t)-1 && \ errno != E2BIG) \ HANDLE_ICONV_ERROR(obp, bp, outleft, len); \ offset = cw->blen1 - outleft; \ } \ } while (0) #else #define CONVERT2(len, cw, offset) #endif MEMSET(&mbs, 0, 1); BINC_RETC(NULL, *tostr, *blen, nlen); dst = *tostr; buflen = *blen; #ifdef USE_ICONV if (strcmp(nl_langinfo(CODESET), enc)) { id = iconv_open(enc, nl_langinfo(CODESET)); if (id == (iconv_t)-1) goto err; dst = buffer; buflen = CONV_BUFFER_SIZE; } #endif for (i = 0, j = 0; i < (size_t)len; ++i) { n = wcrtomb(dst+j, str[i], &mbs); if (n == (size_t)-1) HANDLE_MBR_ERROR(n, mbs, dst[j], str[i]); j += n; if (buflen < j + MB_CUR_MAX) { if (id != (iconv_t)-1) { CONVERT2(j, cw, offset); } else { nlen += 256; BINC_RETC(NULL, *tostr, *blen, nlen); dst = *tostr; buflen = *blen; } } } n = wcrtomb(dst+j, L'\0', &mbs); j += n - 1; /* don't count NUL at the end */ *tolen = j; if (id != (iconv_t)-1) { CONVERT2(j, cw, offset); *tolen = offset; } *pdst = cw->bp1; return 0; err: *tolen = j; *pdst = cw->bp1; return 1; }
/*! * * \par Description: * This function move valuable data from log block to free block,then replace them. * * \param [in] LogNum,serial number within log block space * \return sucess or failed. * \note this function was called when log block is full, and valid pages is less than half of one block. **/ __s32 _free2log_move_merge(__u32 nlogical) { __u8 bank; __u16 LastUsedPage,SuperPage; __u16 SrcPage,DstPage, SrcBlock, DstBlock; struct __SuperPhyBlkType_t FreeBlk,FreeBlk1; struct __LogBlkType_t LogBlk; struct __PhysicOpPara_t SrcParam,DstParam; struct __NandUserData_t UserData[2]; /*init info of log block , and get one free block */ BMM_GetLogBlk(nlogical, &LogBlk); if (NAND_OP_TRUE != BMM_GetFreeBlk(LOWEST_EC_TYPE, &FreeBlk)) return NAND_OP_FALSE; if((SUPPORT_LOG_BLOCK_MANAGE)&&(LogBlk.LogBlkType == LSB_TYPE)) { if (NAND_OP_TRUE != BMM_GetFreeBlk(LOWEST_EC_TYPE, &FreeBlk1)) return NAND_OP_FALSE; //DBUG_INF("[DBUG] lsb move merge, new log0: %x, new log1: %x\n", FreeBlk.PhyBlkNum, FreeBlk1.PhyBlkNum); } SrcParam.MDataPtr = DstParam.MDataPtr = NULL; SrcParam.SDataPtr = DstParam.SDataPtr = NULL; SrcParam.SectBitmap = DstParam.SectBitmap = FULL_BITMAP_OF_SUPER_PAGE; if(SUPPORT_ALIGN_NAND_BNK) { redo: /*copy data bank by bank, for copy-back using*/ LastUsedPage = 0; for (bank = 0; bank < INTERLEAVE_BANK_CNT; bank++) { DstPage = bank; for (SuperPage = bank; SuperPage < PAGE_CNT_OF_SUPER_BLK; SuperPage+= INTERLEAVE_BANK_CNT) { SrcPage = PMM_GetCurMapPage(SuperPage); if (SrcPage != 0xffff) { /*set source and destinate address*/ if((SUPPORT_LOG_BLOCK_MANAGE)&&(LogBlk.LogBlkType == LSB_TYPE)) { DBUG_MSG("[DBUG_MSG] _free2log_move_merge 2, select bak log block\n"); DstPage = PMM_CalNextLogPage(DstPage); while((DstPage%INTERLEAVE_BANK_CNT)!=bank) { DstPage++; DstPage = PMM_CalNextLogPage(DstPage); if(DstPage>=PAGE_CNT_OF_SUPER_BLK) break; } if(DstPage >= PAGE_CNT_OF_SUPER_BLK) { LOGICCTL_ERR("move merge : dst page cal error\n"); return NAND_OP_FALSE; } if(SrcPage&(0x1<<15)) SrcBlock = LogBlk.PhyBlk1.PhyBlkNum; else SrcBlock = LogBlk.PhyBlk.PhyBlkNum; DstBlock = FreeBlk.PhyBlkNum; SrcPage &= (~(0x1<<15)); } else { SrcBlock = LogBlk.PhyBlk.PhyBlkNum; DstBlock = FreeBlk.PhyBlkNum; } LML_CalculatePhyOpPar(&SrcParam,CUR_MAP_ZONE, SrcBlock, SrcPage); LML_CalculatePhyOpPar(&DstParam,CUR_MAP_ZONE, DstBlock, DstPage); if (DstPage == 0) { if ( NAND_OP_FALSE == _copy_page0(SrcBlock,SrcPage,FreeBlk.PhyBlkNum,0)) { LOGICCTL_ERR("move merge : copy page 0 err1\n"); return NAND_OP_FALSE; } } else { if (NAND_OP_TRUE != PHY_PageCopyback(&SrcParam,&DstParam)) { LOGICCTL_ERR("move merge : copy back err\n"); return NAND_OP_FALSE; } } if (NAND_OP_TRUE != PHY_SynchBank(DstParam.BankNum, SYNC_BANK_MODE)) { struct __SuperPhyBlkType_t SubBlk; if (NAND_OP_TRUE != LML_BadBlkManage(&FreeBlk,CUR_MAP_ZONE,0,&SubBlk)) { LOGICCTL_ERR("move merge : bad block manage err after copy back\n"); return NAND_OP_FALSE; } FreeBlk = SubBlk; goto redo; } PMM_SetCurMapPage(SuperPage,DstPage); DstPage += INTERLEAVE_BANK_CNT; } } /*if bank 0 is empty, need write mange info in page 0*/ if ((bank == 0) && (DstPage == 0)) { if ( NAND_OP_FALSE == _copy_page0(LogBlk.PhyBlk.PhyBlkNum,0,FreeBlk.PhyBlkNum,0)) { LOGICCTL_ERR("move merge : copy page 0 err2\n"); return NAND_OP_FALSE; } LML_CalculatePhyOpPar(&DstParam, CUR_MAP_ZONE, FreeBlk.PhyBlkNum, 0); if (NAND_OP_TRUE != PHY_SynchBank(DstParam.BankNum, SYNC_BANK_MODE)) { struct __SuperPhyBlkType_t SubBlk; if (NAND_OP_TRUE != LML_BadBlkManage(&FreeBlk,CUR_MAP_ZONE,0,&SubBlk)) { LOGICCTL_ERR("move merge : bad block manage err after copy back\n"); return NAND_OP_FALSE; } FreeBlk = SubBlk; goto redo; } } /*reset LastUsedPage*/ if ((DstPage - INTERLEAVE_BANK_CNT) > LastUsedPage) { LastUsedPage = DstPage - INTERLEAVE_BANK_CNT; } } } else { /*copy data page by page*/ DstPage = 0; LastUsedPage = 0; for (SuperPage = 0; SuperPage < PAGE_CNT_OF_LOGIC_BLK; SuperPage++) { SrcPage = PMM_GetCurMapPage(SuperPage); if (SrcPage != 0xffff) { /*set source and destinate address*/ if((SUPPORT_LOG_BLOCK_MANAGE)&&(LogBlk.LogBlkType == LSB_TYPE)) { DBUG_MSG("[DBUG_MSG] _free2log_move_merge 3, select bak log block\n"); DstPage = PMM_CalNextLogPage(DstPage); if(DstPage >= PAGE_CNT_OF_SUPER_BLK) { LOGICCTL_ERR("move merge : dst page cal error\n"); return NAND_OP_FALSE; } if(SrcPage&(0x1<<15)) SrcBlock = LogBlk.PhyBlk1.PhyBlkNum; else SrcBlock = LogBlk.PhyBlk.PhyBlkNum; DstBlock = FreeBlk.PhyBlkNum; SrcPage &= 0x7fff; } else { SrcBlock = LogBlk.PhyBlk.PhyBlkNum; DstBlock = FreeBlk.PhyBlkNum; } LML_CalculatePhyOpPar(&SrcParam,CUR_MAP_ZONE, SrcBlock, SrcPage); LML_CalculatePhyOpPar(&DstParam,CUR_MAP_ZONE, DstBlock, DstPage); if (0 == DstPage) { if ( NAND_OP_FALSE == _copy_page0(SrcBlock,SrcPage,FreeBlk.PhyBlkNum,0)) { LOGICCTL_ERR("move merge : copy page 0 err1\n"); return NAND_OP_FALSE; } } else { SrcParam.MDataPtr = DstParam.MDataPtr = LML_TEMP_BUF; SrcParam.SDataPtr = DstParam.SDataPtr = (void *)&UserData; MEMSET((void *)&UserData,0xff,sizeof(struct __NandUserData_t) * 2); SrcParam.SectBitmap = DstParam.SectBitmap = FULL_BITMAP_OF_SUPER_PAGE; if (LML_VirtualPageRead(&SrcParam) < 0){ LOGICCTL_ERR("move merge : read main data err\n"); return NAND_OP_FALSE; } if (NAND_OP_TRUE != LML_VirtualPageWrite(&DstParam)){ LOGICCTL_ERR("move merge : write err\n"); return NAND_OP_FALSE; } } if (NAND_OP_TRUE != PHY_SynchBank(DstParam.BankNum, SYNC_BANK_MODE)) { struct __SuperPhyBlkType_t SubBlk; if (NAND_OP_TRUE != LML_BadBlkManage(&FreeBlk,CUR_MAP_ZONE,LastUsedPage,&SubBlk)) { LOGICCTL_ERR("move merge : bad block manage err after copy back\n"); return NAND_OP_FALSE; } FreeBlk = SubBlk; SuperPage -= 1; } PMM_SetCurMapPage(SuperPage,DstPage); LastUsedPage = DstPage; DstPage++; } } } /*erase log block*/ if(NAND_OP_TRUE != LML_VirtualBlkErase(CUR_MAP_ZONE, LogBlk.PhyBlk.PhyBlkNum)) { if(NAND_OP_TRUE != LML_BadBlkManage(&LogBlk.PhyBlk,CUR_MAP_ZONE,0,NULL)) { LOGICCTL_ERR("move merge : bad block manage err after erase log block\n"); return NAND_OP_FALSE; } } /*move erased log block to free block*/ if(LogBlk.PhyBlk.BlkEraseCnt < 0xffff) { LogBlk.PhyBlk.BlkEraseCnt ++; } BMM_SetFreeBlk(&LogBlk.PhyBlk); if((SUPPORT_LOG_BLOCK_MANAGE)&&(LogBlk.LogBlkType == LSB_TYPE)) { //DBUG_INF("[DBUG] logic %x move merge: erase log block 0: %x\n", LogBlk.LogicBlkNum, LogBlk.PhyBlk.PhyBlkNum); if(NAND_OP_TRUE != LML_VirtualBlkErase(CUR_MAP_ZONE, LogBlk.PhyBlk1.PhyBlkNum)) { if(NAND_OP_TRUE != LML_BadBlkManage(&LogBlk.PhyBlk1,CUR_MAP_ZONE,0,NULL)) { LOGICCTL_ERR("move merge : bad block manage err after erase log block\n"); return NAND_OP_FALSE; } } /*move erased log block to free block*/ if(LogBlk.PhyBlk1.BlkEraseCnt < 0xffff) { LogBlk.PhyBlk1.BlkEraseCnt ++; } BMM_SetFreeBlk(&LogBlk.PhyBlk1); //DBUG_INF("[DBUG] logic %x move merge: erase log block 1: %x\n", LogBlk.LogicBlkNum, LogBlk.PhyBlk1.PhyBlkNum); } /*move free block to log block*/ LogBlk.PhyBlk.PhyBlkNum= FreeBlk.PhyBlkNum; LogBlk.PhyBlk.BlkEraseCnt= FreeBlk.BlkEraseCnt; if((SUPPORT_LOG_BLOCK_MANAGE)&&(LogBlk.LogBlkType == LSB_TYPE)) { DBUG_MSG("[DBUG_MSG] _free2log_move_merge 4, select bak log block\n"); LogBlk.PhyBlk1.PhyBlkNum= FreeBlk1.PhyBlkNum; LogBlk.PhyBlk1.BlkEraseCnt= FreeBlk1.BlkEraseCnt; LogBlk.WriteBlkIndex = 0; LogBlk.ReadBlkIndex = 0; DBUG_MSG("[DBUG] move merge to new log block, logic block: %x, logblock0: %x, logblock1: %x\n", LogBlk.LogicBlkNum, LogBlk.PhyBlk.PhyBlkNum, LogBlk.PhyBlk1.PhyBlkNum); } else { LogBlk.LogBlkType = 0; LogBlk.WriteBlkIndex = 0; LogBlk.ReadBlkIndex = 0; } LogBlk.LastUsedPage = LastUsedPage; BMM_SetLogBlk(nlogical, &LogBlk); //if((SUPPORT_LOG_BLOCK_MANAGE)&&(LogBlk.LogBlkType == LSB_TYPE)) // DBUG_INF("logic %x move merge, lastusedpage: %x\n", LogBlk.LogicBlkNum, LogBlk.LastUsedPage); return NAND_OP_TRUE; }
static BOOL init_slave() { UINT8 *ptr_data_buf, *ptr_temp_buf; UINT32 ptr_zip_pos; UINT8 zero_buf[16]; UINT32 slave_addr; UINT32 total_len, len, chid; int ret; UINT32 i; char strTmp[30]; char strTmp1[30]; ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_INIT_SLAVER),strTmp); callback_fun(2, 0, strTmp); P2PUPG_DBG("init_slave\n"); // init slave sdram for(i=0; i<sizeof(m_SlaveConfig)/sizeof(m_SlaveConfig[0]); i++) { osal_task_sleep(50); // if(0xb8000029 == m_SlaveConfig[i].Address) // { // if(sys_ic_is_M3101()) // m_SlaveConfig[i].Data = *((volatile UINT8 *)m_SlaveConfig[i].Address) & 0x07; // else // m_SlaveConfig[i].Data = *((volatile UINT8 *)m_SlaveConfig[i].Address) & 0x1c; // } erom_wm(m_SlaveConfig[i].Address, &m_SlaveConfig[i].Data, 1, 0); } // set upgrade param init_upgrade_param(); for(i=0; i<sizeof(EROM_UPGRADE_PARAM); i+=sizeof(UINT32)) { if(!send_upgrade_param(i)) { ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_SEND_UPGRADE_PARAM_FAILED),strTmp1); callback_fun(2, 0,strTmp1); return FALSE; } } P2PUPG_DBG("send_upgrade_param OK\n"); unsigned long chunk_id = g_upge_feature_config.chip_flashwr; ptr_zip_pos = (UINT8 *)sto_chunk_goto(&chunk_id, 0xFFFFFFFF, 1); unsigned long zip_size = sto_fetch_long(ptr_zip_pos + CHUNK_LENGTH); ptr_zip_pos += CHUNK_HEADER_SIZE; ptr_data_buf = (UINT8 *)bk_buff; // 48KB for unzip buffer ptr_temp_buf = (UINT8 *)(bk_buff + 0xC000); // 16KB for temp buffer P2PUPG_DBG("ptr_zip_pos = 0x%x\n ptr_data_buf = 0x%x\n ptr_temp_buf = 0x%x\n",ptr_zip_pos,ptr_data_buf,ptr_temp_buf); if(g_upge_feature_config.enable_lzma_out_read == TRUE) ret = un7zip(ptr_zip_pos+SYS_FLASH_BASE_ADDR, zip_size, ptr_temp_buf, 0x4000, ptr_data_buf, 0xC000, NULL); else ret = un7zip(ptr_zip_pos+SYS_FLASH_BASE_ADDR, ptr_data_buf, ptr_temp_buf); P2PUPG_DBG("un7zip ret=%d\n",ret); if(ret) return FALSE; P2PUPG_DBG("un7zip OK"); MEMCPY(&total_len, ptr_temp_buf, sizeof(unsigned int)); P2PUPG_DBG("total_len =%d\n",total_len); uart_high_speed_config(UART_SPEED_NORMAL); // download flashwr erom_download(FLASHWR_RUN_ADDR, ptr_data_buf, total_len); // init slave config buffer P2PUPG_DBG("erom_download1 OK\n"); MEMSET(zero_buf, 0, sizeof(zero_buf)); erom_download(FWCFG_START_ADDR, zero_buf, sizeof(zero_buf)); P2PUPG_DBG("erom_download2 OK\n"); // download config chunk chid = g_upge_feature_config.chip_config; if((chid!=0)&&(chid!=0xFFFFFFFF)) { ptr_data_buf = sto_chunk_goto(&chid, 0xFFFFFFFF, 1); P2PUPG_DBG("ptr_data_buf=0x%x\n",ptr_data_buf); if(ptr_data_buf != NULL) { total_len = sto_fetch_long((unsigned long)(ptr_data_buf+CHUNK_OFFSET)); erom_download(FWCFG_START_ADDR, ptr_data_buf, total_len); } } if(UPGRADE_SINGLE == upgrade_mode) { erom_setpc(FLASHWR_RUN_ADDR); osal_task_sleep(50); sci_mode_set(p2p_uart_id, 115200, SCI_PARITY_EVEN); osal_task_sleep(100); config_uart_speed(UART_DOWNLOAD_SPEED); } return TRUE; }
UINT32 GetChunk(BYTE *buffer, UINT32 nLen) { UINT8 *p, *pblock; UINT32 chunk_pos; struct sto_device *sto_dev = NULL; UINT8 sVer[16], hVer[16]; INT32 i = 0; char strTmp[30]; #if (defined HDCP_IN_FLASH ||defined DIVX_CERT_ENABLE) INT32 temp_slave_blocks_number=0; CHUNK_HEADER *temp_pslave_list = NULL; #endif switch((unsigned int)buffer[0]) { case 1: case 2: case 7: case 10: slave_Flash_type = 0x80000; //flash size break; case 3: case 4: case 8: case 9: case 11: case 13: slave_Flash_type = 0x100000; break; case 5: case 6: case 12: case 14: case 15: case 16: case 25: case 28: case 30: slave_Flash_type = 0x200000; break; case 17: case 18: case 19: case 33: slave_Flash_type = 0x400000; break; default: slave_Flash_type = 0x200000;/*For unkown flash type,default is 2M*/ //return !SUCCESS; } slave_status = (unsigned int)buffer[1]; if(slave_status==0) slave_blocks_number = (nLen -2)/CHUNK_HEADER_SIZE; else slave_blocks_number = 1; pslave_list= (CHUNK_HEADER *)MALLOC(sizeof(CHUNK_HEADER)*slave_blocks_number); if (pslave_list == NULL) return !SUCCESS; MEMSET((void *)pslave_list,0,sizeof(CHUNK_HEADER)*slave_blocks_number); #if (defined HDCP_IN_FLASH ||defined DIVX_CERT_ENABLE) #ifdef HDCP_IN_FLASH if(m_allcode_include_bootloader==0) #endif { temp_pslave_list= (CHUNK_HEADER *)MALLOC(sizeof(CHUNK_HEADER)*slave_blocks_number); if (temp_pslave_list == NULL) return !SUCCESS; MEMSET((void *)temp_pslave_list,0,sizeof(CHUNK_HEADER)*slave_blocks_number); } #endif pblock = &buffer[2]; for(i=0; i<slave_blocks_number; i++) { p = pblock + CHUNK_ID; pslave_list[i].id = (*p<<24)+(*(p+1)<<16)+(*(p+2)<<8)+(*(p+3)<<0); p = pblock + CHUNK_LENGTH; pslave_list[i].len = (*p<<24)+(*(p+1)<<16)+(*(p+2)<<8)+(*(p+3)<<0); p = pblock + CHUNK_OFFSET; pslave_list[i].offset = (*p<<24)+(*(p+1)<<16)+(*(p+2)<<8)+(*(p+3)<<0); p = pblock + CHUNK_CRC; pslave_list[i].crc = (*p<<24)+(*(p+1)<<16)+(*(p+2)<<8)+(*(p+3)<<0); p = pblock + CHUNK_NAME; STRCPY((char *)pslave_list[i].name, (char *)p); p = pblock + CHUNK_VERSION; STRCPY((char *)pslave_list[i].version, (char *)p); p = pblock + CHUNK_TIME; STRCPY((char *)pslave_list[i].time, (char *)p); #if (defined HDCP_IN_FLASH ||defined DIVX_CERT_ENABLE) #ifdef HDCP_IN_FLASH if(m_allcode_include_bootloader==0) #endif { UINT32 special_type = 0; #ifdef HDCP_IN_FLASH if(pslave_list[i].id == HDCPKEY_CHUNK_ID) { special_type =1; } #endif #ifdef DIVX_CERT_ENABLE if(pslave_list[i].id == DIVX_CHUCK_ID) { special_type =1; } #endif if(special_type!=1) { MEMCPY((temp_pslave_list+temp_slave_blocks_number),(pslave_list+i),sizeof(CHUNK_HEADER)); temp_slave_blocks_number++; } else { if(i > 0) { temp_pslave_list[i-1].offset=(temp_pslave_list[i-1].offset+pslave_list[i].offset); } } } #endif pblock += CHUNK_HEADER_SIZE; } #if (defined HDCP_IN_FLASH ||defined DIVX_CERT_ENABLE) #ifdef HDCP_IN_FLASH if(m_allcode_include_bootloader==0) #endif { FREE(pslave_list); slave_blocks_number=temp_slave_blocks_number; pslave_list = (CHUNK_HEADER *)MALLOC(sizeof(CHUNK_HEADER)*slave_blocks_number); MEMCPY(pslave_list,temp_pslave_list,sizeof(CHUNK_HEADER)*slave_blocks_number); FREE(temp_pslave_list); } #endif STRCPY(sVer, pslave_list[0].version); chunk_pos = sto_chunk_goto(&pblock_list[0].id, 0xFFFFFFFF, 1); sto_dev = (struct sto_device*)dev_get_by_id(HLD_DEV_TYPE_STO, 0); sto_open(sto_dev); sto_lseek(sto_dev, chunk_pos+CHUNK_VERSION, STO_LSEEK_SET); sto_read(sto_dev, hVer, 16); //sto_close(sto_dev); #ifdef FORCE_UPGRADE_OLD_PROTOCOL_BOOTLOADER if(g_protocol_version < NEW_PROTOCOL_VERSION) return SUCCESS; #endif if(CheckVersion(sVer, hVer) != SUCCESS) { ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_STB_VERSION_NOT_COMPATIBLE),strTmp); callback_fun(2,0,strTmp); return !SUCCESS; } }
/* ======================================================================== This routine processes CPU interrupts. ======================================================================== */ void check_interrupts(void) { static volatile UINT64 last_rst75=0; if (((last_rst75 + rst7cycles) < cycles) && !INTDIS) { IM |= 0x40; // if(trace && tracefile != NULL) // fprintf(tracefile,"RST 7.5 Issued diff = %d\n", (DWORD) (cycles - last_rst75)); last_rst75=cycles; } /* TRAP should be first */ if(RST75PEND && !INTDIS && !RST75MASK) { if(trace && tracefile != NULL) fprintf(tracefile,"RST 7.5 CALLed\n"); if (gDebugInts) gIntActive = TRUE; gIntSP = SP; DECSP2; if (gReMem) { MEMSET(SP, PCL); MEMSET(SP+1, PCH); } else { gBaseMemory[SP] = PCL; gBaseMemory[SP+1] = PCH; } /* MEM16(SP)=PC; */ PCL=60; PCH=0; /* PC=60; */ cycle_delta += 10; /* This may not be correct */ IM=IM&0xBF; last_isr_cycle = cycles; if (gDelayUpdateKeys == 1) update_keys(); } else if(RST65PEND && !INTDIS && !RST65MASK) { if(trace && tracefile != NULL) fprintf(tracefile,"RST 6.5 CALLed\n"); if (gDebugInts) gIntActive = TRUE; gIntSP = SP; DECSP2; if (gReMem) { MEMSET(SP, PCL); MEMSET(SP+1, PCH); } else { gBaseMemory[SP] = PCL; gBaseMemory[SP+1] = PCH; } /* MEM16(SP)=PC; */ PCL=52; PCH=0; /* PC=52; */ cycle_delta += 10; /* This may not be correct */ // IM=IM&0xDF; last_isr_cycle = cycles; } return; }
INT32 IPPVinfo_got_info() { UINT16 ret; UINT16 total_num = CDCA_MAXNUM_IPPVP; SCDCAIppvInfo total_program_info[CDCA_MAXNUM_IPPVP]; #if 1 MEMSET(total_program_info, 0, sizeof(total_program_info)); ret = CDCASTB_GetIPPVProgram(current_operator_ID, total_program_info, &total_num); if (CDCA_RC_CARD_INVALID== ret) { win_popup_msg(NULL, NULL, RS_CAERR_NOSMC); return 0; } else if (CDCA_RC_DATA_NOT_FIND == ret) { win_popup_msg(NULL, NULL, RS_CAERR_DATA_NOT_FOUND); return 0; } else if (CDCA_RC_DATASPACE_SMALL == ret) { win_popup_msg(NULL, NULL, RS_CAERR_BUFFER_SMALL); return 0; } else if (CDCA_RC_OK == ret) { //success, sort the IPPV prog info by Select Sorting Method UINT32 i, j, k; SCDCAIppvInfo tmp; for (i=0; i<total_num; i++) { k = i; for (j=i+1; j<total_num; j++) { /*if ((total_program_info[j].m_bySlotID < total_program_info[k].m_bySlotID) ||((total_program_info[j].m_bySlotID == total_program_info[k].m_bySlotID) &&(total_program_info[j].m_dwProductID<total_program_info[k].m_dwProductID)))*/ if (total_program_info[j].m_dwProductID<total_program_info[k].m_dwProductID) k = j; } if (k != i) { MEMCPY(&tmp, &total_program_info[i], sizeof(SCDCAIppvInfo)); MEMCPY(&total_program_info[i], &total_program_info[k], sizeof(SCDCAIppvInfo)); MEMCPY(&total_program_info[k], &tmp, sizeof(SCDCAIppvInfo)); } } //just display the viewed records MEMSET(IPPV_program_info, 0, sizeof(IPPV_program_info)); j= 0; for(i=0; i<total_num; i++) { if (CDCA_IPPVSTATUS_VIEWED == total_program_info[i].m_byBookEdFlag) //viewed { MEMCPY(&IPPV_program_info[j], &total_program_info[i], sizeof(SCDCAIppvInfo)); j++; } } total_IPPV_number = j; } else { win_popup_msg(NULL, NULL, RS_CAERR_UNKNOWN); return 0; } #else // for self -testing UINT32 i, j, k; SCDCAIppvInfo tmp; total_num = 201; MEMSET(total_program_info, 0, sizeof(total_program_info)); for (k=0;k<total_num;k++) { i = total_num - k; total_program_info[i].m_dwProductID = 1200000290+i; total_program_info[i].m_bCanTape = i%2; total_program_info[i].m_byBookEdFlag = (i%3) +1; total_program_info[i].m_bySlotID = i%5; total_program_info[i].m_wPrice = i*3; } for (i=0; i<total_num; i++) { k = i; for (j=i+1; j<total_num; j++) { /*if ((total_program_info[j].m_bySlotID < total_program_info[k].m_bySlotID) ||((total_program_info[j].m_bySlotID == total_program_info[k].m_bySlotID) &&(total_program_info[j].m_dwProductID<total_program_info[k].m_dwProductID)))*/ if (total_program_info[j].m_dwProductID<total_program_info[k].m_dwProductID) k = j; } if (k != i) { MEMCPY(&tmp, &total_program_info[i], sizeof(SCDCAIppvInfo)); MEMCPY(&total_program_info[i], &total_program_info[k], sizeof(SCDCAIppvInfo)); MEMCPY(&total_program_info[k], &tmp, sizeof(SCDCAIppvInfo)); } } //just display the viewed records MEMSET(IPPV_program_info, 0, sizeof(IPPV_program_info)); j= 0; for(i=0; i<total_num; i++) { if (CDCA_IPPVSTATUS_VIEWED == total_program_info[i].m_byBookEdFlag) //viewed { MEMCPY(&IPPV_program_info[j], &total_program_info[i], sizeof(SCDCAIppvInfo)); j++; } } total_IPPV_number = j; #endif return 1; }
static void ci_info_init() { char * tmp; UINT8 *tmp_buf; // init MEMSET(&ci_info, 0, sizeof(ci_info)); // get menu string tmp_buf = (void*)(win_ci_get_tmp_buf()); tmp = api_ci_get_menu_string(tmp_buf, CI_DATA_BUFFER_LEN, ci_slot); if(tmp != NULL) { ci_info_set_string(ci_info.name, CI_MENU_TXT_LENGTH, tmp); } else { ci_info.name[0] = '\0'; } //set the window style as the difference show modal win_ci_info_set_colorstyle(); if(win_ci_info_modal == WIN_CI_INFO_SHOW_AS_MODAL) { OSD_SetColor((POBJECT_HEAD)&g_win_ci_info,WIN_SH_IDX_SD,WIN_HL_IDX_SD,WIN_SL_IDX_SD,WIN_GRY_IDX_SD); OSD_MoveObject((POBJECT_HEAD)&g_win_ci_info, W_L_SD,W_T_SD, 0);//62, 55, 0); OSD_MoveObject((POBJECT_HEAD)&txt_ci_info_split1, W_L_SD + 10, SPLIT_1_T_SD, 0); //62, SPLIT_1_T, 0); OSD_MoveObject((POBJECT_HEAD)&txt_ci_info_split2, W_L_SD + 10, SPLIT_2_T_SD, 0);//62, SPLIT_2_T - 1, 0); } else { OSD_SetColor((POBJECT_HEAD)&g_win_ci_info, WIN_SUBMENU_BODY_FRAME, WIN_SUBMENU_BODY_FRAME, WIN_SUBMENU_BODY_FRAME, WIN_SUBMENU_BODY_FRAME);//guop OSD_MoveObject((POBJECT_HEAD)&g_win_ci_info, W_L,W_T, 0); OSD_MoveObject((POBJECT_HEAD)&txt_ci_info_split1, SPLIT_1_L, SPLIT_1_T, 0); OSD_MoveObject((POBJECT_HEAD)&txt_ci_info_split2, SPLIT_1_L, SPLIT_2_T, 0); } ///////////////////////////////////////////////////////////////////////// //clear the menu //1. CI Title OSD_SetTextFieldContent(&txt_ci_info_title, STRING_UNICODE, (UINT32)""); //2. sub title ci_info_subtitle_content[0].text.pString = NULL; //3. bottom OSD_SetTextFieldContent(&txt_ci_info_bottom, STRING_UNICODE, (UINT32)""); //4. list OSD_SetObjListCount(&olst_ci_info, 0); OSD_SetAttr(&sb_ci_info, C_ATTR_HIDDEN); //show the ci enquiry dialog OSD_SetObjpNext(&txt_ci_info_bottom, NULL); //the the windows focus to the dialog g_win_ci_info.FocusObjectID = 1; }
static UINT8 win_satsrch_set_scroll_drawselectsats(UINT8 start_sat_idx) { struct OSDRect rect; UINT16 i,sat_cnt,num; UINT16 col,row; TEXT_FIELD* txt = &satsrch_multisats_name; S_NODE s_node; UINT16 top; UINT16 str[50]; UINT16 nStrLen; UINT8 disp_total_row,adjust_row,start_disp_id; UINT8 next_start_idx=start_sat_idx+2; if(single_multi_srch_flag == 0) return; MEMSET(sat_ids,0,sizeof(sat_ids)/sizeof(sat_ids[0])); sat_cnt = num = get_tuner_sat_cnt(TUNER_EITHER_SELECT);//get_selected_sat_num(); if(num > SELSAT_ROW_CNT *2) num = SELSAT_ROW_CNT *2; txt->pString = display_strs[0]; for(i=0; i<sat_cnt; i++) { get_tuner_sat(TUNER_EITHER_SELECT,i,&s_node); sat_ids[i] = s_node.sat_id; } if(start_sat_idx>=(sat_cnt+SELSAT_ROW_CNT*2-2)) next_start_idx=0; start_disp_id=0; if(start_sat_idx==0) { disp_total_row=1; adjust_row=5; } else if(start_sat_idx==2) { disp_total_row=2; adjust_row=4; } else if(start_sat_idx==4) { disp_total_row=3; adjust_row=3; } else if(start_sat_idx==6) { disp_total_row=4; adjust_row=2; } else { disp_total_row=SELSAT_ROW_CNT; adjust_row=1; if(start_sat_idx>=(SELSAT_ROW_CNT*2)) start_disp_id=start_sat_idx-(SELSAT_ROW_CNT*2)+2; } /*if(start_sat_idx==0) { struct OSDRect r; r.uLeft=SELSAT_L0;//txt.head.frame.uLeft;//200; r.uTop=SELSAT_T-40;//txt.head.frame.uTop;//300; r.uWidth=SELSAT_W*2+40;//txt.head.frame.uWidth;//100; r.uHeight=SELSAT_H*5-30;//txt.head.frame.uHeight;//45; OSD_DrawFrame(&r,RGB24_RGB1555(173,173,173),NULL); }*/ for(i=/*0*//*start_sat_idx*/start_disp_id; i<(/*SELSAT_ROW_CNT*/disp_total_row*2+start_disp_id); i++) { row = (i-start_disp_id)/2+adjust_row; top = SELSAT_T + row * 30/*SELSAT_H*/-40; if(i%2 == 0) OSD_SetRect(&txt->head.frame, SELSAT_L0, top, SELSAT_W, SELSAT_H-6); else OSD_SetRect(&txt->head.frame, SELSAT_L1, top, SELSAT_W, SELSAT_H-6); get_tuner_sat(TUNER_EITHER_SELECT,i,&s_node); if(i<sat_cnt) { if(s_node.DiSEqC_type !=6) ComUniStrCopyChar((UINT8*)txt->pString, s_node.sat_name); } else { ComAscStr2Uni("", txt->pString); //next_start_idx=0; } OSD_DrawObject( (POBJECT_HEAD)txt, C_UPDATE_ALL); //if(adjust_row && (i%2==1)) // adjust_row-=2; } if(num == 0) { txt->pString = NULL; top = SELSAT_T + 2 * SELSAT_H+40; OSD_SetRect(&txt->head.frame, SELSAT_L0 + SELSAT_W/2, top, SELSAT_W, SELSAT_H-6); OSD_SetTextFieldContent(txt, STRING_ID , RS_DISPLAY_NO_SATELLITE/*RS_NO_SATELLITE_SELECT*/); OSD_DrawObject( (POBJECT_HEAD)txt, C_UPDATE_ALL); } return next_start_idx; }
static PRESULT win_tplist_list_unkown_act_proc(VACTION act) { PRESULT ret = PROC_LOOP; UINT8 pre_sat_idx; UINT16 sel,sat_cnt; OSD_RECT rect; COM_POP_LIST_PARAM_T param; OBJLIST* ol; S_NODE s_node; T_NODE t_node; UINT32 freq,symb,pol; UINT8 back_saved; UINT32 ftaonly_VPid,srch_chan_APid,nit_PPid; UINT32 choice; POBJECT_HEAD sub_menu; INT32 iret; UINT16 pre_sat_id,cur_sat_id; sat_cnt = get_tuner_sat_cnt(TUNER_EITHER); get_tuner_sat(TUNER_EITHER, cur_tp_sat_idx, &s_node); ol = &tplst_olist; sel = OSD_GetObjListCurPoint(ol); pre_sat_idx = cur_tp_sat_idx; switch(act) { case VACT_SAT_PRE: if(cur_tp_sat_idx > 0) cur_tp_sat_idx --; else cur_tp_sat_idx = sat_cnt - 1; goto SAT_CHANGE; case VACT_SAT_NEXT: if(cur_tp_sat_idx < (sat_cnt - 1)) cur_tp_sat_idx ++; else cur_tp_sat_idx = 0; goto SAT_CHANGE; case VACT_SAT_SELECT: param.id = TUNER_EITHER; param.cur = cur_tp_sat_idx; param.selecttype = POP_LIST_SINGLESELECT; OSD_SetRect(&rect, LST_SAT_L - 20 , LST_SAT_T, LST_SAT_W + 40, 360); rect.uTop += LST_SAT_H; sel = win_com_open_sub_list(POP_LIST_TYPE_SAT,&rect,¶m); if(sel < sat_cnt) cur_tp_sat_idx = sel; goto SAT_CHANGE; SAT_CHANGE: tp_list_pos = 0; tp_list_top = 0; if(cur_tp_sat_idx != pre_sat_idx) { pre_tp_sat_idx = pre_sat_idx; get_tuner_sat(TUNER_EITHER, pre_sat_idx, &s_node); pre_sat_id = s_node.sat_id; get_tuner_sat(TUNER_EITHER, cur_tp_sat_idx, &s_node); cur_sat_id = s_node.sat_id; #ifdef SUPPORT_TWO_TUNER #ifdef SUPPORT_SELECT_SAME_SAT cur_tuner_idx = s_node.reserve_1; //s_node.tuner1_valid? 0 : 1; #else cur_tuner_idx = s_node.tuner1_valid? 0 : 1; #endif #endif if(win_tplist_check_change()) update_data(); win_tplist_load_sat(TRUE); //OSD_TrackObject( (POBJECT_HEAD)&tplst_olist, C_DRAW_SIGN_EVN_FLG | C_UPDATE_ALL); OSD_TrackObject( (POBJECT_HEAD)&g_win_tplist, C_DRAW_SIGN_EVN_FLG | C_UPDATE_ALL); api_stop_timer(&tpturn_timer_id); tpturn_timer_id = api_start_timer(TPTURN_TIMER_NAME, TPTURN_TIMER_TIME, win_tplist_tpturn_handler); } break; case VACT_TP_EDIT: /* If not TP, can't EDIT */ if(OSD_GetObjListCount(ol) == 0) break; get_tp_at(s_node.sat_id,sel, &t_node); choice = win_tpe_open(0, s_node.sat_id, t_node.tp_id); if( choice) { win_tpe_get_setting(&freq, &symb, &pol); if(freq != t_node.frq || symb != t_node.sym || pol != t_node.pol) { t_node.frq = freq; t_node.sym = symb; t_node.pol = pol; modify_tp(t_node.tp_id,&t_node); api_stop_timer(&tpturn_timer_id); tpturn_timer_id = api_start_timer(TPTURN_TIMER_NAME, TPTURN_TIMER_TIME, win_tplist_tpturn_handler); } } //OSD_TrackObject( (POBJECT_HEAD)ol, C_DRAW_SIGN_EVN_FLG | C_UPDATE_ALL); OSD_TrackObject( (POBJECT_HEAD)&g_win_tplist, C_DRAW_SIGN_EVN_FLG | C_UPDATE_ALL); break; case VACT_TP_ADD: if(OSD_GetObjListCount(ol) == MAX_TP_NUM) break; extern UINT32 edit_tp_exist; edit_tp_exist = 0; choice = win_tpe_open(1, s_node.sat_id, 0); if(choice) { win_tpe_get_setting(&freq, &symb, &pol); MEMSET(&t_node,0,sizeof(t_node) ); t_node.frq = freq; t_node.sym = symb; t_node.pol = pol; t_node.sat_id = s_node.sat_id; iret = add_node(TYPE_TP_NODE,s_node.sat_id,(void*)&t_node); if((iret == DBERR_MAX_LIMIT) || (iret == DBERR_FLASH_FULL)) { OSD_TrackObject( (POBJECT_HEAD)ol, C_DRAW_SIGN_EVN_FLG | C_UPDATE_ALL); win_compopup_init(WIN_POPUP_TYPE_OK); win_compopup_set_msg(NULL,NULL, RS_DISPLAY_TOO_MANY_TP); win_compopup_open_ext(&back_saved); break; } OSD_SetObjListCount(ol, OSD_GetObjListCount(ol) + 1); //OSD_TrackObject( (POBJECT_HEAD)ol, C_DRAW_SIGN_EVN_FLG | C_UPDATE_ALL); OSD_TrackObject( (POBJECT_HEAD)&g_win_tplist, C_DRAW_SIGN_EVN_FLG | C_UPDATE_ALL); OSD_ChangeFocus((POBJECT_HEAD)ol,OSD_GetObjListCount(ol) - 1, C_DRAW_SIGN_EVN_FLG | C_UPDATE_FOCUS); api_stop_timer(&tpturn_timer_id); tpturn_timer_id = api_start_timer(TPTURN_TIMER_NAME, TPTURN_TIMER_TIME, win_tplist_tpturn_handler); } else { OSD_TrackObject( (POBJECT_HEAD)&g_win_tplist, C_DRAW_SIGN_EVN_FLG | C_UPDATE_ALL); //OSD_TrackObject( (POBJECT_HEAD)ol, C_DRAW_SIGN_EVN_FLG | C_UPDATE_ALL); if( edit_tp_exist > 0) { OSD_ChangeFocus((POBJECT_HEAD)ol,edit_tp_exist - 1, C_DRAW_SIGN_EVN_FLG | C_UPDATE_FOCUS); edit_tp_exist = 0; } //OSD_TrackObject( (POBJECT_HEAD)ol, C_DRAW_SIGN_EVN_FLG | C_UPDATE_ALL); } break; case VACT_TP_DEL: /* If not TP, can't DEL */ if(OSD_GetObjListCount(ol) == 0) break; win_compopup_init(WIN_POPUP_TYPE_OKNO); win_compopup_set_msg(NULL, NULL,RS_DISPLAY_SURE_TO_DELETE); if(win_compopup_open_ext(&back_saved) != WIN_POP_CHOICE_YES) break; get_tp_at(s_node.sat_id,sel, &t_node); del_tp_by_id(t_node.tp_id); OSD_SetObjListCount(ol, OSD_GetObjListCount(ol) -1); OSD_TrackObject( (POBJECT_HEAD)ol, C_DRAW_SIGN_EVN_FLG | C_UPDATE_ALL); if( OSD_GetObjListCount(ol) > 0) { if(sel == OSD_GetObjListCount(ol)) /* Delete last TP */ OSD_ChangeFocus((POBJECT_HEAD)ol,OSD_GetObjListCount(ol) - 1, C_DRAW_SIGN_EVN_FLG | C_UPDATE_FOCUS); else tpturn_timer_id = api_start_timer(TPTURN_TIMER_NAME, TPTURN_TIMER_TIME, win_tplist_tpturn_handler); } break; case VACT_TP_SRCH: /* If not TP, can't SEARCH */ if(OSD_GetObjListCount(ol) == 0) break; sys_data_set_cur_satidx(cur_tp_sat_idx); tp_list_pos = OSD_GetObjListCurPoint(ol); tp_list_top = OSD_GetObjListTop(ol); choice = win_tpsrch_open(&ftaonly_VPid,&srch_chan_APid,&nit_PPid); if(choice==1) { win_tpsrch_set_search_param(ftaonly_VPid,srch_chan_APid,nit_PPid); sub_menu = (POBJECT_HEAD)&g_win_search; wincom_close_help(); if(OSD_ObjOpen(sub_menu, 0xFFFFFFFF) != PROC_LEAVE) { menu_stack_push(sub_menu); set_movedish_flag(TRUE);/*only tp search,need not moving dish when return*/ } } else if(choice==2) //pid search { tp_VPid = ftaonly_VPid; tp_APid = srch_chan_APid; tp_PPid = nit_PPid; prog_callback_register((prog_node_return)win_tplist_set_search_pid_callback); get_tp_at(s_node.sat_id,sel,&t_node); win_search_set_pid_param(t_node.tp_id, tp_VPid, tp_APid, tp_PPid); win_tpsrch_set_search_param(P_SEARCH_FTA|P_SEARCH_SCRAMBLED,P_SEARCH_TV|P_SEARCH_RADIO,0); sub_menu = (POBJECT_HEAD)&g_win_search; wincom_close_help(); if(OSD_ObjOpen(sub_menu, 0xFFFFFFFF) != PROC_LEAVE) menu_stack_push(sub_menu); } else { //OSD_TrackObject( (POBJECT_HEAD)ol, C_DRAW_SIGN_EVN_FLG | C_UPDATE_ALL); OSD_TrackObject( (POBJECT_HEAD)&g_win_tplist, C_DRAW_SIGN_EVN_FLG | C_UPDATE_ALL); } break; } return ret; }
BOOL win_signal_update(void) { POBJECT_HEAD pObj; PROGRESS_BAR* bar; TEXT_FIELD* txt; char str[20]; INT str_len; pObj = (POBJECT_HEAD)&g_win_signal; if(pObj->pRoot == NULL) return FALSE; bar = &sig_bar_level; txt = &sig_txt_level_per; OSD_SetTextFieldContent(txt, STRING_NUM_PERCENT, OSD_GetProgressBarPos(bar)); bar = &sig_bar_quality; txt = &sig_txt_quality_per; OSD_SetTextFieldContent(txt, STRING_NUM_PERCENT, OSD_GetProgressBarPos(bar)); OSD_DrawObject(pObj, C_UPDATE_ALL); #if 0 struct OSDRect rect; VSCR vscr; int i,j; extern struct osd_s3601_private *gp_osd_s3601_private0; UINT8 *pBuf,*pbyte; UINT32 *buf; //ge_s3601_private_t *osd_s3601_private0 = (ge_s3601_private_t *)(g_ge_dev->priv); UINT8 *ge_data_buf = (UINT8 *)(__MM_GE_START_ADDR); UINT8 *osd_bg_buf = (UINT8 *)((__MM_OSD_BK_ADDR1 + 31) & 0xFFFFFFE0); rect.uLeft = 240; rect.uTop = 162; rect.uWidth = 80; rect.uHeight = 160; pBuf = (UINT8 *)MALLOC(51200); MEMSET(pBuf,0,51200); vscr.bBlockID = 0; vscr.bColorMode = OSD_HD_ARGB8888; vscr.lpbScr = pBuf; vscr.updatePending = 1; vscr.vR = rect; if(color_test_flag) { libc_printf("\n===============================display buf======================================\n"); for(i = 0; i < 2; i++) { pbyte = (UINT8 *)(ge_data_buf) + 5120 * (i+rect.uTop) + rect.uLeft * 4;// buf = (UINT32 *)pbyte; for(j = 0;j < rect.uWidth;j++) { if(j % 8 == 0) { libc_printf("\n"); } libc_printf("0x%04x,",*buf++); } } libc_printf("\n=================================background buf=================================\n"); for(i = 0; i < 2; i++) { pbyte = (UINT8 *)(osd_bg_buf) + 5120 * (i+rect.uTop) + rect.uLeft * 4;// buf = (UINT32 *)pbyte; for(j = 0;j < rect.uWidth;j++) { if(j % 8 == 0) { libc_printf("\n"); } libc_printf("0x%04x,",*buf++); } } } while(color_test_flag) { MEMSET(pBuf,0,51200); OSDDrv_RegionRead(g_osd_dev,0,&vscr,&vscr.vR); libc_printf("\n----------------------------------------read virtual buf-------------------------------"); for(i = 0; i < 2; i++) { pbyte = vscr.lpbScr; buf = (UINT32 *)pbyte; for(j = 0;j < rect.uWidth;j++) { if(j % 8 == 0) { libc_printf("\n"); } libc_printf("0x%04x,",*buf++); } } libc_printf("\n----------------------------------------read background buf=-------------------------------"); for(i = 0; i < 2; i++) { pbyte = (UINT8 *)(osd_bg_buf) + 5120 * (i+rect.uTop) + rect.uLeft * 4;// buf = (UINT32 *)pbyte; for(j = 0;j < rect.uWidth;j++) { if(j % 8 == 0) { libc_printf("\n"); } libc_printf("0x%04x,",*buf++); } } osal_task_sleep(20); libc_printf("\n----------------------------------------write-------------------------------"); OSDDrv_RegionWrite(g_osd_dev,0,&vscr,&vscr.vR); for(i = 0; i < 2; i++) { pbyte = (UINT8 *)(ge_data_buf) + 5120 * (i+rect.uTop) + rect.uLeft * 4; buf = (UINT32 *)pbyte; for(j = 0;j < rect.uWidth;j++) { if(j % 8 == 0) { libc_printf("\n"); } libc_printf("0x%04x,",*buf++); } } libc_printf("\n----------------------------------------End-------------------------------"); for(i = 0; i < 2; i++) osal_task_sleep(100); } #endif return TRUE; }
static void win_miscset_save_setting(void) { MULTISEL *msel; SYSTEM_DATA* sys_data; UINT32 val; sys_data = sys_data_get(); #ifndef NEW_DEMO_FRAME struct nim_lnb_info lnb_info; for(i=0;i<2;i++) { lib_nimg_get_lnb_info(i+1,&lnb_info); if(LNB_POWER_OFF == sys_data->bLNB_power) lnb_info.lnb_power_off = 1; else lnb_info.lnb_power_off = 0; lib_nimg_set_lnb_info(i+1,&lnb_info); } #else struct nim_config lnb_info; struct nim_device *nim; UINT16 i; for(i=0;i<2;i++) { nim = (struct nim_device *)dev_get_by_id(HLD_DEV_TYPE_NIM, i); dev_get_nim_config(nim,FRONTEND_TYPE,&lnb_info); if(LNB_POWER_OFF == sys_data->bLNB_power) lnb_info.antenna.antenna_enable = /*0*/1; //Seiya fix BUG37540: else lnb_info.antenna.antenna_enable = 1; dev_set_nim_config(nim, FRONTEND_TYPE, &lnb_info); } #endif msel =&miscset_sel1; val = OSD_GetMultiselSel(msel); sys_data->chan_sw = val; msel =&miscset_sel2; val = OSD_GetMultiselSel(msel); sys_data->chchgvideo_type = val; #ifdef CHANCHG_VIDEOTYPE_SUPPORT #ifndef NEW_DEMO_FRAME UIChChgSetVideoType(sys_data->chchgvideo_type); #endif #endif msel =&miscset_sel3; val = OSD_GetMultiselSel(msel); sys_data->install_beep = val; msel =&miscset_sel4; val = OSD_GetMultiselSel(msel); sys_data->auto_standby_en= val; #ifdef ORDER_GZ1207009 msel =&miscset_sel6; val = OSD_GetMultiselSel(msel); sys_data->standbymode= val; #endif #ifdef RAM_TMS_TEST msel =&miscset_sel5; val = OSD_GetMultiselSel(msel); char rec_part[16]; char tms_part[16]; if (sys_data->ram_tms_en != val) // detach tms part { rec_part[0] = tms_part[0] = 0; pvr_get_cur_mode(rec_part, tms_part); if (tms_part[0] != 0) { if (STRCMP(rec_part, tms_part) == 0) pvr_set_disk_use(PVR_REC_ONLY_DISK, rec_part); else pvr_detach_part(tms_part, PVR_TMS_ONLY_DISK); api_pvr_adjust_tms_space(); } } if (sys_data->ram_tms_en == 0 && val == 1) // enable RAM disk timeshift { UINT32 ram_len = RAM_DISK_SIZE; UINT32 ram_addr = (void *)(RAM_DISK_ADDR & 0x0fffffff | 0x80000000); ramdisk_create((UINT32)ram_addr, ram_len); struct pvr_register_info pvr_reg_info; MEMSET(&pvr_reg_info, 0, sizeof(struct pvr_register_info)); STRCPY(pvr_reg_info.mount_name, "/mnt/rda1"); pvr_reg_info.disk_usage = PVR_TMS_ONLY_DISK; pvr_reg_info.sync = 1; pvr_reg_info.init_list = 0; pvr_reg_info.check_speed = 0; pvr_register((UINT32)&pvr_reg_info, 0); } else if (sys_data->ram_tms_en == 1 && val == 0) // disable RAM disk timeshift { ramdisk_delete(); } if (sys_data->ram_tms_en != val) { if (val == 0) // disable RAM disk timeshift, select PVR partition again { UINT8 back_saved; rec_part[0] = tms_part[0] = 0; pvr_select_part(rec_part, tms_part); if (rec_part[0] != 0 || tms_part[0] != 0) { win_compopup_init(WIN_POPUP_TYPE_SMSG); win_compopup_set_msg_ext("Init PVR partitions, please wait...", NULL, 0); win_compopup_open_ext(&back_saved); if (STRCMP(rec_part, tms_part) == 0) { pvr_change_part(rec_part, PVR_REC_AND_TMS_DISK); } else { pvr_change_part(rec_part, PVR_REC_ONLY_DISK); pvr_change_part(tms_part, PVR_TMS_ONLY_DISK); } win_compopup_smsg_restoreback(); } } struct dvr_HDD_info hdd_info; pvr_get_HDD_info(&hdd_info); api_pvr_check_level(&hdd_info); if (pvr_get_cur_mode(NULL, NULL) == PVR_DISK_INVALID) { api_pvr_clear_up_all(); } } sys_data->ram_tms_en = val; #endif sys_data_save(1); }
static int default_char2int(SCR *sp, const char * str, ssize_t len, CONVWIN *cw, size_t *tolen, const CHAR_T **dst, const char *enc) { int j; size_t i = 0; CHAR_T **tostr = (CHAR_T **)(void *)&cw->bp1; size_t *blen = &cw->blen1; mbstate_t mbs; size_t n; ssize_t nlen = len; const char *src = (const char *)str; iconv_t id = (iconv_t)-1; char buffer[CONV_BUFFER_SIZE]; size_t left = len; int error = 1; MEMSET(&mbs, 0, 1); BINC_RETW(NULL, *tostr, *blen, nlen); #ifdef USE_ICONV if (strcmp(nl_langinfo(CODESET), enc)) { id = iconv_open(nl_langinfo(CODESET), enc); if (id == (iconv_t)-1) goto err; CONVERT(str, left, src, len); } #endif for (i = 0, j = 0; j < len; ) { n = mbrtowc((*tostr)+i, src+j, len-j, &mbs); /* NULL character converted */ if (n == (size_t)-2) error = -(len-j); if (n == (size_t)-1 || n == (size_t)-2) HANDLE_MBR_ERROR(n, mbs, (*tostr)[i], src[j]); if (n == 0) n = 1; j += n; if (++i >= *blen) { nlen += 256; BINC_RETW(NULL, *tostr, *blen, nlen); } if (id != (iconv_t)-1 && j == len && left) { CONVERT(str, left, src, len); j = 0; } } *tolen = i; if (id != (iconv_t)-1) iconv_close(id); *dst = cw->bp1; return 0; err: *tolen = i; if (id != (iconv_t)-1) iconv_close(id); *dst = cw->bp1; return error; }
void acpi_ut_init_globals ( void) { u32 i; FUNCTION_TRACE ("Ut_init_globals"); /* Memory allocation and cache lists */ MEMSET (acpi_gbl_memory_lists, 0, sizeof (ACPI_MEMORY_LIST) * ACPI_NUM_MEM_LISTS); acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].link_offset = (u16) (NATIVE_UINT) &(((acpi_generic_state *) NULL)->common.next); acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].link_offset = (u16) (NATIVE_UINT) &(((acpi_parse_object *) NULL)->next); acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].link_offset = (u16) (NATIVE_UINT) &(((acpi_parse2_object *) NULL)->next); acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].link_offset = (u16) (NATIVE_UINT) &(((acpi_operand_object *) NULL)->cache.next); acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].link_offset = (u16) (NATIVE_UINT) &(((acpi_walk_state *) NULL)->next); acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].object_size = sizeof (acpi_namespace_node); acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].object_size = sizeof (acpi_generic_state); acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].object_size = sizeof (acpi_parse_object); acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].object_size = sizeof (acpi_parse2_object); acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].object_size = sizeof (acpi_operand_object); acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].object_size = sizeof (acpi_walk_state); acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].max_cache_depth = MAX_STATE_CACHE_DEPTH; acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].max_cache_depth = MAX_PARSE_CACHE_DEPTH; acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].max_cache_depth = MAX_EXTPARSE_CACHE_DEPTH; acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].max_cache_depth = MAX_OBJECT_CACHE_DEPTH; acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].max_cache_depth = MAX_WALK_CACHE_DEPTH; ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].list_name = "Global Memory Allocation"); ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].list_name = "Namespace Nodes"); ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].list_name = "State Object Cache"); ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].list_name = "Parse Node Cache"); ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].list_name = "Extended Parse Node Cache"); ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].list_name = "Operand Object Cache"); ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].list_name = "Tree Walk Node Cache"); /* ACPI table structure */ for (i = 0; i < NUM_ACPI_TABLES; i++) { acpi_gbl_acpi_tables[i].prev = &acpi_gbl_acpi_tables[i]; acpi_gbl_acpi_tables[i].next = &acpi_gbl_acpi_tables[i]; acpi_gbl_acpi_tables[i].pointer = NULL; acpi_gbl_acpi_tables[i].length = 0; acpi_gbl_acpi_tables[i].allocation = ACPI_MEM_NOT_ALLOCATED; acpi_gbl_acpi_tables[i].count = 0; } /* Address Space handler array */ for (i = 0; i < ACPI_NUM_ADDRESS_SPACES; i++) { acpi_gbl_address_spaces[i].handler = NULL; acpi_gbl_address_spaces[i].context = NULL; } /* Mutex locked flags */ for (i = 0; i < NUM_MTX; i++) { acpi_gbl_acpi_mutex_info[i].mutex = NULL; acpi_gbl_acpi_mutex_info[i].owner_id = ACPI_MUTEX_NOT_ACQUIRED; acpi_gbl_acpi_mutex_info[i].use_count = 0; } /* Global notify handlers */ acpi_gbl_sys_notify.handler = NULL; acpi_gbl_drv_notify.handler = NULL; /* Global "typed" ACPI table pointers */ acpi_gbl_RSDP = NULL; acpi_gbl_XSDT = NULL; acpi_gbl_FACS = NULL; acpi_gbl_FADT = NULL; acpi_gbl_DSDT = NULL; /* Global Lock support */ acpi_gbl_global_lock_acquired = FALSE; acpi_gbl_global_lock_thread_count = 0; /* Miscellaneous variables */ acpi_gbl_system_flags = 0; acpi_gbl_startup_flags = 0; acpi_gbl_rsdp_original_location = 0; acpi_gbl_cm_single_step = FALSE; acpi_gbl_db_terminate_threads = FALSE; acpi_gbl_shutdown = FALSE; acpi_gbl_ns_lookup_count = 0; acpi_gbl_ps_find_count = 0; acpi_gbl_acpi_hardware_present = TRUE; acpi_gbl_next_table_owner_id = FIRST_TABLE_ID; acpi_gbl_next_method_owner_id = FIRST_METHOD_ID; acpi_gbl_debugger_configuration = DEBUGGER_THREADING; /* Hardware oriented */ acpi_gbl_gpe0enable_register_save = NULL; acpi_gbl_gpe1_enable_register_save = NULL; acpi_gbl_original_mode = SYS_MODE_UNKNOWN; /* original ACPI/legacy mode */ acpi_gbl_gpe_registers = NULL; acpi_gbl_gpe_info = NULL; /* Namespace */ acpi_gbl_root_node = NULL; acpi_gbl_root_node_struct.name = ACPI_ROOT_NAME; acpi_gbl_root_node_struct.data_type = ACPI_DESC_TYPE_NAMED; acpi_gbl_root_node_struct.type = ACPI_TYPE_ANY; acpi_gbl_root_node_struct.child = NULL; acpi_gbl_root_node_struct.peer = NULL; acpi_gbl_root_node_struct.object = NULL; acpi_gbl_root_node_struct.flags = ANOBJ_END_OF_PEER_LIST; #ifdef ACPI_DEBUG acpi_gbl_lowest_stack_pointer = ACPI_UINT32_MAX; #endif return_VOID; }
__s32 _copy_page0(__u32 SrcBlk,__u16 SrcDataPage,__u32 DstBlk,__u8 SeqPlus) { __u8 seq; __u16 LogicInfo; struct __NandUserData_t UserData[2]; struct __PhysicOpPara_t SrcParam,DstParam; SrcParam.MDataPtr = DstParam.MDataPtr = LML_TEMP_BUF; SrcParam.SDataPtr = DstParam.SDataPtr = (void *)&UserData; MEMSET((void *)&UserData,0xff,sizeof(struct __NandUserData_t) * 2); /*get seq and logicinfo*/ SrcParam.SectBitmap = 0x3; LML_CalculatePhyOpPar(&SrcParam,CUR_MAP_ZONE, SrcBlk, 0); if (LML_VirtualPageRead(&SrcParam) < 0){ LOGICCTL_ERR("_copy_page0 : read user data err\n"); return NAND_OP_FALSE; } seq = UserData[0].PageStatus; LogicInfo = UserData[0].LogicInfo; /*copy main data */ SrcParam.SectBitmap = DstParam.SectBitmap = FULL_BITMAP_OF_SUPER_PAGE; LML_CalculatePhyOpPar(&SrcParam, CUR_MAP_ZONE, SrcBlk, SrcDataPage); LML_CalculatePhyOpPar(&DstParam, CUR_MAP_ZONE, DstBlk, 0); if (LML_VirtualPageRead(&SrcParam) < 0){ LOGICCTL_ERR("_copy_page0 : read main data err\n"); return NAND_OP_FALSE; } if((SeqPlus!=0)&&(SeqPlus!=1)&&(SeqPlus!=2)) { PRINT("Error, invalid SeqPlus: %x \n", SeqPlus); PRINT("copypage0, SeqPlus, old_seq: %x, new_seq: %x\n", SeqPlus, seq, SeqPlus+seq); PRINT("SrcBlk: %x, DstBlk: %x, SrcDataPage: %x \n", SrcBlk, DstBlk, SrcDataPage); while(1); } else { //PRINT("copypage0, SeqPlus:%x, old_seq: %x, new_seq: %x\n", SeqPlus, seq, SeqPlus+seq); //PRINT("SrcBlk: %x, DstBlk: %x, SrcDataPage: %x \n", SrcBlk, DstBlk, SrcDataPage); } UserData[0].LogicInfo = LogicInfo; UserData[0].PageStatus = seq + SeqPlus; if(SeqPlus) //copy to new data block { UserData[0].LogType = 0xff; UserData[1].LogType = 0xff; } else //copy from log to log, move merge to log block0 { UserData[0].LogType &= 0xf; UserData[0].LogType &= 0xf; } if (NAND_OP_TRUE != LML_VirtualPageWrite(&DstParam)){ LOGICCTL_ERR("_copy_page0 : write err\n"); return NAND_OP_FALSE; } return NAND_OP_TRUE; }
void * xHeap::AllocSmall(uint32 size, const char * filename, int line) { #else void * xHeap::AllocSmall(uint32 size) { #endif // uint32 saveSize = size; size = (size + ALIGN - 1 + sizeof(SmallBlock) + DUMMY_ID_SIZE) & ~(ALIGN-1); uint32 i = size / ALIGN - 1; ASSERT(i < SMALL_SLOT_COUNT); SmallBlock * smallBlock; FreeSmallBlock * first = freeSmallBlocks[i]; if(first) { smallBlock = (SmallBlock*)first; freeSmallBlocks[i] = first->next; smallStats.hitCount++; } else { uint32 freePageSize = smallPage->size - smallPageOffs; if(freePageSize < size) { if(freePageSize > ((ALIGN + ALIGN - 1 + sizeof(SmallBlock) + DUMMY_ID_SIZE) & ~(ALIGN-1))) { uint32 i = freePageSize / ALIGN - 1; ASSERT(i < SMALL_SLOT_COUNT); smallBlock = (SmallBlock*)(((uint8*)smallPage) + smallPageOffs); smallBlock->sizeSlot = (uint8)i; #ifdef DEBUG_APP_HEAP uint8 * p = (uint8*)(smallBlock + 1); *(int*)p = DUMMY_SMALL_FREE_ID_PRE; *(int*)(p + smallBlock->DataSize() + sizeof(int)) = DUMMY_SMALL_FREE_ID_POST; #endif ((FreeSmallBlock*)smallBlock)->next = freeSmallBlocks[i]; freeSmallBlocks[i] = (FreeSmallBlock*)smallBlock; } SmallPage * newSmallPage = (SmallPage*)MALLOC(smallPageSize); if(!newSmallPage) { return NULL; } newSmallPage->size = smallPageSize; smallPageOffs = sizeof(*newSmallPage); smallStats.allocSize += newSmallPage->size; newSmallPage->next = smallPage; smallPage = newSmallPage; } else { smallStats.hitCount++; } ASSERT("Heap corrupted!" && (smallPageOffs & 3) == 0); smallBlock = (SmallBlock*)(((uint8*)smallPage) + smallPageOffs); smallPageOffs += size; } smallBlock->sizeSlot = (uint8)i; #ifdef DEBUG_APP_HEAP smallBlock->filename = filename; smallBlock->line = line; smallBlock->InsertBefore(dummySmallBlock.next); #endif uint32 dataSize = smallBlock->DataSize(); smallStats.RegisterAlloc(smallBlock->Size(), dataSize); uint8 * p = (uint8*)(smallBlock + 1); #ifndef USE_APP_HEAP_SAVING_MODE p[-1] = BT_SMALL; #else p[-1] = BLOCK_TYPE_MASK; #endif #ifdef DEBUG_APP_HEAP *(int*)p = DUMMY_SMALL_USED_ID_PRE; p += sizeof(int); *(int*)(p + dataSize) = DUMMY_SMALL_USED_ID_POST; #endif MEMSET(p, 0, dataSize); #if defined(DEBUG_APP_HEAP) && defined(AEE_SIMULATOR) // CheckMemory(); #endif return p; }
/*! * * \par Description: * This function copy valuable data from log block or dat block to free block, change free to data ,change * data and log to free. * * \param [in] LogNum,serial number within log block space * \return sucess or failed. * \note this function was called when log block is not suit for swap or move. **/ __s32 _free2data_simple_merge(__u32 nlogical) { __u8 InData; __u16 SuperPage; __u16 SrcPage,DstPage; __u32 SrcBlk,DstBlk; struct __SuperPhyBlkType_t DataBlk; struct __SuperPhyBlkType_t FreeBlk; struct __LogBlkType_t LogBlk; struct __PhysicOpPara_t SrcParam,DstParam; /*init block info*/ BMM_GetDataBlk(nlogical,&DataBlk); BMM_GetLogBlk(nlogical,&LogBlk); if (NAND_OP_TRUE != BMM_GetFreeBlk(LOWEST_EC_TYPE, &FreeBlk)) return NAND_OP_FALSE; /*copy data from data block or log block to free block*/ if((SUPPORT_LOG_BLOCK_MANAGE)&&(LogBlk.LogBlkType == LSB_TYPE)) { //DBUG_INF("[DBUG] nand lsb type simple merge block %x\n", nlogical); for (SuperPage = 0; SuperPage < PAGE_CNT_OF_LOGIC_BLK; SuperPage++) { /*set source address and destination address*/ DstPage = SuperPage; DstBlk = FreeBlk.PhyBlkNum; SrcPage = PMM_GetCurMapPage(SuperPage); InData = (SrcPage == 0xffff)?1 : 0; if(InData) { SrcBlk = DataBlk.PhyBlkNum; } else { if(SrcPage&(0x1<<15)) SrcBlk = LogBlk.PhyBlk1.PhyBlkNum; else SrcBlk = LogBlk.PhyBlk.PhyBlkNum; } SrcPage = InData?SuperPage:(SrcPage&0x7fff); LML_CalculatePhyOpPar(&SrcParam, CUR_MAP_ZONE,SrcBlk, SrcPage); LML_CalculatePhyOpPar(&DstParam, CUR_MAP_ZONE,DstBlk, DstPage); if (DstPage == 0) { __u8 SeqPlus; //SeqPlus = InData?1:0; SeqPlus = InData?2:1; if(NAND_OP_FALSE == _copy_page0(SrcBlk, SrcPage, DstBlk,SeqPlus)) { LOGICCTL_ERR("simple_merge : copy page 0 err\n"); return NAND_OP_FALSE; } } else { if(NAND_OP_TRUE != PHY_PageCopyback(&SrcParam,&DstParam)) { LOGICCTL_ERR("simple merge : copy back err\n"); return NAND_OP_FALSE; } } if(NAND_OP_TRUE != PHY_SynchBank(DstParam.BankNum, SYNC_BANK_MODE)) { struct __SuperPhyBlkType_t SubBlk; if(NAND_OP_TRUE != LML_BadBlkManage(&FreeBlk,CUR_MAP_ZONE,DstPage, &SubBlk)) { LOGICCTL_ERR("simgple merge : bad block manage err after copy back\n"); return NAND_OP_FALSE; } FreeBlk = SubBlk; SuperPage -= 1; } } /*move free block to data block*/ BMM_SetDataBlk(nlogical, &FreeBlk); /*move erased data block to free block*/ if ( NAND_OP_TRUE != LML_VirtualBlkErase(CUR_MAP_ZONE, DataBlk.PhyBlkNum)){ if (NAND_OP_TRUE != LML_BadBlkManage(&DataBlk,CUR_MAP_ZONE,0,NULL)){ LOGICCTL_ERR("swap merge : bad block manage err erase data block\n"); return NAND_OP_FALSE; } } /*move erased data block to free block*/ if (DataBlk.BlkEraseCnt < 0xffff) DataBlk.BlkEraseCnt ++; BMM_SetFreeBlk(&DataBlk); //DBUG_INF("[DBUG] logic %x simple merge: erase data block: %x\n", LogBlk.LogicBlkNum, DataBlk.PhyBlkNum); /*move erased log block to free block*/ if ( NAND_OP_TRUE != LML_VirtualBlkErase(CUR_MAP_ZONE, LogBlk.PhyBlk.PhyBlkNum)){ if (NAND_OP_TRUE != LML_BadBlkManage(&LogBlk.PhyBlk,CUR_MAP_ZONE,0,NULL)){ LOGICCTL_ERR("simple merge : bad block manage err after erase log block\n"); return NAND_OP_FALSE; } } if (LogBlk.PhyBlk.BlkEraseCnt < 0xffff) LogBlk.PhyBlk.BlkEraseCnt ++; BMM_SetFreeBlk(&LogBlk.PhyBlk); //DBUG_INF("[DBUG] logic %x simple merge: erase log block 0: %x\n", LogBlk.LogicBlkNum, LogBlk.PhyBlk.PhyBlkNum); /*move erased log block to free block*/ if ( NAND_OP_TRUE != LML_VirtualBlkErase(CUR_MAP_ZONE, LogBlk.PhyBlk1.PhyBlkNum)){ if (NAND_OP_TRUE != LML_BadBlkManage(&LogBlk.PhyBlk1,CUR_MAP_ZONE,0,NULL)){ LOGICCTL_ERR("simple merge : bad block manage err after erase log block\n"); return NAND_OP_FALSE; } } if (LogBlk.PhyBlk1.BlkEraseCnt < 0xffff) LogBlk.PhyBlk1.BlkEraseCnt ++; BMM_SetFreeBlk(&LogBlk.PhyBlk1); //DBUG_INF("[DBUG] logic %x simple merge: erase log block 1: %x\n", LogBlk.LogicBlkNum, LogBlk.PhyBlk1.PhyBlkNum); MEMSET(&LogBlk, 0xff, sizeof(struct __LogBlkType_t)); LogBlk.LogBlkType = 0; LogBlk.WriteBlkIndex = 0; LogBlk.ReadBlkIndex = 0; BMM_SetLogBlk(nlogical, &LogBlk); /*clear page map table*/ PMM_ClearCurMapTbl(); } else { for (SuperPage = 0; SuperPage < PAGE_CNT_OF_LOGIC_BLK; SuperPage++) { /*set source address and destination address*/ DstPage = SuperPage; DstBlk = FreeBlk.PhyBlkNum; SrcPage = PMM_GetCurMapPage(SuperPage); InData = (SrcPage == 0xffff)?1 : 0; SrcBlk = InData?DataBlk.PhyBlkNum : LogBlk.PhyBlk.PhyBlkNum; SrcPage = InData?SuperPage:SrcPage; LML_CalculatePhyOpPar(&SrcParam, CUR_MAP_ZONE,SrcBlk, SrcPage); LML_CalculatePhyOpPar(&DstParam, CUR_MAP_ZONE,DstBlk, DstPage); if (DstPage == 0) { __u8 SeqPlus; //SeqPlus = InData?1:0; SeqPlus = InData?2:1; if(NAND_OP_FALSE == _copy_page0(SrcBlk, SrcPage, DstBlk,SeqPlus)) { LOGICCTL_ERR("simple_merge : copy page 0 err\n"); return NAND_OP_FALSE; } } else { if(NAND_OP_TRUE != PHY_PageCopyback(&SrcParam,&DstParam)) { LOGICCTL_ERR("simple merge : copy back err\n"); return NAND_OP_FALSE; } } if(NAND_OP_TRUE != PHY_SynchBank(DstParam.BankNum, SYNC_BANK_MODE)) { struct __SuperPhyBlkType_t SubBlk; if(NAND_OP_TRUE != LML_BadBlkManage(&FreeBlk,CUR_MAP_ZONE,DstPage, &SubBlk)) { LOGICCTL_ERR("simgple merge : bad block manage err after copy back\n"); return NAND_OP_FALSE; } FreeBlk = SubBlk; SuperPage -= 1; } } /*move free block to data block*/ BMM_SetDataBlk(nlogical, &FreeBlk); /*move erased data block to free block*/ if ( NAND_OP_TRUE != LML_VirtualBlkErase(CUR_MAP_ZONE, DataBlk.PhyBlkNum)){ if (NAND_OP_TRUE != LML_BadBlkManage(&DataBlk,CUR_MAP_ZONE,0,NULL)){ LOGICCTL_ERR("swap merge : bad block manage err erase data block\n"); return NAND_OP_FALSE; } } /*move erased data block to free block*/ if (DataBlk.BlkEraseCnt < 0xffff) DataBlk.BlkEraseCnt ++; BMM_SetFreeBlk(&DataBlk); /*move erased log block to free block*/ if ( NAND_OP_TRUE != LML_VirtualBlkErase(CUR_MAP_ZONE, LogBlk.PhyBlk.PhyBlkNum)){ if (NAND_OP_TRUE != LML_BadBlkManage(&LogBlk.PhyBlk,CUR_MAP_ZONE,0,NULL)){ LOGICCTL_ERR("move merge : bad block manage err after erase log block\n"); return NAND_OP_FALSE; } } if (LogBlk.PhyBlk.BlkEraseCnt < 0xffff) LogBlk.PhyBlk.BlkEraseCnt ++; BMM_SetFreeBlk(&LogBlk.PhyBlk); MEMSET(&LogBlk, 0xff, sizeof(struct __LogBlkType_t)); LogBlk.LogBlkType = 0; LogBlk.WriteBlkIndex = 0; LogBlk.ReadBlkIndex = 0; BMM_SetLogBlk(nlogical, &LogBlk); /*clear page map table*/ PMM_ClearCurMapTbl(); } return NAND_OP_TRUE; }
void * xHeap::AllocMedium(uint32 size, const char * filename, int line) { #else void * xHeap::AllocMedium(uint32 size) { #endif #ifdef DEBUG_APP_HEAP // static int step = 0; // step++; #endif uint32 saveSize = size; size = (size + ALIGN - 1 + sizeof(Block) + DUMMY_ID_SIZE) & ~(ALIGN - 1); Block * block = dummyFree.nextFree; if(block->size < size) // block == &dummyFree => dummyFree.size == 0 { if(size > pageSize / 2) { #ifdef DEBUG_APP_HEAP return AllocLarge(saveSize, filename, line); #else return AllocLarge(saveSize); #endif } block = (Block*)MALLOC(pageSize); if(!block) { return NULL; } #ifdef DEBUG_APP_HEAP block->filename = filename; block->line = line; #endif block->page = nextPage++; block->size = pageSize; block->isFree = true; block->InsertBefore(dummyBlock.next); ((FreeBlock*)block)->InsertBeforeFreeLink(dummyFree.nextFree); mediumStats.allocSize += block->size; } else { mediumStats.hitCount++; #ifdef FIND_BEST_FREE_BLOCK for(FreeBlock * next = ((FreeBlock*)block)->nextFree; next->size >= size; ) { block = next; next = ((FreeBlock*)block)->nextFree; } #endif } block->size -= size; if(block->size < MAX_SMALL_SIZE && (block->size < MAX_SMALL_SIZE/2 || block->next->page != block->page)) { #ifdef DEBUG_APP_HEAP block->filename = filename; block->line = line; #endif block->size += size; ((FreeBlock*)block)->RemoveFreeLink(); } else { #ifdef DEBUG_APP_HEAP *(int*)(block+1) = DUMMY_MEDIUM_FREE_ID_PRE; *(int*)((uint8*)(block+1) + block->DataSize() + sizeof(int)) = DUMMY_MEDIUM_FREE_ID_POST; #endif if(block->size < ((FreeBlock*)block)->nextFree->size) { ((FreeBlock*)block)->RemoveFreeLink(); InsertFreeBlock((FreeBlock*)block); } ASSERT("Heap corrupted!" && (block->size & 3) == 0); Block * newBlock = (Block*)(((uint8*)block) + block->size); #ifdef DEBUG_APP_HEAP newBlock->filename = filename; newBlock->line = line; #endif newBlock->page = block->page; newBlock->size = size; newBlock->InsertAfter(block); block = newBlock; } block->isFree = false; uint32 dataSize = block->DataSize(); mediumStats.RegisterAlloc(block->size, dataSize); uint8 * p = (uint8*)(block+1); p[-1] = BT_MEDIUM; #ifdef DEBUG_APP_HEAP *(int*)p = DUMMY_MEDIUM_USED_ID_PRE; p += sizeof(int); *(int*)(p + dataSize) = DUMMY_MEDIUM_USED_ID_POST; #endif MEMSET(p, 0, dataSize); #if defined(DEBUG_APP_HEAP) && defined(AEE_SIMULATOR) // CheckMemory(); #endif return p; }
/******************************************** * NAME: vbi_cc_init * init cc parameters and set callback fucn of vpo_isr to excute push user data for cc using * * Returns : BOOL * 1 : RET_FAILURE * 0 : RET_SUCCESS * Parameter Flow Description * ------------------------------------------------------------------------------ * None * ------------------------------------------------------------------------------ * Additional information: ******************************************/ __ATTRIBUTE_REUSE_ INT32 vbi_cc_init() { struct vbi_device *dev; struct vbi_m3327_private *tp; void *priv_mem; g_vbi_m3327_name = (char *)ccvbi_m3327_name; dev = dev_alloc(g_vbi_m3327_name,HLD_DEV_TYPE_VBI,sizeof(struct vbi_device)); if (dev == NULL) { VBI_PRINTF("Error: Alloc video vbiplay device error!\n"); return RET_FAILURE; } /* Alloc structure space of private */ priv_mem = (void *)MALLOC(sizeof(struct vbi_m3327_private)); if (priv_mem == NULL) { dev_free(dev); VBI_PRINTF("Alloc vbiplay device prive memory error!/n"); return RET_FAILURE; } MEMSET(priv_mem, 0, sizeof(struct vbi_m3327_private)); g_vbi_priv = dev->priv = tp = (struct vbi_m3327_private *)priv_mem; ccg_vbi27_pconfig_par = &(g_vbi_priv->config_par); ccg_vbi27_ttx_by_osd = &(g_vbi_priv->ttx_by_osd); ccg_vbi27_cc_by_osd = &(g_vbi_priv->cc_by_osd); //====================================== #ifdef CC_BY_OSD ccg_vbi27_dtvcc_by_osd=&(g_vbi_priv->dtvcc_by_osd);//hbchen #endif //====================================== /*according the macro , config the VBI driver*/ //vbi_data_array = (struct vbi_data_array_t *)MALLOC((VBI_QUEUE_DEPTH)*sizeof(struct vbi_data_array_t)); //MEMSET(vbi_data_array, 0, (VBI_QUEUE_DEPTH)*sizeof(struct vbi_m3327_private)); *ccg_vbi27_ttx_by_osd = FALSE; g_vbi_priv->init_ttx_decoder = NULL; #ifdef CC_BY_OSD *ccg_vbi27_cc_by_osd = TRUE; g_vbi_priv->init_cc_decoder = vbi_m3327_init_cc_decoder; g_vbi_priv->vbi_line21_push_by_cc = vbi_line21_push; g_vbi_priv->vbi_line21_push_by_dtvcc = vbi_line21_push_dtvcc;//xing for DTVCC #else *ccg_vbi27_cc_by_osd = FALSE; #endif #ifdef CC_BY_VBI ccg_vbi27_pconfig_par->cc_by_vbi = TRUE; #else ccg_vbi27_pconfig_par->cc_by_vbi = FALSE; #endif //dev->setoutput = vbi_m3327_setoutput; dev->next = NULL; dev->flags = 0; /* Function point init */ dev->init = vbi_cc_init; dev->open = vbi_cc_open; dev->close = NULL; dev->request_write = NULL; dev->update_write = NULL; dev->setoutput = ccvbi_m3327_setoutput; dev->start = NULL; dev->stop = NULL; /* Add this device to queue */ if(dev_register(dev) != RET_SUCCESS) { VBI_PRINTF("Error: Register vbiplay device error!\n"); FREE(priv_mem); dev_free(dev); return RET_FAILURE; } return RET_SUCCESS; }
xHeap::xHeap() { ASSERT(CeilPowerOfTwo(APP_HEAP_CHUNK_SIZE) == APP_HEAP_CHUNK_SIZE); pageSize = CeilPowerOfTwo(DEF_PAGE_SIZE < MAX_SMALL_SIZE*8 ? MAX_SMALL_SIZE*8 : DEF_PAGE_SIZE); smallPageSize = pageSize; MEMSET(&smallStats, 0, sizeof(smallStats)); MEMSET(&largeStats, 0, sizeof(largeStats)); #ifdef DEBUG_APP_HEAP smallStats.minBlockDataSize = 0xFFFFFFFF; largeStats.minBlockDataSize = 0xFFFFFFFF; #endif dummySmallPage.size = 0; dummySmallPage.next = NULL; smallPage = &dummySmallPage; MEMSET(freeSmallBlocks, 0, sizeof(freeSmallBlocks)); smallPageOffs = 0; #ifdef DEBUG_APP_HEAP dummySmallBlock.ResetLink(); dummySmallBlock.sizeSlot = 0; dummySmallBlock.filename = "#dummy#"; dummySmallBlock.line = 0; #endif #ifndef USE_APP_HEAP_SAVING_MODE mediumSizeMask = pageSize/2-1; MEMSET(&mediumStats, 0, sizeof(mediumStats)); #ifdef DEBUG_APP_HEAP mediumStats.minBlockDataSize = 0xFFFFFFFF; #endif dummyBlock.ResetLink(); dummyBlock.size = 0; dummyBlock.page = (uint16)-1; dummyBlock.isFree = true; // dummyBlock.type = BT_MEDIUM; #ifdef DEBUG_APP_HEAP dummyBlock.filename = "#dummy#"; dummyBlock.line = 0; #endif dummyFree.ResetLink(); dummyFree.ResetFreeLink(); dummyFree.size = 0; dummyFree.page = (uint16)-1; dummyFree.isFree = false; // dummyFree.type = BT_MEDIUM; #ifdef DEBUG_APP_HEAP dummyFree.filename = "#dummy#"; dummyFree.line = 0; #endif nextPage = 1; #endif // USE_APP_HEAP_SAVING_MODE dummyLargeBlock.ResetLink(); dummyLargeBlock.size = 0; dummyLargeBlock.page = (uint16)-1; dummyLargeBlock.isFree = false; // dummyLargeBlock.type = BT_LARGE; #ifdef DEBUG_APP_HEAP dummyLargeBlock.filename = "#dummy#"; dummyLargeBlock.line = 0; #endif if(!instance) { *((xHeap**)(&instance)) = this; } }
/**************************************************************************** * * Name: packet_receive * Function: receive a packet * variable: pPacket -- packet information point * nTimeOut -- time out * ****************************************************************************/ UINT32 packet_receive(PPACKET pPacket, UINT32 nTimeOut) { //receive and compare packet head flag unsigned char c = 0; BOOL bPacketHead = FALSE; BOOL bComtest = FALSE; UINT32 i = 0; int n = 0; UINT32 nLength = 0; MEMSET(pPacket, 0, sizeof(PACKET)); for(i = 0; i < nTimeOut;) { if( c == 'H') { // judge if packet head for(n = 0; n < 3; n++) { if(SUCCESS != com_read_tm(&c, 1, 1)) { c = 0; break; } if(c != l_packet_head_flag[n + 1]) break; } if(n == 3) { bPacketHead = TRUE; break; } } else if(c == 'c') { pPacket->data_buffer[0] = 'c'; LIB_ASH_OC(c); //judge if comtest for(n = 0; n < 6; n++) { // c = LIB_ASH_IC(); if(SUCCESS != com_read_tm(&c, 1, 100)) { c = 0; SH_PRINTF("comtest not all : %d\n", n); break; } if(c != l_packet_comtest[n + 1]) break; LIB_ASH_OC(c); } if(n == 6) { SH_PRINTF("RECEIVE comtest\n"); bComtest = TRUE; break; } } else if(SUCCESS != com_read(&c, 1)) { Sleep(1); i++; } } if(bPacketHead) { //receive packet head unsigned char packet_head[PACKET_HEAD_LEN]; if(SUCCESS != com_read_tm(packet_head + PACKET_TYPE_OFFSET, PACKET_HEAD_LEN - 4, 1000)) { SH_PRINTF("ERROR:receive head error"); return ERROR_PACKET_RECEIVEHEAD; } //compare CRC about packet head UINT32 nCRC = MG_Table_Driven_CRC(0xFFFFFFFF, packet_head + PACKET_TYPE_OFFSET, PACKET_HEAD_LEN - 8); if(nCRC != fetch_long(packet_head + PACKET_HEAD_CRC_OFFSET)) return ERROR_PACKET_HEADCRC; MakePacketHead(packet_head, pPacket); //Receive data and CRC nLength = pPacket->packet_length; // if blank packet receive 4B packet number only if(0 != pPacket->blank_flag && PACKET_DATA == pPacket->packet_type) nLength = 4; if(SUCCESS != com_read_tm(pPacket->data_buffer, nLength + 4, 1000)) return ERROR_PACKET_RECEIVEDATA; nCRC = MG_Table_Driven_CRC(0xFFFFFFFF, pPacket->data_buffer, nLength); if(nCRC != fetch_long(pPacket->data_buffer + nLength)) return ERROR_PACKET_DATACRC; if(PACKET_DATA == pPacket->packet_type) { if(1 == pPacket->blank_flag) memset(pPacket->data_buffer + 4, 0xFF, pPacket->packet_length - 4); else if(2 == pPacket->blank_flag) memset(pPacket->data_buffer + 4, 0x00, pPacket->packet_length - 4); } } else if(bComtest) { pPacket->packet_type = PACKET_COMMAND; MEMCPY(pPacket->data_buffer, l_packet_comtest, 7); i = 7; while(i < 128) { pPacket->data_buffer[i] = LIB_ASH_IC(); c = pPacket->data_buffer[i]; LIB_ASH_OC(c); if (c == 0x0D || c == 0x0A) break; i++; } pPacket->packet_length = STRLEN(pPacket->data_buffer); // for(i = 0; i < pPacket->packet_length; i++) // LIB_ASH_OC(pPacket->data_buffer[i]); SH_PRINTF(pPacket->data_buffer); g_packet_index = 0; g_packet_repeat = 0; } else return ERROR_NOPACKETRECEIVE; return SUCCESS; }
static EmberStatus setEntry(uint8_t index, const EmberAfRf4ceMsoIrRfDatabaseEntry *entry) { // When a new entry comes in, we always remove the old entry, even though the // new entry might not fit. The rationale is that the old entry is being // replaced because it is no longer valid for the peripheral devices in the // system. Reverting to a default entry seems better than keeping the old, // invalid entry. uint32_t reclaimableBytes = calculateHeapUsage(&database[index]); if (reclaimableBytes != 0) { uint8_t *head; uint8_t i; // If the space we think we are using is ever less than what we think we // can reclaim, then something has gone very wrong. assert(reclaimableBytes <= USED_HEAP_SPACE()); // The RF payloads and the IR code are all stored contiguously in the heap, // although some of them may be empty. We just need to find whichever one // is first. If we expect to have one but can't find it or we do find it // but its not actually within the heap area, then something has gone very // wrong. head = findHead(&database[index]); assert(head != NULL); assert(heap <= head); assert(head + reclaimableBytes <= tail); // Rewind the tail pointer and all the RF payload and IR code pointers for // entries that follow the old one. This makes them point to where they // should after the heap is adjusted. This means the pointers are NOT // valid until the heap is adjusted. tail -= reclaimableBytes; for (i = 0; i < COUNTOF(database); i++) { if (head < database[i].rfPressedDescriptor.payload) { database[i].rfPressedDescriptor.payload -= reclaimableBytes; } if (head < database[i].rfRepeatedDescriptor.payload) { database[i].rfRepeatedDescriptor.payload -= reclaimableBytes; } if (head < database[i].rfReleasedDescriptor.payload) { database[i].rfReleasedDescriptor.payload -= reclaimableBytes; } if (head < database[i].irDescriptor.irCode) { database[i].irDescriptor.irCode -= reclaimableBytes; } } // Move the stuff after the old entry so it immediately follows the stuff // preceding the old entry. The old entry is now gone and the tail, RF // payload, and IR pointers are all valid again. MEMMOVE(head, head + reclaimableBytes, tail - head); // Wipe the stuff following the new tail. MEMSET(tail, 0, reclaimableBytes); } // The free space is the unused space and includes what we reclaimed from the // old entry. If we don't have enough room, we drop the new entry and leave // a default in its place. if (FREE_HEAP_SPACE() < calculateHeapUsage(entry)) { SET_DEFAULT(&database[index]); return EMBER_TABLE_FULL; } // The basic structure of the new entry is copied as is to the database. The // variable-sized portion of each descriptor is copied into the heap and then // the pointer to that data from the database is adjusted to point into the // heap. MEMCOPY(&database[index], entry, sizeof(EmberAfRf4ceMsoIrRfDatabaseEntry)); database[index].rfPressedDescriptor.payload = copyRfPayload(emberAfRf4ceMsoIrRfDatabaseEntryHasRfPressedDescriptor(entry), &entry->rfPressedDescriptor); database[index].rfRepeatedDescriptor.payload = copyRfPayload(emberAfRf4ceMsoIrRfDatabaseEntryHasRfRepeatedDescriptor(entry), &entry->rfRepeatedDescriptor); database[index].rfReleasedDescriptor.payload = copyRfPayload(emberAfRf4ceMsoIrRfDatabaseEntryHasRfReleasedDescriptor(entry), &entry->rfReleasedDescriptor); database[index].irDescriptor.irCode = copyIrCode(emberAfRf4ceMsoIrRfDatabaseEntryHasIrDescriptor(entry), &entry->irDescriptor); return EMBER_SUCCESS; }
void Curl_speedinit(struct SessionHandle *data) { MEMSET(&data->state.keeps_speed, 0, sizeof(struct timeval)); }
GtpImsiGenerator::GtpImsiGenerator() { MEMSET((VOID *)m_imsiStr, 0, GTP_IMSI_MAX_DIGITS); }
void tcp_echo_recv(void) { int len; /* length of recv data */ int e; /* error holder */ unsigned i; /* generic index */ int count; /* select return */ fd_set fd_recv; /* fd for recv */ fd_set fd_accept; /* fd for accept */ TCPCLIENT tmpclient = tcpq; struct sockaddr_in client; SOCKTYPE tmpsock; /* scratch socket */ if (elisten_sock == INVALID_SOCKET && tcpq == NULL) return; /* Echo not set up, don't bother */ #ifdef USE_FDS FD_ZERO(&fd_recv); FD_ZERO(&fd_accept); #endif /* select on all open data sockets */ i = 0; count = 0; #ifdef USE_FDS while (tmpclient) { if (tmpclient->sock != INVALID_SOCKET) { FD_SET(tmpclient->sock, &fd_recv); i++; } tmpclient=tmpclient->next; } #else while (tmpclient) { if (tmpclient->sock != INVALID_SOCKET) fd_recv.fd_array[i++] = tmpclient->sock ; tmpclient=tmpclient->next; } #endif /* USE_FDS */ #ifndef TCP_ZEROCOPY /* if we need to listen for server receives too */ #ifdef USE_FDS if (tcpecho_server && (esvr_sock != INVALID_SOCKET)) { FD_SET(esvr_sock, &fd_recv); } #else if (tcpecho_server) { if (esvr_sock != INVALID_SOCKET) fd_recv.fd_array[i++] = esvr_sock; } #endif /* USE_FDS */ #else /* if we need to close the server's active socket */ if (esvr_sock_close != FALSE) { if (esvr_sock != INVALID_SOCKET) { socketclose(esvr_sock); esvr_sock = INVALID_SOCKET; } esvr_sock_close = FALSE; } #endif /* TCP_ZEROCOPY */ #ifndef USE_FDS fd_recv.fd_count = i; #endif /* make this a short timeout since elisten may create soon */ if (elisten_sock != INVALID_SOCKET) { #ifdef USE_FDS FD_SET(elisten_sock, &fd_accept); #else fd_accept.fd_array[0] = elisten_sock; fd_accept.fd_count = 1; #endif /* USE_FDS */ count = t_select(&fd_recv, NULL, &fd_accept, 1); } else { if (i) /* if no fd_set sockets filled in, don't bother */ count = t_select(&fd_recv, NULL, NULL, 1); } /* While the t_select() was executing, commands can be * executed from cmd-prompt and sockets can be cleaned up. * Check for that. */ if (elisten_sock == INVALID_SOCKET && tcpq == NULL) return; /* Echo not set up, don't bother */ for (i = 0; i < fd_recv.fd_count; i++) { #ifdef USE_FDS tmpsock = FD_GET(i, &fd_recv); if (tmpsock == INVALID_SOCKET) continue; #else tmpsock = fd_recv.fd_array[i]; #endif /* USE_FDS */ /* Find out the client connection corresponding to this socket */ tmpclient = tcp_client_from_sock(tmpsock); /* try a receive. Pick buffer according to client or server */ if (tmpclient) /* found a client for this one */ len = recv(tmpsock, tmpclient->inbuf, ECHOBUFSIZE, 0); #ifndef TCP_ZEROCOPY else if (tmpsock == esvr_sock) len = recv(tmpsock, srv_inbuf, ECHOBUFSIZE, 0); #endif /* TCP_ZEROCOPY */ else { continue; } if (len < 0) { e = t_errno(tmpsock); if (e != EWOULDBLOCK) { if (tmpsock != esvr_sock) ns_printf(tmpclient->pio,"TCP echo recv error %d\n", e); else ns_printf(NULL,"TCP echo recv error %d\n", e); } } else if (len == 0) { ns_printf(NULL,"TCPECHO:socket closed by other side\n"); if (tmpsock == esvr_sock) { socketclose (tmpsock); esvr_sock = INVALID_SOCKET; } else { if (tmpclient == NULL) { dtrap(); } else { tmpclient->sock = INVALID_SOCKET ; tcp_client_del(tmpclient); } } } else /* if (len > 0) - got some echo data */ { #ifndef TCP_ZEROCOPY if (tmpsock == esvr_sock) { /* we must be server, send echo reply */ if (tcpecho_server) { e = send(esvr_sock, srv_inbuf, len, 0); if (e < 0) { /* Print the error to console */ e = t_errno(esvr_sock); ns_printf(NULL, "TCP echo server, error %d sending reply\n", e); } } } else /* not the server socket, must be client */ #endif /* TCP_ZEROCOPY */ { /* If not a bulk test, print info */ if (tmpclient->len <= ECHOBUFSIZE) { ns_printf(tmpclient->pio,"TCP echo reply from:%s, len:%d, reply:%lu", print_ipad(tmpclient->rhost), len, tmpclient->replies); ns_printf(tmpclient->pio,"\n%s",prompt); } else { u_long dataval; u_long * rxbuf = (u_long*)(tmpclient->inbuf); u_long * rxend = (u_long*)(tmpclient->inbuf + (len & ~3)); dataval = tmpclient->tot_rcvd/4; /* adjust for odd sized previous receives */ if (tmpclient->tot_rcvd & 3) { MEMMOVE(rxbuf, tmpclient->inbuf + (len & 3), len); rxend--; dataval++; /* ignore sliced word */ } while (rxbuf < rxend) { if (*rxbuf != dataval) { ns_printf(tmpclient->pio, "tcp_echo data error; got %lu, expected %lu\n", *rxbuf, dataval); } rxbuf++; dataval++; } } tmpclient->replies++; tmpclient->tot_rcvd += len; } } } /* if no server listen to poll, return now */ if (elisten_sock == INVALID_SOCKET) return; #ifdef NOTDEF MEMSET(&client, 0, sizeof(client)); client.sin_family = AF_INET; client.sin_addr.s_addr = INADDR_ANY; client.sin_port = htons(ECHO_PORT); #endif /* check for received echo connection on server */ len = sizeof(client); tmpsock = accept(elisten_sock, (struct sockaddr*)&client, &len); if (tmpsock != INVALID_SOCKET) { if (esvr_sock == INVALID_SOCKET) { esvr_sock = tmpsock; #ifdef TCP_ZEROCOPY t_setsockopt(esvr_sock, SOL_SOCKET, SO_CALLBACK, (void*)echo_svr_upcall, 0); #endif /* TCP_ZEROCOPY */ } else /* we already have a connection */ { dprintf("tcpecho: rejected extra connection\n"); socketclose(tmpsock); /* refuse to serve another */ } } }
struct dvb_frontend* dvb_d6158earda_attach(struct i2c_adapter* i2c, UINT8 system) { struct dvb_d6158_fe_ofdm_state* state = NULL; struct nim_panic6158_private *priv; int ret; struct COFDM_TUNER_CONFIG_API Tuner_API; /* allocate memory for the internal state */ state = kzalloc(sizeof(struct dvb_d6158_fe_ofdm_state), GFP_KERNEL); if (state == NULL) goto error; priv = (PNIM_PANIC6158_PRIVATE)YWOS_Malloc(sizeof(struct nim_panic6158_private)); if (NULL == priv) { goto error; } MEMSET(priv, 0, sizeof(struct nim_panic6158_private)); /* create dvb_frontend */ if (system == DEMO_BANK_T2) //dvb-t { printk("DEMO_BANK_T2\n"); memcpy(&state->frontend.ops, &dvb_d6158_fe_ofdm_ops, sizeof(struct dvb_frontend_ops)); } else if (system == DEMO_BANK_C) //dvb-c { printk("DEMO_BANK_C\n"); memcpy(&state->frontend.ops, &dvb_d6158_fe_qam_ops, sizeof(struct dvb_frontend_ops)); } printf("[%s]%d\n", __FUNCTION__, __LINE__); state->frontend.ops.set_frontend = d6158earda_set_frontend; state->frontend.demodulator_priv = state; state->i2c = i2c; state->DeviceMap.Timeout = IOREG_DEFAULT_TIMEOUT; state->DeviceMap.Registers = STV0367ofdm_NBREGS; state->DeviceMap.Fields = STV0367ofdm_NBFIELDS; state->DeviceMap.Mode = IOREG_MODE_SUBADR_16; state->DeviceMap.RegExtClk = 27000000; //Demod External Crystal_HZ state->DeviceMap.RegMap = (TUNER_IOREG_Register_t *) kzalloc(state->DeviceMap.Registers * sizeof(TUNER_IOREG_Register_t), GFP_KERNEL); state->DeviceMap.priv = (void *)state; state->spark_nimdev.priv = priv; state->spark_nimdev.base_addr = PANIC6158_T2_ADDR; //state->spark_nimdev.i2c_type_id= pConfig->ext_dm_config.i2c_type_id; //state->spark_nimdev.nim_idx = pConfig->ext_dm_config.nim_idx;//distinguish left or right priv->i2c_adap = i2c; priv->i2c_addr[0] = PANIC6158_T_ADDR; priv->i2c_addr[1] = PANIC6158_T2_ADDR; priv->i2c_addr[2] = PANIC6158_C_ADDR; priv->if_freq = DMD_E_IF_5000KHZ; priv->flag_id = OSAL_INVALID_ID; priv->i2c_mutex_id = OSAL_INVALID_ID; priv->system = system; //T2 C priv->tuner_id = 2; YWOS_TaskSleep(50); nim_config_EARDATEK11658(&Tuner_API, 0, 0); Tuner_API.tuner_config.i2c_adap = (IOARCH_Handle_t*)i2c; MEMCPY((void*) & (priv->tc), (void*)&Tuner_API, sizeof(struct COFDM_TUNER_CONFIG_API)); printf("[%s]%d\n", __FUNCTION__, __LINE__); if (NULL != Tuner_API.nim_Tuner_Init) { if (SUCCESS == Tuner_API.nim_Tuner_Init(&priv->tuner_id, &Tuner_API.tuner_config)) { printf("[%s]%d\n", __FUNCTION__, __LINE__); DEM_WRITE_READ_TUNER ThroughMode; priv->tc.nim_Tuner_Init = Tuner_API.nim_Tuner_Init; priv->tc.nim_Tuner_Control = Tuner_API.nim_Tuner_Control; priv->tc.nim_Tuner_Status = Tuner_API.nim_Tuner_Status; YWLIB_Memcpy(&priv->tc.tuner_config, &Tuner_API.tuner_config, sizeof(struct COFDM_TUNER_CONFIG_EXT)); ThroughMode.nim_dev_priv = state->spark_nimdev.priv; printf("[%s]%d\n", __FUNCTION__, __LINE__); ThroughMode.Dem_Write_Read_Tuner = DMD_TCB_WriteRead;/////////////////////////////////// nim_panic6158_ioctl_earda(&state->spark_nimdev, NIM_TUNER_SET_THROUGH_MODE, (UINT32)&ThroughMode); printf("[%s]%d\n", __FUNCTION__, __LINE__); } } printf("[%s]%d\n", __FUNCTION__, __LINE__); state->spark_nimdev.get_lock = nim_panic6158_get_lock; state->spark_nimdev.get_AGC = nim_panic6158_get_AGC_603; ret = nim_panic6158_open(&state->spark_nimdev); printk("[%s]%d,open result=%d \n", __FUNCTION__, __LINE__, ret); /* Setup init work mode */ return &state->frontend; error: kfree(state); return NULL; }