2 * Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
19 * QEMU Hexagon Disassembler
22 #include "qemu/osdep.h"
23 #include "disas/dis-asm.h"
24 #include "target/hexagon/cpu_bits.h"
27 * We will disassemble a packet with up to 4 instructions, so we need
28 * a hefty size buffer.
30 #define PACKET_BUFFER_LEN 1028
32 int print_insn_hexagon(bfd_vma memaddr
, struct disassemble_info
*info
)
34 uint32_t words
[PACKET_WORDS_MAX
];
35 bool found_end
= false;
39 for (i
= 0; i
< PACKET_WORDS_MAX
&& !found_end
; i
++) {
40 int status
= (*info
->read_memory_func
)(memaddr
+ i
* sizeof(uint32_t),
41 (bfd_byte
*)&words
[i
],
42 sizeof(uint32_t), info
);
47 (*info
->memory_error_func
)(status
, memaddr
, info
);
50 if (is_packet_end(words
[i
])) {
56 (*info
->fprintf_func
)(info
->stream
, "<invalid>");
57 return PACKET_WORDS_MAX
* sizeof(uint32_t);
60 buf
= g_string_sized_new(PACKET_BUFFER_LEN
);
61 len
= disassemble_hexagon(words
, i
, memaddr
, buf
);
62 (*info
->fprintf_func
)(info
->stream
, "%s", buf
->str
);
63 g_string_free(buf
, true);