diff -Naur gdb-7.2.orig/config.sub gdb-7.2/config.sub
--- gdb-7.2.orig/config.sub	2011-02-11 14:53:29.636165776 -0500
+++ gdb-7.2/config.sub	2011-02-11 14:55:32.647412584 -0500
@@ -276,6 +276,7 @@
 	| mipsisa32r2 | mipsisa32r2el \
 	| mipsisa64 | mipsisa64el \
 	| mipsisa64r2 | mipsisa64r2el \
+	| mipsisa64r2nlm \
 	| mipsisa64sb1 | mipsisa64sb1el \
 	| mipsisa64sr71k | mipsisa64sr71kel \
 	| mipstx39 | mipstx39el \
@@ -372,6 +373,7 @@
 	| mipsisa32r2-* | mipsisa32r2el-* \
 	| mipsisa64-* | mipsisa64el-* \
 	| mipsisa64r2-* | mipsisa64r2el-* \
+	| mipsisa64r2nlm-* | mipsisa64r2-nlm-* \
 	| mipsisa64sb1-* | mipsisa64sb1el-* \
 	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
 	| mipstx39-* | mipstx39el-* \
@@ -1454,6 +1456,8 @@
 	        ;;
 	-none)
 		;;
+	-ejtag)
+		;;
 	*)
 		# Get rid of the `-' at the beginning of $os.
 		os=`echo $os | sed 's/[^-]*-//'`
diff -Naur gdb-7.2.orig/gdb/gdbserver/configure.srv gdb-7.2/gdb/gdbserver/configure.srv
--- gdb-7.2.orig/gdb/gdbserver/configure.srv	2011-02-11 14:53:29.087414512 -0500
+++ gdb-7.2/gdb/gdbserver/configure.srv	2011-02-11 14:55:32.647412584 -0500
@@ -142,6 +142,14 @@
 			srv_linux_regsets=yes
 			srv_linux_thread_db=yes
 			;;
+  mipsisa64r2-nlm-ejtag)
+			srv_regobj="mips64-linux.o"
+			srv_tgtobj="ejtag-mips64-low.o"
+			srv_xmlfiles="mips64-linux.xml"
+			srv_xmlfiles="${srv_xmlfiles} mips64-cpu.xml"
+			srv_xmlfiles="${srv_xmlfiles} mips64-cp0.xml"
+			srv_xmlfiles="${srv_xmlfiles} mips64-fpu.xml"
+			;;
   mips*-*-linux*)	srv_regobj="mips-linux.o mips64-linux.o"
 			srv_tgtobj="linux-low.o linux-mips-low.o"
 			srv_xmlfiles="mips-linux.xml"
