]> git.proxmox.com Git - mirror_qemu.git/blobdiff - disas/arm.c
linux-user: rename gettid() to sys_gettid() to avoid clash with glibc
[mirror_qemu.git] / disas / arm.c
index 70da5298a086610e0a1de5890d81c6fdc37d8e5e..17ea120b444833ac94cb43b560819cb24056fb77 100644 (file)
@@ -24,8 +24,6 @@
 
 #include "qemu/osdep.h"
 #include "disas/bfd.h"
-#define ATTRIBUTE_UNUSED __attribute__((unused))
-#define ISSPACE(x) ((x) == ' ' || (x) == '\t' || (x) == '\n')
 
 #define ARM_EXT_V1      0
 #define ARM_EXT_V2      0
@@ -72,16 +70,18 @@ static void floatformat_to_double (unsigned char *data, double *dest)
     *dest = u.f;
 }
 
-/* End of qemu specific additions.  */
+static int arm_read_memory(bfd_vma memaddr, bfd_byte *b, int length,
+                           struct disassemble_info *info)
+{
+    assert((info->flags & INSN_ARM_BE32) == 0 || length == 2 || length == 4);
 
-/* FIXME: Belongs in global header.  */
-#ifndef strneq
-#define strneq(a,b,n)  (strncmp ((a), (b), (n)) == 0)
-#endif
+    if ((info->flags & INSN_ARM_BE32) != 0 && length == 2) {
+        memaddr ^= 2;
+    }
+    return info->read_memory_func(memaddr, b, length, info);
+}
 
-#ifndef NUM_ELEM
-#define NUM_ELEM(a)     (sizeof (a) / sizeof (a)[0])
-#endif
+/* End of qemu specific additions.  */
 
 struct opcode32
 {
@@ -1077,7 +1077,7 @@ static const struct opcode32 arm_opcodes[] =
    %S                   print Thumb register (bits 3..5 as high number if bit 6 set)
    %D                   print Thumb register (bits 0..2 as high number if bit 7 set)
    %<bitfield>I         print bitfield as a signed decimal
-                               (top bit of range being the sign bit)
+                               (top bit of range being the sign bit)
    %N                   print Thumb register mask (with LR)
    %O                   print Thumb register mask (with PC)
    %M                   print Thumb register mask
@@ -1529,7 +1529,6 @@ static const char *const iwmmxt_cregnames[] =
 /* Default to GCC register name set.  */
 static unsigned int regname_selected = 1;
 
-#define NUM_ARM_REGNAMES  NUM_ELEM (regnames)
 #define arm_regnames      regnames[regname_selected].reg_names
 
 static bfd_boolean force_thumb = false;
@@ -1663,7 +1662,7 @@ print_insn_coprocessor (bfd_vma pc, struct disassemble_info *info, long given,
        }
       else
        {
-         /* Only match unconditional instuctions against unconditional
+          /* Only match unconditional instructions against unconditional
             patterns.  */
          if ((given & 0xf0000000) == 0xf0000000)
            {
@@ -1817,7 +1816,7 @@ print_insn_coprocessor (bfd_vma pc, struct disassemble_info *info, long given,
                          func (stream, "e");
                          break;
                        default:
-                         func (stream, _("<illegal precision>"));
+                         func (stream, "<illegal precision>");
                          break;
                        }
                      break;
@@ -3822,7 +3821,7 @@ find_ifthen_state (bfd_vma pc, struct disassemble_info *info,
          return;
        }
       addr -= 2;
-      status = info->read_memory_func (addr, (bfd_byte *)b, 2, info);
+      status = arm_read_memory (addr, (bfd_byte *)b, 2, info);
       if (status)
        return;
 
@@ -3894,7 +3893,7 @@ print_insn_arm (bfd_vma pc, struct disassemble_info *info)
       info->bytes_per_chunk = size;
       printer = print_insn_data;
 
-      status = info->read_memory_func (pc, (bfd_byte *)b, size, info);
+      status = arm_read_memory (pc, (bfd_byte *)b, size, info);
       given = 0;
       if (little)
        for (i = size - 1; i >= 0; i--)
@@ -3911,11 +3910,11 @@ print_insn_arm (bfd_vma pc, struct disassemble_info *info)
       info->bytes_per_chunk = 4;
       size = 4;
 
-      status = info->read_memory_func (pc, (bfd_byte *)b, 4, info);
+      status = arm_read_memory (pc, (bfd_byte *)b, 4, info);
       if (little)
-       given = (b[0]) | (b[1] << 8) | (b[2] << 16) | (b[3] << 24);
+       given = (b[0]) | (b[1] << 8) | (b[2] << 16) | ((unsigned)b[3] << 24);
       else
-       given = (b[3]) | (b[2] << 8) | (b[1] << 16) | (b[0] << 24);
+       given = (b[3]) | (b[2] << 8) | (b[1] << 16) | ((unsigned)b[0] << 24);
     }
   else
     {
@@ -3927,7 +3926,7 @@ print_insn_arm (bfd_vma pc, struct disassemble_info *info)
       info->bytes_per_chunk = 2;
       size = 2;
 
-      status = info->read_memory_func (pc, (bfd_byte *)b, 2, info);
+      status = arm_read_memory (pc, (bfd_byte *)b, 2, info);
       if (little)
        given = (b[0]) | (b[1] << 8);
       else
@@ -3941,7 +3940,7 @@ print_insn_arm (bfd_vma pc, struct disassemble_info *info)
              || (given & 0xF800) == 0xF000
              || (given & 0xF800) == 0xE800)
            {
-             status = info->read_memory_func (pc + 2, (bfd_byte *)b, 2, info);
+             status = arm_read_memory (pc + 2, (bfd_byte *)b, 2, info);
              if (little)
                given = (b[0]) | (b[1] << 8) | (given << 16);
              else