Commit 95cbfc643dd8e0c4dd3690fbbbbc20f2a8af5998
1 parent
5898e816
changed disas() prototype for multi target support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@233 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
18 additions
and
13 deletions
disas.c
| @@ -92,8 +92,9 @@ bfd_vma bfd_getb32 (const bfd_byte *addr) | @@ -92,8 +92,9 @@ bfd_vma bfd_getb32 (const bfd_byte *addr) | ||
| 92 | return (bfd_vma) v; | 92 | return (bfd_vma) v; |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | -/* Disassemble this for me please... (debugging). */ | ||
| 96 | -void disas(FILE *out, void *code, unsigned long size, enum disas_type type) | 95 | +/* Disassemble this for me please... (debugging). 'flags' is only used |
| 96 | + for i386: non zero means 16 bit code */ | ||
| 97 | +void disas(FILE *out, void *code, unsigned long size, int is_host, int flags) | ||
| 97 | { | 98 | { |
| 98 | uint8_t *pc; | 99 | uint8_t *pc; |
| 99 | int count; | 100 | int count; |
| @@ -106,7 +107,7 @@ void disas(FILE *out, void *code, unsigned long size, enum disas_type type) | @@ -106,7 +107,7 @@ void disas(FILE *out, void *code, unsigned long size, enum disas_type type) | ||
| 106 | disasm_info.buffer_vma = (unsigned long)code; | 107 | disasm_info.buffer_vma = (unsigned long)code; |
| 107 | disasm_info.buffer_length = size; | 108 | disasm_info.buffer_length = size; |
| 108 | 109 | ||
| 109 | - if (type == DISAS_TARGET) { | 110 | + if (is_host) { |
| 110 | #ifdef WORDS_BIGENDIAN | 111 | #ifdef WORDS_BIGENDIAN |
| 111 | disasm_info.endian = BFD_ENDIAN_BIG; | 112 | disasm_info.endian = BFD_ENDIAN_BIG; |
| 112 | #else | 113 | #else |
| @@ -128,13 +129,23 @@ void disas(FILE *out, void *code, unsigned long size, enum disas_type type) | @@ -128,13 +129,23 @@ void disas(FILE *out, void *code, unsigned long size, enum disas_type type) | ||
| 128 | return; | 129 | return; |
| 129 | #endif | 130 | #endif |
| 130 | } else { | 131 | } else { |
| 131 | - /* Currently only source supported in x86. */ | 132 | +#ifdef TARGET_WORDS_BIGENDIAN |
| 133 | + disasm_info.endian = BFD_ENDIAN_BIG; | ||
| 134 | +#else | ||
| 132 | disasm_info.endian = BFD_ENDIAN_LITTLE; | 135 | disasm_info.endian = BFD_ENDIAN_LITTLE; |
| 133 | - if (type == DISAS_I386_I386) | 136 | +#endif |
| 137 | +#if defined(TARGET_I386) | ||
| 138 | + if (!flags) | ||
| 134 | disasm_info.mach = bfd_mach_i386_i386; | 139 | disasm_info.mach = bfd_mach_i386_i386; |
| 135 | else | 140 | else |
| 136 | disasm_info.mach = bfd_mach_i386_i8086; | 141 | disasm_info.mach = bfd_mach_i386_i8086; |
| 137 | print_insn = print_insn_i386; | 142 | print_insn = print_insn_i386; |
| 143 | +#elif defined(TARGET_ARM) | ||
| 144 | + print_insn = print_insn_arm; | ||
| 145 | +#else | ||
| 146 | + fprintf(out, "Asm output not supported on this arch\n"); | ||
| 147 | + return; | ||
| 148 | +#endif | ||
| 138 | } | 149 | } |
| 139 | 150 | ||
| 140 | for (pc = code; pc < (uint8_t *)code + size; pc += count) { | 151 | for (pc = code; pc < (uint8_t *)code + size; pc += count) { |
| @@ -142,7 +153,7 @@ void disas(FILE *out, void *code, unsigned long size, enum disas_type type) | @@ -142,7 +153,7 @@ void disas(FILE *out, void *code, unsigned long size, enum disas_type type) | ||
| 142 | #ifdef __arm__ | 153 | #ifdef __arm__ |
| 143 | /* since data are included in the code, it is better to | 154 | /* since data are included in the code, it is better to |
| 144 | display code data too */ | 155 | display code data too */ |
| 145 | - if (type == DISAS_TARGET) { | 156 | + if (is_host) { |
| 146 | fprintf(out, "%08x ", (int)bfd_getl32((const bfd_byte *)pc)); | 157 | fprintf(out, "%08x ", (int)bfd_getl32((const bfd_byte *)pc)); |
| 147 | } | 158 | } |
| 148 | #endif | 159 | #endif |
disas.h
| 1 | #ifndef _QEMU_DISAS_H | 1 | #ifndef _QEMU_DISAS_H |
| 2 | #define _QEMU_DISAS_H | 2 | #define _QEMU_DISAS_H |
| 3 | 3 | ||
| 4 | -enum disas_type { | ||
| 5 | - DISAS_I386_I386, | ||
| 6 | - DISAS_I386_I8086, | ||
| 7 | - DISAS_TARGET, /* whatever host is. */ | ||
| 8 | -}; | ||
| 9 | - | ||
| 10 | /* Disassemble this for me please... (debugging). */ | 4 | /* Disassemble this for me please... (debugging). */ |
| 11 | -void disas(FILE *out, void *code, unsigned long size, enum disas_type type); | 5 | +void disas(FILE *out, void *code, unsigned long size, int is_host, int flags); |
| 12 | 6 | ||
| 13 | /* Look up symbol for debugging purpose. Returns "" if unknown. */ | 7 | /* Look up symbol for debugging purpose. Returns "" if unknown. */ |
| 14 | const char *lookup_symbol(void *orig_addr); | 8 | const char *lookup_symbol(void *orig_addr); |