]> git.proxmox.com Git - qemu.git/blobdiff - cris-dis.c
vnc: rename vnc-encoding-* vnc-enc-*
[qemu.git] / cris-dis.c
index 3b09f2767648ac76374842e23cb0ee00786091ec..455ba8af3f035ded982a84bfd193d4b3f3d1f208 100644 (file)
@@ -16,9 +16,7 @@
    more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
-   MA 02110-1301, USA.  */
+   along with this program; if not, see <http://www.gnu.org/licenses/>. */
 
 #include "dis-asm.h"
 //#include "sysdep.h"
@@ -26,8 +24,8 @@
 //#include "libiberty.h"
 \f
 
-#define FALSE 0
-#define TRUE 1
+void *qemu_malloc(size_t len); /* can't include qemu-common.h here */
+
 #define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0)
 
 /* cris-opc.c -- Table of opcodes for the CRIS processor.
@@ -49,8 +47,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
+along with this program; if not, see <http://www.gnu.org/licenses/>.  */
 
 #ifndef NULL
 #define NULL (0)
@@ -1321,7 +1318,7 @@ cris_parse_disassembler_options (disassemble_info *info,
   info->private_data = calloc (1, sizeof (struct cris_disasm_data));
   disdata = (struct cris_disasm_data *) info->private_data;
   if (disdata == NULL)
-    return FALSE;
+    return false;
 
   /* Default true.  */
   disdata->trace_case
@@ -1329,7 +1326,7 @@ cris_parse_disassembler_options (disassemble_info *info,
        || (strcmp (info->disassembler_options, "nocase") != 0));
 
   disdata->distype = distype;
-  return TRUE;
+  return true;
 }
 
 static const struct cris_spec_reg *
@@ -1401,44 +1398,32 @@ get_opcode_entry (unsigned int insn,
   /* Allocate and clear the opcode-table.  */
   if (opc_table == NULL)
     {
-      opc_table = malloc (65536 * sizeof (opc_table[0]));
-      if (opc_table == NULL)
-       return NULL;
+      opc_table = qemu_malloc (65536 * sizeof (opc_table[0]));
 
       memset (opc_table, 0, 65536 * sizeof (const struct cris_opcode *));
 
       dip_prefixes
-       = malloc (65536 * sizeof (const struct cris_opcode **));
-      if (dip_prefixes == NULL)
-       return NULL;
+       = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
 
       memset (dip_prefixes, 0, 65536 * sizeof (dip_prefixes[0]));
 
       bdapq_m1_prefixes
-       = malloc (65536 * sizeof (const struct cris_opcode **));
-      if (bdapq_m1_prefixes == NULL)
-       return NULL;
+       = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
 
       memset (bdapq_m1_prefixes, 0, 65536 * sizeof (bdapq_m1_prefixes[0]));
 
       bdapq_m2_prefixes
-       = malloc (65536 * sizeof (const struct cris_opcode **));
-      if (bdapq_m2_prefixes == NULL)
-       return NULL;
+       = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
 
       memset (bdapq_m2_prefixes, 0, 65536 * sizeof (bdapq_m2_prefixes[0]));
 
       bdapq_m4_prefixes
-       = malloc (65536 * sizeof (const struct cris_opcode **));
-      if (bdapq_m4_prefixes == NULL)
-       return NULL;
+       = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
 
       memset (bdapq_m4_prefixes, 0, 65536 * sizeof (bdapq_m4_prefixes[0]));
 
       rest_prefixes
-       = malloc (65536 * sizeof (const struct cris_opcode **));
-      if (rest_prefixes == NULL)
-       return NULL;
+       = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
 
       memset (rest_prefixes, 0, 65536 * sizeof (rest_prefixes[0]));
     }
@@ -2625,12 +2610,10 @@ print_insn_cris_generic (bfd_vma memaddr,
      If we can't get any data, or we do not get enough data, we print
      the error message.  */
 
-  for (nbytes = MAX_BYTES_PER_CRIS_INSN; nbytes > 0; nbytes -= 2)
-    {
-      status = (*info->read_memory_func) (memaddr, buffer, nbytes, info);
-      if (status == 0)
-       break;
-    }
+  nbytes = info->buffer_length;
+  if (nbytes > MAX_BYTES_PER_CRIS_INSN)
+         nbytes = MAX_BYTES_PER_CRIS_INSN;
+  status = (*info->read_memory_func) (memaddr, buffer, nbytes, info);  
 
   /* If we did not get all we asked for, then clear the rest.
      Hopefully this makes a reproducible result in case of errors.  */
@@ -2794,7 +2777,7 @@ print_insn_cris_with_register_prefix (bfd_vma vma,
   if (info->private_data == NULL
       && !cris_parse_disassembler_options (info, cris_dis_v0_v10))
     return -1;
-  return print_insn_cris_generic (vma, info, TRUE);
+  return print_insn_cris_generic (vma, info, true);
 }
 #endif
 /* Disassemble, prefixing register names with `$'.  CRIS v32.  */
@@ -2806,7 +2789,7 @@ print_insn_crisv32_with_register_prefix (bfd_vma vma,
   if (info->private_data == NULL
       && !cris_parse_disassembler_options (info, cris_dis_v32))
     return -1;
-  return print_insn_cris_generic (vma, info, TRUE);
+  return print_insn_cris_generic (vma, info, true);
 }
 
 #if 0
@@ -2820,7 +2803,7 @@ print_insn_crisv10_v32_with_register_prefix (bfd_vma vma,
   if (info->private_data == NULL
       && !cris_parse_disassembler_options (info, cris_dis_common_v10_v32))
     return -1;
-  return print_insn_cris_generic (vma, info, TRUE);
+  return print_insn_cris_generic (vma, info, true);
 }
 
 /* Disassemble, no prefixes on register names.  CRIS v0..v10.  */
@@ -2832,7 +2815,7 @@ print_insn_cris_without_register_prefix (bfd_vma vma,
   if (info->private_data == NULL
       && !cris_parse_disassembler_options (info, cris_dis_v0_v10))
     return -1;
-  return print_insn_cris_generic (vma, info, FALSE);
+  return print_insn_cris_generic (vma, info, false);
 }
 
 /* Disassemble, no prefixes on register names.  CRIS v32.  */
@@ -2844,7 +2827,7 @@ print_insn_crisv32_without_register_prefix (bfd_vma vma,
   if (info->private_data == NULL
       && !cris_parse_disassembler_options (info, cris_dis_v32))
     return -1;
-  return print_insn_cris_generic (vma, info, FALSE);
+  return print_insn_cris_generic (vma, info, false);
 }
 
 /* Disassemble, no prefixes on register names.
@@ -2857,7 +2840,7 @@ print_insn_crisv10_v32_without_register_prefix (bfd_vma vma,
   if (info->private_data == NULL
       && !cris_parse_disassembler_options (info, cris_dis_common_v10_v32))
     return -1;
-  return print_insn_cris_generic (vma, info, FALSE);
+  return print_insn_cris_generic (vma, info, false);
 }
 #endif