📄 tb.c
字号:
//cmp
dp_tmp1 = 0;
dp_tmp1 += dp_head_len;
dp_tmp1 += op_movl_Tx_reg_array_maxlen[0];
dp_tmp1 += op_subl_T0_T1_scv.len;
dp_tmp1 += op_setcpsr_nzcv_len;
if (dp_tmp1 > dp_len) {
dp_len = dp_tmp1;
}
TEA_OUT(printf("cmp insn's max len is %d\n", dp_tmp1 + tb_insn_len_max));
//cmn
dp_tmp1 = 0;
dp_tmp1 += dp_head_len;
dp_tmp1 += op_movl_Tx_reg_array_maxlen[0];
dp_tmp1 += op_addl_T0_T1_scv.len;
dp_tmp1 += op_setcpsr_nzcv_len;
if (dp_tmp1 > dp_len) {
dp_len = dp_tmp1;
}
TEA_OUT(printf("cmn insn's max len is %d\n", dp_tmp1 + tb_insn_len_max));
//orr
dp_tmp1 = 0;
dp_tmp1 += dp_head_len;
dp_tmp1 += op_movl_Tx_reg_array_maxlen[0];
dp_tmp1 += op_orrl_T0_T1.len;
dp_tmp1 += op_setcpsr_nzc_setreg_len;
if (dp_tmp1 > dp_len) {
dp_len = dp_tmp1;
}
TEA_OUT(printf("orr insn's max len is %d\n", dp_tmp1 + tb_insn_len_max));
//mov
dp_tmp1 = 0;
dp_tmp1 += dp_head_len;
dp_tmp1 += op_movl_T0_T1.len;
dp_tmp1 += op_setcpsr_nzc_setreg_len;
if (dp_tmp1 > dp_len) {
dp_len = dp_tmp1;
}
TEA_OUT(printf("mov insn's max len is %d\n", dp_tmp1 + tb_insn_len_max));
//bic
dp_tmp1 = 0;
dp_tmp1 += dp_head_len;
dp_tmp1 += op_movl_Tx_reg_array_maxlen[0];
dp_tmp1 += op_bicl_T0_T1.len;
dp_tmp1 += op_setcpsr_nzc_setreg_len;
if (dp_tmp1 > dp_len) {
dp_len = dp_tmp1;
}
TEA_OUT(printf("bic insn's max len is %d\n", dp_tmp1 + tb_insn_len_max));
//mvn
dp_tmp1 = 0;
dp_tmp1 += dp_head_len;
dp_tmp1 += op_notl_T0_T1.len;
dp_tmp1 += op_setcpsr_nzc_setreg_len;
if (dp_tmp1 > dp_len) {
dp_len = dp_tmp1;
}
TEA_OUT(printf("mvn insn's max len is %d\n", dp_tmp1 + tb_insn_len_max));
}
//other_len
{
int op_add_data_offset_len = 0, ldr_head_len = 0, str_head_len = 0;
int other_tmp1, other_tmp2;
//op_add_data_offset_len
op_add_data_offset_len += op_movl_Tx_reg_array_maxlen[2];
op_add_data_offset_len += op_shift_T2_im_maxlen;
op_add_data_offset_len += sizeof(uint8_t);
if (op_subl_T1_T2.len > op_addl_T1_T2.len) {
op_add_data_offset_len += op_subl_T1_T2.len;
}
else {
op_add_data_offset_len += op_addl_T1_T2.len;
}
if (op_addl_T1_im.len + sizeof(ARMword) > op_add_data_offset_len) {
op_add_data_offset_len = op_addl_T1_im.len + sizeof(ARMword);
}
//ldr_head_len str_head_len
ldr_head_len += op_movl_Tx_reg_array_maxlen[1];
ldr_head_len += op_add_data_offset_len;
ldr_head_len += op_movl_reg_Tx_array_maxlen[1];
//if (!state->is_XScale) {
if (state->abort_model > 1) {
ldr_head_len += op_test_dataabort_ret.len;
}
str_head_len = ldr_head_len;
ldr_head_len += op_movl_reg_Tx_array_maxlen[0];
//if (!state->is_XScale) {
if (state->abort_model > 1) {
ldr_head_len += op_test_dataabort.len;
}
str_head_len += op_movl_Tx_reg_array_maxlen[0];
//ldrh
other_tmp1 = ldr_head_len;
other_tmp1 += op_ldrh_T0_T1.len;
if (other_tmp1 > other_len) {
other_len = other_tmp1;
}
TEA_OUT(printf("ldrh insn's max len is %d\n", other_tmp1 + tb_insn_len_max));
//ldrsb
other_tmp1 = ldr_head_len;
other_tmp1 += op_ldrb_T0_T1.len;
other_tmp1 += op_signextend_byte_T0.len;
if (other_tmp1 > other_len) {
other_len = other_tmp1;
}
TEA_OUT(printf("ldrsb insn's max len is %d\n", other_tmp1 + tb_insn_len_max));
//ldrsh
other_tmp1 = ldr_head_len;
other_tmp1 += op_ldrh_T0_T1.len;
other_tmp1 += op_signextend_halfword_T0.len;
if (other_tmp1 > other_len) {
other_len = other_tmp1;
}
TEA_OUT(printf("ldrsh insn's max len is %d\n", other_tmp1 + tb_insn_len_max));
//ldrb
other_tmp1 = ldr_head_len;
other_tmp1 += op_ldrb_T0_T1.len;
if (other_tmp1 > other_len) {
other_len = other_tmp1;
}
TEA_OUT(printf("ldrb insn's max len is %d\n", other_tmp1 + tb_insn_len_max));
//ldr
other_tmp1 = ldr_head_len;
other_tmp1 += op_ldr_T0_T1.len;
if (other_tmp1 > other_len) {
other_len = other_tmp1;
}
TEA_OUT(printf("ldr insn's max len is %d\n", other_tmp1 + tb_insn_len_max));
//strh
other_tmp1 = str_head_len;
other_tmp1 += op_strh_T0_T1.len;
if (other_tmp1 > other_len) {
other_len = other_tmp1;
}
TEA_OUT(printf("strh insn's max len is %d\n", other_tmp1 + tb_insn_len_max));
//strb
other_tmp1 = str_head_len;
other_tmp1 += op_strb_T0_T1.len;
if (other_tmp1 > other_len) {
other_len = other_tmp1;
}
TEA_OUT(printf("strb insn's max len is %d\n", other_tmp1 + tb_insn_len_max));
//str
other_tmp1 = str_head_len;
other_tmp1 += op_str_T0_T1.len;
if (other_tmp1 > other_len) {
other_len = other_tmp1;
}
TEA_OUT(printf("str insn's max len is %d\n", other_tmp1 + tb_insn_len_max));
//mul
other_tmp1 = 0;
other_tmp1 += op_movl_Tx_reg_array_maxlen[0];
other_tmp1 += op_movl_Tx_reg_array_maxlen[1];
other_tmp1 += op_mul_T0_T1.len;
other_tmp1 += op_logic_T0_sn.len;
other_tmp1 += op_set_nf.len;
other_tmp1 += op_logic_T0_sz.len;
other_tmp1 += op_set_zf.len;
other_tmp1 += op_movl_reg_Tx_array_maxlen[0];
TEA_OUT(printf("mul insn's max len is %d\n", other_tmp1 + tb_insn_len_max));
//mla
other_tmp1 += op_movl_Tx_reg_array_maxlen[1];
other_tmp1 += op_addl_T0_T1.len;
if (other_tmp1 > other_len) {
other_len = other_tmp1;
}
TEA_OUT(printf("mla insn's max len is %d\n", other_tmp1 + tb_insn_len_max));
//mull
other_tmp1 = 0;
other_tmp1 += op_movl_Tx_reg_array_maxlen[0];
other_tmp1 += op_movl_Tx_reg_array_maxlen[1];
if (op_smull_T0_T1.len > op_umull_T0_T1.len) {
other_tmp1 += op_smull_T0_T1.len;
}
else {
other_tmp1 += op_umull_T0_T1.len;
}
other_tmp1 += op_movl_Tx_reg_array_maxlen[2];
other_tmp1 += op_movl_eax_T2.len;
other_tmp1 += op_movl_Tx_reg_array_maxlen[2];
other_tmp1 += op_addq_T0_T1_eax_T2.len;
other_tmp1 += op_logic_T0_sn.len;
other_tmp1 += op_set_nf.len;
other_tmp1 += op_logic_T0_sz.len;
other_tmp1 += op_set_zf.len;
other_tmp1 += op_movl_reg_Tx_array_maxlen[0];
other_tmp1 += op_movl_reg_Tx_array_maxlen[1];
if (other_tmp1 > other_len) {
other_len = other_tmp1;
}
TEA_OUT(printf("mull insn's max len is %d\n", other_tmp1 + tb_insn_len_max));
//swp
other_tmp1 = 0;
other_tmp1 += op_movl_Tx_reg_array_maxlen[0];
other_tmp1 += op_movl_Tx_reg_array_maxlen[1];
if (op_ldrb_T2_T1.len + op_strb_T0_T1.len > op_ldr_T2_T1.len + op_str_T0_T1.len) {
other_tmp1 += op_ldrb_T2_T1.len + op_strb_T0_T1.len;
}
else {
other_tmp1 += op_ldr_T2_T1.len + op_str_T0_T1.len;
}
other_tmp1 += op_movl_reg_Tx_array_maxlen[2];
if (other_tmp1 > other_len) {
other_len = other_tmp1;
}
TEA_OUT(printf("swp insn's max len is %d\n", other_tmp1 + tb_insn_len_max));
//insn_undef
other_tmp1 = 0;
other_tmp1 += op_movl_Tx_im[2].len + sizeof(ARMword) + op_movl_trap_T2.len;
if (other_tmp1 > other_len) {
other_len = other_tmp1;
}
TEA_OUT(printf("insn_undef insn's max len is %d\n", other_tmp1 + tb_insn_len_max));
//ldm stm
other_tmp1 = 0;
other_tmp1 += op_test_cpsr_ret_UNP.len;
other_tmp1 += op_movl_Tx_reg_array_maxlen[1];
other_tmp1 += op_movl_Tx_im[2].len + sizeof(ARMword) + op_movl_trap_T2.len;
other_tmp1 += op_addl_T1_im.len + sizeof(ARMword);
other_tmp1 += op_movl_Tx_im[0].len + sizeof(ARMword);
other_tmp2 = op_ldm_user_T1_T0.len;
if (op_ldm_T1_T0.len > other_tmp2) {
other_tmp2 = op_ldm_T1_T0.len;
}
if (op_stm_user_T1_T0.len > other_tmp2) {
other_tmp2 = op_stm_user_T1_T0.len;
}
if (op_stm_T1_T0.len > other_tmp2) {
other_tmp2 = op_stm_T1_T0.len;
}
other_tmp1 += other_tmp2;
//if (!state->is_XScale) {
if (state->abort_model > 1) {
ldr_head_len += op_test_dataabort.len;
}
other_tmp1 += op_addl_T1_im.len + sizeof(ARMword);
other_tmp1 += op_movl_reg_Tx_array_maxlen[1];
//if (!state->is_XScale) {
if (state->abort_model > 1) {
ldr_head_len += op_test_dataabort_ret.len;
}
if (other_tmp1 > other_len) {
other_len = other_tmp1;
}
TEA_OUT(printf("ldm stm insn's max len is %d\n", other_tmp1 + tb_insn_len_max));
//b
other_tmp1 = 0;
other_tmp1 += op_b_offset.len + sizeof(ARMword);
if (other_tmp1 > other_len) {
other_len = other_tmp1;
}
TEA_OUT(printf("b insn's max len is %d\n", other_tmp1 + tb_insn_len_max));
//bl
other_tmp1 = 0;
other_tmp1 += op_bl_offset.len + sizeof(ARMword);
if (other_tmp1 > other_len) {
other_len = other_tmp1;
}
TEA_OUT(printf("bl insn's max len is %d\n", other_tmp1 + tb_insn_len_max));
//ldc stc
other_tmp1 = 0;
other_tmp1 += op_movl_Tx_reg_array_maxlen[1];
other_tmp1 += op_addl_T1_im.len + sizeof(ARMword);
other_tmp1 += op_movl_Tx_im[0].len + sizeof(ARMword);
if (op_ldc_T0_T1.len > op_stc_T0_T1.len) {
other_tmp1 += op_ldc_T0_T1.len;
}
else {
other_tmp1 += op_stc_T0_T1.len;
}
other_tmp1 += op_movl_reg_Tx_array_maxlen[1];
if (other_tmp1 > other_len) {
other_len = other_tmp1;
}
TEA_OUT(printf("ldc stc insn's max len is %d\n", other_tmp1 + tb_insn_len_max));
//mrc
other_tmp1 = 0;
other_tmp1 += op_movl_Tx_im[0].len + sizeof(ARMword);
other_tmp1 += op_movl_Tx_im[1].len + sizeof(ARMword);
other_tmp1 += op_mrc_T0_T1.len;
if (other_tmp1 > other_len) {
other_len = other_tmp1;
}
TEA_OUT(printf("mrc insn's max len is %d\n", other_tmp1 + tb_insn_len_max));
//mcr
other_tmp1 = 0;
other_tmp1 += op_movl_Tx_im[0].len + sizeof(ARMword);
other_tmp1 += op_movl_Tx_im[1].len + sizeof(ARMword);
other_tmp1 += op_mcr_T0_T1.len;
if (other_tmp1 > other_len) {
other_len = other_tmp1;
}
TEA_OUT(printf("mcr insn's max len is %d\n", other_tmp1 + tb_insn_len_max));
//cdp
other_tmp1 = 0;
other_tmp1 += op_movl_Tx_im[0].len + sizeof(ARMword);
other_tmp1 += op_movl_Tx_im[1].len + sizeof(ARMword);
other_tmp1 += op_cdp_T0_T1.len;
if (other_tmp1 > other_len) {
other_len = other_tmp1;
}
TEA_OUT(printf("cdp insn's max len is %d\n", other_tmp1 + tb_insn_len_max));
//swi
other_tmp1 = 0;
other_tmp1 += op_movl_Tx_im[2].len + sizeof(ARMword) + op_movl_trap_T2.len;
if (other_tmp1 > other_len) {
other_len = other_tmp1;
}
TEA_OUT(printf("swi insn's max len is %d\n", other_tmp1 + tb_insn_len_max));
}
if (dp_len > other_len) {
tb_insn_len_max += dp_len;
}
else {
tb_insn_len_max += other_len;
}
TEA_OUT(printf("tb_insn_len_max is %d\n", tb_insn_len_max));
return(0);
}
//teawater add for new tb manage function 2005.07.10----------------------------
int
tb_memory_init(ARMul_State * state)
{
int i;
uint32_t tmp_u32;
mem_bank_t *mbp;
//tbt
if (TB_TBT_SIZE) {
//get align tbt size
TB_TBT_SIZE = ALIGN(TB_TBT_SIZE, sizeof(tb_cache_t));
if (TB_TBT_SIZE < sizeof(tb_cache_t)) {
fprintf(stderr, "SKYEYE: tb_memory_init: TB_TBT_SIZE %u is too little.\n", (unsigned int)TB_TBT_SIZE);
return(-1);
}
//get tbt max size
tmp_u32 = 0;
for(i = 0;i < skyeye_config.mem.current_num; i++){
tmp_u32 += skyeye_config.mem.mem_banks[i].len;
}
tmp_u32 = tmp_u32 / TB_LEN * sizeof(tb_cache_t);
if (TB_TBT_SIZE >= tmp_u32) {
//if set size >= max size, use the simple function
TB_TBT_SIZE = 0;
}
else {
//get mem by TB_TBT_SIZE
tbt_table = (tb_t *)malloc(TB_TBT_SIZE);
if (!tbt_table) {
fprintf(stderr, "SKYEYE: tb_memory_init: Error allocating mem.\n");
return(-1);
}
memset(tbt_table, 0, TB_TBT_SIZE);
tbt_table_size = TB_TBT_SIZE / sizeof(tb_cache_t);
}
}
//tbp
if (TB_TBP_SIZE) {
//get align tbp size
TB_TBP_SIZE = ALIGN(TB_TBP_SIZE, TB_TBP_MAX);
if (TB_TBP_SIZE < TB_TBP_MAX) {
fprintf(stderr, "SKYEYE: tb_memory_init: TB_TBP_SIZE %u is too little.\n", (unsigned int)TB_TBP_SIZE);
return(-1);
}
}
if (TB_TBT_SIZE) {
//get tbp max size
tmp_u32 = tbt_table_size * TB_LEN / sizeof(ARMword) * TB_INSN_LEN_MAX + tbt_table_size * op_return.len;
if (TB_TBP_SIZE == 0 || TB_TBP_SIZE > tmp_u32) {
TB_TBP_SIZE = tmp_u32;
}
else {
tbp_dynamic = 1;
}
}
else {
if (TB_TBP_SIZE) {
//get tbp max size
tmp_u32 = 0;
for(i = 0;i < skyeye_config.mem.current_num; i++){
tmp_u32 += skyeye_config.mem.mem_banks[i].len;
}
tmp_u32 = tmp_u32 / sizeof(ARMword) * TB_INSN_LEN_MAX + tmp_u32 / TB_LEN * op_return.len;
if (TB_TBP_SIZE >= tmp_u32) {
//if set size >= max size, use the simple function
TB_TBP_SIZE = 0;
}
else {
tbp_dynamic = 1;
}
}
}
if (TB_TBP_SIZE) {
//get mem by TB_TBP_SIZE
tbp_begin = mmap(NULL, TB_TBP_SIZE, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
if (tbp_begin == MAP_FAILED) {
fprintf(stderr, "SKYEYE: tb_memory_init: Error allocating mem.\n");
return(-1);
}
tbp_now_size = TB_TBP_SIZE;
tbp_now = tbp_begin;
}
if (TB_TBT_SIZE) {
printf("dbct translate block entry use memory 0x%08x bytes.\n", TB_TBT_SIZE);
}
if (TB_TBP_SIZE) {
printf("dbct translate block use memory 0x%08x bytes.\n", TB_TBP_SIZE);
}
return(0);
}
//AJ2D--------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -