1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#include "qemu/osdep.h"
23#include "disas/dis-asm.h"
24#include "target/hexagon/cpu_bits.h"
25
26
27
28
29
30#define PACKET_BUFFER_LEN 1028
31
32int print_insn_hexagon(bfd_vma memaddr, struct disassemble_info *info)
33{
34 uint32_t words[PACKET_WORDS_MAX];
35 bool found_end = false;
36 GString *buf;
37 int i, len;
38
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);
43 if (status) {
44 if (i > 0) {
45 break;
46 }
47 (*info->memory_error_func)(status, memaddr, info);
48 return status;
49 }
50 if (is_packet_end(words[i])) {
51 found_end = true;
52 }
53 }
54
55 if (!found_end) {
56 (*info->fprintf_func)(info->stream, "<invalid>");
57 return PACKET_WORDS_MAX * sizeof(uint32_t);
58 }
59
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);
64
65 return len;
66}
67