int xlate_pro_disk_header(xlate_table_pro table, int standard_or_debug, Elf64_Xword * ototal_memory_req, Elf64_Xword * onum_blocks) { Uword total_memory_req = 0; Uword num_blocks = 0; int retstatus = XLATE_TB_STATUS_NO_ERROR; int tretstatus; if(table->tb_magic != PRO_MAGIC_VAL) { return XLATE_TB_STATUS_INVALID_TABLE; } /* Finish up any tentative output if present */ retstatus = _xlate_add_tentative_new_range(table,0, 0, 0, 0); if(retstatus != XLATE_TB_STATUS_NO_ERROR) { return retstatus; } table->tb_no_new_entries_allowed = 1; table->tb_std_header_returned = 0; table->tb_debug_header_returned = 0; table->tb_reginfoRet = 0; table->tb_header_set_to_std_or_debug = standard_or_debug; if(standard_or_debug == XLATE_PRO_STANDARD_SETUP) { table->tb_header_called_on_std = 1; table->tb_blockRet = table->tb_std_block_head; _xlate_final_update_highwater_addrs(table, table->tb_std_block_tail, &table->tb_std_highwater); /* determine if the output is empty */ if(table->tb_blockRet == 0 && table->tb_regInfoOffset == 0) { xlate_table_con contab = table->tb_con_table; if(contab) { if(contab->xc_hdr.ich_total_reginfo_bytes == 0) { /* No need to look at con_table translation ** bytes since there is no input range to ** merge them with. ** just check con table reginfo. */ *ototal_memory_req = 0; *onum_blocks = 0; return retstatus; } } else { *ototal_memory_req = 0; *onum_blocks = 0; return retstatus; } } } else if (standard_or_debug == XLATE_PRO_DEBUG_SETUP) { table->tb_header_called_on_debug = 1; table->tb_blockRet = table->tb_debug_block_head; /* determine if the output is empty */ if(table->tb_blockRet == 0 && table->tb_regInfoOffset == 0) { *ototal_memory_req = 0; *onum_blocks = 0; return retstatus; } _xlate_final_update_highwater_addrs(table, table->tb_debug_block_tail, &table->tb_debug_highwater); } else { retstatus = XLATE_TB_STATUS_PRO_REQ_INVALID; return retstatus; } /* do an initial call on each to get total size */ for(;;) { Elf64_Xword len; tretstatus = xlate_pro_disk_next_block(table, /*data=*/0, &len); if(tretstatus == XLATE_TB_STATUS_NO_ERROR) { total_memory_req += len; num_blocks += 1; continue; } else if (tretstatus == XLATE_TB_STATUS_ALREADY_DONE) { break; } /* major failure!? */ return tretstatus; } /* now reset for user to call for real. */ table->tb_no_new_entries_allowed = 1; table->tb_std_header_returned = 0; table->tb_debug_header_returned = 0; table->tb_reginfoRet = 0; table->tb_header_set_to_std_or_debug = standard_or_debug; if(standard_or_debug == XLATE_PRO_STANDARD_SETUP) { table->tb_header_called_on_std = 1; table->tb_blockRet = table->tb_std_block_head; } else if (standard_or_debug == XLATE_PRO_DEBUG_SETUP) { table->tb_header_called_on_debug = 1; table->tb_blockRet = table->tb_debug_block_head; } else { retstatus = XLATE_TB_STATUS_PRO_REQ_INVALID; return retstatus; } *ototal_memory_req = total_memory_req; *onum_blocks = num_blocks; return retstatus; }
int _xlate_pro_add_range_ps32(xlate_table_pro tab, Block_s **ppblk_head, Block_s **ppblk_tail, Elf64_Addr inew_addr, Elf64_Xword inew_range, Elf64_Addr iold_addr, Elf64_Xword iold_range, highwater_mark *highwater) { int retstatus = XLATE_TB_STATUS_NO_ERROR; Elf32_Addr new_addr = (Elf32_Addr)inew_addr; Elf32_Addr old_addr = (Elf32_Addr)iold_addr; Elf32_Word new_range = (Elf32_Addr)inew_range; Elf32_Word old_range = (Elf32_Addr)iold_range; Block_s *pblk_tail; char *range_buffer; Elf32_Word lnewaddr; Elf32_Sword loldaddr; int bufused; Uword byteoff; if(*ppblk_head == 0) { retstatus = do_blk_alloc(tab,ppblk_head,ppblk_tail, inew_addr,inew_range,iold_addr,iold_range); if(retstatus != XLATE_TB_STATUS_NO_ERROR) { return retstatus; } pblk_tail = *ppblk_tail; byteoff = pblk_tail->bk_next_data_to_use; range_buffer = pblk_tail->bk_data + byteoff; lnewaddr = (Elf32_Word)inew_range; loldaddr = 0; } else { pblk_tail = *ppblk_tail; if(inew_addr != (pblk_tail->bk_prev_new_addr + pblk_tail->bk_prev_new_range)) { return XLATE_TB_STATUS_INVALID_SEQUENCE; } byteoff = pblk_tail->bk_next_data_to_use; range_buffer = pblk_tail->bk_data + byteoff; lnewaddr = (Elf32_Word)inew_range; loldaddr = (Elf32_Sword) ((Elf32_Addr)old_addr - (Elf32_Addr)(pblk_tail->bk_prev_old_addr)); } if(inew_range != iold_range) { return XLATE_TB_STATUS_UNEQUAL_RANGE; } bufused = _leb128_unsigned_encode32(lnewaddr>>2,range_buffer); bufused += _leb128_signed_encode32(loldaddr>>2,range_buffer + bufused); if((bufused + byteoff) > TB_BLOCK_SIZE) { Block_s *newtail; char * lclbuf; /* Ran off end of desired area into slop area. */ _xlate_final_update_highwater_addrs(tab,pblk_tail,highwater); /* Get new block */ retstatus = do_blk_alloc(tab,ppblk_head,ppblk_tail, inew_addr,inew_range,iold_addr,iold_range); if(retstatus != XLATE_TB_STATUS_NO_ERROR) { return retstatus; } newtail = *ppblk_tail; lclbuf = newtail->bk_data; lnewaddr = (Elf32_Word)inew_range; loldaddr = 0; bufused = _leb128_unsigned_encode32(lnewaddr>>2,lclbuf); bufused += _leb128_signed_encode32(loldaddr>>2,lclbuf + bufused); newtail->bk_next_data_to_use += bufused; newtail->bk_numEntries++; } else {