__s32 ui_release_resource(__hdle show_hd) { ui_show_multi_set_t *pic_info = (ui_show_multi_set_t *)show_hd; __u32 i, j; __s32 *addr; if(!show_hd) { return -1; } De_CloseLayer(board_res.layer_hd); addr = (__s32 *)pic_info->lcd_info.display_buffer; for(i=0;i<pic_info->lcd_info.lcd_height;i++) { for(j=0;j<pic_info->lcd_info.lcd_width;j++) { *addr = 0xff000000; addr ++; } } wBoot_free(pic_info->layer_para); wBoot_free(pic_info); wBoot_timer_delay(50); return 0; }
/* ******************************************************************************* * ui_FreeLayerPara * * Description: * 释放一个图层参数 * * Parameters: * layer_para : input. 图层参数 * * Return value: * 0 : 成功 * !0 : 失败 * * note: * void * ******************************************************************************* */ __s32 ui_FreeLayerPara(display_layer_info_t *layer_para) { if(layer_para){ wBoot_free(layer_para); } return 0; }
//------------------------------------------------------------------------------------------------------------ // // 函数说明 // // // 参数说明 // // // 返回值 // // // 其他 // 无 // //------------------------------------------------------------------------------------------------------------ __s32 script_patch(char *script_name, void *script_buf, __s32 boot_script_type) { H_FILE script_file = NULL; int ret = -1; char *script_addr = NULL; int script_len; //打开脚本文件,打不开则失败 if(!script_name) { __wrn("the input script is empty\n"); return -1; } script_file = wBoot_fopen(script_name, "rb"); if(!script_file) { __wrn("unable to open script file %s\n", script_name); return -1; } //首先获取脚本的长度 script_len = wBoot_flen(script_file); //读出脚本所有的内容 script_addr = (char *)wBoot_malloc(script_len); if(!script_addr) { __wrn("unable to malloc memory for script\n"); goto _err_out; } wBoot_fread(script_addr, 1, script_len, script_file); wBoot_fclose(script_file); script_file = NULL; //解析脚本,根据脚本类型作区别 if(!boot_script_type) { ret = parser_script_os_sel(script_addr, script_len, script_buf); } if(ret) { __wrn("script is invalid\n"); } _err_out: //退出时候的处理 if(script_addr) { wBoot_free(script_addr); } if(script_file) { wBoot_fclose(script_file); script_file = NULL; } return ret; }
__s32 boot_ui_progressbar_destroy(__hdle p) { progressbar_t *progress = (progressbar_t *)p; int base_color; if(!p) { return -1; } base_color = boot_ui_get_color(); boot_ui_set_color(UI_BOOT_GUI_BLACK); boot_ui_draw_solidrectangle(progress->x1, progress->y1, progress->x2, progress->y2); boot_ui_set_color(base_color); wBoot_free(progress); return 0; }
/* ************************************************************************************************************ * * function * * 函数名称: * * 参数列表: * * 返回值 : * * 说明 : * * ************************************************************************************************************ */ int env_fetch_from_boot1(void) { char *tmp_boot1 = NULL; int ret = 0; tmp_boot1 = wBoot_malloc(512 * 1024); if(!tmp_boot1) { __inf("not enough memory to read boot1!\n"); return 0; } else { if(Nand_Load_Boot1(tmp_boot1, 512 * 1024)) { __inf("the boot1 in flash is bad!\n"); return 0; } else { boot1_file_head_t *tmp_boot1_head = (boot1_file_head_t *)tmp_boot1; char *base = (char *)tmp_boot1_head->prvt_head.script_buf; int i; dynamic_data_form *dform; dynamic_boot_head *dhead; dhead = (dynamic_boot_head *)base; if(strncmp(dhead->magic, "dynamic", sizeof("dynamic"))) { __inf("dynamic data magic error\n"); return 0; } base += sizeof(dynamic_boot_head); for(i=0;i<dhead->count;i++) { dform = (dynamic_data_form *)base; if(!strncmp(dform->name, "MAC", sizeof("MAC"))) { char *buf0 = env_flash_dram_base+4; char *buf1 = base + sizeof(dynamic_data_form); int j, k, l; __inf("dynamic data form1 find\n"); strcpy(env_flash_dram_base, "mac="); k = 0; l = 0; for(j=0;j<5;j++) { buf0[k++] = buf1[l++]; buf0[k++] = buf1[l++]; buf0[k++] = ':'; } buf0[k++] = buf1[l++]; buf0[k++] = buf1[l++]; buf0[k] = '\0'; ret = 1; env_exist = 2; break; } else if(!strncmp(dform->name, "mac_addr", sizeof("mac_addr"))) { __inf("dynamic data form2 find\n"); __inf("usedsize=%d\n", dform->usedsize>>2); { char *tm = base + sizeof(dynamic_data_form); int p; for(p=0;p<4;p++) { __inf("%c %c %c %c %c %c %c %c\n", *(tm + 0), *(tm + 1), *(tm + 2), *(tm + 3), *(tm + 4), *(tm + 5), *(tm + 6), *(tm + 7)); tm += 8; } __inf("\n"); } memcpy(env_flash_dram_base, base + sizeof(dynamic_data_form), dform->usedsize); ret = 1; env_exist = 2; } base += dform->usedsize; } } wBoot_free(tmp_boot1); }
/******************************************************************************* *函数名称: NAND_BadBlockScan *函数原型:bad_blcok_scan(const boot_nand_para_t *nand_param) *函数功能: 标记blk_num指定的块为坏块。 *入口参数: nand_param *返 回 值: >0 编程操作成功 * -1 编程操作失败 *备 注: *******************************************************************************/ __s32 NAND_BadBlockScan(const boot_nand_para_t *nand_param) { boot_flash_info_t info; struct boot_physical_param para; __s32 i, j, k; __u32 page_with_bad_block, page_per_block; __s32 page_index[4]; __u32 bad_block_cnt[8]; __u32 bad_block_num = 0; __u32 good_block_num = 0; __s32 good_block_ratio = -1; __u32 chip; __u8 oob_buf[OOB_BUF_SIZE]; __u8* page_buf; __u32 die_skip_flag = (nand_param->OperationOpt)&(0x1<<11); __u32 block_cnt_of_die = (nand_param->BlkCntPerDie); for(i=0; i<8; i++) bad_block_cnt[i] = 0; NAND_Print("Ready to scan bad blocks.\n"); // get nand info to cal NAND_Print("nfb phy init ok.\n"); if( NAND_GetFlashInfo( &info ) ) { NAND_Print("get flash info failed.\n"); return -1; } NAND_Print("Succeed in getting flash info.\n"); //cal nand parameters //page_buf = (__u8*)(BAD_BLK_SCAN_BUF_ADR); page_buf = (__u8*)wBoot_malloc(32 * 1024); if(!page_buf) { NAND_Print("malloc memory for page buf fail\n"); return -1; } page_with_bad_block = info.pagewithbadflag; page_per_block = info.blocksize/info.pagesize; //read the first, second, last, last-1 page for check bad blocks page_index[0] = 0; page_index[1] = 0xEE; page_index[2] = 0xEE; page_index[3] = 0xEE; switch(page_with_bad_block & 0x03) { case 0x00: //the bad block flag is in the first page, same as the logical information, just read 1 page is ok break; case 0x01: //the bad block flag is in the first page or the second page, need read the first page and the second page page_index[1] = 1; break; case 0x02: //the bad block flag is in the last page, need read the first page and the last page page_index[1] = page_per_block - 1; break; case 0x03: //the bad block flag is in the last 2 page, so, need read the first page, the last page and the last-1 page page_index[1] = page_per_block - 1; page_index[2] = page_per_block - 2; break; } //scan bad blocks for( i = 0; i < info.chip_cnt; i++ ){ chip = _cal_real_chip( i, nand_param->ChipConnectInfo ); NAND_Print("scan CE %u\n", chip); bad_block_cnt[chip] = 0; for( j = 0; j < info.blk_cnt_per_chip; j++ ) { para.chip = chip; if(!die_skip_flag) para.block = j; else para.block = j%block_cnt_of_die + 2*block_cnt_of_die*(j/block_cnt_of_die); para.mainbuf = page_buf; para.oobbuf = oob_buf; for(k = 0; k<4; k++) { // read pages for check para.page = page_index[k]; if(para.page == 0xEE) continue; NAND_PhyRead(¶ ); // find bad blocks if(oob_buf[0] != 0xff) { NAND_Print("find defined bad block in chip %u, block %u.\n", i, j); bad_block_cnt[chip]++; break; } } } } // cal bad block num if(info.chip_cnt == 0x1) //for one CE { if(nand_param->ChipConnectInfo == 0x1) { bad_block_num = bad_block_cnt[0]<<1; } else { NAND_Print("chip connect parameter %x error \n", nand_param->ChipConnectInfo); wBoot_free(page_buf); return -1; } } else if(info.chip_cnt == 2) //for two CE { if(nand_param->ChipConnectInfo == 0x3) { bad_block_num = (bad_block_cnt[0] + bad_block_cnt[1])<<1; } else if(nand_param->ChipConnectInfo == 0x5) { bad_block_num = (bad_block_cnt[0] + bad_block_cnt[2])<<1; } else if(nand_param->ChipConnectInfo == 0x81) { bad_block_num = (bad_block_cnt[0] + bad_block_cnt[7])<<1; } else { NAND_Print("chip connect parameter %x error \n", nand_param->ChipConnectInfo); wBoot_free(page_buf); return -1; } } else if(info.chip_cnt == 4) //for four CE { if(nand_param->ChipConnectInfo == 0xf) { bad_block_num = max_badblk((bad_block_cnt[0] + bad_block_cnt[2]),(bad_block_cnt[1] + bad_block_cnt[3]))<<1; } else if(nand_param->ChipConnectInfo == 0x55) { bad_block_num = max_badblk((bad_block_cnt[0] + bad_block_cnt[2]),(bad_block_cnt[4] + bad_block_cnt[6]))<<1; } else { NAND_Print("chip connect parameter %x error \n",nand_param->ChipConnectInfo); wBoot_free(page_buf); return -1; } } else if(info.chip_cnt == 8) //for eight CE { if(nand_param->ChipConnectInfo == 0xff) { bad_block_num = max_badblk((bad_block_cnt[0] + bad_block_cnt[2]),(bad_block_cnt[1] + bad_block_cnt[3])); bad_block_num = 2*max_badblk(bad_block_num, max_badblk((bad_block_cnt[4] + bad_block_cnt[6]),(bad_block_cnt[5] + bad_block_cnt[7]))); } else { NAND_Print("chip connect parameter %x error \n",nand_param->ChipConnectInfo); wBoot_free(page_buf); return -1; } } else { NAND_Print("chip cnt parameter %x error \n",nand_param->ChipCnt); wBoot_free(page_buf); return -1; } //cal good block num required per 1024 blocks good_block_num = (1024*(info.blk_cnt_per_chip - bad_block_num))/info.blk_cnt_per_chip -114; for(i=0; i<info.chip_cnt; i++) { chip = _cal_real_chip( i, nand_param->ChipConnectInfo ); NAND_Print(" %d bad blocks in CE %u \n", bad_block_cnt[chip], chip); } NAND_Print("cal bad block num is %u \n", bad_block_num); NAND_Print("cal good block num is %u \n", good_block_num); //cal good block ratio for(i=0; i<10; i++) { if(good_block_num >= (nand_param->good_block_ratio - 32*i)) { good_block_ratio = (nand_param->good_block_ratio - 32*i); NAND_Print("good block ratio is %u \n",good_block_ratio); break; } } wBoot_free(page_buf); return good_block_ratio; }
/* ************************************************************************************************************************ * NAND_EraseChip * *Description: Erase chip, only erase the all 0x0 blocks * *Arguments : connecnt info. * *Return : = 0 OK; * other Fail. ************************************************************************************************************************ */ __s32 NAND_EraseChip( const boot_nand_para_t *nand_param) { boot_flash_info_t info; struct boot_physical_param para_read; __s32 i,j,k,m; __s32 ret; __s32 cnt0, cnt1; __s32 mark_err_flag; __u32 bad_block_flag; __u32 page_with_bad_block, page_size, page_per_block; __s32 page_index[4]; __u32 chip; __u8 oob_buf_read[OOB_BUF_SIZE]; __u8* page_buf_read; __s32 error_flag = 0; __s32 block_start; __u32 die_skip_flag = (nand_param->OperationOpt)&(0x1<<11); __u32 block_cnt_of_die = (nand_param->BlkCntPerDie); bad_block_scan_flag = 0; page_buf_read = (__u8*)wBoot_malloc(32 * 1024); if(!page_buf_read) { NAND_Print("malloc memory for page read fail\n"); return -1; } NAND_Print("Ready to erase chip.\n"); // get nand info to cal NAND_Print("nfb phy init ok.\n"); if( NAND_GetFlashInfo( &info ) != 0 ) { NAND_Print("get flash info failed.\n"); wBoot_free(page_buf_read); return -1; } NAND_Print("Succeed in getting flash info.\n"); page_size = 512*info.pagesize; page_with_bad_block = info.pagewithbadflag; page_per_block = info.blocksize/info.pagesize; NAND_Print("page size:%x, block size: %x, bad block position: %x.\n",page_size, page_per_block,page_with_bad_block); page_index[0] = 0; page_index[1] = 0xEE; page_index[2] = 0xEE; page_index[3] = 0xEE; switch(page_with_bad_block & 0x03) { case 0x00: //the bad block flag is in the first page, same as the logical information, just read 1 page is ok break; case 0x01: //the bad block flag is in the first page or the second page, need read the first page and the second page page_index[1] = 1; break; case 0x02: //the bad block flag is in the last page, need read the first page and the last page page_index[1] = page_per_block - 1; break; case 0x03: //the bad block flag is in the last 2 page, so, need read the first page, the last page and the last-1 page page_index[1] = page_per_block - 1; page_index[2] = page_per_block - 2; break; } NAND_Print("chip_cnt = %x, chip_connect = %x, rb_cnt = %x, rb_connect = %x, good_block_ratio =%x \n",nand_param->ChipCnt,nand_param->ChipConnectInfo,nand_param->RbCnt,nand_param->RbConnectInfo,nand_param->good_block_ratio); for( i = 0; i < nand_param->ChipCnt; i++ ) { //select chip chip = _cal_real_chip( i, nand_param->ChipConnectInfo ); NAND_Print("erase chip %u \n", chip); //scan for bad blocks, only erase good block, all 0x00 blocks is defined bad blocks if(i == 0) { block_start = 7; } else { block_start = 0; } for( j = block_start; j < info.blk_cnt_per_chip; j++ ) { para_read.chip = chip; if(!die_skip_flag) para_read.block = j; else para_read.block = j%block_cnt_of_die + 2*block_cnt_of_die*(j/block_cnt_of_die); para_read.mainbuf = page_buf_read; para_read.oobbuf = oob_buf_read; bad_block_flag = 0; for(k = 0; k<4; k++) { cnt0 =0; cnt1 =0; para_read.page = page_index[k]; if( para_read.page== 0xEE) break; ret = NAND_PhyRead(& para_read ); //check the current block is a all 0x00 block #if 0 for(m=0; m<8; m++) //check user data, 8 byte { if(oob_buf_read[m] == ((__u8)0x0) ) cnt1++; else break; } for(m=0; m<page_size; m++) //check main data { if(page_buf_read[m] == ((__u8)0x0) ) cnt0++; else break; } if((cnt0 == page_size)&&(cnt1 == 8)) { bad_block_flag = 1; NAND_Print("find a all 0x00 block %u\n", j); break; } #endif if(oob_buf_read[0] == 0x0) { bad_block_flag = 1; NAND_Print("find a bad block %u\n", j); break; } } if(bad_block_flag) continue; ret = NAND_PhyErase( ¶_read ); if( ret != 0 ) { NAND_Print("erasing block %u failed.\n", j ); mark_err_flag = mark_bad_block( i, j ); if( mark_err_flag!= 0 ) { error_flag++; NAND_Print("error in marking bad block flag in chip %u, block %u, mark error flag %u.\n", i, j, mark_err_flag); } } } } NAND_Print("has cleared the chip.\n"); if(error_flag) NAND_Print("the nand is Bad.\n"); else NAND_Print("the nand is OK.\n"); wBoot_free(page_buf_read); return 0; }
/* ************************************************************************************************************************ * NAND_VersionCheck * *Description: Check the nand flash driver is current version * *Arguments : void. * *Return : = 0 version match; * 1 version not match * -1 can't get invalid version info ************************************************************************************************************************ */ __s32 NAND_VersionCheck(void) { struct boot_physical_param boot0_readop_temp; struct boot_physical_param *boot0_readop = NULL; __u32 block_index; __u32 cnt1; __s32 version_match_flag = -1; //__u32 chip_type; __s32 i; __u8 oob_buf[32]; __u32* main_data; __u8 nand_version[4]; /******************************************************************************** * nand_version[2] = 0xFF; //the sequnece mode version < * nand_version[2] = 0x01; //the first interleave mode version, care ecc * 2010-06-05 * nand_version[2] = 0x02; //the current version, don't care ecc * 2010-07-13 * NOTE: need update the nand version in update_boot0 at the same time ********************************************************************************/ nand_version[0] = 0xff; //bad block flag nand_version[1] = 0x00; //reserved, set to 0x00 nand_version[2] = NAND_VERSION_0; //nand driver version 0, current vresion is 0x02 nand_version[3] = NAND_VERSION_1; //nand driver version 1, current vresion is 0x00 NAND_Print("check nand version start.\n"); NAND_Print("Current nand driver version is %x %x %x %x \n", nand_version[0], nand_version[1], nand_version[2], nand_version[3]); boot0_readop = &boot0_readop_temp; //init boot0_readop boot0_readop->block = 0x0; boot0_readop->chip = 0; boot0_readop->mainbuf = (void*)wBoot_malloc(32 * 1024); if(!boot0_readop->mainbuf) { NAND_Print("malloc memory for boot0 read operation fail\n"); return -1; } boot0_readop->oobbuf = oob_buf; boot0_readop->page = 0; boot0_readop->sectorbitmap = 0; main_data = (__u32*)wBoot_malloc(32 * 1024); if(!main_data) { NAND_Print("malloc memory for main data fail\n"); return -1; } //scan boot0 area blocks for(block_index=BOOT0_START_BLK_NUM;block_index<BOOT0_LAST_BLK_NUM + 1;block_index++) { boot0_readop->block = block_index; boot0_readop->page = 0; cnt1 = 0; NAND_PhyRead_1K(boot0_readop); //check the current block is a bad block if(oob_buf[0] != 0xFF) { NAND_Print("block %u is bad block.\n",block_index); continue; } //check the current block is a all 0xFF block for(i=0; i<256; i++) { if(*(main_data+i) == 0xffffffff) cnt1++; } if(cnt1 == 256) { NAND_Print("block %u is cleared block.\n",block_index); continue; } if((oob_buf[1] == 0x00) || (oob_buf[1] == 0xFF)) { NAND_Print("Media version is valid in block %u, version info is %x %x %x %x \n", block_index, oob_buf[0], oob_buf[1], oob_buf[2], oob_buf[3]); if(oob_buf[2] == nand_version[2]) { NAND_Print("nand driver version match ok in block %u.\n",block_index); version_match_flag = 0; break; } else { NAND_Print("nand driver version match fail in block %u.\n",block_index); version_match_flag = 1; break; } } else { NAND_Print("Media version is invalid in block %uversion info is %x %x %x %x \n", block_index, oob_buf[0], oob_buf[1], oob_buf[2], oob_buf[3]); } } if(block_index == (BOOT0_LAST_BLK_NUM + 1)) { NAND_Print("can't find valid version info in boot blocks. \n"); version_match_flag = -1; } wBoot_free(main_data); return version_match_flag; }
/******************************************************************************* *函数名称: mark_bad_block *函数原型:mark_bad_block( __u32 chip_num, __u32 blk_num ) *函数功能: 标记blk_num指定的块为坏块。 *入口参数: chip_num chip number blk_num 块号 *返 回 值: 0 编程操作成功 * other 编程操作失败 *备 注: *******************************************************************************/ static __s32 mark_bad_block( __u32 chip_num, __u32 blk_num) { boot_flash_info_t info; struct boot_physical_param para; __u8 oob_buf[OOB_BUF_SIZE]; __u8* page_buf; __s32 page_index[4]; __u32 page_with_bad_block, page_per_block; __u32 i; __s32 mark_err_flag = -1; if( NAND_GetFlashInfo( &info )) { NAND_Print("get flash info failed.\n"); return -1; } //cal nand parameters //page_buf = (__u8*)(MARK_BAD_BLK_BUF_ADR); page_buf = (__u8*)wBoot_malloc(32 * 1024); if(!page_buf) { NAND_Print("malloc memory for page buf fail\n"); return -1; } page_with_bad_block = info.pagewithbadflag; page_per_block = info.blocksize/info.pagesize; //read the first, second, last, last-1 page for check bad blocks page_index[0] = 0; page_index[1] = 0xEE; page_index[2] = 0xEE; page_index[3] = 0xEE; switch(page_with_bad_block & 0x03) { case 0x00: //the bad block flag is in the first page, same as the logical information, just read 1 page is ok break; case 0x01: //the bad block flag is in the first page or the second page, need read the first page and the second page page_index[1] = 1; break; case 0x02: //the bad block flag is in the last page, need read the first page and the last page page_index[1] = page_per_block - 1; break; case 0x03: //the bad block flag is in the last 2 page, so, need read the first page, the last page and the last-1 page page_index[1] = page_per_block - 1; page_index[2] = page_per_block - 2; break; } for(i =0; i<4; i++) { oob_buf[0] = 0x0; oob_buf[1] = 0x1; oob_buf[2] = 0x2; oob_buf[3] = 0x3; oob_buf[4] = 0x89; oob_buf[5] = 0xab; oob_buf[6] = 0xcd; oob_buf[7] = 0xef; para.chip = chip_num; para.block = blk_num; para.page = page_index[i]; para.mainbuf = page_buf; para.oobbuf = oob_buf; if(para.page == 0xEE) continue; NAND_PhyWrite( ¶ ); NAND_PhyRead( ¶ ); if(oob_buf[0] !=0xff) mark_err_flag = 0; } wBoot_free(page_buf); return mark_err_flag; }
/* ******************************************************************************* * ui_AllocLayerPara * * Description: * 初始化一个图层参数 * * Parameters: * PictureInfo : input. 图片信息 * * Return value: * 返回图层参数 * * note: * void * ******************************************************************************* */ display_layer_info_t *LCD_DisplayAllocLayerPara(void) { display_layer_info_t *layer_para = NULL; __u32 screen_width = 0; __u32 screen_height = 0; __u32 buffer_size; layer_para = (display_layer_info_t *)wBoot_malloc(sizeof(display_layer_info_t)); if(layer_para == NULL) { DMSG_PANIC("ERR: wBoot_malloc failed\n"); return NULL; } memset(layer_para, 0, sizeof(display_layer_info_t)); /* 初始化图形参数 */ screen_width = De_GetSceenWidth(); screen_height = De_GetSceenHeight(); //根据屏幕的大小,申请framebuffer的大小 display_info.screen_width = screen_width; display_info.screen_height = screen_height; buffer_size = screen_width * screen_height * 4 * 2; display_info.screen_buf = wBoot_malloc(buffer_size); if(!display_info.screen_buf) { __wrn("LCD_DisplayAllocLayerPara: malloc memory for display buffer failed\n"); wBoot_free(layer_para); return NULL; } memset(display_info.screen_buf, 0, buffer_size); layer_para->fb.size.width = screen_width; layer_para->fb.size.height = screen_height; layer_para->fb.addr[0] = (__u32)display_info.screen_buf; layer_para->fb.mode = DISP_MOD_INTERLEAVED; layer_para->fb.format = DISP_FORMAT_ARGB8888; layer_para->fb.br_swap = 0; layer_para->fb.seq = DISP_SEQ_ARGB; layer_para->ck_enable = 0; layer_para->mode = DISP_LAYER_WORK_MODE_NORMAL; layer_para->alpha_en = 0; layer_para->alpha_val = 0xff; layer_para->pipe = 0; layer_para->src_win.x = 0; layer_para->src_win.y = 0; layer_para->src_win.width = screen_width; layer_para->src_win.height = screen_height; layer_para->scn_win.x = 0; layer_para->scn_win.y = 0; layer_para->scn_win.width = screen_width; layer_para->scn_win.height = screen_height; display_info.crt_addr = display_info.screen_buf; display_info.total_height = ((buffer_size / 4) / (screen_width)) / (WORD_SIZE); //总的高度,可以显示的行数 display_info.rest_screen_height = display_info.total_height - 1; //记录屏幕的剩余高度,行数, 剩余1行不用 display_info.rest_display_height = screen_height/WORD_SIZE - 1; //记录显示的剩余高度,行数,剩余1行不用 display_info.rest_screen_width = screen_width; //剩余宽度等于显示宽度, 像素单位 display_info.current_height = 0; display_info.fb_addr = display_info.screen_buf; display_info.x = 0; display_info.y = 0; return layer_para; }
__s32 fetch_dynamic_data(char *buffer, int buffer_size) { int ret, i; H_FILE index_file = NULL; H_FILE data_file = NULL; int index_length; int data_length; char index_buffer[1024]; char *data_buffer; Dynamic_index *dindex; char data_file_name[32]; Dyamic_head *ddata; int index_number; char tmp_data_file_name[16]; ret = -1; // if(wBoot_fsmount('Z')) //其实是挂标准MBR的用户盘 // { // __inf("log error: cant find user disk\n"); // // return; // } //打开索引文件 index_file = wBoot_fopen("z:\\dynamic\\dindex.bin", "rb+"); if(!index_file) { sprite_wrn("dynamic data error: cant find dynamic data index file\n"); goto dynamic_data_err; } index_length = wBoot_flen(index_file); if(!index_length) { sprite_wrn("dynamic data error: dynamic data index file is bad\n"); goto dynamic_data_err; } //读出索引数据 memset(index_buffer, 0, 1024); wBoot_fread(index_buffer, 1, index_length, index_file); dindex = (Dynamic_index *)index_buffer; //校验索引数据 if(memcmp(dindex->magic, "dynamic", sizeof("dynamic"))) { sprite_wrn("dynamic data error: bad dynamic data index\n"); goto dynamic_data_err; } //生成数据文件名称 memset(data_file_name, 0, 32); strcpy(data_file_name, "z:\\dynamic\\"); while(dindex->used_count < dindex->total_count) { dindex->used_count ++; dindex->err_times ++; memset(tmp_data_file_name, 0, 16); strcpy(tmp_data_file_name, dindex->last_file); index_number = 0; for(i=1;(i<8) && (tmp_data_file_name[i] != '.');i++) { index_number = index_number * 10 + (tmp_data_file_name[i] - '0'); } //保存当前要查找的文件名 strcpy(data_file_name + sizeof("z:\\dynamic\\") - 1, dindex->last_file); //生成新的索引文件名称 index_number ++; for(i=7;i>0;i--) { tmp_data_file_name[i] = (index_number%10) + '0'; index_number /= 10; } //回写到索引文件中(缓存) strcpy(dindex->last_file, tmp_data_file_name); //打开数据文件 data_file = wBoot_fopen(data_file_name, "rb+"); if(!data_file) { //对应的数据文件不存在 sprite_wrn("dynamic data error: dynamic data file %s is not exist\n", data_file_name); data_file = NULL; continue; } data_length = wBoot_flen(data_file); if(!data_length) { sprite_wrn("dynamic data error: dynamic data file %s is bad\n", data_file_name); wBoot_fclose(data_file); data_file = NULL; continue; } data_buffer = wBoot_malloc(data_length); if(!data_buffer) { sprite_wrn("dynamic data error: not enough memory for dynamic data\n"); goto dynamic_data_err; } wBoot_fread(data_buffer, 1, data_length, data_file); //检查数据的校验和 // if(simple_check_data_valid(data_buffer, data_length)) // { // sprite_wrn("dynamic data error: dynamic data checksum error\n"); // wBoot_free(data_buffer); // data_buffer = NULL; // wBoot_fclose(data_file); // data_file = NULL; // // continue; // } ddata = (Dyamic_head *)data_buffer; if(ddata->used) //已经被使用过,切换下一个文件 { wBoot_free(data_buffer); data_buffer = NULL; wBoot_fclose(data_file); data_file = NULL; wBoot_fclose(data_file); } else { ddata->used = 1; //取出所有数据 dynamic_data_get(data_buffer, data_length, buffer, buffer_size); dindex->successed_times ++; dindex->err_times --; //保存回原文件 // simple_data_checksum(data_buffer, data_length); wBoot_fseek(data_file, 0, 0); wBoot_write(data_buffer, 1, data_length, data_file); wBoot_fclose(data_file); break; } } //修改索引文件 strcpy(dindex->last_file, tmp_data_file_name); wBoot_fseek(index_file, 0, 0); wBoot_write(index_buffer, 1, index_length, index_file); ret = 0; //完毕 dynamic_data_err: if(data_buffer) { wBoot_free(data_buffer); } if(data_file) { wBoot_fclose(data_file); } if(index_file) { wBoot_fclose(index_file); } return ret; }
/* ******************************************************************************* * ui_AllocLayerPara * * Description: * 初始化一个图层参数 * * Parameters: * PictureInfo : input. 图片信息 * * Return value: * 返回图层参数 * * note: * void * ******************************************************************************* */ display_layer_info_t *ui_multi_AllocLayerPara(display_lcd_set_t *lcd_info, __u32 address) { display_layer_info_t *layer_para = NULL; __u32 screen_width = 0; __u32 screen_height = 0; __u32 buffer_size; layer_para = (display_layer_info_t *)wBoot_malloc(sizeof(display_layer_info_t)); if(layer_para == NULL) { DMSG_PANIC("ERR: wBoot_malloc failed\n"); return NULL; } memset(layer_para, 0, sizeof(display_layer_info_t)); /* 初始化图形参数 */ screen_width = De_GetSceenWidth(); screen_height = De_GetSceenHeight(); //根据屏幕的大小,申请framebuffer的大小 lcd_info->lcd_width = screen_width; lcd_info->lcd_height = screen_height; buffer_size = screen_width * screen_height * 4; if(!address) { lcd_info->display_buffer = wBoot_malloc(buffer_size); if(!lcd_info->display_buffer) { __inf("multi displya fail: malloc memory for display buffer failed\n"); wBoot_free(layer_para); return NULL; } } else { lcd_info->display_buffer = (__u32 *)address; } memset(lcd_info->display_buffer, 0, buffer_size); layer_para->fb.size.width = screen_width; layer_para->fb.size.height = screen_height; layer_para->fb.addr[0] = (__u32)lcd_info->display_buffer; layer_para->fb.mode = DISP_MOD_INTERLEAVED; layer_para->fb.format = DISP_FORMAT_ARGB8888; layer_para->fb.br_swap = 0; layer_para->fb.seq = DISP_SEQ_ARGB; layer_para->ck_enable = 0; layer_para->mode = DISP_LAYER_WORK_MODE_NORMAL; layer_para->alpha_en = 1; layer_para->alpha_val = 0xff; layer_para->pipe = 0; layer_para->src_win.x = 0; layer_para->src_win.y = 0; layer_para->src_win.width = screen_width; layer_para->src_win.height = screen_height; layer_para->scn_win.x = 0; layer_para->scn_win.y = 0; layer_para->scn_win.width = screen_width; layer_para->scn_win.height = screen_height; return layer_para; }
/* ************************************************************************************************************ * * function * * 函数名称: * * 参数列表: * * 返回值 : * * 说明 : * * ************************************************************************************************************ */ int private_fetch_from_flash(void) { char *mbr_buf; MBR *mbr_info; int crc, i; int size, start; int ret = -1; int s_type = 0; memset(mac_addr_store, 0, 32); env_flash_dram_base = (char *)ENV_FLASH_DRAM_ADDRESS; private_flash_dram_base = (char *)PRIVATE_FLASH_DRAM_ADDRESS; #if 1 if(sprite_flash_init(&s_type)) { __inf("update flash env err: flash init\n"); return -1; } mbr_buf=wBoot_malloc(MBR_SIZE*MBR_COPY_NUM); if(0 == mbr_buf) { __inf("update flash env err: malloc mbr buffer failed!\n"); goto update_flash_env_err; } if(sprite_flash_read(0, MBR_SIZE*MBR_COPY_NUM/512, mbr_buf)) { __inf("update flash env err: read flash error\n"); goto update_flash_env_err; } for(i=0;i<MBR_COPY_NUM;i++) { mbr_info = (MBR *)(mbr_buf + i * MBR_SIZE); crc = calc_crc32((void *)&mbr_info->version, sizeof(MBR) - 4); if(crc == mbr_info->crc32) { break; } } if(4 == i) { ret = 0; __inf("update flash env err: cant find good flash mbr\n"); wBoot_free(mbr_buf); goto update_flash_env_err; } for(i=0;i<mbr_info->PartCount;i++) { if(!strcmp("env", (const char *)mbr_info->array[i].name)) { __inf("env part found\n"); start = mbr_info->array[i].addrlo; size = mbr_info->array[i].lenlo; memset(env_flash_dram_base, 0, size<<9); if(sprite_flash_read(start, size, env_flash_dram_base)) { __inf("update flash env err: read env data error\n"); wBoot_free(mbr_buf); goto update_flash_env_err; } env_exist = 1; } else if(!strcmp("private", (const char *)mbr_info->array[i].name)) { __inf("private part found\n"); start = mbr_info->array[i].addrlo; size = mbr_info->array[i].lenlo; memset(private_flash_dram_base, 0, size<<9); if(sprite_flash_read(start, size, private_flash_dram_base)) { __inf("update flash private err: read private data error\n"); wBoot_free(mbr_buf); goto update_flash_env_err; } private_flash_flash_size = size<<9; private_exist = 1; } } ret = 0; wBoot_free(mbr_buf); update_flash_env_err: sprite_flash_exit(s_type); #endif // if(!env_exist) //如果在旧的环境变量中没有找到动态数据,则去boot1中寻找 // { // ret = env_fetch_from_boot1(); // } return ret; }