//初始化中断相关变量 void Init_Interr_Sram(void) { mem_set((void *)(&Key_Value_Pub),0,sizeof(Key_Value_Pub),\ (void *)(&Key_Value_Pub),sizeof(Key_Value_Pub)); INIT_STRUCT_VAR(Key_Value_Pub); mem_set((void *)(&Irda_Wake_Ctrl),0,sizeof(Irda_Wake_Ctrl),\ (void *)(&Irda_Wake_Ctrl),sizeof(Irda_Wake_Ctrl)); INIT_STRUCT_VAR(Irda_Wake_Ctrl); #ifdef REMOTER_FUNC_EN mem_set((void *)(&Irda_Decode_Ctrl),0,sizeof(Irda_Decode_Ctrl),\ (void *)(&Irda_Decode_Ctrl),sizeof(Irda_Decode_Ctrl)); INIT_STRUCT_VAR(Irda_Decode_Ctrl); #endif mem_set((void *)(&Pulse_Num_Temp),0,sizeof(Pulse_Num_Temp),\ (void *)(&Pulse_Num_Temp),sizeof(Pulse_Num_Temp)); INIT_STRUCT_VAR(Pulse_Num_Temp); Irda_WkUP_Ms_Timr=Ms_Timer_Pub; Key_WkUP_Ms_Timr=Ms_Timer_Pub; mem_set((void *)(&Curr_Media_Status),0,sizeof(Curr_Media_Status),\ (void *)(&Curr_Media_Status),sizeof(Curr_Media_Status)); SET_STRUCT_SUM(Curr_Media_Status); }
void initialize_private_mib(void) { TROUT_FUNC_ENTER; mem_set(&P_MIB, 0, sizeof(p_mib_t)); mem_set(P_MIB.bssid, 0, 6); mem_set(P_MIB.bcst_addr, 0xFF, 6); P_MIB.auth_type = (UWORD8)OPEN_SYSTEM; P_MIB.scan_type = ACTIVE_SCAN; P_MIB.listen_interval = 3; P_MIB.chan_mgmt_enable = TV_FALSE; P_MIB.chan_switch_cnt = MAX(2 * mget_DTIMPeriod(), WIFI_MIN_CH_SWITCH_CNT); P_MIB.chan_switch_mode = 1; #ifdef MAC_802_11H if(get_current_start_freq() == RC_START_FREQ_5) P_MIB.chan_mgmt_enable = TV_TRUE; #endif /* MAC_802_11H */ //chenq add for wapi 2012-09-19 #ifdef MAC_WAPI_SUPP memset(&P_WAPI_MIB,0x00,sizeof(p_wapi_mib_t)); P_WAPI_MIB.wapi_enable = TV_FALSE; P_WAPI_MIB.wapi_key_ok = TV_FALSE; #endif }
void cavan_sha_finish(struct cavan_sha_context *context, u8 *digest) { u64 bits = context->count << 3; cavan_sha_update(context, "\x80", 1); if (context->remain > sizeof(context->buff) - sizeof(bits)) { mem_set(context->buff + context->remain, 0, sizeof(context->buff) - context->remain); context->transform(context->digest, context->dwbuff); mem_set(context->buff, 0, context->remain); } else { mem_set(context->buff + context->remain, 0, sizeof(context->buff) - context->remain - sizeof(bits)); } if (context->flags & SHA_FLAG_SWAP) { mem_copy_invert8(context->buff + sizeof(context->buff) - sizeof(bits), (void *) &bits, sizeof(bits)); } else { mem_copy(context->buff + sizeof(context->buff) - sizeof(bits), (void *) &bits, sizeof(bits)); } context->transform(context->digest, context->dwbuff); if (context->flags & SHA_FLAG_SWAP) { mem_swap32((u32 *) digest, context->digest, context->digest_size >> 2); } else {
//从ROM中读出当前需量数据 void Read_Demand_Data_From_Rom() { INT8U Err,Re,Rate,i; S_Demand *p; //先读取掉电存储区数据 //再读普通数据 //最后读备份区数据 Re=CHECK_STRUCT_SUM(Cur_Rate_Info); if(ASSERT(A_WARNING,0!=Re)) Check_Data_Avail(); OS_Sem_Pend(PUB_BUF0_SEM_ID); p=(S_Demand *)Pub_Buf0; if(Read_Storage_Data(CUR_DEMAND_PD,p,p,sizeof(Pub_Buf0),&Err)!=sizeof(Cur_Demand) ||\ Check_Demand_Data((S_Demand *)p)==0) { DEBUG_PRINT(HUCK,DEBUG_0,"Read CUR_DEMAND_PD data error"); OS_TimeDly_Ms(500); //读取总和当前费率需量 for(i=0;i<2;i++) { if(i==0) Rate=0;//读总需量时偏移为0 else Rate=Cur_Rate_Info.Rate;//非总时根据费率计算偏移 p->Rate=Cur_Rate_Info.Rate; //从当前数据区读取当前和总费率的需量数据 if(Read_Demand_Rate_Data(Rate,(void *)&p->Demand[i],(void *)&p->Demand[i],sizeof(S_One_Demand))!=ONE_DEMAND_SAVE_SIZE) { DEBUG_PRINT(HUCK,DEBUG_0,"Read CUR_DEMAND Rate %d data error",Rate); mem_set((void *)&p->Demand[i],0,sizeof(p->Demand[i]),(void *)&p->Demand[i],sizeof(p->Demand[i])); } } } if(Check_Demand_Data((S_Demand *)p)==0) { ASSERT(A_WARNING,0); mem_set(p,0,sizeof(Cur_Demand),p,sizeof(Pub_Buf0)); } DIS_PD_INT;//更新Cur_Demand数据前关掉电中断 mem_cpy((void *)&Cur_Demand,p,sizeof(Cur_Demand),(void *)&Cur_Demand,sizeof(Cur_Demand)); INIT_STRUCT_VAR(Cur_Demand); SET_DATA_READY_FLAG(Cur_Demand); SET_STRUCT_SUM(Cur_Demand); EN_PD_INT; OS_Sem_Post(PUB_BUF0_SEM_ID); //SET_STRUCT_SUM(Cur_Demand); //更新当前存储区和备份存储区,补冻函数可能要用到这两个区,因此要保证这两个区的数据更新 Save_Cur_Demand_Data(); Save_Cur_Demand_Bak_Data(); }
// 事件处理函数 //注意:该函数调用Read_Event_Status查询某个事件状态时,是该事件发生前的状态 //例如 某事件发生,调用该函数处理,则该函数内调用Read_Event_Status时返回0 // 相反,某事件结束,调用该函数处理,则该函数内调用Read_Event_Status时返回1 void Event_Data_Proc(INT8U Event_ID,INT8U Occur_Or_End) { INT8U Total_Event_ID; INT8U Clr_Demand_Man_Flag; INT8U Op_ID[4],Op_ID1[4]; _Debug_Print("\r\n++++++++++Event Data Proc,ID:%d,%s++++++++++",Event_ID,(Occur_Or_End EQ EVENT_OCCUR)?"Occur":"End"); Clr_Demand_Man_Flag = 0; if(Event_ID EQ ID_EVENT_CLR_DEMAND_MAN)//手动清需量转为通信清需量,同一事件ID处理,但是手动清需量的操作者ID为全FF { Clr_Demand_Man_Flag = 1; Event_ID = ID_EVENT_CLR_DEMAND_COM; //当前操作者id先备份 mem_set(Op_ID1, 0xFF, sizeof(Op_ID1), Op_ID1, sizeof(Op_ID1)); Store_Op_ID(Op_ID1, Op_ID, Op_ID, sizeof(Op_ID)); } else if(Event_ID EQ ID_EVENT_RELAY_ON || Event_ID EQ ID_EVENT_RELAY_OFF) //拉合闸,本地拉合闸记录操作者代码为FF { if(Relay_Status.Switch_Cause EQ S_OFF_PREPAID) //本地拉闸需要置操作者代码为全FF { mem_set(Op_ID1, 0xFF, sizeof(Op_ID1), Op_ID1, sizeof(Op_ID1)); Store_Op_ID(Op_ID1, Op_ID, Op_ID, sizeof(Op_ID)); } else //远程拉闸需要采用其操作者代码 { Store_Op_ID((INT8U *)Event_Data.Relay_Status.Op_ID, Op_ID, Op_ID, sizeof(Op_ID)); } } Event_Cumu_Proc(Event_ID,Occur_Or_End,EVENT_REAL); Total_Event_ID = Get_Total_Event_ID(Event_ID);//本事件对应的总计数也要处理 if(Total_Event_ID != NULL_EVENT_ID) { Debug_Print("Total Event Proc"); Event_Cumu_Proc(Total_Event_ID,Occur_Or_End,EVENT_REAL); } Event_Separate_Proc(Event_ID,Occur_Or_End,EVENT_REAL); //恢复操作者ID if(Clr_Demand_Man_Flag EQ 1) { Restore_Op_ID(Op_ID); } else if(Event_ID EQ ID_EVENT_RELAY_ON || Event_ID EQ ID_EVENT_RELAY_OFF) { Restore_Op_ID(Op_ID); } Debug_Print("++++++++++Event Data Proc:End++++++++++\r\n"); OS_TimeDly_Ms(10); //延迟10ms }
void Test_Memory(void) { INT8U j,Flag,RandBuf[TEST_BUF_LEN]; INT16U i; INT32U timr; static INT16U RdErr[MAX_MEM_NUM],WrErr[MAX_MEM_NUM],CompareErr[MAX_MEM_NUM]; mem_set(Drv_Test_Buf+ID_TEST_EXT_U10,0x01,MAX_MEM_NUM,Drv_Test_Buf+ID_TEST_EXT_U10,MAX_MEM_NUM); Temp_Timer_Bak=Ms_Timer_Pub; //用来查看花费的时间 for(i=0;i<EPPROM_TEST_NUM;i++) { mem_set(RandBuf,0x55+i,sizeof(RandBuf),RandBuf,sizeof(RandBuf)); for(j=ID_TEST_EXT_U10;j<=ID_MEM_IIC_U15;j++) { Flag=!Write_EEPROM_Dvice_PUCK(j,TEST_ADDR[j],TEST_BUF_LEN,RandBuf); WrErr[j]+=Flag; mem_set(Test_Temp_Buf,0x33,sizeof(Test_Temp_Buf),Test_Temp_Buf,sizeof(Test_Temp_Buf)); Flag=!Read_EEPROM_Dvice_PUCK(j,TEST_ADDR[j],TEST_BUF_LEN,Test_Temp_Buf); RdErr[j]+=Flag; if((memcmp(Test_Temp_Buf,RandBuf,TEST_BUF_LEN)!=0)||(Test_Temp_Buf[TEST_BUF_LEN]!=0x33))//比较相等,但底层不能多写造成越界! CompareErr[j]++; if(RdErr[j]|WrErr[j]|CompareErr[j]) //有其中一个错误发生,置标志失败标志 Drv_Test_Buf[j]=0; } Flag=!flash_writ_abs(TEST_FLASH_ADDR,RandBuf,TEST_BUF_LEN); WrErr[j]+=Flag; mem_set(Test_Temp_Buf,0x33,sizeof(Test_Temp_Buf),Test_Temp_Buf,sizeof(Test_Temp_Buf)); Flag=!flash_read_abs(TEST_FLASH_ADDR,Test_Temp_Buf,TEST_BUF_LEN); RdErr[j]+=Flag; if((memcmp(Test_Temp_Buf,RandBuf,TEST_BUF_LEN)!=0)||(Test_Temp_Buf[TEST_BUF_LEN]!=0x33))//比较相等,但底层不能多写造成越界!//比较 CompareErr[j]++; if(RdErr[ID_TEST_EXT_U8]|WrErr[ID_TEST_EXT_U8]|CompareErr[ID_TEST_EXT_U8]) //有其中一个错误发生,置标志失败 Drv_Test_Buf[ID_TEST_EXT_U8]=0; } timr=Ms_Timer_Pub-Temp_Timer_Bak; DEBUG_PRINT(PUCK,PRINT_PUCK_MEA_EN,"|-----------------------Test Memory-----------------------------------|"); DEBUG_PRINT(PUCK,PRINT_PUCK_MEA_EN,"| Total_Times Read_Err Write_Err Compare_Err Result |"); for(j=ID_TEST_EXT_U10;j<=ID_TEST_EXT_U8;j++) DEBUG_PRINT(PUCK,PRINT_PUCK_MEA_EN,"|%s %3d %3d %3d %3d %s |",\ Const_Drv_Test[j],EPPROM_TEST_NUM,RdErr[j],WrErr[j],CompareErr[j],TEST_INFO[Drv_Test_Buf[j]]); DEBUG_PRINT(PUCK,PRINT_PUCK_MEA_EN,"| All Run Time=%9ldMS |",timr); DEBUG_PRINT(PUCK,PRINT_PUCK_MEA_EN,"|---------------------------------------------------------------------|"); }
static void mem_write_auto(int idx) { switch(codefreakdec(mem_gv.mem_table[idx].addr) >> 28) { case 1: //1xxxxxxx mem_set(codefreakdec(mem_gv.mem_table[idx].addr) & 0xFFFFFFF, (unsigned int)&mem_gv.mem_table[idx].value, 2); break; case 2: //2xxxxxxx mem_set(codefreakdec(mem_gv.mem_table[idx].addr) & 0xFFFFFFF, (unsigned int)&mem_gv.mem_table[idx].value, 4); break; default: //0xxxxxxx switch(mem_gv.mem_table[idx].type) { case 1: mem_set(codefreakdec(mem_gv.mem_table[idx].addr), (unsigned int)&mem_gv.mem_table[idx].value, 1); break; case 2: mem_set(codefreakdec(mem_gv.mem_table[idx].addr), (unsigned int)&mem_gv.mem_table[idx].value, 2); break; case 3: mem_set(codefreakdec(mem_gv.mem_table[idx].addr), (unsigned int)&mem_gv.mem_table[idx].value, 4); break; default: if(mem_gv.mem_table[idx].value < 0x100) mem_set(codefreakdec(mem_gv.mem_table[idx].addr), (unsigned int)&mem_gv.mem_table[idx].value, 1); else if(codefreakdec(mem_gv.mem_table[idx].addr) < 0x10000) mem_set(codefreakdec(mem_gv.mem_table[idx].addr), (unsigned int)&mem_gv.mem_table[idx].value, 2); else mem_set(codefreakdec(mem_gv.mem_table[idx].addr), (unsigned int)&mem_gv.mem_table[idx].value, 4); break; } break; } }
static Handle vbv_init(void) { int i; u8* vbv_buf; vbv_t* vbv; vbv = (vbv_t*)mem_alloc(sizeof(vbv_t)); if (vbv) { mem_set(vbv, 0, sizeof(vbv_t)); vbv->frame_fifo.in_frames = (stream_frame_t*)mem_alloc(VBV_MAX_FRAME_NUM * sizeof(stream_frame_t)); if (!vbv->frame_fifo.in_frames) { mem_free(vbv); return NULL; } mem_set(vbv->frame_fifo.in_frames, 0, VBV_MAX_FRAME_NUM * sizeof(stream_frame_t)); for(i = 0; i < VBV_MAX_FRAME_NUM; i++) { vbv->frame_fifo.in_frames[i].vstream.id = i; } vbv_buf = (u8*)mem_palloc(VBV_FRAME_SIZE, 1024); if (!vbv_buf) { mem_free(vbv); mem_free(vbv->frame_fifo.in_frames); return NULL; } vbv->vbv_buf = vbv_buf; vbv->vbv_buf_end = vbv_buf + VBV_FRAME_SIZE; vbv->max_size = VBV_FRAME_SIZE; vbv->write_addr = vbv_buf; vbv->valid_size = 0; vbv->frame_fifo.frame_num = 0; vbv->frame_fifo.write_index = 0; vbv->frame_fifo.max_frame_num = VBV_MAX_FRAME_NUM; vbv->frame_queue.frame_num = 0; vbv->frame_queue.head = NULL; pthread_mutex_init(&vbv->mutex, NULL); return (Handle)vbv; } return NULL; }
/********************************************************************************** 函数功能:填满整屏 入口: 无 出口: 无 **********************************************************************************/ void FillAllScreen(void) { mem_set(Show_Lcd_Ram,0xff,sizeof(Show_Lcd_Ram),Show_Lcd_Ram,sizeof(Show_Lcd_Ram)); Show_Lcd_Flag=1; UpdataLcdShow(); //OS_TimeDly_Ms(150);//500ms睡眠 }
/********************************************************************************** LCD显示每屏结果 **********************************************************************************/ void Dis_Per_Item(INT8U Item) { INT8U i; if(Item>=MAX_ID_TEST_NUM) return ; if(Drv_Test_Buf[Item]>1) return ; mem_set(Temp_Buf_PUCK,0x00,sizeof(Temp_Buf_PUCK),Temp_Buf_PUCK,sizeof(Temp_Buf_PUCK)); strcpy((char *)Temp_Buf_PUCK,(char*)Const_Drv_Test[Item]); if(Drv_Test_Buf[Item]==0) strcpy((char *)Temp_Buf_PUCK+5,"Error"); else strcpy((char *)Temp_Buf_PUCK+5," 6ood"); for(i=3;i<=12;i++) SetOnLED8Device_PUCK(N_LED(i),Temp_Buf_PUCK[i-3]); SetOnLED8Device_PUCK(N_LED(20),Item/10+'0'); SetOnLED8Device_PUCK(N_LED(21),Item%10+'0'); UpdataLcdShow(); }
//需量检查当前费率是否发生了变化,如果变化了,则读出当前费率的最大需量值 void Demand_Check_Rate_Change() { INT8U Re; Re=1; Re=CHECK_STRUCT_SUM(Cur_Rate_Info); Re=CHECK_STRUCT_SUM(Cur_Demand); if(ASSERT(A_WARNING,1==Re)) Check_Data_Avail(); if(Cur_Rate_Info.Rate!=Cur_Demand.Rate)//费率已经发生变化了 { DEBUG_PRINT(HUCK,DEBUG_0,"Rate_Changed!Save Old Rate Demand && Read New Rate Demand"); Save_Cur_Demand_Data();//先将Cur_Demand数据保存起来 Save_Cur_Demand_Bak_Data(); //重新根据当前费率读取需量数据 Cur_Demand.Rate=Cur_Rate_Info.Rate; //读出该分费率数据 if(Read_Demand_Rate_Data(Cur_Demand.Rate,(void *)&Cur_Demand.Demand[1],(void *)&Cur_Demand.Demand[1],sizeof(S_One_Demand))!=ONE_DEMAND_SAVE_SIZE) { mem_set((void *)&Cur_Demand.Demand[1],0,sizeof(Cur_Demand.Demand[1]),(void *)&Cur_Demand.Demand[1],sizeof(Cur_Demand.Demand[1])); SET_STRUCT_SUM(Cur_Demand.Demand[1]); } SET_STRUCT_SUM(Cur_Demand); Save_Cur_Demand_PD_Data();//更新掉电存储区的需量数据 } }
cedarv_decoder_t* libcedarv_init(s32* return_value) { video_decoder_t* p; *return_value = CEDARV_RESULT_ERR_FAIL; p = (video_decoder_t*)mem_alloc(sizeof(video_decoder_t)); if (p == NULL) { *return_value = CEDARV_RESULT_ERR_NO_MEMORY; return NULL; } mem_set(p, 0, sizeof(video_decoder_t)); p->icedarv.open = vdecoder_open; p->icedarv.close = vdecoder_close; p->icedarv.decode = vdecoder_decode; p->icedarv.ioctrl = vdecoder_io_ctrl; p->icedarv.request_write = vdecoder_request_write; p->icedarv.update_data = vdecoder_update_data; p->icedarv.display_request = vdeocder_display_request; p->icedarv.display_release = vdecoder_display_release; p->icedarv.set_vstream_info = vdecoder_set_video_bitstream_info; p->icedarv.query_quality = vdecoder_query_quality; p->config_info.max_video_width = MAX_SUPPORTED_VIDEO_WIDTH; p->config_info.max_video_height = MAX_SUPPORTED_VIDEO_HEIGHT; cedardev_init(); ve_init_clock(); *return_value = CEDARV_RESULT_OK; return (cedarv_decoder_t*)p; }
cedarx_result_e libcedarx_display_open(void) { cedarx_display_t* display; if (!cedarx_decoder) return CEDARX_RESULT_NO_INIT; display = (cedarx_display_t*)mem_alloc(sizeof(cedarx_display_t)); if (!display) return CEDARX_RESULT_NO_ENOUGH_MEMORY; mem_set(display, 0, sizeof(cedarx_display_t)); cedarx_display = display; display->fd = open("/dev/disp", O_RDWR); if (display->fd == -1) { free(display); cedarx_display = NULL; return CEDARX_RESULT_DE_FAILED; } display->info.layer = -1; pthread_mutex_init(&display->mutex, NULL); return CEDARX_RESULT_OK; }
int cavan_font_init(struct cavan_font *font) { byte *body; if (font->body) { return 0; } body = malloc(font->width * font->height); if (body == NULL) { pr_error_info("malloc"); return -ENOMEM; } font->body = body; font->stride = font->width * font->cheight; if (font->rundata && font->rundata_size > 0) { const byte *rundata, *rundata_end; for (rundata = font->rundata, rundata_end = rundata + font->rundata_size; rundata < rundata_end; rundata++) { int count = (*rundata) & 0x7F; mem_set(body, ((*rundata) & (1 << 7)) ? 0xFF : 0, count); body += count; } } return 0; }
static FRESULT create_name ( DIR *dj, /* Pointer to the directory object */ const char **path /* Pointer to pointer to the segment in the path string */ ) { BYTE c, ni, si, i, *sfn; const char *p; /* Create file name in directory form */ sfn = dj->fn; mem_set(sfn, ' ', 11); si = i = 0; ni = 8; p = *path; for (;;) { c = p[si++]; if (c < ' ' || c == '/') break; /* Break on end of segment */ if (c == '.' || i >= ni) { if (ni != 8 || c != '.') return FR_INVALID_NAME; i = 8; ni = 11; continue; } if (c >= 0x7F || chk_chr(" +,;[=\\]\"*:<>\?|", c)) /* Reject unallowable chrs for SFN */ return FR_INVALID_NAME; if (c >='a' && c <= 'z') c -= 0x20; sfn[i++] = c; } if (!i) return FR_INVALID_NAME; /* Reject null string */ *path = &p[si]; /* Rerurn pointer to the next segment */ sfn[11] = (c < ' ') ? 1 : 0; /* Set last segment flag if end of path */ return FR_OK; }
/********************************************************************************** 测试EPPROM **********************************************************************************/ void Test_Epprom_Err(void) { INT8U Err; mem_set(Temp_Buf_PUCK,0xa5,sizeof(Temp_Buf_PUCK),Temp_Buf_PUCK,sizeof(Temp_Buf_PUCK)); I2cReset(); Read_Storage_Data(0x10003,Temp_Buf_PUCK,Temp_Buf_PUCK,180,&Err); }
void initialize_wmm(void) { mem_set(g_wmm_capability, 0, MAX_STA_SUPPORTED); init_qif_table(); //destroy_mac_qmu(&g_q_handle); //masked by chengwg, 2013-01-15. //init_mac_qmu(); //masked by chengwg, 2013-01-15. }
void math_memory_shift_left_byte(const byte *mem, size_t mem_size, size_t shift, byte *res, size_t res_size) { if (res == NULL) { res = (byte *) mem; } if (res_size == 0) { res_size = mem_size; } if (shift < mem_size && shift < res_size) { math_memory_copy(res + shift, res_size - shift, mem, mem_size - shift); mem_set(res, 0, shift); } else { mem_set(res, 0, res_size); } }
int main() { int num = 0x4D; mem_set(&num, 42, sizeof(num)); printf("num = %d\n length = %lu\n",num,sizeof(num)); //name_print(my_name); return 0; }
void modem_init (void) { /* Initializes the modem variables and control signals DTR & RTS. */ mlen = 0; mem_set (mbuf, 0, sizeof(mbuf)); wait_for = 0; wait_conn = 0; modem_st = MODEM_IDLE; }
/********************************************************************************** 函数功能:初始化显示RAM 入口: 无 出口: 无 **********************************************************************************/ void InitLcdAllRam(void) { //mem_set(Show_Lcd_Ram,0x00,MAX_SEG+1,Show_Lcd_Ram,MAX_SEG+1); //mem_set(Show_Lcd_Ram,0x00,sizeof(Show_Lcd_Ram),Show_Lcd_Ram,sizeof(Show_Lcd_Ram)); //mem_set(void *pDst, INT8U Value,INT32U SetLen,void *pDst_Start,INT32U Dst_Len) mem_set(Show_Lcd_Ram,0x00,sizeof(Show_Lcd_Ram),Show_Lcd_Ram,sizeof(Show_Lcd_Ram)); }
//设置默认的需量数据 void Set_Def_Cur_Demand_Data() { INT8U i,Re; INT32U Off; //将初始需量写入存储器中 DEBUG_PRINT(HUCK,DEBUG_0,"Set Def Demand Data"); mem_set((void *)&Cur_Demand,0,sizeof(Cur_Demand),(void *)&Cur_Demand,sizeof(Cur_Demand)); SET_STRUCT_SUM(Cur_Demand.Demand[0]); SET_STRUCT_SUM(Cur_Demand.Demand[1]); INIT_STRUCT_VAR(Cur_Demand); SET_DATA_READY_FLAG(Cur_Demand); SET_STRUCT_SUM(Cur_Demand); //将各个费率的需量数据清0 for(i=0;i<=MAX_RATES;i++) { Cur_Demand.Rate=i; SET_STRUCT_SUM(Cur_Demand); Off=DEMAND_RATE_OFF(Cur_Demand.Rate); Re=Write_Storage_Data_Fix_Len(CUR_DEMAND,Off,(void *)&Cur_Demand.Demand[0],ONE_DEMAND_SAVE_SIZE); ASSERT(A_WARNING,NO_ERR==Re); Off=DEMAND_RATE_OFF(Cur_Demand.Rate); Re=Write_Storage_Data_Fix_Len(CUR_DEMAND_BAK,Off,(void *)&Cur_Demand.Demand[0],ONE_DEMAND_SAVE_SIZE); ASSERT(A_WARNING,NO_ERR==Re); } mem_set((void *)&Cur_Demand,0,sizeof(Cur_Demand),(void *)&Cur_Demand,sizeof(Cur_Demand)); Cur_Demand.Rate=0; SET_STRUCT_SUM(Cur_Demand.Demand[0]); SET_STRUCT_SUM(Cur_Demand.Demand[1]); INIT_STRUCT_VAR(Cur_Demand); SET_DATA_READY_FLAG(Cur_Demand); SET_STRUCT_SUM(Cur_Demand); mem_set((void *)&Demand_Accu,0,sizeof(Demand_Accu),(void *)&Demand_Accu,sizeof(Demand_Accu));//清中间累加单元 SET_STRUCT_SUM(Demand_Accu); Save_Cur_Demand_PD_Data(); }
//需量清0,入口参数pTime表示清除的时间点,一般是当前时间 //清需量后要根据该时间点计算下次需量数据冻结的时间 void Demand_Clear(S_HEX_Time *pTime) { //Demand_Accu_Clear();//清累加,跨月的情况下一定要清累加? mem_set((void *)&Cur_Demand,0,sizeof(Cur_Demand),(void *)&Cur_Demand,sizeof(Cur_Demand));//清需量 SET_STRUCT_SUM(Cur_Demand.Demand[0]); SET_STRUCT_SUM(Cur_Demand.Demand[1]); SET_STRUCT_SUM(Cur_Demand); }
void math_memory_copy(byte *dest, size_t dest_size, const byte *src, size_t src_size) { size_t size = MIN(dest_size, src_size); mem_move(dest, src, size); if (dest_size > size) { mem_set(dest + size, 0, dest_size - size); } }
void mnew_RSNAStats(UWORD8 index) { /* Reset all the counters and RNSA information */ mem_set(&(MIB_11I.dot11RSNAStatsEntry[index]), 0, sizeof(dot11RSNAStatsEntry_t)); /* Set the index of the Entry and the version number for the RSNA */ MIB_11I.dot11RSNAStatsEntry[index].dot11RSNAStatsIndex = index; MIB_11I.dot11RSNAStatsEntry[index].dot11RSNAStatsVersion = MIB_11I. dot11RSNAConfigVersion; }
/* ======================================= 像素填充 ======================================= */ CR_API void_t line_fill ( __CR_IN__ uint_t line, __CR_IN__ byte_t c ) { /* 颜色扩展到1个字节 */ c &= 3; c |= (c << 2); c |= (c << 4); /* 填充整个屏幕 */ if (line >= SCREEN_LINE) { mem_set(s_backs, c, SCREEN_SIZE); return; } /* 只填充一行 */ line *= (SCREEN_BPL * 16); mem_set(&s_backs[line], c, SCREEN_BPL * 16); }
/********************************************************************************** 函数功能:更新显示屏 入口: Flag----1:表示初始化;0:表示进入主程序调用 出口: 无 **********************************************************************************/ void UpdataLcdShow(void) { if(Show_Lcd_Flag) { //mem_set(Show_Lcd_Ram,0xff,sizeof(Show_Lcd_Ram),Show_Lcd_Ram,sizeof(Show_Lcd_Ram)); //HTLCDWriteMultiData(0,Show_Lcd_Ram,sizeof(Show_Lcd_Ram)); //mem_set(Show_Lcd_Ram,0x0f,sizeof(Show_Lcd_Ram),Show_Lcd_Ram,sizeof(Show_Lcd_Ram)); HTLCDWriteMultiData(0,Show_Lcd_Ram,sizeof(Show_Lcd_Ram)); Show_Lcd_Flag=0; mem_set(Show_Lcd_Ram,0x00,sizeof(Show_Lcd_Ram),Show_Lcd_Ram,sizeof(Show_Lcd_Ram)); } }
static FRESULT create_name ( DIR *dj, /* Pointer to the directory object */ const char **path /* Pointer to pointer to the segment in the path string */ ) { BYTE c, ni, si, i, *sfn; const char *p; #if _USE_LCC #ifdef _EXCVT static const BYTE cvt[] = _EXCVT; #endif #endif /* Create file name in directory form */ sfn = dj->fn; mem_set(sfn, ' ', 11); si = i = 0; ni = 8; p = *path; for (;;) { c = p[si++]; if (c <= ' ' || c == '/') break; /* Break on end of segment */ if (c == '.' || i >= ni) { if (ni != 8 || c != '.') break; i = 8; ni = 11; continue; } #if _USE_LCC #ifdef _EXCVT if (c >= 0x80) /* To upper extended char (SBCS) */ c = cvt[c - 0x80]; #endif if (IsDBCS1(c) && i < ni - 1) { /* DBC 1st byte? */ BYTE d = p[si++]; /* Get 2nd byte */ sfn[i++] = c; sfn[i++] = d; } else #endif { /* Single byte code */ if (_USE_LCC && IsLower(c)) c -= 0x20; /* toupper */ sfn[i++] = c; } } *path = &p[si]; /* Rerurn pointer to the next segment */ sfn[11] = (c <= ' ') ? 1 : 0; /* Set last segment flag if end of path */ return FR_OK; }
static Handle fbm_init(u32 max_frame_num, u32 min_frame_num, u32 size_y[2], u32 size_u[2], u32 size_v[2], u32 size_alpha[2], _3d_mode_e out_3d_mode, pixel_format_e format, void* parent) { s32 i; fbm_t* fbm; cedarx_decoder_t* decoder = cedarx_decoder; // libve_io_ctrl(LIBVE_COMMAND_GET_PARENT, (u32)&decoder, parent); // if (!decoder) // return NULL; fbm = (fbm_t*) mem_alloc(sizeof(fbm_t)); if(!fbm) return NULL; mem_set(fbm, 0, sizeof(fbm_t)); fbm->size_y[0] = size_y[0]; fbm->size_u[0] = size_u[0]; fbm->mode = out_3d_mode; if (fbm->mode == _3D_MODE_DOUBLE_STREAM) { fbm->size_y[1] = size_y[1]; fbm->size_u[1] = size_u[1]; } for(i = 0; i < FBM_MAX_FRAME_NUM; i++) { fbm->frames[i].status = FS_EMPTY; fbm->frames[i].vpicture.id = i; fbm->frames[i].vpicture._3d_mode = fbm->mode; fbm->frames[i].vpicture.size_y = fbm->size_y[0]; fbm->frames[i].vpicture.size_u = fbm->size_u[0]; fbm->frames[i].vpicture.size_v = fbm->size_v[0]; fbm->frames[i].vpicture.size_alpha = fbm->size_alpha[0]; fbm->frames[i].vpicture.size_y2 = fbm->size_y[1]; fbm->frames[i].vpicture.size_u2 = fbm->size_u[1]; fbm->frames[i].vpicture.size_v2 = fbm->size_v[1]; fbm->frames[i].vpicture.size_alpha2 = fbm->size_alpha[1]; if(i < max_frame_num) { fbm_enqueue_tail(&fbm->empty_queue, &fbm->frames[i]); fbm->init_frame_num ++; } } fbm->decoder = decoder; decoder->fbm = fbm; pthread_mutex_init(&fbm->mutex, NULL); return (Handle)fbm; }
void hello_world() { const int length = 10; int* a = 0; int* b = length * sizeof(int); int* res = 2*length * sizeof(int); int i; for(i=0; i<length; i++) a[i] = i; mem_set(b, length, 1); vector_add(res, a, b, length); }