diff -Naur gdb-7.2.orig/gdb/gdbserver/cpumask.h gdb-7.2/gdb/gdbserver/cpumask.h
--- gdb-7.2.orig/gdb/gdbserver/cpumask.h	1969-12-31 19:00:00.000000000 -0500
+++ gdb-7.2/gdb/gdbserver/cpumask.h	2011-02-11 14:55:32.647412584 -0500
@@ -0,0 +1,140 @@
+/*************************************************************************
+ Copyright 2003-2010 Netlogic Microsystems ("Netlogic"). All rights
+ reserved.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ 1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution.
+ THIS SOFTWARE IS PROVIDED BY Netlogic Microsystems ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ THE POSSIBILITY OF SUCH DAMAGE.
+*******************************#NETL_2#**********************************/
+#ifndef __CPUMASK_H__
+#define __CPUMASK_H__
+
+#define CPUMASK_ABSOLUTE_MAX_CPUS 32
+
+typedef unsigned long cpumask_t;
+
+#ifdef CPUMASK_MAX_CPUS
+  #if CPUMASK_MAX_CPUS > CPUMASK_ABSOLUTE_MAX_CPUS
+    #warning CPUMASK_MAX_CPUS must be <= 32
+    #undef CPUMASK_MAX_CPUS
+    #define CPUMASK_MAX_CPUS CPUMASK_ABSOLUTE_MAX_CPUS
+  #endif
+#else
+  #define CPUMASK_MAX_CPUS CPUMASK_ABSOLUTE_MAX_CPUS
+#endif
+
+static inline void
+cpumask_set_cpu (cpumask_t *mask, int cpu)
+{
+  *mask = *mask | (1 << cpu);
+}
+
+static inline int
+cpumask_isset_cpu (cpumask_t mask, int cpu)
+{
+  return (mask & (1 << cpu));
+}
+
+static inline void
+cpumask_clear_cpu (cpumask_t *mask, int cpu)
+{
+  *mask = *mask & ~(1 << cpu);
+}
+
+static inline cpumask_t
+cpumask_only_cpu (int cpu)
+{
+  return (1 << cpu);
+}
+
+static inline cpumask_t
+cpumask_all_except_cpu (int cpu)
+{
+  return ~(1 << cpu);
+}
+
+static inline void
+cpumask_clear_all (cpumask_t *mask)
+{
+  *mask = 0;
+}
+
+static inline int
+cpumask_none (cpumask_t mask)
+{
+  return (mask == 0);
+}
+
+static inline void
+cpumask_assign (cpumask_t *dst, cpumask_t src)
+{
+  *dst = src;
+}
+
+static inline cpumask_t
+cpumask_inverse (cpumask_t mask)
+{
+  return ~mask;
+}
+
+static inline cpumask_t
+cpumask_or (cpumask_t mask1, cpumask_t mask2)
+{
+  return (mask1 | mask2);
+}
+
+static inline cpumask_t
+cpumask_and (cpumask_t mask1, cpumask_t mask2)
+{
+  return (mask1 & mask2);
+}
+
+static inline cpumask_t
+cpumask_xor (cpumask_t mask1, cpumask_t mask2)
+{
+  return (mask1 ^ mask2);
+}
+
+static inline int
+get_next_cpu (cpumask_t cpumask, int start_cpu)
+{
+  if (cpumask == 0)
+    return -1;
+
+  if (start_cpu < 0)
+    start_cpu = 0;
+
+  int cpu;
+
+  /* Start looking from the specified point. */
+  for (cpu = start_cpu; cpu < CPUMASK_MAX_CPUS; cpu++)
+    if (cpumask & (1 << cpu))
+      return cpu;
+
+  /* Wraparound and start looking from the beginning. */
+  for (cpu = 0; cpu < start_cpu && cpu < CPUMASK_MAX_CPUS; cpu++)
+    if (cpumask & (1 << cpu))
+      return cpu;
+
+  /* Since we've checked that cpumask is non-empty,
+     we must have found a match in one of the two for-loops above. */
+  return -1;
+}
+
+#endif /* __CPUMASK_H__ */
diff -Naur gdb-7.2.orig/gdb/gdbserver/ejtag-mips64-low.c gdb-7.2/gdb/gdbserver/ejtag-mips64-low.c
--- gdb-7.2.orig/gdb/gdbserver/ejtag-mips64-low.c	1969-12-31 19:00:00.000000000 -0500
+++ gdb-7.2/gdb/gdbserver/ejtag-mips64-low.c	2011-02-11 14:55:32.656163114 -0500
@@ -0,0 +1,2394 @@
+/*************************************************************************
+ Copyright 2003-2010 Netlogic Microsystems ("Netlogic"). All rights
+ reserved.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ 1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution.
+ THIS SOFTWARE IS PROVIDED BY Netlogic Microsystems ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ THE POSSIBILITY OF SUCH DAMAGE.
+*******************************#NETL_2#**********************************/
+/* Low level interface to EJTAG, for GDB remote server.
+   Copyright (C) 2010 NetLogic Microsystems, Inc. */
+
+#include <assert.h>
+#include "server.h"
+#include "libdbgrtool.h"
+#define NUM_STD_REGS  MAX_CPU_STD_REGS
+
+#define MAX_CPUS 32
+#define CPUMASK_MAX_CPUS (MAX_CPUS)
+#include "cpumask.h"
+
+#if defined(SUPPORT_FLASHLIB)
+#include "dsa_flashif.h"
+#endif /* if defined(SUPPORT_FLASHLIB) */
+
+const char *p_cmd_completed           = "Command Completed";
+const char *p_cmd_failed              = "Command Failed";
+const char *p_cmd_unsupported         = "Command Unsupported";
+const char *p_cmd_already_installed   = "Remove Before Re-install";
+const char *p_cmd_non_existent        = "Handler Not Present";
+const char *p_cmd_not_serviced        = "DM Not Serviced";
+const char *p_cmd_chk_cli             = "Check Command Line";
+const char *p_cmd_chk_args_count      = "Check Args Count";
+const char *p_cmd_chk_args_values     = "Check Args Values";
+const char *p_cmd_chk_outparam_ptr    = "Check Outparam Ptr";
+const char *p_cmd_err_unknown         = "Unknown Error";
+const char *p_cmd_chk_cpu_specified   = "Check Specified CPU";
+const char *p_cmd_chk_index_range     = "Index Beyond Range";
+const char *p_cmd_chk_index_limit     = "Index Beyond Limit";
+const char *p_cmd_chk_num_opcodes     = "Check Num Opcodes";
+const char *p_cmd_chk_num_inparams    = "Check Num Inparams";
+const char *p_cmd_chk_num_outparams   = "Check Num Outparams";
+const char *p_cmd_chk_inparams_array  = "Check Inparams Array";
+const char *p_cmd_chk_outparams_array = "Check Outparams Array";
+
+static cpumask_t all_cpumask;
+static cpumask_t stop_cpumask;
+static cpumask_t dmcpumask;
+
+#define BAD_CPUID -9999
+
+#define CPUID_OFFSET 1000
+#define CPUID_TO_GDBTID(cpu) ((cpu) + CPUID_OFFSET)
+#define GDBTID_TO_CPUID(tid) ((tid) - CPUID_OFFSET)
+
+static inline int
+get_cpuid_from_thread (struct thread_info *inf)
+{
+  int tid;
+  if (inf == NULL)
+    return BAD_CPUID;
+
+  tid = ptid_get_lwp (((struct inferior_list_entry *) inf)->id);
+  return GDBTID_TO_CPUID (tid);
+}
+
+static int debug = 0;
+#define dprintf(args...) \
+  if (debug)             \
+    fprintf (args)
+
+#define is_valid_cpuid(cpu) ((cpu) >= 0 || (cpu) < MAX_CPUS)
+
+#define set_and_check_cpuid(cpu, inf, ret)                        \
+  do {                                                            \
+    cpu = get_cpuid_from_thread (inf);                            \
+    if (!is_valid_cpuid (cpu))                                    \
+      {                                                           \
+        dprintf (stderr, "%s invalid cpuid %d\n", __func__, cpu); \
+        ret;                                                      \
+      }                                                           \
+  } while (0)
+
+static int ejtag_debug = 0;
+#define edprintf(args...) \
+  if (ejtag_debug)        \
+    dprintf (args)
+
+static int swap_endian = 1; /* Assume Big Endian by default */
+#define TARGET_LITTLE_ENDIAN 0
+#define TARGET_BIG_ENDIAN 1
+
+static inline void
+set_target_endian (int endian)
+{
+  swap_endian = (endian == TARGET_BIG_ENDIAN);
+}
+
+static int reg_hack = 0;
+
+static int mem_hack = 0;
+static uint64_t mem_hack_pc[MAX_CPUS];
+
+static int sign_extend = 1; /* Assume non-N64 ABI by default */
+
+static inline CORE_ADDR
+sign_extend_memaddr (CORE_ADDR memaddr)
+{
+  if (!sign_extend)
+    return memaddr;
+
+  if ((memaddr >> 32) || !(memaddr & 0x80000000ULL))
+    return memaddr;
+
+  return (0xffffffff00000000ULL | memaddr);
+}
+
+/* Defined in auto-generated file mips64-linux.c.  */
+void init_registers_mips64_linux (void);
+
+/* remote-utils.c looks for this. */
+int using_threads = 1;
+
+/* For now, we assume one process (hence one Process ID) for EJTAG.
+   This will change when GDB natively supports multi-exec.
+
+   We map each CPU to a Thread in GDB.
+   Thread ID corresponds to the physical CPU ID.
+*/
+#define EJTAG_PID 88888888
+static ptid_t cpu_ptid[MAX_CPUS];
+
+/* We implement TAP as a Thread. */
+#define TAP_PID 8888
+static ptid_t tap_ptid;
+
+static inline int
+is_tap_thread (struct thread_info *inf)
+{
+  if (inf == NULL)
+    return 0;
+
+  ptid_t ptid = ((struct inferior_list_entry *) inf)->id;
+  return ptid_equal (ptid, tap_ptid);
+}
+
+static inline void
+add_maintap (void)
+{
+  tap_ptid = ptid_build (EJTAG_PID, TAP_PID, 0);
+
+  struct thread_info *thread = find_thread_ptid (tap_ptid);
+  if (thread == NULL)
+    {
+      dprintf (stderr, "Adding MainTAP\n");
+      add_thread (tap_ptid, NULL);
+    }
+}
+
+static inline void
+remove_maintap (void)
+{
+  struct thread_info *thread = find_thread_ptid (tap_ptid);
+  assert (thread != NULL);
+
+  dprintf (stderr, "Hiding MainTAP\n");
+  remove_thread (thread);
+}
+
+#define THREADS_PER_CORE (4)
+#define NUM_CORES (8)
+
+int force_config           = 0;
+int force_is_bigendian     = 1;
+int force_num_cores        = NUM_CORES; 
+int force_threads_per_core = THREADS_PER_CORE; 
+
+/* We use the command line arguments to specify which probe to use. */
+static int
+ejtag_parse_args (char **args)
+{
+  int arg = 0;
+  if (args[arg] == NULL)
+    return -1;
+
+  if (dsa_select_probe (args[arg]) < 0)
+    return -1;
+
+  arg++;
+  while (args[arg] != NULL)
+    {
+      if (strcmp (args[arg], "debug") == 0)
+        {
+          debug = 1;
+        }
+      else if (strcmp (args[arg], "ejtag-debug") == 0)
+        {
+          ejtag_debug = 1;
+          dprintf (stderr, "EJTAG debug output enabled.\n");
+        }
+      else if (strcmp (args[arg], "dsa-debug") == 0)
+        {
+          dsa_debug_on ();
+          dsa_verbose_on ();
+          dprintf (stderr, "EJTAG driver debug output enabled.\n");
+        }
+      else if (strcmp (args[arg], "force-cfg") == 0)
+        {
+          force_config = 1;
+          arg++;
+
+          assert(args[arg] != NULL);
+          force_is_bigendian     =  atoi(args[arg]);
+          assert((force_is_bigendian == 0) || (force_is_bigendian == 1));
+          arg++;
+
+          assert(args[arg] != NULL);
+          force_num_cores        =  atoi(args[arg]);
+          assert((force_num_cores >= 0) && (force_num_cores <= NUM_CORES));
+          arg++;
+
+          assert(args[arg] != NULL);
+          force_threads_per_core =  atoi(args[arg]);
+          assert((force_threads_per_core >= 0) &&
+                 (force_threads_per_core <= THREADS_PER_CORE));
+        }
+      arg++;
+    }
+
+  return 0;
+}
+
+#define set_dm_cpu(cpu)   cpumask_set_cpu (&dmcpumask, cpu)
+#define isset_dm_cpu(cpu) cpumask_isset_cpu (dmcpumask, cpu)
+#define clear_dm_cpu(cpu) cpumask_clear_cpu (&dmcpumask, cpu)
+
+static int
+ejtag_stop_cpu (int cpu)
+{
+  int rc = -1;
+  if (isset_dm_cpu (cpu))
+    {
+      dprintf (stderr, "%s cpu%02d is already in Debug Mode\n", __func__, cpu);
+      rc = 0;
+    }
+  else if (dsa_stop_cpu (cpu) < 0)
+    {
+      fprintf (stderr, "%s ERROR: Failed to put cpu%02d in Debug Mode\n",
+              __func__, cpu);
+      rc = -1;
+    }
+  else
+    {
+      /* cpu was either in STOP mode or DSA put it in DM */
+      if (ejtag_debug)
+        dprintf (stderr, "DSA: dsa_stop_cpu(%d)\n", cpu);
+
+      set_dm_cpu (cpu);
+      rc = 0;
+    }
+
+  return rc;
+}
+
+static int
+ejtag_resume_cpu (int cpu)
+{
+  int rc = -1;
+  if (!isset_dm_cpu (cpu))
+    {
+      dprintf (stderr, "%s cpu%02d was not in Debug Mode\n", __func__, cpu);
+      rc = 0;
+    }
+  else if (dsa_resume_cpu (cpu) < 0)
+    {
+      fprintf (stderr, "%s ERROR: Failed to take cpu%02d out of Debug Mode\n",
+              __func__, cpu);
+      rc = -1;
+    }
+  else
+    {
+      /* cpu was either in RUN mode or DSA took it out of DM */
+      if (ejtag_debug)
+        dprintf (stderr, "DSA: dsa_resume_cpu(%d)\n", cpu);
+
+      clear_dm_cpu (cpu);
+      rc = 0;
+    }
+
+  return rc;
+}
+
+static int
+ejtag_step_cpu (int cpu)
+{
+  if (!isset_dm_cpu (cpu))
+    {
+      dprintf (stderr, "%s cpu%02d was not in Debug Mode\n",
+               __func__, cpu);
+      return -1;
+    }
+
+  uint64_t out_params[MAX_STEP_OUT_PARAMS];
+  if (dsa_step_cpu (cpu, out_params, MAX_STEP_OUT_PARAMS) == -1)
+    return -1;
+
+  if (ejtag_debug)
+    dprintf (stderr, "DSA: dsa_step_cpu(%d)\n", cpu);
+
+  return 0;
+}
+
+static void
+foreach_cpu (cpumask_t cpumask, int (*fn) (int cpu))
+{
+  int i;
+  for (i = 0; i < MAX_CPUS; i++)
+    if (cpumask_isset_cpu (cpumask, i))
+      fn (i);
+}
+
+static int
+ejtag_get_num_threads (int core)
+{
+  if (core < 0 || core >= NUM_CORES)
+    return -1;
+
+  int enabled_prev = dsa_is_ejtag_enabled (); /* capture the state at entry */
+  if (!enabled_prev)
+    if (dsa_enable_ejtag () < 0)
+      return -1;
+
+  int cpu = core << 2;
+
+  int stopped_prev = isset_dm_cpu (cpu); /* capture the state at entry */
+  if (!stopped_prev)
+    if (ejtag_stop_cpu (cpu) < 0)
+      return -1;
+
+  /* FIXME: Remove hardcoding */
+  uint32_t thrmode = dsa_read_ctrl_reg (cpu, 0xa00);
+  if (ejtag_debug)
+    dprintf (stderr, "DSA: dsa_read_ctrl_reg(%d)\n", cpu);
+
+  dprintf (stderr, "%s core%d threadmode = %#x\n", __func__, core, thrmode);
+
+  /* restore CPU Run/Stop to same state found at entry */
+  if (!stopped_prev)
+    if (ejtag_resume_cpu (cpu) < 0)
+      return -1;
+
+  /* restore ejtag en/dis to same state as found at entry */
+  if (!enabled_prev)
+    dsa_disable_ejtag ();
+
+  if (thrmode == 0x2)
+    return 2;
+  else if (thrmode == 0x3)
+    return 4;
+  else
+    return 1;
+}
+
+static uint32_t
+get_cores_disabled ()
+{
+  uint64_t adr            = 0x18035108;
+  uint32_t cores_disabled = 0xff;
+  int ret = dsa_read_pmem32 (adr, &cores_disabled);
+  if (ret != 0)
+    fprintf (stderr, "DSA: dsa_read_pmem32(0x%010llx) ret=%d\n", adr, ret);
+  else
+    fprintf (stderr, "[%s] cores_disabled = 0x%08x\n", __func__, cores_disabled);
+
+  return cores_disabled & 0xff;
+}
+
+static uint32_t
+get_cores_in_reset ()
+{
+  uint64_t adr            = 0x1803512c;
+  uint32_t cores_in_reset = 0xff;
+  int ret = dsa_read_pmem32 (adr, &cores_in_reset);
+  if (ret != 0)
+    fprintf (stderr, "DSA: dsa_read_pmem32(0x%010llx) ret=%d\n", adr, ret);
+  else
+    fprintf (stderr, "[%s] cores_in_reset = 0x%08x\n", __func__, cores_in_reset);
+
+  return cores_in_reset & 0xff;
+}
+
+static inline uint32_t
+get_cores_to_probe (cpumask_t cpumask)
+{
+  uint32_t cores_to_probe = 0;
+  int i;
+  for (i = 0; i < MAX_CPUS; i++)
+    if (cpumask_isset_cpu (cpumask, i))
+      cores_to_probe |= (1 << (i / 4));
+
+  dprintf (stderr, "%s cores_to_probe=0x%08x\n", __func__, cores_to_probe);
+  return cores_to_probe;
+}
+
+static int
+ejtag_get_available_cpumask (cpumask_t *cpumask)
+{
+  cpumask_t probe_cpumask;
+  cpumask_assign (&probe_cpumask, *cpumask);
+  uint32_t cores_to_probe = get_cores_to_probe (probe_cpumask);
+
+  cpumask_clear_all (cpumask);
+
+  uint32_t cores_disabled = get_cores_disabled ();
+  uint32_t cores_in_reset = get_cores_in_reset ();
+
+  int num_cores = NUM_CORES;
+  int core;
+  for (core = 0; core < NUM_CORES; core++)
+    if (cores_disabled & (1 << core))
+      num_cores--;
+
+  for (core = 0; core < num_cores; core++)
+    {
+      if ((cores_to_probe & (1 << core)) == 0)
+        continue;
+
+      if (cores_in_reset & (1 << core))
+        {
+          fprintf (stdout, "[%s] core %d in reset\n", __func__, core);
+          continue;
+        }
+
+      int num_threads = ejtag_get_num_threads (core);
+      int t;
+      for (t = 0; t < num_threads; t++)
+        cpumask_set_cpu (cpumask, (core << 2) | t);
+    }
+
+  dprintf (stderr, "%s cpumask=%#lx\n", __func__, *cpumask);
+
+  return 0;
+}
+
+static int
+ejtag_add_threads (cpumask_t add_cpumask)
+{
+  int cpu;
+  for (cpu = 0; cpu < MAX_CPUS; cpu++)
+    {
+      if (!cpumask_isset_cpu (add_cpumask, cpu))
+        continue;
+
+      /* GDB is not happy if we use LWP 0 or TID != 0. */
+      cpu_ptid[cpu] = ptid_build (EJTAG_PID, CPUID_TO_GDBTID (cpu), 0);
+      add_thread (cpu_ptid[cpu], NULL);
+
+      if (ejtag_stop_cpu (cpu) < 0)
+        return -1;
+
+      cpumask_set_cpu (&all_cpumask, cpu);
+    }
+
+  init_registers_mips64_linux ();
+
+  return 0;
+}
+
+static int
+ejtag_remove_threads (cpumask_t remove_cpumask)
+{
+  int cpu;
+  for (cpu = 0; cpu < MAX_CPUS; cpu++)
+    {
+      if (!cpumask_isset_cpu (remove_cpumask, cpu))
+        continue;
+
+      ptid_t ptid = ptid_build (EJTAG_PID, CPUID_TO_GDBTID (cpu), 0);
+      struct thread_info *thread = find_thread_ptid (ptid);
+      assert (thread != NULL);
+
+      if (ejtag_resume_cpu (cpu) < 0)
+        return -1;
+
+      remove_thread (thread);
+
+      cpumask_clear_cpu (&all_cpumask, cpu);
+    }
+
+  return 0;
+}
+
+static void ejtag_set_breakpoint (void);
+
+static int
+ejtag_probe_init (void)
+{
+  if (dsa_start (force_config, force_is_bigendian, force_num_cores,
+                 force_threads_per_core) < 0)
+    return -1;
+
+  set_target_endian (dsa_is_soc_bigendian () ? TARGET_BIG_ENDIAN : TARGET_LITTLE_ENDIAN);
+  ejtag_set_breakpoint ();
+  return 0;
+}
+
+static int
+ejtag_create_inferior (char *program, char **args)
+{
+  int pid = EJTAG_PID;
+  struct process_info *proc;
+
+  dprintf (stderr, "%s\n", __func__);
+  /* EJTAG supports one inferior/process only. */
+  if (all_processes.head != NULL)
+    return pid;
+
+  if (ejtag_parse_args (args) < 0)
+    return -1;
+
+  if (ejtag_probe_init () < 0)
+    {
+      fprintf (stderr, "*******************************\n");
+      fprintf (stderr, "* PROBE INITIALIZATION FAILED *\n");
+      fprintf (stderr, "*******************************\n");
+      return -1;
+    }
+
+  proc = add_process (pid, 0);
+
+  add_maintap ();
+
+  init_registers_mips64_linux ();
+
+  cpumask_clear_all (&all_cpumask);
+  cpumask_clear_all (&stop_cpumask);
+  cpumask_clear_all (&dmcpumask);
+
+  memset(mem_hack_pc, 0x0, sizeof(mem_hack_pc));
+
+  return pid;
+}
+
+static int
+ejtag_attach (unsigned long pid)
+{
+  /* EJTAG does not support attaching to a running process. */
+  dprintf (stderr, "%s pid=%ld\n", __func__, pid);
+  return -1;
+}
+
+static int
+ejtag_kill_one_thread (struct inferior_list_entry *entry, void *args)
+{
+  struct thread_info *thread = (struct thread_info *) entry;
+  int pid = * (int *) args;
+
+  dprintf (stderr, "%s pid=%d\n", __func__, pid);
+
+  if (ptid_get_pid (entry->id) != pid)
+    return 0;
+
+  if (is_tap_thread (thread))
+    {
+      remove_thread (thread);
+      return 0;
+    }
+
+  int cpu = get_cpuid_from_thread (thread);
+  if (ejtag_resume_cpu (cpu) < 0)
+    return -1;
+
+  remove_thread (thread);
+
+  /* Always return 0 so find_inferior() will iterate through all threads. */
+  return 0;
+}
+
+static int
+ejtag_kill (int pid)
+{
+  dprintf (stderr, "%s pid=%d\n", __func__, pid);
+
+  struct process_info *proc;
+  proc = find_process_pid (pid);
+  if (proc == NULL)
+    return -1;
+
+  delete_all_breakpoints ();
+
+  find_inferior (&all_threads, ejtag_kill_one_thread, &pid);
+
+  remove_process (proc);
+
+  dsa_finish ();
+
+  return 0;
+}
+
+static int
+ejtag_detach (int pid)
+{
+  /* EJTAG does not support detaching from an inferior. */
+  dprintf (stderr, "%s\n", __func__);
+  return -1;
+}
+
+static void
+ejtag_join (int pid)
+{
+  /* EJTAG does not support waiting for an inferior to exit. */
+  dprintf (stderr, "%s pid=%d\n", __func__, pid);
+  return;
+}
+
+static int
+ejtag_thread_alive (ptid_t ptid)
+{
+  /* For now we're assuming all threads are alive. */
+  dprintf (stderr, "%s [%s]\n", __func__, target_pid_to_str (ptid));
+  return 1;
+}
+
+static void
+ejtag_resume (struct thread_resume *resume_info, size_t n)
+{
+  cpumask_t stepmask, contmask, stopmask;
+  cpumask_clear_all (&stepmask);
+  cpumask_clear_all (&contmask);
+  cpumask_clear_all (&stopmask);
+  int default_action = -1;
+  int i;
+  for (i = 0; i < n; i++)
+    {
+      struct thread_resume *r = &resume_info[i];
+      ptid_t ptid = r->thread;
+      dprintf (stderr, "%s resume_info[%d] [%s] %d\n", __func__,
+               i, target_pid_to_str (ptid), r->kind);
+
+      if (ptid_equal (ptid, tap_ptid))
+        continue;
+
+      if (ptid_equal (ptid, minus_one_ptid))
+        {
+          if (default_action != -1)
+            fprintf (stderr, "Error: multiple default actions specified\n");
+          default_action = r->kind;
+          continue;
+        }
+
+      struct thread_info *thread = find_thread_ptid (ptid);
+      assert (thread != NULL);
+      int cpu = get_cpuid_from_thread (thread);
+      if (!is_valid_cpuid (cpu))
+        {
+          dprintf (stderr, "%s invalid cpuid %d\n", __func__, cpu);
+          continue;
+        }
+
+      if (r->kind == resume_step)
+        cpumask_set_cpu (&stepmask, cpu);
+      else if (r->kind == resume_continue)
+        cpumask_set_cpu (&contmask, cpu);
+      else if (r->kind == resume_stop && non_stop)
+        cpumask_set_cpu (&stopmask, cpu);
+    }
+
+  cpumask_t defmask;
+  defmask = cpumask_or (cpumask_or (stepmask, contmask), stopmask);
+  defmask = cpumask_xor (defmask, all_cpumask);
+  if (default_action == resume_step)
+    stepmask = cpumask_or (stepmask, defmask);
+  else if (default_action == resume_continue)
+    contmask = cpumask_or (contmask, defmask);
+  else if (default_action == resume_stop && non_stop)
+    stopmask = cpumask_or (stopmask, defmask);
+
+  if (!cpumask_none (stepmask))
+    {
+      /* "Step" means a single execution step. */
+      if (ejtag_debug)
+        fprintf (stderr, "EJTAG: Stepping cpumask=%lx\n", stepmask);
+      foreach_cpu (stepmask, ejtag_step_cpu);
+    }
+
+  if (!cpumask_none (contmask))
+    {
+      if (ejtag_debug)
+        fprintf (stderr, "EJTAG: Resuming cpumask=%lx\n", contmask);
+      foreach_cpu (contmask, ejtag_resume_cpu);
+    }
+
+  if (!cpumask_none (stopmask))
+    {
+      if (ejtag_debug)
+        fprintf (stderr, "EJTAG: Stopping cpumask=%lx\n", stopmask);
+      foreach_cpu (stopmask, ejtag_stop_cpu);
+    }
+
+  /* Invalidate register cache so we don't get stale values
+     the next time we stop. */
+  regcache_invalidate ();
+}
+
+static inline int
+ejtag_wait_for_event (cpumask_t cpumask)
+{
+  cpumask_t wait_cpumask = cpumask_and (cpumask, all_cpumask);
+
+  int cpu;
+  cpu = get_cpuid_from_thread (find_thread_ptid (cont_thread));
+  if (is_valid_cpuid (cpu))
+    cpu = cpu - 1;
+  else
+    cpu = -1;
+
+  while (!cpumask_none (wait_cpumask)) {
+    cpu = get_next_cpu (wait_cpumask, cpu + 1);
+    if (dsa_is_cpu_stopped (cpu))
+      {
+        set_dm_cpu (cpu);
+        cpumask_clear_cpu (&wait_cpumask, cpu);
+        if (!non_stop)
+          {
+            stop_cpumask = cpumask_and (all_cpumask,
+                                        cpumask_all_except_cpu (cpu));
+          }
+        dprintf (stderr, "%s CPU%d STOPPED wait=%#lx stop=%#lx\n",
+                 __func__, cpu, wait_cpumask, stop_cpumask);
+      }
+
+    if (!cpumask_none (stop_cpumask))
+      {
+        dprintf (stderr, "%s STOP CPUS stop=%#lx\n",
+                 __func__, stop_cpumask);
+        int i;
+        for (i = 0; i < MAX_CPUS; i++)
+          if (cpumask_isset_cpu (stop_cpumask, i))
+            ejtag_stop_cpu (i);
+        cpumask_clear_all (&stop_cpumask);
+        break;
+      }
+  }
+  return cpu;
+}
+
+static ptid_t
+ejtag_wait (ptid_t ptid, struct target_waitstatus *status, int options)
+{
+  dprintf (stderr, "%s ptid [%s]\n", __func__, target_pid_to_str (ptid));
+
+  dprintf (stderr, "%s cont[%s] step[%s] gen[%s]\n", __func__,
+           target_pid_to_str (cont_thread),
+           target_pid_to_str (step_thread),
+           target_pid_to_str (general_thread));
+
+  int all_cpus = 0;
+
+  if (ptid_equal (ptid, minus_one_ptid))
+    {
+      dprintf (stderr, "%s any PID\n", __func__);
+      /* FIXME: In multi-exec case, this would be different... */
+      all_cpus = 1;
+    }
+
+  if (ptid_is_pid (ptid))
+    {
+      dprintf (stderr, "%s any CPU\n", __func__);
+      struct process_info *proc;
+      proc = find_process_pid (ptid_get_pid (ptid));
+      if (proc == NULL)
+        {
+          /* Error */
+          return minus_one_ptid;
+        }
+      all_cpus = 1;
+    }
+
+  if (options & TARGET_WNOHANG)
+    {
+      dprintf (stderr, "%s [%s] TARGET_WNOHANG\n", __func__,
+               target_pid_to_str (ptid));
+
+      status->kind = TARGET_WAITKIND_IGNORE;
+      return null_ptid;
+    }
+
+  int stopped = 0;
+
+  if (cpumask_none (all_cpumask) || ptid_equal (ptid, tap_ptid))
+    {
+      ptid = tap_ptid;
+      stopped = 1;
+      goto event_happened;
+    }
+
+  cpumask_t waitmask;
+  if (all_cpus)
+    {
+      cpumask_assign (&waitmask, all_cpumask);
+    }
+  else
+    {
+      struct thread_info *thread = find_thread_ptid (ptid);
+      if (thread == NULL)
+        {
+          /* Error */
+          return minus_one_ptid;
+        }
+
+      int cpu;
+      set_and_check_cpuid (cpu, thread, assert (0));
+      cpumask_assign (&waitmask, cpumask_only_cpu (cpu));
+    }
+
+  if (!stopped)
+    {
+      int cpu;
+      cpu = ejtag_wait_for_event (waitmask);
+      if (is_valid_cpuid (cpu))
+        ptid = cpu_ptid[cpu];
+      else
+        ptid = tap_ptid;
+      stopped = 1;
+    }
+
+event_happened:
+  if (stopped)
+    {
+      status->kind = TARGET_WAITKIND_STOPPED;
+      status->value.sig = TARGET_SIGNAL_0;
+      dprintf (stderr, "%s [%s] %d, %s\n", __func__,
+               target_pid_to_str (ptid),
+               status->kind, target_signal_to_string (status->value.sig));
+    }
+  else
+    {
+      assert (0);
+    }
+
+  return ptid;
+}
+
+static unsigned short
+swap16 (unsigned short x)
+{
+  if (!swap_endian)
+    return x;
+
+  return ((x & 0xff00) >> 8) | ((x & 0x00ff) << 8);
+}
+
+static unsigned long
+swap32 (unsigned long x)
+{
+  if (!swap_endian)
+    return x;
+
+  return ((x & 0xff000000) >> 24) |
+         ((x & 0x00ff0000) >>  8) |
+         ((x & 0x0000ff00) <<  8) |
+         ((x & 0x000000ff) << 24);
+}
+
+static unsigned long long
+swap64 (unsigned long long x)
+{
+  if (!swap_endian)
+    return x;
+
+  return ((x & 0xff00000000000000ULL) >> 56) |
+         ((x & 0x00ff000000000000ULL) >> 40) |
+         ((x & 0x0000ff0000000000ULL) >> 24) |
+         ((x & 0x000000ff00000000ULL) >>  8) |
+         ((x & 0x00000000ff000000ULL) <<  8) |
+         ((x & 0x0000000000ff0000ULL) << 24) |
+         ((x & 0x000000000000ff00ULL) << 40) |
+         ((x & 0x00000000000000ffULL) << 56);
+}
+
+union reg64
+{
+  unsigned char uc[8];
+  short s;
+  unsigned short us;
+  long l;
+  unsigned long ul;
+  long long ll;
+  unsigned long long ull;
+};
+
+#define RA_REG_NUM 31
+#define PC_REG_NUM 37
+
+static void
+tap_fetch_registers (struct regcache *regcache, int regno)
+{
+  dprintf (stderr, "%s regno=%d\n", __func__, regno);
+  if ((regno == -1) || (regno == PC_REG_NUM))
+    {
+      union reg64 reg;
+      reg.ll = swap64 (0x18035104);
+      supply_register (regcache, PC_REG_NUM, reg.uc);
+    }
+}
+
+#define my_supply_register(i, val) do {        \
+  reg.ll = swap64 (val);                       \
+  supply_register (regcache, i, reg.uc);       \
+  edprintf (stderr, "%s regno=%d val=%#llx\n", \
+            __func__, i, swap64 (reg.ll));     \
+} while (0)
+
+static void
+ejtag_fetch_registers (struct regcache *regcache, int regno)
+{
+  if (is_tap_thread (current_inferior))
+    {
+      tap_fetch_registers (regcache, regno);
+      return;
+    }
+
+  int cpu;
+  set_and_check_cpuid (cpu, current_inferior, return);
+
+  dprintf (stderr, "%s regno=%d cpu=%d\n", __func__, regno, cpu);
+
+  union reg64 reg;
+  if (regno == -1)
+    {
+      /* Fetch all registers. */
+      uint64_t regs[NUM_STD_REGS];
+      memset (regs, 0, sizeof(regs));
+
+      if (reg_hack)
+        {
+          edprintf (stderr, "DSA: dsa_read_std_regs_fast_cpu(%d)\n", cpu);
+          int ret;
+          ret = dsa_read_std_regs_fast_cpu (cpu, regs, NUM_STD_REGS);
+          if (ret != 0)
+            {
+              fprintf (stderr, "DSA: dsa_read_std_regs_fast_cpu(%d) ret=%d\n",
+                       cpu, ret);
+              return;
+            }
+
+          my_supply_register (RA_REG_NUM, regs[RA_REG_NUM]);
+          fprintf (stderr, "reghack: cpu=%d RA = %#llx\n",
+                   cpu, regs[RA_REG_NUM]);
+
+          my_supply_register (PC_REG_NUM, regs[PC_REG_NUM]);
+          fprintf (stderr, "reghack: cpu=%d PC = %#llx\n",
+                   cpu, regs[PC_REG_NUM]);
+        }
+      else
+        {
+          edprintf (stderr, "DSA: dsa_read_std_regs_cpu(%d)\n", cpu);
+          int ret;
+          ret = dsa_read_std_regs_cpu (cpu, regs, NUM_STD_REGS);
+          if (ret != 0)
+            {
+              fprintf (stderr, "DSA: dsa_read_std_regs_cpu(%d) ret=%d\n",
+                       cpu, ret);
+              return;
+            }
+
+          int i;
+          for (i = 0; i < NUM_STD_REGS; i++)
+            my_supply_register (i, regs[i]);
+        }
+
+      if (mem_hack)
+        mem_hack_pc[cpu] = regs[PC_REG_NUM];
+    }
+  else if (regno > 0 && regno < NUM_STD_REGS)
+    {
+      edprintf (stderr, "DSA: dsa_read_std_reg_cpu(%d)\n", cpu);
+      uint64_t val = 0;
+      int ret;
+      ret = dsa_read_std_reg_cpu (cpu, regno, &val);
+      if (ret != 0)
+        {
+          fprintf (stderr, "DSA: dsa_read_std_reg_cpu(%d) ret=%d\n",
+                   cpu, ret);
+          return;
+        }
+
+      my_supply_register (regno, val);
+    }
+  else if (regno == 0)
+    {
+      my_supply_register (regno, 0);
+    }
+  else
+    {
+      fprintf (stderr, "%s regno=%d unsupported\n", __func__, regno);
+    }
+}
+
+static void
+tap_store_registers (struct regcache *regcache, int regno)
+{
+  dprintf (stderr, "%s regno=%d\n", __func__, regno);
+}
+
+static void
+ejtag_store_registers (struct regcache *regcache, int regno)
+{
+  if (is_tap_thread (current_inferior))
+    {
+      tap_store_registers (regcache, regno);
+      return;
+    }
+
+  int cpu;
+  set_and_check_cpuid (cpu, current_inferior, return);
+
+  dprintf (stderr, "%s regno=%d cpu=%d\n", __func__, regno, cpu);
+
+  union reg64 reg;
+  if (regno == -1)
+    {
+      /* Store all registers. */
+      int i;
+      for (i = 0; i < NUM_STD_REGS; i++)
+        {
+          collect_register (regcache, i, reg.uc);
+          if (0 && ejtag_debug)
+            dprintf (stderr, "%s regno=%d val=%#llx\n", __func__,
+                     i, swap64 (reg.ll));
+        }
+    }
+  else
+    {
+      /* Store at least REGNO. */
+      collect_register (regcache, regno, reg.uc);
+      if (ejtag_debug)
+        dprintf (stderr, "%s regno=%d val=%#llx\n", __func__,
+                 regno, swap64 (reg.ll));
+    }
+
+  /* FIXME: Invoke EJTAG write register function. (Not yet implemented.) */
+}
+
+static int
+tap_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
+{
+  int ret;
+
+  dprintf (stderr, "%s memaddr=%#llx len=%d\n", __func__, memaddr, len);
+
+  CORE_ADDR addr = memaddr;
+  unsigned char *dst = myaddr;
+  while (len > 0)
+    {
+      union reg64 tmp;
+      int offset;
+
+      if (((addr & 0x3f) == 0) && (len >= 64))
+        {
+          if (ejtag_debug)
+            fprintf (stderr, "DSA: dsa_read_pmem() 64B\n");
+
+          ret = dsa_read_pmem (addr, dst, 64);
+          if (ret != 0)
+            {
+              fprintf (stderr, "DSA: dsa_read_pmem(0x%010llx) ret=%d 64B\n", addr, ret);
+              return ret;
+            }
+          else
+            dprintf (stderr, "%s read 64B @ %#llx\n", __func__, addr);
+
+          offset = 64;
+        }
+      else if (((addr & 0x1f) == 0) && (len >= 32))
+        {
+          if (ejtag_debug)
+            fprintf (stderr, "DSA: dsa_read_pmem() 32B\n");
+
+          ret = dsa_read_pmem (addr, dst, 32);
+          if (ret != 0)
+            {
+              fprintf (stderr, "DSA: dsa_read_pmem(0x%010llx) ret=%d 32B\n", addr, ret);
+              return ret;
+            }
+          else
+            dprintf (stderr, "%s read 32B @ %#llx\n", __func__, addr);
+
+          offset = 32;
+        }
+      else if (((addr & 0xf) == 0) && (len >= 16))
+        {
+          if (ejtag_debug)
+            fprintf (stderr, "DSA: dsa_read_pmem() 16B\n");
+
+          ret = dsa_read_pmem (addr, dst, 16);
+          if (ret != 0)
+            {
+              fprintf (stderr, "DSA: dsa_read_pmem(0x%010llx) ret=%d 16B\n", addr, ret);
+              return ret;
+            }
+          else
+            dprintf (stderr, "%s read 16B @ %#llx\n", __func__, addr);
+
+          offset = 16;
+        }
+      else if (((addr & 0x7) == 0) && (len >= 8))
+        {
+          if (ejtag_debug)
+            fprintf (stderr, "DSA: dsa_read_pmem64()\n");
+
+          ret = dsa_read_pmem64 (addr, &tmp.ull);
+          if (ret != 0)
+            {
+              fprintf (stderr, "DSA: dsa_read_pmem64(0x%010llx) ret=%d\n", addr, ret);
+              return ret;
+            }
+          else
+            dprintf (stderr, "%s read %#llx @ %#llx\n", __func__, tmp.ull, addr);
+
+          tmp.ull = swap64 (tmp.ull);
+          memcpy (dst, tmp.uc, 8);
+          offset = 8;
+        }
+      else if (((addr & 0x3) == 0) && (len >= 4))
+        {
+          if (ejtag_debug)
+            fprintf (stderr, "DSA: dsa_read_pmem32()\n");
+
+          ret = dsa_read_pmem32 (addr, (uint32_t *)&tmp.ul);
+          if (ret != 0)
+            {
+              fprintf (stderr, "DSA: dsa_read_pmem32(0x%010llx) ret=%d\n", addr, ret);
+              return ret;
+            }
+          else
+            dprintf (stderr, "%s read %#lx @ %#llx\n", __func__, tmp.ul, addr);
+
+          tmp.ul = swap32 (tmp.ul);
+          memcpy (dst, tmp.uc, 4);
+          offset = 4;
+        }
+      else if (((addr & 0x1) == 0) && (len >= 2))
+        {
+          if (ejtag_debug)
+            fprintf (stderr, "DSA: dsa_read_pmem16()\n");
+
+          ret = dsa_read_pmem16 (addr, &tmp.us);
+          if (ret != 0)
+            {
+              fprintf (stderr, "DSA: dsa_read_pmem16(0x%010llx) ret=%d\n", addr, ret);
+              return ret;
+            }
+          else
+            dprintf (stderr, "%s read %#x @ %#llx\n", __func__, tmp.us, addr);
+
+          tmp.us = swap16 (tmp.us);
+          memcpy (dst, tmp.uc, 2);
+          offset = 2;
+        }
+      else
+        {
+          if (ejtag_debug)
+            fprintf (stderr, "DSA: dsa_read_pmem8()\n");
+
+          ret = dsa_read_pmem8 (addr, &tmp.uc[0]);
+          if (ret != 0)
+            {
+              fprintf (stderr, "DSA: dsa_read_pmem8(0x%010llx) ret=%d\n", addr, ret);
+              return ret;
+            }
+          else
+            dprintf (stderr, "%s read %#x @ %#llx\n", __func__, tmp.uc[0], addr);
+
+          memcpy (dst, tmp.uc, 1);
+          offset = 1;
+        }
+
+      addr += offset;
+      dst += offset;
+      len -= offset;
+    }
+
+  return 0;
+}
+
+static int
+ejtag_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
+{
+  if (is_tap_thread (current_inferior))
+    return tap_read_memory (memaddr, myaddr, len);
+
+  int cpu;
+  set_and_check_cpuid (cpu, current_inferior, return -1);
+
+  memaddr = sign_extend_memaddr (memaddr);
+  dprintf (stderr, "%s memaddr=%#llx len=%d cpu=%d\n",
+           __func__, memaddr, len, cpu);
+
+  if (len == 0)
+    return 0;
+
+  if (mem_hack && (mem_hack_pc[cpu] == memaddr) && (len == 4))
+    {
+      fprintf (stderr, "memhack: cpu=%d memaddr=%#llx\n",
+               cpu, memaddr);
+      union reg64 nop;
+      nop.ll = 0;
+      memcpy (myaddr, nop.uc, 4);
+      return 0;
+    }
+
+  /* FIXME */
+  CORE_ADDR addr = memaddr;
+  unsigned char *dst = myaddr;
+  while (len > 0)
+    {
+      union reg64 tmp;
+      if (ejtag_debug)
+        fprintf (stderr, "DSA: dsa_read_vmem32(%d)\n", cpu);
+      tmp.l = dsa_read_vmem32 (cpu, addr);
+      dprintf (stderr, "%s read %#lx @ %#llx\n", __func__,
+               tmp.l, addr);
+      tmp.l = swap32 (tmp.l);
+      memcpy (dst, tmp.uc, 4);
+      addr += 4;
+      dst += 4;
+      len -= 4;
+    }
+
+  return 0;
+}
+
+static inline unsigned long long
+get_ull_from_uc (const unsigned char *myaddr, int len)
+{
+  unsigned long long val;
+
+  if (len == 0)
+    return 0;
+
+  val = * (unsigned long long *) myaddr;
+  if (len == 1)
+    val &= 0xff;
+  else if (len == 2)
+    val &= 0xffff;
+  else if (len == 3)
+    val &= 0xffffff;
+  else if (len == 4)
+    val &= 0xffffffff;
+  else if (len == 5)
+    val &= 0xffffffffffULL;
+  else if (len == 6)
+    val &= 0xffffffffffffULL;
+  else if (len == 7)
+    val &= 0xffffffffffffffULL;
+
+  return val;
+}
+
+static int
+tap_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len)
+{
+  dprintf (stderr, "%s memaddr=%#llx len=%d\n", __func__, memaddr, len);
+
+  CORE_ADDR addr = memaddr;
+  const unsigned char *src = myaddr;
+  while (len > 0)
+    {
+      int bytes;
+      if (((addr & 0x3f) == 0) && (len >= 64))
+        bytes = 64;
+      else if (((addr & 0x1f) == 0) && (len >= 32))
+        bytes = 32;
+      else if (((addr & 0xf) == 0) && (len >= 16))
+        bytes = 16;
+      else if (((addr & 0x7) == 0) && (len >= 8))
+        bytes = 8;
+      else if (((addr & 0x3) == 0) && (len >= 4))
+        bytes = 4;
+      else if (((addr & 0x1) == 0) && (len >= 2))
+        bytes = 2;
+      else
+        bytes = 1;
+
+      if (bytes > 8)
+        {
+          int ret;
+
+          if (ejtag_debug)
+            fprintf (stderr, "DSA: dsa_write_pmem() %dB\n", bytes);
+
+          ret = dsa_write_pmem (addr, (unsigned char *) src, bytes);
+
+          if (ret == 0)
+            {
+              dprintf (stderr, "%s wrote %dB @ %#llx\n", __func__, bytes, addr);
+            }
+          else
+            {
+              fprintf (stderr, "DSA: dsa_read_pmem(0x%010llx) ret=%d 64B\n", addr, ret);
+              return ret;
+            }
+
+          addr += bytes;
+          src += bytes;
+          len -= bytes;
+
+          continue;
+        }
+
+      union reg64 val;
+      val.ull = get_ull_from_uc (src, bytes);
+      dprintf (stderr, "%s *(%#llx) = swap(%#llx)\n", __func__, addr, val.ull);
+
+      if (bytes == 8)
+        {
+          val.ull = swap64 (val.ull);
+          if (ejtag_debug)
+            fprintf (stderr, "DSA: dsa_write_pmem64()\n");
+          dsa_write_pmem64 (addr, val.ull);
+          dprintf (stderr, "%s wrote %#llx @ %#llx\n", __func__, val.ull, addr);
+        }
+      else if (bytes == 4)
+        {
+          val.ul = swap32 (val.ul);
+          if (ejtag_debug)
+            fprintf (stderr, "DSA: dsa_write_pmem32()\n");
+          dsa_write_pmem32 (addr, val.ul);
+          dprintf (stderr, "%s wrote %#lx @ %#llx\n", __func__, val.ul, addr);
+        }
+      else if (bytes == 2)
+        {
+          val.us = swap16 (val.us);
+          if (ejtag_debug)
+            fprintf (stderr, "DSA: dsa_write_pmem16()\n");
+          dsa_write_pmem16 (addr, val.us);
+          dprintf (stderr, "%s wrote %#x @ %#llx\n", __func__, val.us, addr);
+        }
+      else
+        {
+          if (ejtag_debug)
+            fprintf (stderr, "DSA: dsa_write_pmem8()\n");
+          dsa_write_pmem8 (addr, val.uc[0]);
+          dprintf (stderr, "%s wrote %#x @ %#llx\n", __func__, val.uc[0], addr);
+        }
+
+      addr += bytes;
+      src += bytes;
+      len -= bytes;
+    }
+
+  return 0;
+}
+
+/* FIXME: Only support writing LEN <= 4. */
+static int
+ejtag_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len)
+{
+  if (is_tap_thread (current_inferior))
+    return tap_write_memory (memaddr, myaddr, len);
+
+  int cpu;
+  set_and_check_cpuid (cpu, current_inferior, return -1);
+
+  memaddr = sign_extend_memaddr (memaddr);
+  dprintf (stderr, "%s memaddr=%#llx len=%d cpu=%d\n",
+           __func__, memaddr, len, cpu);
+
+  if (len == 0)
+    return 0;
+
+  /* FIXME */
+  unsigned long long val = get_ull_from_uc (myaddr, len);
+  dprintf (stderr, "%s *(%#llx) = swap(%#llx)\n", __func__, memaddr, val);
+
+  if (len > 4)
+    {
+      dprintf (stderr, "%s WARNING len=%d -> 4\n", __func__, len);
+      len = 4;
+    }
+
+  if (ejtag_debug)
+    fprintf (stderr, "DSA: dsa_write_vmem32(%d)\n", cpu);
+  unsigned long val32 = swap32 ((unsigned long) val);
+  dsa_write_vmem32 (cpu, memaddr, val32);
+  dprintf (stderr, "%s wrote %#lx @ %#llx\n", __func__,
+           val32, memaddr);
+
+  return 0;
+}
+
+static inline int
+ptid_null_or_minus_one (ptid_t ptid)
+{
+  return (ptid_equal (ptid, null_ptid)
+          || ptid_equal (ptid, minus_one_ptid));
+}
+
+static void
+ejtag_request_interrupt (void)
+{
+  dprintf (stderr, "%s cont[%s] step[%s] gen[%s]\n", __func__,
+           target_pid_to_str (cont_thread),
+           target_pid_to_str (step_thread),
+           target_pid_to_str (general_thread));
+
+  /* FIXME: For now stop all cpus. */
+  cpumask_assign (&stop_cpumask, all_cpumask);
+}
+
+static void
+ejtag_cache_invalidate_cpu (int cpu, CORE_ADDR addr)
+{
+  if (!isset_dm_cpu (cpu))
+    {
+      dprintf (stderr, "%s cpu%02d was not in Debug Mode\n",
+               __func__, cpu);
+      return;
+    }
+
+  if (ejtag_debug)
+    fprintf (stderr, "DSA: dsa_cache_invalidate_cpu(%d, %#llx)\n", cpu, addr);
+  dsa_cache_invalidate_cpu (cpu, addr);
+}
+
+/* SDBBP
+   31..26  25.6  5....0
+   011100  CODE  111111 */
+/* FIXME: For now we are using an arbitrary CODE. */
+static unsigned long bp_ul;
+static const unsigned char *breakpoint = (const unsigned char *) &bp_ul;
+static int breakpoint_len = 4;
+
+static void
+ejtag_set_breakpoint (void)
+{
+  bp_ul = swap32 (0x7000003f | (0xc0de << 8));
+}
+
+static int
+ejtag_insert_point (char type, CORE_ADDR addr, int len)
+{
+  /* Note: type and return value defined in target.h. */
+  int cpu;
+  set_and_check_cpuid (cpu, current_inferior, return -1);
+  addr = sign_extend_memaddr (addr);
+  dprintf (stderr, "%s type=%c addr=%#llx len=%d cpu=%d\n",
+           __func__, type, addr, len, cpu);
+  assert (len == breakpoint_len);
+
+  switch (type)
+    {
+    case '0': /* software-breakpoint */
+      if (set_gdb_breakpoint_at (addr) != 0)
+        return -1;
+      ejtag_cache_invalidate_cpu (cpu, addr);
+      return 0;
+    case '1': /* hardware-breakpoint */
+    case '2': /* write watchpoint */
+    case '3': /* read watchpoint */
+    case '4': /* access watchpoint */
+    default:
+      /* Unsupported */
+      return 1;
+    }
+}
+
+static int
+ejtag_remove_point (char type, CORE_ADDR addr, int len)
+{
+  struct thread_info *saved_inferior = current_inferior;
+  int stopped = 1;
+  if (is_tap_thread (current_inferior))
+    {
+      int cpu = get_next_cpu (all_cpumask, 0);
+      if (cpu == -1)
+        {
+          stopped = 0;
+          cpu = 0;
+        }
+      current_inferior = find_thread_ptid (cpu_ptid[cpu]);
+      assert (current_inferior != NULL);
+    }
+
+  /* Note: type and return value defined in target.h. */
+  int cpu;
+  set_and_check_cpuid (cpu, current_inferior, return -1);
+  addr = sign_extend_memaddr (addr);
+  dprintf (stderr, "%s type=%c addr=%#llx len=%d cpu=%d\n",
+           __func__, type, addr, len, cpu);
+  assert (len == breakpoint_len);
+
+  int rv;
+  switch (type)
+    {
+    case '0': /* software-breakpoint */
+      if (!stopped)
+        if (ejtag_stop_cpu (cpu) < 0)
+          return -1;
+
+      if (delete_gdb_breakpoint_at (addr) != 0)
+        return -1;
+      ejtag_cache_invalidate_cpu (cpu, addr);
+      if (!stopped)
+        if (ejtag_resume_cpu (cpu) < 0)
+          return -1;
+
+      rv = 0;
+    case '1': /* hardware-breakpoint */
+    case '2': /* write watchpoint */
+    case '3': /* read watchpoint */
+    case '4': /* access watchpoint */
+    default:
+      /* Unsupported */
+      rv = 1;
+    }
+
+  current_inferior = saved_inferior;
+  return rv;
+}
+
+static int
+ejtag_supports_non_stop (void)
+{
+  /* FIXME: For now always return false. */
+  int cpu;
+  set_and_check_cpuid (cpu, current_inferior, return 0);
+  dprintf (stderr, "%s 0 cpu=%d\n", __func__, cpu);
+  return 0;
+}
+
+static int
+ejtag_supports_multi_process (void)
+{
+  /* FIXME: For now always return false.
+     When multi-exec is supported, we'll need to revisit this. */
+  int cpu;
+  set_and_check_cpuid (cpu, current_inferior, return 0);
+  dprintf (stderr, "%s 0 cpu=%d\n", __func__, cpu);
+  return 0;
+}
+
+static void
+monitor_tap_show_help (void)
+{
+  monitor_output ("The following tap commands are supported:\n");
+  monitor_output ("  chipreset <en|dis>\n");
+  monitor_output ("  ejtagena <en|dis>\n");
+  monitor_output ("  read8 <paddr>\n");
+  monitor_output ("  read16 <paddr>\n");
+  monitor_output ("  read32 <paddr>\n");
+  monitor_output ("  read64 <paddr>\n");
+  monitor_output ("  write8 <paddr> <val>\n");
+  monitor_output ("  write16 <paddr> <val>\n");
+  monitor_output ("  write32 <paddr> <val>\n");
+  monitor_output ("  write64 <paddr> <val>\n");
+  monitor_output ("where\n");
+  monitor_output ("  <paddr> = physical address (hexadecimal)\n");
+  monitor_output ("  <val>   = value (hexadecimal)\n\n");
+}
+
+#define MAX_TAP_CMD_STR_SIZE 10 
+
+static int
+handle_monitor_tap_command (char *mon)
+{
+  char *buf = xmalloc (PBUFSIZ);
+  uint64_t addr = 0;
+  uint64_t val = 0;
+  char cmd[MAX_TAP_CMD_STR_SIZE];
+  char arg[MAX_TAP_CMD_STR_SIZE];
+  int rc       = -500;
+  int ret;
+
+  if (!dsa_is_probe_initialized ())
+    return -1;
+
+  int rv = sscanf (mon, " %s %llx %llx", buf, &addr, &val);
+  if (rv == 2)
+    {
+      if (strcmp (buf, "read32") == 0)
+        {
+          uint32_t val32;
+          ret = dsa_read_pmem32 (addr, &val32);
+          if (ret != 0)
+            sprintf (buf, "DSA: dsa_read_pmem32(0x%010llx) ret=%d\n", addr, ret);
+          else
+            sprintf (buf, "R %010llx : %08lx\n", addr, (unsigned long) val32);
+        }
+      else if (strcmp (buf, "read64") == 0)
+        {
+          ret = dsa_read_pmem64 (addr, &val);
+          if (ret != 0)
+            sprintf (buf, "DSA: dsa_read_pmem64(0x%010llx) ret=%d\n", addr, ret);
+          else
+            sprintf (buf, "R %010llx : %016llx\n", addr, val);
+        }
+      else if (strcmp (buf, "read8") == 0)
+        {
+          uint8_t val8;
+          ret = dsa_read_pmem8 (addr, &val8);
+          if (ret != 0)
+            sprintf (buf, "DSA: dsa_read_pmem8(0x%010llx) ret=%d\n", addr, ret);
+          else
+            sprintf (buf, "R %010llx : %02x\n", addr, val8);
+        }
+      else if (strcmp (buf, "read16") == 0)
+        {
+          uint16_t val16;
+          ret = dsa_read_pmem16 (addr, &val16);
+          if (ret != 0)
+            sprintf (buf, "DSA: dsa_read_pmem16(0x%010llx) ret=%d\n", addr, ret);
+          else
+            sprintf (buf, "R %010llx : %04x\n", addr, val16);
+        }
+      else
+        {
+          int rv_cmd = sscanf (mon, " %s %s", cmd, arg);
+          if (rv_cmd != 2)
+            goto err;
+
+          if (strncmp (cmd, "chipreset", strlen ("chipreset")) == 0)
+            {
+              if (strncmp (arg, "en", strlen ("en")) == 0)
+                rc = dsa_enable_chipreset ();
+              else if (strncmp (arg, "dis", strlen ("dis")) == 0)
+                rc = dsa_disable_chipreset ();
+              else
+                goto err;
+
+              sprintf (buf, "Chip Reset: %s %s\n", arg,
+                       (rc == 0) ? "Success" : "Fail" );
+            }
+          else if (strncmp (cmd, "ejtagena", strlen ("ejtagena")) == 0)
+            {
+              if (strncmp (arg, "en", strlen ("en")) == 0)
+                rc = dsa_enable_ejtag ();
+              else if (strncmp (arg, "dis", strlen ("dis")) == 0)
+                rc = dsa_disable_ejtag ();
+              else
+                goto err;
+
+              sprintf (buf, "EJTAG Chain: %s %s\n", arg,
+                       (rc == 0) ? "Success" : "Fail" );
+            }
+          else
+            goto err;
+        }
+    }
+  else if (rv == 3)
+    {
+      if (strcmp (buf, "write32") == 0)
+        {
+          uint32_t val32 = (uint32_t) val;
+          dsa_write_pmem32 (addr, val32);
+          sprintf (buf, "W %010llx : %08lx\n", addr, (unsigned long) val32);
+        }
+      else if (strcmp (buf, "write64") == 0)
+        {
+          dsa_write_pmem64 (addr, val);
+          sprintf (buf, "W %010llx : %016llx\n", addr, val);
+        }
+      else if (strcmp (buf, "write8") == 0)
+        {
+          uint8_t val8 = (uint8_t) val;
+          dsa_write_pmem8 (addr, val8);
+          sprintf (buf, "W %010llx : %02x\n", addr, val8);
+        }
+      else if (strcmp (buf, "write16") == 0)
+        {
+          uint16_t val16 = (uint16_t) val;
+          dsa_write_pmem16 (addr, val16);
+          sprintf (buf, "W %010llx : %04x\n", addr, val16);
+        }
+      else
+        goto err;
+    }
+  else if (rv == 1)
+    {
+      if (strncmp (buf, "reset", strlen ("reset")) == 0)
+        {
+          dsa_reset ();
+          sprintf (buf, "TAP Reset\n");
+        }
+      else if (strncmp (buf, "id", strlen ("id")) == 0)
+        {
+          uint32_t idcode = 0;
+          rc = dsa_maintap_idcode (&idcode);
+          if (!rc)
+            sprintf (buf, "MAINTAP IDCODE = %#x\n", idcode);
+          else
+            sprintf (buf, "Failed to read MAINTAP IDCODE\n");
+        }
+      else
+        goto err;
+    }
+  else
+    goto err;
+
+  monitor_output (buf);
+  free (buf);
+  return 1;
+
+err:
+  free (buf);
+  monitor_tap_show_help ();
+  return 1;
+}
+
+static void
+monitor_ejtag_show_help (void)
+{
+  monitor_output ("The following ejtag commands are supported:\n");
+  monitor_output ("  getmask\n");
+  monitor_output ("  setmask <cpumask>\n");
+  monitor_output ("  signext [0|1]\n");
+  monitor_output ("  ejtagboot <bootfname>\n");
+  monitor_output ("  normalboot\n");
+  monitor_output ("where\n");
+  monitor_output ("  <cpumask>    = mask of cpus to be debugged (hexadecimal)\n");
+  monitor_output ("  <bootfname>  = bootloader ELF file (ascii hex) to load at next reset\n");
+}
+
+#if defined(SUPPORT_FLASHLIB)
+/*
+ * SPI NOR Flash CLI support
+ */
+static void
+monitor_sf_show_help (void)
+{
+  monitor_output ("The following SF commands are supported:\n");
+  monitor_output ("  sf probe [bus:]cs [hz] [mode (hexadecimal)]\n");
+  monitor_output ("  sf read  <to padr> <from flash offset> <num bytes> (all hexadecimal)\n");
+  monitor_output ("  sf write <from padr> <to flash offset> <num bytes> (all hexadecimal)\n");
+  monitor_output ("  sf erase <from flash offset> <num bytes> (all hexadecimal)\n");
+  monitor_output ("  sf dump <from flash offset> <num bytes> <dumpfname> (all hexadecimal)\n");
+  monitor_output ("  sf program <from flash offset> <num bytes> <flashfname> (all hexadecimal)\n");
+  monitor_output ("where\n");
+  monitor_output ("  <dumpfname>  = backup file (binary) to dump SPI NOR Flash content to\n");
+  monitor_output ("  <flashfname> = loader file (binary) from which to program SPI NOR Flash\n");
+}
+
+int
+sf_cli (int num_tokens, char *p_token[], char **pp_status_str)
+{
+  int rc = -1;
+  assert (pp_status_str != NULL);
+
+  if (num_tokens <= 0)
+    {
+      *pp_status_str = (char *) p_cmd_unsupported;
+      rc = 1;
+    }
+  else
+    {
+      dprintf (stderr, "%s(): CLI:%s number of args:%d\n",
+               __func__, p_token[0], (num_tokens - 1));
+      rc = do_spi_flash (NULL, 0, num_tokens, p_token);
+      if (rc == 0)
+        *pp_status_str = (char *) p_cmd_completed;
+      else
+        *pp_status_str = (char *) p_cmd_failed;
+    }
+  dprintf (stderr, "%s(): CLI:%s return code rc: %d\n", __func__,
+           p_token[0], rc);
+  return rc;
+}
+
+static int
+handle_monitor_sf_command (char *mon)
+{
+  int rc = -1;
+  char *buf = xmalloc (PBUFSIZ);
+  int   num_tokens = 0;
+  char *p_mon_str  = mon;
+  char *p_cmd      = "Undefined";
+  char *p_status   = "Unknown";
+  char *p_token[MAX_FLASH_ARGS];
+  char *p_sf_cli_array[MAX_FLASH_ARGS + 1];
+  int c_i = 0;
+
+  dprintf (stderr, "%s(): line: %d mon = %s\n",__func__, __LINE__, mon);
+  if (dsa_is_probe_initialized ())
+    {
+      num_tokens = dsa_getargs (&p_mon_str, &p_cmd, p_token, MAX_FLASH_ARGS);
+      p_sf_cli_array[0] = p_cmd;
+      for (c_i = 0; c_i < num_tokens; c_i++)
+         {
+           p_sf_cli_array[c_i + 1] = p_token[c_i];
+         }
+      dprintf (stderr, "%s(): cmd = %s num_tokens = %d\n",__func__,
+               p_cmd, num_tokens);
+      if (num_tokens > 0)
+        rc = sf_cli ((num_tokens + 1), p_sf_cli_array, &p_status);
+
+      sprintf (buf, "%s CLI: %s %s\n", p_cmd, p_token[0], p_status);
+      monitor_output (buf);
+
+      if ((num_tokens <= 0) || (rc != 0))
+        monitor_sf_show_help ();
+    }
+  else
+    {
+      sprintf (buf, "ERROR: DSA probe init failed, can not execute: %s\n", mon);
+      monitor_output (buf);
+    }
+
+  free (buf);
+  return 1;
+}
+#endif /* if defined(SUPPORT_FLASHLIB) */
+
+static int
+handle_monitor_ejtag_command (char *mon)
+{
+  char *buf = xmalloc (PBUFSIZ);
+  uint64_t cpumask;
+  /* Do not handle monitor ejtag command if inferior hasn't been created. */
+  if (all_processes.head == NULL)
+    return 0;
+
+  int rv = sscanf (mon, " %s %llx", buf, &cpumask);
+  if ((rv == 1) && (strcmp (buf, "getmask") == 0))
+    {
+      cpumask_t avail_cpumask;
+      cpumask_clear_all (&avail_cpumask);
+      avail_cpumask = cpumask_inverse (avail_cpumask);
+      ejtag_get_available_cpumask (&avail_cpumask);
+
+      cpumask = (uint64_t) avail_cpumask;
+      sprintf (buf, "Available cpumask = %#llx\n", cpumask);
+    }
+  else if ((rv == 2) && (strcmp (buf, "setmask") == 0))
+    {
+      cpumask_t avail_cpumask;
+      cpumask_assign (&avail_cpumask, cpumask);
+      ejtag_get_available_cpumask (&avail_cpumask);
+
+      cpumask_t user_cpumask = (cpumask_t) cpumask;
+      user_cpumask = cpumask_and (user_cpumask, avail_cpumask);
+
+      cpumask_t add_cpumask;
+      add_cpumask = cpumask_and (user_cpumask,
+                                 cpumask_inverse (all_cpumask));
+      cpumask_t rem_cpumask;
+      rem_cpumask = cpumask_and (cpumask_inverse (user_cpumask),
+                                 all_cpumask);
+
+      cpumask_t prev_all_cpumask;
+      cpumask_assign (&prev_all_cpumask, all_cpumask);
+
+      buf[0] = '\0';
+      if (!cpumask_none (add_cpumask))
+        {
+          if (!dsa_is_ejtag_enabled ())
+            if (dsa_enable_ejtag () < 0)
+              return -1;
+          ejtag_add_threads (add_cpumask);
+          sprintf (buf, "Added cpumask %#lx\n", add_cpumask);
+        }
+      if (!cpumask_none (rem_cpumask))
+        {
+          ejtag_remove_threads (rem_cpumask);
+          sprintf (buf, "Removed cpumask %#lx\n", rem_cpumask);
+        }
+
+      sprintf (buf + strlen (buf),
+               "Currently debugging cpumask %#lx\n", all_cpumask);
+
+      if (cpumask_none (all_cpumask))
+        {
+          if (dsa_is_ejtag_enabled ())
+            if (dsa_disable_ejtag () < 0)
+              return -1;
+
+          add_maintap ();
+        }
+      else if (cpumask_none (prev_all_cpumask))
+        {
+          /* Previously, no CPUs were in Debug Mode.
+           * In "EJTAG mode", we hide the MainTAP to
+           * prevent confusion. */
+          remove_maintap ();
+        }
+    }
+  else if (strcmp (buf, "signext") == 0)
+    {
+      if (rv == 2)
+        {
+          int val = cpumask;
+          sign_extend = (val != 0);
+        }
+      sprintf (buf, "Sign extension for pointers turned %s\n",
+               (sign_extend) ? "on" : "off");
+    }
+  else if (strcmp (buf, "reghack") == 0)
+    {
+      if (rv == 2)
+        {
+          int val = cpumask;
+          reg_hack = (val != 0);
+        }
+      sprintf (buf, "Register info hack turned %s\n",
+               (reg_hack) ? "on" : "off");
+    }
+  else if (strcmp (buf, "memhack") == 0)
+    {
+      if (rv == 2)
+        {
+          int val = cpumask;
+          mem_hack = (val != 0);
+        }
+      sprintf (buf, "Memory read hack turned %s\n",
+               (mem_hack) ? "on" : "off");
+    }
+  else if (strcmp (buf, "ejtagboot") == 0)
+    {
+      rv = sscanf (mon, " %s %s", buf, buf);
+      if (rv == 2)
+        {
+          char *fname = NULL;
+          int buflen = strlen (buf);
+          fname = (char *) malloc (sizeof (char) * (buflen + 1));
+          strncpy (fname, buf, buflen);
+          fname[buflen] = '\0';
+          sprintf (buf, "EJTAGBOOT will take effect with bootloader %s\n",
+                   fname);
+          if (dsa_ejtagboot_cpu (0, fname) < 0)
+            sprintf (buf, "EJTAGBOOT failed\n");
+          if (fname)
+            free (fname);
+        }
+      else
+        goto err;
+    }
+  else if ((rv == 1) && (strcmp (buf, "normalboot") == 0))
+    {
+      if (dsa_normalboot_cpu (0) < 0)
+        sprintf (buf, "NORMALBOOT failed\n");
+      else
+        sprintf (buf, "NORMALBOOT is taking effect\n");
+    }
+  else
+    goto err;
+
+  monitor_output (buf);
+  free (buf);
+  return 1;
+
+err:
+  free (buf);
+  monitor_ejtag_show_help ();
+  return 1;
+}
+
+#define ICACHE "icache"
+
+static int
+handle_monitor_cpu_command (char *mon)
+{
+  char *buf = xmalloc (PBUFSIZ);
+  int cpu;
+  uint64_t addr;
+  int rv = sscanf (mon, " %s %d %llx", buf, &cpu, &addr);
+  if (rv < 2)
+    goto err;
+
+  if (!is_valid_cpuid (cpu) || !isset_dm_cpu (cpu))
+    {
+      sprintf (buf, "invalid cpu=%d\n", cpu);
+      goto err_msg;
+    }
+
+  if ((rv == 3) && (strcmp (buf, ICACHE) == 0))
+    {
+      if (addr & 0x3)
+        {
+          sprintf (buf, "invalid addr=%#llx\n", addr);
+          goto err_msg;
+        }
+      ejtag_cache_invalidate_cpu (cpu, addr);
+      sprintf (buf, ICACHE": invalidate cpu=%d, addr=%#llx\n", cpu, addr);
+    }
+  else
+    goto err;
+
+err_msg:
+  monitor_output (buf);
+err:
+  free (buf);
+  return 1;
+}
+
+static void
+monitor_oph_show_help (void)
+{
+  monitor_output ("The following OPH commands are supported:\n");
+  monitor_output ("  install  <handler index> <num opcodes> <num inparams> <num outparams> (all decimal)\n");
+  monitor_output ("  remove   <handler index (dec)>\n");
+  monitor_output ("  opcode   <handler index (dec)> <opcode index (dec)> <opcode word (hex)>\n");
+  monitor_output ("  inparam  <handler index (dec)> <inparam index (dec)> <inparam dword (hex)>\n");
+  monitor_output ("  execute  <handler index (dec)> <cpu>\n");
+  monitor_output ("  outparam <handler index (dec)> <outparam index (dec)>\n");
+}
+
+static int
+do_oph (int num_tokens, char *p_token[], unsigned long long *p_outparam)
+{
+  int num_args                 =  0;
+  int rc                       = -1;
+  int oph_i                    = -1;
+  int inp_i                    = -1;
+  int out_i                    = -1;
+  int opc_i                    = -1;
+  unsigned int num_opcodes     =  0;
+  unsigned int num_inparams    =  0;
+  unsigned int num_outparams   =  0;
+  unsigned long long inparam   =  0;
+  unsigned long opcode         =  0;
+  char *ends;
+
+  /* check arguments and invoke DSA */
+  num_args = (num_tokens - 1);
+  oph_i    = atoi (p_token[1]);
+
+  if (!strncmp (p_token[0], "install", strlen ("install")))
+    {
+      if (num_args != ARGS_OPH_INSTALL)
+        rc = -200;
+      else
+        {
+          num_opcodes   = strtoul (p_token[2], NULL, 0);
+          num_inparams  = strtoul (p_token[3], NULL, 0);
+          num_outparams = strtoul (p_token[4], NULL, 0);
+          rc = dsa_install_oph (oph_i, num_opcodes, num_inparams, num_outparams);
+        }
+    }
+  else if (!strncmp (p_token[0], "remove", strlen ("remove")))
+    {
+      if (num_args != ARGS_OPH_REMOVE)
+        rc = -200;
+      else
+        rc = dsa_remove_oph (oph_i);
+    }
+  else if (!strncmp (p_token[0], "opcode", strlen ("opcode")))
+    {
+      if (num_args != ARGS_OPH_OPCODE)
+        rc = -200;
+      else
+        {
+          opc_i   = atoi (p_token[2]);
+          opcode  = strtoul (p_token[3], &ends, 16);
+          rc      = dsa_opcode_to_oph (oph_i, opc_i, opcode);
+        }
+    }
+  else if (!strncmp (p_token[0], "inparam", strlen ("inparam")))
+    {
+      if (num_args != ARGS_OPH_INPARAM)
+        rc = -200;
+      else
+        {
+          inp_i   = atoi (p_token[2]);
+          inparam = strtoull (p_token[3], &ends, 16);
+          rc      = dsa_inparam_to_oph (oph_i, inp_i, inparam);
+        }
+    }
+  else if (!strncmp (p_token[0], "execute", strlen ("execute")))
+    {
+      if (num_args != ARGS_OPH_EXECUTE)
+        rc = -200;
+      else
+        rc = dsa_execute_oph (oph_i, atoi (p_token[2]));
+    }
+  else if (!strncmp (p_token[0], "outparam", strlen ("outparam")))
+    {
+      if (num_args != ARGS_OPH_OUTPARAM)
+        rc = -200;
+      else
+        {
+          out_i   = atoi (p_token[2]);
+          rc      = dsa_outparam_from_oph (oph_i, out_i, p_outparam);
+        }
+    }
+  else
+    rc = -100;         /* ERROR: Command not supported */
+
+  return rc;
+}
+
+int
+oph_cli (int num_tokens, char *p_token[], char **pp_status_str,
+         unsigned long long *p_outparam)
+{
+  int rc = -1;
+  assert (pp_status_str != NULL);
+
+  if (num_tokens < 2)
+    {
+      *pp_status_str = (char *) p_cmd_chk_cli;
+      rc = 1;
+    }
+  else
+    {
+      dprintf (stderr, "%s(): CLI: %s number of args:%d\n",
+               __func__, p_token[0], (num_tokens - 1));
+      rc = do_oph (num_tokens, p_token, p_outparam);
+      switch (rc)
+        {
+        case 0:
+          *pp_status_str = (char *) p_cmd_completed;
+          break;
+
+        case 1:
+        case -100:
+          *pp_status_str = (char *) p_cmd_unsupported;
+          break;
+
+        case -200:
+          *pp_status_str = (char *) p_cmd_chk_args_count;
+          break;
+
+        default:
+          if (!strncmp (p_token[0], "install", strlen ("install")))
+            {
+              switch (rc)
+                {
+                case -1:
+                  *pp_status_str = (char *) p_cmd_already_installed;
+                  break;
+
+                case -2:
+                case -3:
+                case -4:
+                  *pp_status_str = (char *) p_cmd_chk_args_values;
+                  break;
+
+                default:
+                  *pp_status_str = (char *) p_cmd_err_unknown;
+                }
+            }
+          else if (!strncmp (p_token[0], "remove", strlen ("remove")))
+            {
+              switch (rc)
+                {
+                case -1:
+                  *pp_status_str = (char *) p_cmd_non_existent;
+                  break;
+
+                default:
+                  *pp_status_str = (char *) p_cmd_err_unknown;
+                }
+            }
+          else if (!strncmp (p_token[0], "opcode", strlen ("opcode")) ||
+                   !strncmp (p_token[0], "inparam", strlen ("inparam")) ||
+                   !strncmp (p_token[0], "outparam", strlen ("outparam")))
+            {
+              switch (rc)
+                {
+                case -1:
+                  *pp_status_str = (char *) p_cmd_non_existent;
+                  break;
+
+                case -2:
+                  *pp_status_str = (char *) p_cmd_chk_index_range;
+                  break;
+
+                case -3:
+                  *pp_status_str = (char *) p_cmd_chk_index_limit;
+                  break;
+
+                case -4:
+                  if (!strncmp (p_token[0], "outparam", strlen ("outparam")))
+                    *pp_status_str = (char *) p_cmd_not_serviced;
+
+                  break;
+                case -5:
+                  if (!strncmp (p_token[0], "outparam", strlen ("outparam")))
+                    *pp_status_str = (char *) p_cmd_chk_outparam_ptr;
+
+                  break;
+
+                default:
+                  *pp_status_str = (char *) p_cmd_err_unknown;
+                }
+            }
+          else if (!strncmp (p_token[0], "execute", strlen ("execute")))
+            {
+              switch (rc)
+                {
+                case -1:
+                  *pp_status_str = (char *) p_cmd_non_existent;
+                  break;
+
+                case -2:
+                case -3:
+                  *pp_status_str = (char *) p_cmd_chk_num_opcodes;
+                  break;
+
+                case -4:
+                  *pp_status_str = (char *) p_cmd_chk_num_inparams;
+                  break;
+
+                case -5:
+                  *pp_status_str = (char *) p_cmd_chk_inparams_array;
+                  break;
+
+                case -6:
+                  *pp_status_str = (char *) p_cmd_chk_num_outparams;
+                  break;
+
+                case -7:
+                  *pp_status_str = (char *) p_cmd_chk_outparams_array;
+                  break;
+
+                case -8:
+                case -10:
+                  *pp_status_str = (char *) p_cmd_chk_cpu_specified;
+                  break;
+
+                case -9:
+                  *pp_status_str = (char *) p_cmd_failed;
+                  break;
+
+                default:
+                  *pp_status_str = (char *) p_cmd_err_unknown;
+                }
+            }
+        }
+     }
+  dprintf (stderr, "%s(): CLI: %s return code rc: %d\n", __func__, p_token[0], rc);
+  return rc;
+}
+
+static int
+handle_monitor_oph_command (char *mon)
+{
+  int   rc         = -1;
+  int   c_i        =  0;
+  char *buf        =  xmalloc (PBUFSIZ);
+  int   num_tokens =  0;
+  char *p_mon_str  =  mon;
+  char *p_cmd      =  "Undefined";
+  char *p_status   =  "Unknown";
+  char *p_token[MAX_OPH_ARGS];
+  unsigned long long outparam = 0;
+
+  dprintf (stderr, "%s(): line: %d mon = %s\n", __func__, __LINE__, mon);
+  if (dsa_is_probe_initialized ())
+    {
+      num_tokens = dsa_getargs (&p_mon_str, &p_cmd, p_token, MAX_OPH_ARGS);
+
+      dprintf (stderr, "%s(): CMD = %s CLI = %s argc = %d\n", __func__, p_cmd,
+               p_token[0], num_tokens -1);
+
+      /* call CLI function entry point with supplied arguments */
+      if (num_tokens > 0)
+        {
+          if (!strncmp (p_token[0], "outparam", strlen ("outparam")))
+            dprintf (stderr, "%s(): Before calling CLI outparam = %#llx\n",
+                     __func__, outparam);
+
+          for (c_i = 0; c_i < num_tokens; c_i++)
+            dprintf (stderr, "%s(): p_token[%0d] = %s\n", __func__, c_i,
+                     p_token[c_i]);
+
+          rc = oph_cli (num_tokens, p_token, &p_status, &outparam);
+        }
+
+      /* build appropriate output message based on CLI invocation results */
+      if ((rc == 0) && (!strncmp (p_token[0], "outparam", strlen ("outparam"))))
+        {
+          dprintf (stderr, "%s(): After calling CLI outparam = 0x%llx\n",
+                   __func__, outparam);
+          sprintf (buf, "0x%016llx\n", outparam);
+        }
+      else
+        sprintf (buf, "%s %s Status: %s\n\n", p_cmd, p_token[0], p_status);
+
+      dprintf (stderr, "%s(): %s", __func__, buf);
+
+      /* selectively direct status output message to GDB client side */
+      if ((rc != 0) || (!strncmp (p_token[0], "outparam", strlen ("outparam"))))
+        monitor_output (buf);
+
+      if ((num_tokens <= 0) || (rc == 1) || (rc == -100) || (rc == -200))
+        monitor_oph_show_help ();
+    }
+  else
+    {
+      sprintf (buf, "ERROR: DSA probe init failed, can not execute: %s\n", mon);
+      monitor_output (buf);
+    }
+
+  free (buf);
+  return 1;
+}
+
+static int
+ejtag_handle_monitor_command (char *mon)
+{
+  if (strncmp (mon, "tap", 3) == 0)
+    return handle_monitor_tap_command (mon + 3);
+  else if (strncmp (mon, "ejtag", 5) == 0)
+    return handle_monitor_ejtag_command (mon + 5);
+  else if (strncmp (mon, "cpu", 3) == 0)
+    return handle_monitor_cpu_command (mon + 3);
+  else if (strncmp (mon, "oph", 3) == 0)
+    return handle_monitor_oph_command (mon);
+#if defined(SUPPORT_FLASHLIB)
+  else if (strncmp (mon, "sf", 2) == 0)
+    return handle_monitor_sf_command (mon);
+#endif /* if defined(SUPPORT_FLASHLIB) */
+  else
+    return 0;
+}
+
+static int
+ejtag_core_of_thread (ptid_t ptid)
+{
+  struct thread_info *thread = find_thread_ptid (ptid);
+  if (thread == NULL)
+    {
+      dprintf (stderr, "%s ptid [%s]\n", __func__, target_pid_to_str (ptid));
+      return -1;
+    }
+
+  if (is_tap_thread (thread))
+    return TAP_PID;
+
+  /* "core" == virtual core == vcpu */
+  int core = get_cpuid_from_thread (thread);
+  dprintf (stderr, "%s virtual core %d\n", __func__, core);
+  return core;
+}
+
+static struct target_ops ejtag_target_ops = {
+  .create_inferior = ejtag_create_inferior,
+  .attach = ejtag_attach,
+  .kill = ejtag_kill,
+  .detach = ejtag_detach,
+  .join = ejtag_join,
+  .thread_alive = ejtag_thread_alive,
+  .resume = ejtag_resume,
+  .wait = ejtag_wait,
+  .fetch_registers = ejtag_fetch_registers,
+  .store_registers = ejtag_store_registers,
+  .read_memory = ejtag_read_memory,
+  .write_memory = ejtag_write_memory,
+  .look_up_symbols = NULL,
+  .request_interrupt = ejtag_request_interrupt,
+  .read_auxv = NULL,
+  .insert_point = ejtag_insert_point,
+  .remove_point = ejtag_remove_point,
+  .stopped_by_watchpoint = NULL,
+  .stopped_data_address = NULL,
+  .read_offsets = NULL,
+  .get_tls_address = NULL,
+  .qxfer_spu = NULL,
+  .hostio_last_error = hostio_last_error_from_errno,
+  .qxfer_osdata = NULL,
+  .qxfer_siginfo = NULL,
+  .supports_non_stop = ejtag_supports_non_stop,
+  .async = NULL,
+  .start_non_stop = NULL,
+  .supports_multi_process = ejtag_supports_multi_process,
+  .handle_monitor_command = ejtag_handle_monitor_command,
+  .core_of_thread = ejtag_core_of_thread
+};
+
+void
+initialize_low (void)
+{
+  dprintf (stderr, "%s\n", __func__);
+  set_target_ops (&ejtag_target_ops);
+
+  ejtag_set_breakpoint ();
+  set_breakpoint_data (breakpoint, breakpoint_len);
+}
diff -Naur gdb-7.2.orig/gdb/gdbserver/Makefile.in gdb-7.2/gdb/gdbserver/Makefile.in
--- gdb-7.2.orig/gdb/gdbserver/Makefile.in	2011-02-11 14:53:29.087414512 -0500
+++ gdb-7.2/gdb/gdbserver/Makefile.in	2011-02-11 14:55:32.647412584 -0500
@@ -148,6 +148,33 @@
 IPA_DEPFILES = @IPA_DEPFILES@
 extra_libraries = @extra_libraries@
 
