int read_lcd_k_cal( char *buf) { int err=0; int mtd_op_result = 0; // int i; const MmcPartition *pMisc_part; unsigned long lcdkcal_bytes_pos_in_emmc = 0; printk(KERN_INFO"read read_lcd_k_cal\n"); lge_mmc_scan_partitions(); pMisc_part = lge_mmc_find_partition_by_name("misc"); if ( pMisc_part == NULL ) { printk(KERN_INFO"NO MISC\n"); return 0; } lcdkcal_bytes_pos_in_emmc = (pMisc_part->dfirstsec*512)+K_CAL_DATA_OFFSET_IN_BYTES; memset(lcd_buf, 0 ,LCD_K_CAL_SIZE); mtd_op_result = lge_read_block(lcdkcal_bytes_pos_in_emmc, &lcd_buf[0], LCD_K_CAL_SIZE); if (mtd_op_result != LCD_K_CAL_SIZE ) { printk(KERN_INFO" read %ld block fail\n", lcdkcal_bytes_pos_in_emmc); return err; } printk(KERN_INFO"read %ld block\n", lcdkcal_bytes_pos_in_emmc); memcpy(&buf[0],&lcd_buf[0],LCD_K_CAL_SIZE); return LCD_K_CAL_SIZE; }
//[START]kcal for 325 static int write_lcd_k_cal(const char *val, struct kernel_param *kp) { int i = 0; int err = 0; // int mtd_op_result = 0; int mmc_scan_partion_result = 0; const MmcPartition *pMisc_part; unsigned long lcdkcal_bytes_pos_in_emmc = 0; static unsigned char lcd_buf2[6]; memcpy(lcd_buf,val,LCD_K_CAL_SIZE); #if 1 for(i=0;i<LCD_K_CAL_SIZE;i++) { printk("write_lcd_k_cal :%x:\n",lcd_buf[i]); } #endif mmc_scan_partion_result = lge_mmc_scan_partitions(); if (mmc_scan_partion_result < 0) { printk(KERN_INFO"mmc_scan_fail\n"); return 0; } pMisc_part = lge_mmc_find_partition_by_name("misc"); if ( pMisc_part == NULL ) { printk(KERN_INFO"NO MISC\n"); return 0; } lcdkcal_bytes_pos_in_emmc = (pMisc_part->dfirstsec*512)+PTN_LCD_K_CAL_PARTITION; printk("write_lcd_k_cal %ld block\n", lcdkcal_bytes_pos_in_emmc); mtd_op_result = lge_write_block(lcdkcal_bytes_pos_in_emmc, lcd_buf, LCD_K_CAL_SIZE); if ( mtd_op_result != LCD_K_CAL_SIZE ) { printk("%s: write %u block fail\n", __func__, i); return err; } mtd_op_result = lge_read_block(lcdkcal_bytes_pos_in_emmc, &lcd_buf2[0], LCD_K_CAL_SIZE); if ( mtd_op_result != LCD_K_CAL_SIZE ) { printk("%s: write %u block fail\n", __func__, i); return err; } #if 1 for(i=0;i<LCD_K_CAL_SIZE;i++) { printk("read_lcd_k_cal :%x:\n",lcd_buf2[i]); } #endif printk("write %d block\n", i); return 0; }
static int test_read_block(char *buf, struct kernel_param *kp) { //int i; int err; int mtd_op_result = 0; const MmcPartition *pMisc_part; unsigned long factoryreset_bytes_pos_in_emmc = 0; printk(KERN_INFO"read block1\n"); lge_mmc_scan_partitions(); // lge_mmc_partition_initialied = 4; pMisc_part = lge_mmc_find_partition_by_name("misc"); if ( pMisc_part == NULL ) { printk(KERN_INFO"NO MISC\n"); return 0; } // lge_mmc_partition_initialied = 5; factoryreset_bytes_pos_in_emmc = (pMisc_part->dfirstsec*512)+PTN_FRST_PERSIST_POSITION_IN_MISC_PARTITION; printk(KERN_INFO"read block\n"); // lge_mmc_partition_initialied = 6; memset(global_buf, 0 , FACTORY_RESET_STR_SIZE+2); mtd_op_result = lge_read_block(factoryreset_bytes_pos_in_emmc, global_buf, FACTORY_RESET_STR_SIZE+2); // lge_mmc_partition_initialied = 7; if (mtd_op_result != (FACTORY_RESET_STR_SIZE+2) ) { printk(KERN_INFO" read %ld block fail\n", factoryreset_bytes_pos_in_emmc); return err; } // lge_mmc_partition_initialied = 8; printk(KERN_INFO"read %ld block\n", factoryreset_bytes_pos_in_emmc); // printk(KERN_INFO"%s\n", __func__, global_buf); // BEGIN: 0009484 [email protected] 2010-09-24 // MOD 0009484: [FactoryReset] Enable FactoryReset if(memcmp(global_buf, FACTORY_RESET_STR, FACTORY_RESET_STR_SIZE)==0){ err = sprintf(buf,"%s",global_buf+FACTORY_RESET_STR_SIZE); // err = sprintf(buf,"123456789"); return err; } else{ //#if 0 // LS696_me : Return 1 if no Factory reset string error: err = sprintf(buf,"1"); return err; //#endif } // END: 0009484 [email protected] 2010-09-24 }
// Begin: hyechan.lee 2011-04-06 // 0018768: [fota]Fix an issue that when VZW logo is displayed, remove battery it won¡¯t enter recovery mode static int fota_write_block(const char *val, struct kernel_param *kp) { const MmcPartition *pMisc_part; unsigned long bootmsg_bytes_pos = 0; unsigned long fotamsg_bytes_pos = 0; unsigned int bootmsg_size, fotamsg_size; unsigned int fota_reboot_result; lge_mmc_scan_partitions(); pMisc_part = lge_mmc_find_partition_by_name("misc"); if ( pMisc_part == NULL ) { printk(KERN_INFO"NO MISC\n"); return -1; } bootmsg_bytes_pos = (pMisc_part->dfirstsec*512); printk(KERN_INFO"writing block\n"); bootmsg_size= sizeof("boot-recovery"); fota_reboot_result = lge_write_block(bootmsg_bytes_pos, "boot-recovery", bootmsg_size); if ( fota_reboot_result != bootmsg_size ) { printk(KERN_INFO"%s: write block fail\n", __func__); return -1; } fotamsg_bytes_pos = ((pMisc_part->dfirstsec+3)*512); printk(KERN_INFO"%lx writing block\n", fotamsg_bytes_pos); fotamsg_size= sizeof("fota-recovery"); fota_reboot_result = lge_write_block(fotamsg_bytes_pos, "fota-recovery", fotamsg_size); if ( fota_reboot_result != fotamsg_size ) { printk(KERN_INFO"%s: write block fail\n", __func__); return -1; } printk(KERN_INFO"fota write block\n"); return 0; }
boolean userWebDnBadCalc(void) { const MmcPartition *pMisc_part; pMisc_part = lge_mmc_find_partition_by_name("blb");/* web status variable saving region */ if (pMisc_part ==NULL) { return FALSE; } web_status_bytes_pos_in_emmc = (pMisc_part->dfirstsec)*512; return TRUE; }
boolean userDataBackUpBadCalc(void) { const MmcPartition *pMisc_part; pMisc_part = lge_mmc_find_partition_by_name("misc"); if (pMisc_part ==NULL) { return FALSE; } srd_bytes_pos_in_emmc = (pMisc_part->dfirstsec)*512; return TRUE; #if 0 int i; int start_blk; int end_blk; int max_badBlk; int total_bad_count = 0; if(userDataBackupFlashInit()==FALSE) return FALSE; start_blk = flash_nand_partition_start_block(MIBIB_DIDBACKUP_PARTI_NAME); end_blk = flash_nand_partition_end_block(MIBIB_DIDBACKUP_PARTI_NAME); max_badBlk = (int)(end_blk - start_blk); for (i=start_blk; i<= end_blk; i++) { if ( nand_device->bad_block_check(nand_device, i) == FS_DEVICE_BAD_BLOCK) { total_bad_count++; } else { uBadBlockAddress[i - start_blk - total_bad_count] = i; } } if (total_bad_count > MIN_NEED_BLOCK_SRD) return FALSE; else return TRUE; #endif }
//heebae.song for kcal static int write_lcd_k_cal(const char *val, struct kernel_param *kp) { int i = 0; int err; int mtd_op_result = 0; const MmcPartition *pMisc_part; unsigned long lcdkcal_bytes_pos_in_emmc = 0; unsigned char buf[10]={255,}; memcpy(buf,val,10); lcd_buf[0] = lcdtest_ascii_to_int(buf[0]) * 100 + lcdtest_ascii_to_int(buf[1])*10 + lcdtest_ascii_to_int(buf[2]); lcd_buf[1] = lcdtest_ascii_to_int(buf[3]) * 100 + lcdtest_ascii_to_int(buf[4])*10 + lcdtest_ascii_to_int(buf[5]); lcd_buf[2] = lcdtest_ascii_to_int(buf[6]) * 100 + lcdtest_ascii_to_int(buf[7])*10 + lcdtest_ascii_to_int(buf[8]); lcd_buf[3]=0; lcd_buf[4]=111; lcd_buf[5]=222; #if 1 for(i=0;i<LCD_K_CAL_SIZE;i++) { printk("write_lcd_k_cal, lcd_buf[%d] :%d:\n",i,lcd_buf[i]); } #endif lge_mmc_scan_partitions(); pMisc_part = lge_mmc_find_partition_by_name("misc"); if ( pMisc_part == NULL ) { printk(KERN_INFO"NO MISC\n"); return 0; } lcdkcal_bytes_pos_in_emmc = (pMisc_part->dfirstsec*512)+K_CAL_DATA_OFFSET_IN_BYTES; printk("write_lcd_k_cal %ld block\n", lcdkcal_bytes_pos_in_emmc); mtd_op_result = lge_write_block(lcdkcal_bytes_pos_in_emmc, lcd_buf, LCD_K_CAL_SIZE); if ( mtd_op_result != LCD_K_CAL_SIZE ) { printk("%s: write %u block fail\n", __func__, i); return err; } printk("write %d block\n", i); return 0; }
boolean userDataBackUpBadCalc(void) { const MmcPartition *pMisc_part; pMisc_part = lge_mmc_find_partition_by_name("misc"); // if (pMisc_part ==NULL) // { // printk(KERN_INFO "[SRD] misc finde error! "); // return FALSE; // } // srd_bytes_pos_in_emmc = (pMisc_part->dfirstsec)*512 + 0x400000; srd_bytes_pos_in_emmc = 0x10000; return TRUE; }
static int test_read_block( char *buf, struct kernel_param *kp) { int err=0; int mtd_op_result = 0; const MmcPartition *pMisc_part; unsigned long factoryreset_bytes_pos_in_emmc = 0; printk(KERN_INFO"read block1\n"); lge_mmc_scan_partitions(); pMisc_part = lge_mmc_find_partition_by_name("misc"); if ( pMisc_part == NULL ) { printk(KERN_INFO"NO MISC\n"); return 0; } factoryreset_bytes_pos_in_emmc = (pMisc_part->dfirstsec*512)+PTN_FRST_PERSIST_POSITION_IN_MISC_PARTITION; printk(KERN_INFO"read block\n"); memset(global_buf, 0 , FACTORY_RESET_STR_SIZE+2); mtd_op_result = lge_read_block(factoryreset_bytes_pos_in_emmc, global_buf, FACTORY_RESET_STR_SIZE+2); if (mtd_op_result != (FACTORY_RESET_STR_SIZE+2) ) { printk(KERN_INFO" read %ld block fail\n", factoryreset_bytes_pos_in_emmc); return err; } printk(KERN_INFO"read %ld block\n", factoryreset_bytes_pos_in_emmc); // // MOD 0009484: [FactoryReset] Enable FactoryReset if(memcmp(global_buf, FACTORY_RESET_STR, FACTORY_RESET_STR_SIZE)==0){ err = sprintf(buf,"%s",global_buf+FACTORY_RESET_STR_SIZE); return err; } else{ err = sprintf(buf,"1"); return err; } // }
static int test_bootcmd_write_block(const char *val, struct kernel_param *kp) { int i = 0; int err = 0; /* mbhyun.kim 2013.01.22 : WBT ID 100709 */ int mtd_op_result = 0; const MmcPartition *pMisc_part; unsigned long bootcmd_bytes_pos_in_emmc = 0; struct bootloader_message boot; memset(&boot, 0, sizeof(boot)); strlcpy(boot.command, "boot-recovery", sizeof(boot.command)); strlcpy(boot.recovery, "recovery\n", sizeof(boot.recovery)); printk(KERN_INFO"bootcmd write block\n"); lge_mmc_scan_partitions(); pMisc_part = lge_mmc_find_partition_by_name("misc"); if ( pMisc_part == NULL ) { printk(KERN_INFO"NO MISC\n"); return 0; } bootcmd_bytes_pos_in_emmc = (pMisc_part->dfirstsec*512)+BOOTCMD_FLAG_OFFSET_IN_BYTES; printk(KERN_INFO"bootcmd writing block\n"); mtd_op_result = lge_write_block(bootcmd_bytes_pos_in_emmc, (void *)&boot, sizeof(boot)); if ( mtd_op_result != sizeof(boot) ) { printk(KERN_INFO"bootcmd %s: write %u block fail\n", __func__, i); return err; } printk(KERN_INFO"bootcmd write %d block\n", i); return 0; }
static int test_write_block(const char *val, struct kernel_param *kp) { int i = 0; // int err = 0; //int normal_block_seq = 0; int mtd_op_result = 0; const MmcPartition *pMisc_part; unsigned long factoryreset_bytes_pos_in_emmc = 0; unsigned long flag=0; unsigned char *test_string; test_string = kmalloc(FACTORY_RESET_STR_SIZE+2, GFP_KERNEL); // allocation exception handling if(!test_string) { printk(KERN_ERR "allocation failed, return\n"); return 0; } printk(KERN_INFO"write block1\n"); flag = simple_strtoul(val,NULL,10); sprintf(test_string,"FACT_RESET_%d\n", (char)flag); lge_mmc_scan_partitions(); pMisc_part = lge_mmc_find_partition_by_name("misc"); if ( pMisc_part == NULL ) { printk(KERN_INFO"NO MISC\n"); return 0; } factoryreset_bytes_pos_in_emmc = (pMisc_part->dfirstsec*512)+PTN_FRST_PERSIST_POSITION_IN_MISC_PARTITION; printk(KERN_INFO"writing block\n"); mtd_op_result = lge_write_block(factoryreset_bytes_pos_in_emmc, test_string, FACTORY_RESET_STR_SIZE+2); if ( mtd_op_result != (FACTORY_RESET_STR_SIZE+2) ) { printk(KERN_INFO"%s: write %u block fail\n", __func__, i); kfree(test_string); return err; } /* */ /* ADD 0013860: [FACTORY RESET] ERI file save */ /* request rpc for eri file when the factory reset completes */ /* migrate eri codes to qem daemon */ #if 0 // if (flag == 5) { printk(KERN_INFO "%s, received flag : %ld, activate work queue\n", __func__, flag); eri_dload_data.flag = flag; queue_work(eri_dload_wq, &eri_dload_data.work); } #endif /* */ printk(KERN_INFO"write %d block\n", i); kfree(test_string); return 0; }
void remote_did_rpc(void) { struct oem_rapi_client_streaming_func_arg arg; struct oem_rapi_client_streaming_func_ret ret; int rc= -1; //int file_size=0; char fs_err_buf[20]; //test_mode_emmc_direct_type did_info; const MmcPartition *pMisc_part; unsigned int did_bytes_pos_in_emmc ; int mtd_op_result ; printk(KERN_ERR "%s, start OEM_RAPI\n",__func__); //memset(&did_info,0x0,sizeof(test_mode_emmc_direct_type)); //memset(fs_err_buf, 0, sizeof(fs_err_buf)); Open_check(); arg.event = LG_FW_DID_BACKUP_REQUEST; arg.cb_func = NULL; arg.handle = (void*) 0; arg.in_len = sizeof(fs_err_buf); arg.input =fs_err_buf; arg.out_len_valid = 1; arg.output_valid = 1; arg.output_size = sizeof(pbuf_emmc); ret.output = NULL; ret.out_len = NULL; rc = oem_rapi_client_streaming_function(client,&arg,&ret); if(ret.output == NULL || ret.out_len == NULL){ printk(KERN_ERR "%s, output is NULL\n",__func__); return; } printk(KERN_ERR "%s, output lenght =%dis\n",__func__,*ret.out_len); //memcpy(&did_info, ret.output, *ret.out_len); memcpy((void *)&pbuf_emmc2[0], ret.output, 192); //form modem length =192 //===================== emmc wirte routine ======================= printk(KERN_ERR "%s, lge_mmc_scan_partitions\n",__func__); rc = lge_mmc_scan_partitions(); if (rc < 0) { printk(KERN_ERR "%s couldn't scan the partition\n", __func__); return ; } pMisc_part = lge_mmc_find_partition_by_name("misc"); printk(KERN_ERR "%s, lge_mmc_find_partition_by_name\n",__func__); if (pMisc_part ==NULL) { if (ret.output) kfree(ret.output); if (ret.out_len) kfree(ret.out_len); return ; } did_bytes_pos_in_emmc = (pMisc_part->dfirstsec)*512+0x300000; //3M memset((void *)pbuf_emmc, 0, sizeof(pbuf_emmc)); mtd_op_result = lge_read_block(did_bytes_pos_in_emmc, pbuf_emmc, 192); //printk(KERN_ERR "%s,lge_read_block\n",__func__); //if(memcmp((void *)pbuf_emmc,(void *)ret.output, sizeof(pbuf_emmc)) != 0) if(memcmp((void *)pbuf_emmc,(void *)pbuf_emmc2, sizeof(pbuf_emmc)) != 0) { //printk(KERN_ERR "%s,lge_write_block0\n",__func__); lge_write_block(did_bytes_pos_in_emmc, pbuf_emmc2, 192); // printk(KERN_ERR "%s,lge_write_block1\n",__func__); } //============================================================= /* */ /* MOD 0014591: [LG_RAPI] rpc request heap leakage bug fix */ // free received buffers if it is not empty if (ret.output) kfree(ret.output); if (ret.out_len) kfree(ret.out_len); /* */ return; }
static int test_write_block(const char *val, struct kernel_param *kp) { int i; int err; //int normal_block_seq = 0; int mtd_op_result = 0; const MmcPartition *pMisc_part; unsigned long factoryreset_bytes_pos_in_emmc = 0; unsigned long flag=0; unsigned char *test_string; test_string = kmalloc(FACTORY_RESET_STR_SIZE+2, GFP_KERNEL); // allocation exception handling if(!test_string) { printk(KERN_ERR "allocation failed, return\n"); return 0; } printk(KERN_INFO"write block1\n"); flag = simple_strtoul(val,NULL,10); // if (flag == 5 || flag == 6 ) // { /* BEGIN: 0014076 [email protected] 20110114 */ /* MOD 0014076: [FACTORY RESET] Android factory reset flag bug fix */ /* make sure to store only 13 bytes, string 11, flag 1, carriage 1 */ //sprintf(test_string,"FACT_RESET_%d\n", flag); sprintf(test_string,"FACT_RESET_%d\n", (char)flag); /* END: 0014076 [email protected] 20110114 */ // } else { // kfree(test_string); // return -1; // } lge_mmc_scan_partitions(); pMisc_part = lge_mmc_find_partition_by_name("misc"); if ( pMisc_part == NULL ) { printk(KERN_INFO"NO MISC\n"); return 0; } factoryreset_bytes_pos_in_emmc = (pMisc_part->dfirstsec*512)+PTN_FRST_PERSIST_POSITION_IN_MISC_PARTITION; printk(KERN_INFO"writing block\n"); mtd_op_result = lge_write_block(factoryreset_bytes_pos_in_emmc, test_string, FACTORY_RESET_STR_SIZE+2); if ( mtd_op_result != (FACTORY_RESET_STR_SIZE+2) ) { printk(KERN_INFO"%s: write %u block fail\n", __func__, i); kfree(test_string); return err; } /* BEGIN: 0013860 [email protected] 20110111 */ /* ADD 0013860: [FACTORY RESET] ERI file save */ /* request rpc for eri file when the factory reset completes */ #ifdef CONFIG_LGE_ERI_DOWNLOAD if (flag == 5) { printk(KERN_INFO "%s, received flag : %ld, activate work queue\n", __func__, flag); eri_dload_data.flag = flag; queue_work(eri_dload_wq, &eri_dload_data.work); } #endif /* END: 0013860 [email protected] 20110111 */ printk(KERN_INFO"write %d block\n", i); kfree(test_string); return 0; }
void remote_did_rpc(void) { struct oem_rapi_client_streaming_func_arg arg; struct oem_rapi_client_streaming_func_ret ret; int rc= -1; char fs_err_buf[20]; const MmcPartition *pMisc_part; unsigned int did_bytes_pos_in_emmc ; int mtd_op_result ; printk(KERN_ERR "%s, start OEM_RAPI\n",__func__); Open_check(); arg.event = LG_FW_DID_BACKUP_REQUEST; arg.cb_func = NULL; arg.handle = (void*) 0; arg.in_len = sizeof(fs_err_buf); arg.input =fs_err_buf; arg.out_len_valid = 1; arg.output_valid = 1; arg.output_size = sizeof(pbuf_emmc); ret.output = NULL; ret.out_len = NULL; rc = oem_rapi_client_streaming_function(client,&arg,&ret); if(ret.output == NULL || ret.out_len == NULL){ printk(KERN_ERR "%s, output is NULL\n",__func__); return; } printk(KERN_ERR "%s, output lenght =%dis\n",__func__,*ret.out_len); memcpy((void *)&pbuf_emmc2[0], ret.output, 192); //form modem length =192 printk(KERN_ERR "%s, lge_mmc_scan_partitions\n",__func__); lge_mmc_scan_partitions(); pMisc_part = lge_mmc_find_partition_by_name("misc"); printk(KERN_ERR "%s, lge_mmc_find_partition_by_name\n",__func__); if (pMisc_part ==NULL) { if (ret.output) kfree(ret.output); if (ret.out_len) kfree(ret.out_len); return ; } did_bytes_pos_in_emmc = (pMisc_part->dfirstsec)*512+0x300000; memset((void *)pbuf_emmc, 0, sizeof(pbuf_emmc)); mtd_op_result = lge_read_block(did_bytes_pos_in_emmc, pbuf_emmc, 192); if(memcmp((void *)pbuf_emmc,(void *)pbuf_emmc2, sizeof(pbuf_emmc)) != 0) { lge_write_block(did_bytes_pos_in_emmc, pbuf_emmc2, 192); } if (ret.output) kfree(ret.output); if (ret.out_len) kfree(ret.out_len); return; }