21 return ((parse_bits == 0x3) || (parse_bits == 0x0));
33 return ((pb_hi_0 == 0x2) && ((pb_hi_1 == 0x1) || (pb_hi_1 == 0x3)));
46 return ((pb_hi_0 == 0x2) && (pb_hi_1 == 0x0));
58 return ((pb_hi_0 == 0x1) && (pb_hi_1 == 0x2));
70 return ((pb_hi_0 == 0x2) && (pb_hi_1 == 0x2));
86 rz_list_foreach (
p->insn,
iter, pi) {
109 rz_list_foreach (
p->insn, it,
hi) {
124 p->last_instr_present =
false;
141 if (
state->pkts[
i].last_access < oldest) {
142 stale_state_pkt = &
state->pkts[
i];
145 return stale_state_pkt;
161 rz_list_foreach (
p->insn,
iter, pi) {
205 if (
sp->pkt_addr ==
p->pkt_addr) {
225 RZ_LOG_FATAL(
"Could not allocate memory for HexState!");
229 if (!
state->pkts[
i].insn) {
373 bool is_first = (
k == 0);
391 }
else if (is_first) {
433 if (update_mnemonic) {
484 if (
p->pkt_addr == pkt_addr) {
492 rz_list_foreach (
p->insn, it,
hi) {
510 RZ_LOG_FATAL(
"Could not allocate memory for new instruction.\n");
527 RZ_LOG_FATAL(
"Instruction could not be set! A packet can only hold four instructions but k=%d.",
k);
534 p->pkt_addr =
hi->addr;
539 if (
k == 0 && p_l > 1) {
544 if (
p->last_instr_present) {
567 new_p->hw_loop0_addr =
p->hw_loop0_addr;
568 new_p->hw_loop1_addr =
p->hw_loop1_addr;
569 new_p->is_valid = (
p->is_valid ||
p->last_instr_present);
570 new_p->pkt_addr =
hi->addr;
573 if (new_p->last_instr_present) {
595 p->pkt_addr = new_ins->
addr;
599 if (
p->last_instr_present) {
619 bool add_to_pkt =
false;
620 bool new_pkt =
false;
621 bool write_to_stale_pkt =
false;
622 bool insert_before_pkt_hi =
false;
626 if (new_ins->
addr == 0x0) {
635 rz_list_foreach (
p->insn,
iter, pkt_instr) {
636 if (new_ins->
addr == (pkt_instr->
addr - 4)) {
639 write_to_stale_pkt =
true;
642 insert_before_pkt_hi =
true;
646 }
else if (new_ins->
addr == (pkt_instr->
addr + 4)) {
657 if (add_to_pkt || new_pkt || write_to_stale_pkt) {
664 if (insert_before_pkt_hi) {
669 }
else if (new_pkt) {
688 hi->parse_bits = parse_bits;
697 for (
ut8 i = 0;
i < 6; ++
i) {
722 rz_list_foreach (ce_list,
iter, ce) {
748 if (set_new_extender) {
783 switch (rz_reverse->
action) {
804 ut8 parse_bits = (data & 0x0000c000) >> 14;
817 switch (rz_reverse->
action) {
RZ_API RZ_OWN RzAsmTokenString * rz_asm_tokenize_asm_regex(RZ_BORROW RzStrBuf *asm_str, RzPVector *patterns)
Splits an asm string into tokens by using the given regex patterns.
RZ_API bool rz_config_get_b(RzConfig *cfg, RZ_NONNULL const char *name)
unsigned short prefix[65536]
int hexagon_disasm_instruction(HexState *state, const ut32 hi_u32, RZ_INOUT HexInsn *hi, HexPkt *pkt)
#define HEXAGON_STATE_PKTS
RZ_API void hex_insn_free(RZ_NULLABLE HexInsn *i)
Frees an instruction.
RZ_API void hex_const_ext_free(RZ_NULLABLE HexConstExt *ce)
Frees an constant extender.
static HexPkt * hex_get_pkt(HexState *state, const ut32 addr)
Returns the packet which covers the given address.
static HexInsn * hex_get_instr_at_addr(HexState *state, const ut32 addr)
Gives the instruction at a given address from the state.
RZ_API HexLoopAttr hex_get_loop_flag(const HexPkt *p)
Returns the loop type of a packet. Though only if this packet is the last packet in last packet in a ...
static bool is_endloop0_pkt(const ut8 pb_hi_0, const ut8 pb_hi_1)
Checks if packet ends hardware loop 0.
RZ_API void hexagon_reverse_opcode(const RzAsm *rz_asm, HexReversedOpcode *rz_reverse, const ut8 *buf, const ut64 addr)
Reverses a given opcode and copies the result into one of the rizin structs in rz_reverse.
static HexPkt * hex_get_stale_pkt(HexState *state)
Gives the least used packet.
static char * get_pkt_indicator(const bool utf8, const bool sdk, const bool prefix, HexPktSyntaxIndicator ind_type)
Get the pkt indicator string.
RZ_API ut8 hexagon_get_pkt_index_of_addr(const ut32 addr, const HexPkt *p)
Returns the index of an addr in a given packet.
static ut8 get_state_pkt_index(HexState *state, const HexPkt *p)
Get the index of a packet in the state.
static bool is_endloop1_pkt(const ut8 pb_hi_0, const ut8 pb_hi_1)
Checks if packet ends hardware loop 1.
static void hex_clear_pkt(RZ_NONNULL HexPkt *p)
Clears a packet and sets its attributes to invalid values.
RZ_API HexInsn * alloc_instr()
Allocates a new instruction on the heap.
static void hex_set_pkt_info(const RzAsm *rz_asm, RZ_INOUT HexInsn *hi, const HexPkt *p, const ut8 k, const bool update_mnemonic)
Sets the packet related information in an instruction.
static HexInsn * hex_add_to_pkt(HexState *state, const HexInsn *new_ins, RZ_INOUT HexPkt *p, const ut8 k)
Copies an instruction to the packet p at position k.
static void make_next_packet_valid(HexState *state, const HexPkt *pkt)
Sets the packet after pkt to valid and updates its mnemonic.
RZ_API HexState * hexagon_get_state()
Initializes each packet of the state once.
static bool is_pkt_full(const HexPkt *p)
Checks if the packet has 4 instructions set.
static bool is_endloop01_pkt(const ut8 pb_hi_0, const ut8 pb_hi_1)
Checks if packet ends hardware loop 0 and hw-loop 1.
static HexInsn * hex_to_new_pkt(HexState *state, const HexInsn *new_ins, const HexPkt *p, RZ_INOUT HexPkt *new_p)
Cleans the packet new_p, copies the instruction new_ins and the attributes of p to it.
RZ_API void hex_extend_op(HexState *state, RZ_INOUT HexOp *op, const bool set_new_extender, const ut32 addr)
Applies the constant extender to the immediate value in op.
static HexInsn * hex_add_instr_to_state(HexState *state, const HexInsn *new_ins)
Copies the given instruction to a state packet it belongs to. If the instruction does not fit to any ...
static HexConstExt * get_const_ext_from_addr(const RzList *ce_list, const ut32 addr)
Searched the constant extender in the ce_list, where addr is the key.
static bool is_last_instr(const ut8 parse_bits)
static void setup_new_instr(HexInsn *hi, const HexReversedOpcode *rz_reverse, const ut32 addr, const ut8 parse_bits)
Set the up new instr.
static bool is_undoc_endloop0_pkt(const ut8 pb_hi_0, const ut8 pb_hi_1)
Checks if packet ends hardware loop 0. But for an undocumented variant where the packet has only two ...
static bool imm_is_scaled(const HexOpAttr attr)
static HexInsn * hex_add_to_stale_pkt(HexState *state, const HexInsn *new_ins)
Cleans the least accessed packet and copies the given instruction into it.
#define HEX_PKT_ELOOP_01_UTF8
#define HEX_PKT_SINGLE_UTF8
#define HEX_PKT_ELOOP_0_UTF8
#define HEX_PKT_ELOOP_1_SDK
#define HEX_PKT_LAST_UTF8
#define HEX_PKT_FIRST_UTF8
#define HEX_PKT_SDK_PADDING
#define HEX_PKT_ELOOP_0_SDK
#define HEX_PKT_ELOOP_1_UTF8
#define HEX_PKT_FIRST_SDK
#define HEX_PKT_ELOOP_01_SDK
RZ_API void Ht_() free(HtName_(Ht) *ht)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
RZ_API RZ_BORROW RzListIter * rz_list_insert(RZ_NONNULL RzList *list, ut32 n, void *data)
Inserts a new element at the N-th position.
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
RZ_API bool rz_list_delete_data(RZ_NONNULL RzList *list, void *ptr)
Deletes an entry in the list by searching for a pointer.
RZ_API RZ_BORROW void * rz_list_get_top(RZ_NONNULL const RzList *list)
Returns the last element of the list.
RZ_API RZ_BORROW void * rz_list_get_n(RZ_NONNULL const RzList *list, ut32 n)
Returns the N-th element of the list.
RZ_API ut32 rz_list_length(RZ_NONNULL const RzList *list)
Returns the length of the list.
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
RZ_API void rz_list_purge(RZ_NONNULL RzList *list)
Empties the list without freeing the list pointer.
void * calloc(size_t number, size_t size)
#define rz_return_if_fail(expr)
#define rz_return_val_if_fail(expr, val)
static ut32 rz_read_le32(const void *src)
void(* RzListFree)(void *ptr)
#define RZ_LOG_VERBOSE(fmtstr,...)
#define RZ_LOG_FATAL(fmtstr,...)
RZ_API const char * rz_strbuf_set(RzStrBuf *sb, const char *s)
RZ_API ut64 rz_time_now(void)
Returns the current time in microseconds.
Pointer to the rizin structs for disassembled and analysed instructions.
Buffer packets for reversed instructions.
ut32 op_type
RzAnalysisOpType. Mnemonic color depends on this.
RzAsmTokenString * asm_toks
Tokenized asm string.
ut64(WINAPI *w32_GetEnabledXStateFeatures)()