+# EJTAG
+ifeq ("$(target_alias)", "mipsisa64r2-nlm-ejtag")
+
+  # DBGRTOOL
+  ifeq ("$(NETL_DBGRTOOL)", "")
+    $(error NETL_DBGRTOOL must be specified)
+  endif
+  EJTAG_CFLAGS  += -I$(NETL_DBGRTOOL)/include
+  EJTAG_LDFLAGS += -L$(NETL_DBGRTOOL)/lib
+  EJTAG_LIBS    += -lxlpdbgrtool
+  dbgrtool_h = $(NETL_DBGRTOOL)/include/libdbgrtool.h
+
+  # FLASHLIB
+  ifeq ("$(FLASH)", "1")
+    EJTAG_CFLAGS += -DSUPPORT_FLASHLIB
+    ifeq ("$(NETL_FLASHLIB)", "")
+      $(error NETL_FLASHLIB must be specified)
+    endif
+    EJTAG_CFLAGS  += -I$(NETL_FLASHLIB)/include
+    EJTAG_LDFLAGS += -L$(NETL_FLASHLIB)/lib
+    EJTAG_LIBS    += -lgeneric -lcommon -lspi -lspi_flash
+  endif
+
+  INTERNAL_LDFLAGS += $(EJTAG_LDFLAGS)
+  GDBSERVER_LIBS   += $(EJTAG_LIBS)
+endif
+
 # Prevent Sun make from putting in the machine type.  Setting
 # TARGET_ARCH to nothing works for SunOS 3, 4.0, but not for 4.1.
 .c.o:
@@ -164,7 +191,7 @@
 install-only:
 	n=`echo gdbserver | sed '$(program_transform_name)'`; \
 	if [ x$$n = x ]; then n=gdbserver; else true; fi; \
-	if [ x$IPA_DEPFILES != x ]; then \
+	if [ x$(IPA_DEPFILES) != x ]; then \
 		$(SHELL) $(srcdir)/../../mkinstalldirs $(DESTDIR)$(libdir); \
 		$(INSTALL_PROGRAM) $(IPA_LIB) $(DESTDIR)$(libdir)/$(IPA_LIB); \
 	fi; \
@@ -517,4 +544,8 @@
 reg-xtensa.o : reg-xtensa.c $(regdef_h)
 reg-xtensa.c : $(srcdir)/../regformats/reg-xtensa.dat $(regdat_sh)
 	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-xtensa.dat reg-xtensa.c
+
+ejtag-mips64-low.o: ejtag-mips64-low.c $(server_h) $(dbgrtool_h)
+	$(CC) -c $(CPPFLAGS) $(INTERNAL_CFLAGS) $(EJTAG_CFLAGS) $<
+
 # This is the end of "Makefile.in".
diff -Naur gdb-7.2.orig/gdb/gdbserver/Makefile.in.orig gdb-7.2/gdb/gdbserver/Makefile.in.orig
--- gdb-7.2.orig/gdb/gdbserver/Makefile.in.orig	1969-12-31 19:00:00.000000000 -0500
+++ gdb-7.2/gdb/gdbserver/Makefile.in.orig	2010-07-01 06:36:11.000000000 -0400
@@ -0,0 +1,520 @@
+# Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+# 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+# Free Software Foundation, Inc.
+
+# This file is part of GDB.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# 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, see <http://www.gnu.org/licenses/>.
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+host_alias = @host_alias@
+target_alias = @target_alias@
+program_transform_name = @program_transform_name@
+bindir = @bindir@
+libdir = @libdir@
+tooldir = $(libdir)/$(target_alias)
+
+datarootdir = @datarootdir@
+datadir = @datadir@
+mandir = @mandir@
+man1dir = $(mandir)/man1
+man2dir = $(mandir)/man2
+man3dir = $(mandir)/man3
+man4dir = $(mandir)/man4
+man5dir = $(mandir)/man5
+man6dir = $(mandir)/man6
+man7dir = $(mandir)/man7
+man8dir = $(mandir)/man8
+man9dir = $(mandir)/man9
+infodir = @infodir@
+htmldir = $(prefix)/html
+includedir = @includedir@
+
+SHELL = /bin/sh
+EXEEXT = @EXEEXT@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+
+CC = @CC@
+
+# Directory containing source files.  Don't clean up the spacing,
+# this exact string is matched for by the "configure" script.
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+# It is also possible that you will need to add -I/usr/include/sys to the
+# CFLAGS section if your system doesn't have fcntl.h in /usr/include (which
+# is where it should be according to Posix).
+
+# Set this up with gcc if you have gnu ld and the loader will print out
+# line numbers for undefinded refs.
+#CC-LD=gcc -static
+CC-LD=${CC}
+
+# Where is the "include" directory?  Traditionally ../include or ./include
+INCLUDE_DIR =  ${srcdir}/../../include
+INCLUDE_DEP = $$(INCLUDE_DIR)
+
+# Where is ust?  These will be empty if ust was not available.
+ustlibs = @ustlibs@
+ustinc = @ustinc@
+
+# All the includes used for CFLAGS and for lint.
+# -I. for config files.
+# -I${srcdir} for our headers.
+# -I$(srcdir)/../regformats for regdef.h.
+INCLUDE_CFLAGS = -I. -I${srcdir} -I$(srcdir)/../common \
+	-I$(srcdir)/../regformats -I$(INCLUDE_DIR)
+
+# M{H,T}_CFLAGS, if defined, has host- and target-dependent CFLAGS
+# from the config/ directory.
+GLOBAL_CFLAGS = ${MT_CFLAGS} ${MH_CFLAGS}
+#PROFILE_CFLAGS = -pg
+
+WARN_CFLAGS = -Wall
+
+# CFLAGS is specifically reserved for setting from the command line
+# when running make.  I.E.  "make CFLAGS=-Wmissing-prototypes".
+CFLAGS = @CFLAGS@
+
+# INTERNAL_CFLAGS is the aggregate of all other *CFLAGS macros.
+INTERNAL_CFLAGS =  $(WARN_CFLAGS) ${CFLAGS} ${GLOBAL_CFLAGS} \
+	${PROFILE_CFLAGS} ${INCLUDE_CFLAGS}
+
+# LDFLAGS is specifically reserved for setting from the command line
+# when running make.
+LDFLAGS = @LDFLAGS@
+INTERNAL_LDFLAGS = $(LDFLAGS) @RDYNAMIC@
+
+# All source files that go into linking GDB remote server.
+
+SFILES=	$(srcdir)/gdbreplay.c $(srcdir)/inferiors.c \
+	$(srcdir)/mem-break.c $(srcdir)/proc-service.c \
+	$(srcdir)/proc-service.list $(srcdir)/regcache.c \
+	$(srcdir)/remote-utils.c $(srcdir)/server.c $(srcdir)/target.c \
+	$(srcdir)/thread-db.c $(srcdir)/utils.c \
+	$(srcdir)/linux-arm-low.c $(srcdir)/linux-cris-low.c \
+	$(srcdir)/linux-crisv32-low.c \
+	${srcdir}/i386-low.c $(srcdir)/i387-fp.c \
+	$(srcdir)/linux-ia64-low.c $(srcdir)/linux-low.c \
+	$(srcdir)/linux-m32r-low.c \
+	$(srcdir)/linux-m68k-low.c $(srcdir)/linux-mips-low.c \
+	$(srcdir)/linux-ppc-low.c \
+	$(srcdir)/linux-s390-low.c \
+	$(srcdir)/linux-sh-low.c $(srcdir)/linux-sparc-low.c \
+	$(srcdir)/linux-x86-low.c \
+	$(srcdir)/linux-xtensa-low.c \
+	$(srcdir)/win32-arm-low.c $(srcdir)/win32-i386-low.c \
+	$(srcdir)/win32-low.c $(srcdir)/wincecompat.c \
+	$(srcdir)/hostio.c $(srcdir)/hostio-errno.c
+
+DEPFILES = @GDBSERVER_DEPFILES@
+
+LIBOBJS = @LIBOBJS@
+
+SOURCES = $(SFILES)
+TAGFILES = $(SOURCES) ${HFILES} ${ALLPARAM} ${POSSLIBS}
+
+OBS = inferiors.o regcache.o remote-utils.o server.o signals.o target.o \
+	utils.o version.o \
+	mem-break.o hostio.o event-loop.o tracepoint.o \
+	$(XML_BUILTIN) \
+	$(DEPFILES) $(LIBOBJS)
+GDBREPLAY_OBS = gdbreplay.o version.o
+GDBSERVER_LIBS = @GDBSERVER_LIBS@
+XM_CLIBS = @LIBS@
+CDEPS = $(srcdir)/proc-service.list
+
+# XML files to compile in to gdbserver, if any.
+XML_DIR = $(srcdir)/../features
+XML_FILES = @srv_xmlfiles@
+XML_BUILTIN = @srv_xmlbuiltin@
+
+IPA_DEPFILES = @IPA_DEPFILES@
+extra_libraries = @extra_libraries@
+
+# Prevent Sun make from putting in the machine type.  Setting
+# TARGET_ARCH to nothing works for SunOS 3, 4.0, but not for 4.1.
+.c.o:
+	${CC} -c ${INTERNAL_CFLAGS} $<
+
+all: gdbserver$(EXEEXT) gdbreplay$(EXEEXT) $(extra_libraries)
+
+# Traditionally "install" depends on "all".  But it may be useful
+# not to; for example, if the user has made some trivial change to a
+# source file and doesn't care about rebuilding or just wants to save the
+# time it takes for make to check that all is up to date.
+# install-only is intended to address that need.
+install: all install-only
+install-only:
+	n=`echo gdbserver | sed '$(program_transform_name)'`; \
+	if [ x$$n = x ]; then n=gdbserver; else true; fi; \
+	if [ x$IPA_DEPFILES != x ]; then \
+		$(SHELL) $(srcdir)/../../mkinstalldirs $(DESTDIR)$(libdir); \
+		$(INSTALL_PROGRAM) $(IPA_LIB) $(DESTDIR)$(libdir)/$(IPA_LIB); \
+	fi; \
+	$(SHELL) $(srcdir)/../../mkinstalldirs $(DESTDIR)$(bindir); \
+	$(INSTALL_PROGRAM) gdbserver$(EXEEXT) $(DESTDIR)$(bindir)/$$n$(EXEEXT); \
+	$(SHELL) $(srcdir)/../../mkinstalldirs $(DESTDIR)$(man1dir); \
+	$(INSTALL_DATA) $(srcdir)/gdbserver.1 $(DESTDIR)$(man1dir)/$$n.1
+
+uninstall: force
+	n=`echo gdbserver | sed '$(program_transform_name)'`; \
+	if [ x$$n = x ]; then n=gdbserver; else true; fi; \
+	rm -f $(bindir)/$$n$(EXEEXT) $(DESTDIR)$(man1dir)/$$n.1
+
+installcheck:
+check:
+info dvi pdf:
+install-info:
+install-pdf:
+html:
+install-html:
+clean-info:
+
+gdbserver$(EXEEXT): $(OBS) ${ADD_DEPS} ${CDEPS}
+	rm -f gdbserver$(EXEEXT)
+	${CC-LD} $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) -o gdbserver$(EXEEXT) $(OBS) \
+	  $(GDBSERVER_LIBS) $(XM_CLIBS)
+
+gdbreplay$(EXEEXT): $(GDBREPLAY_OBS)
+	rm -f gdbreplay$(EXEEXT)
+	${CC-LD} $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) -o gdbreplay$(EXEEXT) $(GDBREPLAY_OBS) \
+	  $(XM_CLIBS)
+
+IPA_OBJS=tracepoint-ipa.o utils-ipa.o regcache-ipa.o remote-utils-ipa.o ${IPA_DEPFILES}
+
+IPA_LIB=libinproctrace.so
+
+$(IPA_LIB): $(IPA_OBJS) ${ADD_DEPS} ${CDEPS}
+	rm -f $(IPA_LIB)
+	${CC-LD} -shared -fPIC -Wl,--no-undefined $(INTERNAL_CFLAGS) \
+	$(INTERNAL_LDFLAGS) -o $(IPA_LIB) ${IPA_OBJS} -ldl -pthread
+
+# Put the proper machine-specific files first, so M-. on a machine
+# specific routine gets the one for the correct machine.
+# The xyzzy stuff below deals with empty DEPFILES
+TAGS:	${TAGFILES}
+	etags `find ${srcdir}/../config -name $(DEPRECATED_TM_FILE) -print` \
+	  `find ${srcdir}/../config -name ${XM_FILE} -print` \
+	  `find ${srcdir}/../config -name ${NAT_FILE} -print` \
+	  `for i in yzzy ${DEPFILES}; do \
+	     if [ x$$i != xyzzy ]; then \
+	       echo ${srcdir}/$$i | sed -e 's/\.o$$/\.c/' ; \
+	     fi; \
+	   done` \
+	  ${TAGFILES}
+tags: TAGS
+
+clean:
+	rm -f *.o ${ADD_FILES} *~
+	rm -f version.c
+	rm -f gdbserver$(EXEEXT) gdbreplay$(EXEEXT) core make.log
+	rm -f $(IPA_LIB)
+	rm -f reg-arm.c i386.c reg-ia64.c reg-m32r.c reg-m68k.c
+	rm -f reg-sh.c reg-sparc.c reg-spu.c amd64.c i386-linux.c
+	rm -f reg-cris.c reg-crisv32.c amd64-linux.c reg-xtensa.c
+	rm -f arm-with-iwmmxt.c
+	rm -f arm-with-vfpv2.c arm-with-vfpv3.c arm-with-neon.c
+	rm -f mips-linux.c mips64-linux.c
+	rm -f powerpc-32l.c powerpc-64l.c powerpc-e500l.c
+	rm -f powerpc-altivec32l.c powerpc-cell32l.c powerpc-vsx32l.c
+	rm -f powerpc-altivec64l.c powerpc-cell64l.c powerpc-vsx64l.c
+	rm -f powerpc-isa205-32l.c powerpc-isa205-64l.c
+	rm -f powerpc-isa205-altivec32l.c powerpc-isa205-vsx32l.c powerpc-isa205-altivec64l.c
+	rm -f powerpc-isa205-vsx64l.c
+	rm -f s390-linux32.c s390-linux64.c s390x-linux64.c
+	rm -f xml-builtin.c stamp-xml
+	rm -f i386-avx.c i386-avx-linux.c
+	rm -f amd64-avx.c amd64-avx-linux.c
+	rm -f i386-mmx.c i386-mmx-linux.c
+
+maintainer-clean realclean distclean: clean
+	rm -f nm.h tm.h xm.h config.status config.h stamp-h config.log
+	rm -f Makefile
+
+config.h: stamp-h ; @true
+stamp-h: config.in config.status
+	CONFIG_FILES="" CONFIG_HEADERS=config.h:config.in $(SHELL) ./config.status
+
+Makefile: Makefile.in config.status
+	CONFIG_HEADERS="" $(SHELL) ./config.status
+
+config.status: configure configure.srv
+	$(SHELL) ./config.status --recheck
+
+force:
+
+version.c: Makefile $(srcdir)/../version.in
+	rm -f version.c-tmp version.c
+	echo '#include "server.h"' >> version.c-tmp
+	echo 'const char version[] = "'"`sed q ${srcdir}/../version.in`"'";' >> version.c-tmp
+	echo 'const char host_name[] = "$(host_alias)";' >> version.c-tmp
+	mv version.c-tmp version.c
+version.o: version.c $(server_h)
+
+xml-builtin.c: stamp-xml; @true
+stamp-xml: $(XML_DIR)/feature_to_c.sh Makefile $(XML_FILES)
+	rm -f xml-builtin.tmp
+	$(SHELL) $(XML_DIR)/feature_to_c.sh xml-builtin.tmp $(XML_FILES)
+	$(SHELL) $(srcdir)/../../move-if-change xml-builtin.tmp xml-builtin.c
+	echo stamp > stamp-xml
+
+.PRECIOUS: xml-builtin.c
+
+# GNU Make has an annoying habit of putting *all* the Makefile variables
+# into the environment, unless you include this target as a circumvention.
+# Rumor is that this will be fixed (and this target can be removed)
+# in GNU Make 4.0.
+.NOEXPORT:
+
+# GNU Make 3.63 has a different problem: it keeps tacking command line
+# overrides onto the definition of $(MAKE).  This variable setting
+# will remove them.
+MAKEOVERRIDES=
+
+gdb_proc_service_h = $(srcdir)/gdb_proc_service.h
+regdat_sh = $(srcdir)/../regformats/regdat.sh
+regdef_h = $(srcdir)/../regformats/regdef.h
+regcache_h = $(srcdir)/regcache.h
+server_h = $(srcdir)/server.h $(regcache_h) config.h $(srcdir)/target.h \
+		$(srcdir)/mem-break.h $(srcdir)/../common/gdb_signals.h
+
+linux_low_h = $(srcdir)/linux-low.h
+
+nto_low_h = $(srcdir)/nto-low.h
+
+UST_CFLAGS = $(ustinc) -DCONFIG_UST_GDB_INTEGRATION
+
+# Note, we only build the IPA if -fvisibility=hidden is supported in
+# the first place.
+IPAGENT_CFLAGS = $(CPPFLAGS) $(INTERNAL_CFLAGS) $(UST_CFLAGS) \
+	-fPIC -DGDBSERVER -DIN_PROCESS_AGENT \
+	-fvisibility=hidden
+
+# In-process agent object rules
+tracepoint-ipa.o: tracepoint.c $(server_h)
+	$(CC) -c $(IPAGENT_CFLAGS) $< -o tracepoint-ipa.o
+utils-ipa.o: utils.c $(server_h)
+	$(CC) -c $(IPAGENT_CFLAGS) $< -o utils-ipa.o
+remote-utils-ipa.o: remote-utils.c $(server_h)
+	$(CC) -c $(IPAGENT_CFLAGS) $< -o remote-utils-ipa.o
+regcache-ipa.o: regcache.c $(server_h)
+	$(CC) -c $(IPAGENT_CFLAGS) $< -o regcache-ipa.o
+i386-linux-ipa.o : i386-linux.c $(regdef_h)
+	$(CC) -c $(IPAGENT_CFLAGS) $< -o i386-linux-ipa.o
+linux-i386-ipa.o: linux-i386-ipa.c $(server_h)
+	$(CC) -c $(IPAGENT_CFLAGS) $< -o linux-i386-ipa.o
+linux-amd64-ipa.o: linux-amd64-ipa.c $(server_h)
+	$(CC) -c $(IPAGENT_CFLAGS) $< -o linux-amd64-ipa.o
+amd64-linux-ipa.o : amd64-linux.c $(regdef_h)
+	$(CC) -c $(IPAGENT_CFLAGS) $< -o amd64-linux-ipa.o
+
+event-loop.o: event-loop.c $(server_h)
+hostio.o: hostio.c $(server_h)
+hostio-errno.o: hostio-errno.c $(server_h)
+inferiors.o: inferiors.c $(server_h)
+mem-break.o: mem-break.c $(server_h)
+proc-service.o: proc-service.c $(server_h) $(gdb_proc_service_h)
+regcache.o: regcache.c $(server_h) $(regdef_h)
+remote-utils.o: remote-utils.c terminal.h $(server_h)
+server.o: server.c $(server_h)
+target.o: target.c $(server_h)
+thread-db.o: thread-db.c $(server_h) $(linux_low_h) $(gdb_proc_service_h)
+tracepoint.o: tracepoint.c $(server_h)
+utils.o: utils.c $(server_h)
+gdbreplay.o: gdbreplay.c config.h
+
+signals.o: ../common/signals.c $(server_h)
+	$(CC) -c $(CPPFLAGS) $(INTERNAL_CFLAGS) $< -DGDBSERVER
+
+memmem.o: ../gnulib/memmem.c
+	$(CC) -o memmem.o -c $(CPPFLAGS) $(INTERNAL_CFLAGS) $<
+
+i386_low_h = $(srcdir)/i386-low.h
+
+i386-low.o: i386-low.c $(i386_low_h) $(server_h) $(target_h)
+
+i387-fp.o: i387-fp.c $(server_h)
+
+linux-low.o: linux-low.c $(linux_low_h) $(server_h)
+	$(CC) -c $(CPPFLAGS) $(INTERNAL_CFLAGS) $< @USE_THREAD_DB@
+
+linux-arm-low.o: linux-arm-low.c $(linux_low_h) $(server_h) \
+	$(gdb_proc_service_h)
+linux-cris-low.o: linux-cris-low.c $(linux_low_h) $(server_h)
+linux-crisv32-low.o: linux-crisv32-low.c $(linux_low_h) $(server_h)
+linux-ia64-low.o: linux-ia64-low.c $(linux_low_h) $(server_h)
+linux-m32r-low.o: linux-m32r-low.c $(linux_low_h) $(server_h)
+linux-mips-low.o: linux-mips-low.c $(linux_low_h) $(server_h) \
+	$(gdb_proc_service_h)
+linux-ppc-low.o: linux-ppc-low.c $(linux_low_h) $(server_h)
+linux-s390-low.o: linux-s390-low.c $(linux_low_h) $(server_h)
+linux-sh-low.o: linux-sh-low.c $(linux_low_h) $(server_h)
+linux-x86-low.o: linux-x86-low.c $(linux_low_h) $(server_h) \
+	$(gdb_proc_service_h) $(i386_low_h)
+linux-xtensa-low.o: linux-xtensa-low.c xtensa-xtregs.c $(linux_low_h) $(server_h)
+
+nto-low.o: nto-low.c $(server_h) $(nto_low_h)
+nto-x86-low.o: nto-x86-low.c $(server_h) $(nto_low_h) $(regdef_h) $(regcache_h)
+
+win32_low_h = $(srcdir)/win32-low.h
+
+win32-low.o: win32-low.c $(win32_low_h) $(server_h) $(regdef_h) $(regcache_h)
+
+win32-arm-low.o: win32-arm-low.c $(win32_low_h) $(server_h)
+win32-i386-low.o: win32-i386-low.c $(win32_low_h) $(server_h) $(i386_low_h)
+
+spu-low.o: spu-low.c $(server_h)
+
+reg-arm.o : reg-arm.c $(regdef_h)
+reg-arm.c : $(srcdir)/../regformats/reg-arm.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-arm.dat reg-arm.c
+arm-with-iwmmxt.o : arm-with-iwmmxt.c $(regdef_h)
+arm-with-iwmmxt.c : $(srcdir)/../regformats/arm-with-iwmmxt.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/arm-with-iwmmxt.dat arm-with-iwmmxt.c
+arm-with-vfpv2.o : arm-with-vfpv2.c $(regdef_h)
+arm-with-vfpv2.c : $(srcdir)/../regformats/arm-with-vfpv2.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/arm-with-vfpv2.dat arm-with-vfpv2.c
+arm-with-vfpv3.o : arm-with-vfpv3.c $(regdef_h)
+arm-with-vfpv3.c : $(srcdir)/../regformats/arm-with-vfpv3.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/arm-with-vfpv3.dat arm-with-vfpv3.c
+arm-with-neon.o : arm-with-neon.c $(regdef_h)
+arm-with-neon.c : $(srcdir)/../regformats/arm-with-neon.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/arm-with-neon.dat arm-with-neon.c
+reg-cris.o : reg-cris.c $(regdef_h)
+reg-cris.c : $(srcdir)/../regformats/reg-cris.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-cris.dat reg-cris.c
+reg-crisv32.o : reg-crisv32.c $(regdef_h)
+reg-crisv32.c : $(srcdir)/../regformats/reg-crisv32.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-crisv32.dat reg-crisv32.c
+i386.o : i386.c $(regdef_h)
+i386.c : $(srcdir)/../regformats/i386/i386.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/i386/i386.dat i386.c
+i386-linux.o : i386-linux.c $(regdef_h)
+i386-linux.c : $(srcdir)/../regformats/i386/i386-linux.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/i386/i386-linux.dat i386-linux.c
+i386-avx.o : i386-avx.c $(regdef_h)
+i386-avx.c : $(srcdir)/../regformats/i386/i386-avx.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/i386/i386-avx.dat i386-avx.c
+i386-avx-linux.o : i386-avx-linux.c $(regdef_h)
+i386-avx-linux.c : $(srcdir)/../regformats/i386/i386-avx-linux.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/i386/i386-avx-linux.dat i386-avx-linux.c
+i386-mmx.o : i386-mmx.c $(regdef_h)
+i386-mmx.c : $(srcdir)/../regformats/i386/i386-mmx.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/i386/i386-mmx.dat i386-mmx.c
+i386-mmx-linux.o : i386-mmx-linux.c $(regdef_h)
+i386-mmx-linux.c : $(srcdir)/../regformats/i386/i386-mmx-linux.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/i386/i386-mmx-linux.dat i386-mmx-linux.c
+reg-ia64.o : reg-ia64.c $(regdef_h)
+reg-ia64.c : $(srcdir)/../regformats/reg-ia64.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-ia64.dat reg-ia64.c
+reg-m32r.o : reg-m32r.c $(regdef_h)
+reg-m32r.c : $(srcdir)/../regformats/reg-m32r.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-m32r.dat reg-m32r.c
+reg-m68k.o : reg-m68k.c $(regdef_h)
+reg-m68k.c : $(srcdir)/../regformats/reg-m68k.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-m68k.dat reg-m68k.c
+reg-cf.o : reg-cf.c $(regdef_h)
+reg-cf.c : $(srcdir)/../regformats/reg-cf.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-cf.dat reg-cf.c
+mips-linux.o : mips-linux.c $(regdef_h)
+mips-linux.c : $(srcdir)/../regformats/mips-linux.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/mips-linux.dat mips-linux.c
+mips64-linux.o : mips64-linux.c $(regdef_h)
+mips64-linux.c : $(srcdir)/../regformats/mips64-linux.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/mips64-linux.dat mips64-linux.c
+powerpc-32l.o : powerpc-32l.c $(regdef_h)
+powerpc-32l.c : $(srcdir)/../regformats/rs6000/powerpc-32l.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/rs6000/powerpc-32l.dat powerpc-32l.c
+powerpc-altivec32l.o : powerpc-altivec32l.c $(regdef_h)
+powerpc-altivec32l.c : $(srcdir)/../regformats/rs6000/powerpc-altivec32l.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/rs6000/powerpc-altivec32l.dat powerpc-altivec32l.c
+powerpc-cell32l.o : powerpc-cell32l.c $(regdef_h)
+powerpc-cell32l.c : $(srcdir)/../regformats/rs6000/powerpc-cell32l.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/rs6000/powerpc-cell32l.dat powerpc-cell32l.c
+powerpc-vsx32l.o : powerpc-vsx32l.c $(regdef_h)
+powerpc-vsx32l.c : $(srcdir)/../regformats/rs6000/powerpc-vsx32l.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/rs6000/powerpc-vsx32l.dat powerpc-vsx32l.c
+powerpc-isa205-32l.o : powerpc-isa205-32l.c $(regdef_h)
+powerpc-isa205-32l.c : $(srcdir)/../regformats/rs6000/powerpc-isa205-32l.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/rs6000/powerpc-isa205-32l.dat powerpc-isa205-32l.c
+powerpc-isa205-altivec32l.o : powerpc-isa205-altivec32l.c $(regdef_h)
+powerpc-isa205-altivec32l.c : $(srcdir)/../regformats/rs6000/powerpc-isa205-altivec32l.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/rs6000/powerpc-isa205-altivec32l.dat powerpc-isa205-altivec32l.c
+powerpc-isa205-vsx32l.o : powerpc-isa205-vsx32l.c $(regdef_h)
+powerpc-isa205-vsx32l.c : $(srcdir)/../regformats/rs6000/powerpc-isa205-vsx32l.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/rs6000/powerpc-isa205-vsx32l.dat powerpc-isa205-vsx32l.c
+powerpc-e500l.o : powerpc-e500l.c $(regdef_h)
+powerpc-e500l.c : $(srcdir)/../regformats/rs6000/powerpc-e500l.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/rs6000/powerpc-e500l.dat powerpc-e500l.c
+powerpc-64l.o : powerpc-64l.c $(regdef_h)
+powerpc-64l.c : $(srcdir)/../regformats/rs6000/powerpc-64l.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/rs6000/powerpc-64l.dat powerpc-64l.c
+powerpc-altivec64l.o : powerpc-altivec64l.c $(regdef_h)
+powerpc-altivec64l.c : $(srcdir)/../regformats/rs6000/powerpc-altivec64l.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/rs6000/powerpc-altivec64l.dat powerpc-altivec64l.c
+powerpc-cell64l.o : powerpc-cell64l.c $(regdef_h)
+powerpc-cell64l.c : $(srcdir)/../regformats/rs6000/powerpc-cell64l.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/rs6000/powerpc-cell64l.dat powerpc-cell64l.c
+powerpc-vsx64l.o : powerpc-vsx64l.c $(regdef_h)
+powerpc-vsx64l.c : $(srcdir)/../regformats/rs6000/powerpc-vsx64l.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/rs6000/powerpc-vsx64l.dat powerpc-vsx64l.c
+powerpc-isa205-64l.o : powerpc-isa205-64l.c $(regdef_h)
+powerpc-isa205-64l.c : $(srcdir)/../regformats/rs6000/powerpc-isa205-64l.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/rs6000/powerpc-isa205-64l.dat powerpc-isa205-64l.c
+powerpc-isa205-altivec64l.o : powerpc-isa205-altivec64l.c $(regdef_h)
+powerpc-isa205-altivec64l.c : $(srcdir)/../regformats/rs6000/powerpc-isa205-altivec64l.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/rs6000/powerpc-isa205-altivec64l.dat powerpc-isa205-altivec64l.c
+powerpc-isa205-vsx64l.o : powerpc-isa205-vsx64l.c $(regdef_h)
+powerpc-isa205-vsx64l.c : $(srcdir)/../regformats/rs6000/powerpc-isa205-vsx64l.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/rs6000/powerpc-isa205-vsx64l.dat powerpc-isa205-vsx64l.c
+s390-linux32.o : s390-linux32.c $(regdef_h)
+s390-linux32.c : $(srcdir)/../regformats/s390-linux32.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/s390-linux32.dat s390-linux32.c
+s390-linux64.o : s390-linux64.c $(regdef_h)
+s390-linux64.c : $(srcdir)/../regformats/s390-linux64.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/s390-linux64.dat s390-linux64.c
+s390x-linux64.o : s390x-linux64.c $(regdef_h)
+s390x-linux64.c : $(srcdir)/../regformats/s390x-linux64.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/s390x-linux64.dat s390x-linux64.c
+reg-sh.o : reg-sh.c $(regdef_h)
+reg-sh.c : $(srcdir)/../regformats/reg-sh.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-sh.dat reg-sh.c
+reg-sparc64.o : reg-sparc64.c $(regdef_h)
+reg-sparc64.c : $(srcdir)/../regformats/reg-sparc64.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-sparc64.dat reg-sparc64.c
+reg-spu.o : reg-spu.c $(regdef_h)
+reg-spu.c : $(srcdir)/../regformats/reg-spu.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-spu.dat reg-spu.c
+amd64.o : amd64.c $(regdef_h)
+amd64.c : $(srcdir)/../regformats/i386/amd64.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/i386/amd64.dat amd64.c
+amd64-linux.o : amd64-linux.c $(regdef_h)
+amd64-linux.c : $(srcdir)/../regformats/i386/amd64-linux.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/i386/amd64-linux.dat amd64-linux.c
+amd64-avx.o : amd64-avx.c $(regdef_h)
+amd64-avx.c : $(srcdir)/../regformats/i386/amd64-avx.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/i386/amd64-avx.dat amd64-avx.c
+amd64-avx-linux.o : amd64-avx-linux.c $(regdef_h)
+amd64-avx-linux.c : $(srcdir)/../regformats/i386/amd64-avx-linux.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/i386/amd64-avx-linux.dat amd64-avx-linux.c
+reg-xtensa.o : reg-xtensa.c $(regdef_h)
+reg-xtensa.c : $(srcdir)/../regformats/reg-xtensa.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-xtensa.dat reg-xtensa.c
+# This is the end of "Makefile.in".
diff -Naur gdb-7.2.orig/gdb/gdbserver/server.c gdb-7.2/gdb/gdbserver/server.c
--- gdb-7.2.orig/gdb/gdbserver/server.c	2011-02-11 14:53:29.087414512 -0500
+++ gdb-7.2/gdb/gdbserver/server.c	2011-02-11 14:55:32.656163114 -0500
@@ -2938,7 +2938,7 @@
       {
 	char *lenptr;
 	char *dataptr;
-	CORE_ADDR addr = strtoul (&own_buf[3], &lenptr, 16);
+	CORE_ADDR addr = strtoull (&own_buf[3], &lenptr, 16);
 	int len = strtol (lenptr + 1, &dataptr, 16);
 	char type = own_buf[1];
 	int res;
diff -Naur gdb-7.2.orig/gdb/python/py-utils.c gdb-7.2/gdb/python/py-utils.c
--- gdb-7.2.orig/gdb/python/py-utils.c	2011-02-11 14:53:29.077414377 -0500
+++ gdb-7.2/gdb/python/py-utils.c	2011-02-11 14:55:32.656163114 -0500
@@ -287,8 +287,8 @@
     *addr = value_as_address (value_object_to_value (obj));
   else if (PyLong_Check (obj))
     {
-      /* Assume CORE_ADDR corresponds to unsigned long.  */
-      *addr = PyLong_AsUnsignedLong (obj);
+      /* Assume CORE_ADDR corresponds to unsigned long long.  */
+      *addr = PyLong_AsUnsignedLongLong (obj);
       if (PyErr_Occurred () != NULL)
 	return 0;
     }
diff -Naur gdb-7.2.orig/gdb/top.c gdb-7.2/gdb/top.c
--- gdb-7.2.orig/gdb/top.c	2011-02-11 14:53:29.077414377 -0500
+++ gdb-7.2/gdb/top.c	2011-02-11 14:55:32.656163114 -0500
@@ -477,10 +477,12 @@
 
   make_cleanup_restore_ui_file (&gdb_stdout);
   make_cleanup_restore_ui_file (&gdb_stderr);
+  make_cleanup_restore_ui_file (&gdb_stdtarg);
   make_cleanup_ui_file_delete (str_file);
 
   gdb_stdout = str_file;
   gdb_stderr = str_file;
+  gdb_stdtarg = str_file;
 
   execute_command (p, from_tty);
 
