⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdb-6.1-bdm-m68k.patch

📁 WaitForSingleObject 摩托罗拉的68k源程序
💻 PATCH
📖 第 1 页 / 共 5 页
字号:
+  inferior_ptid = pid_to_ptid (42000);++  /* Clean up from the last time we were running.  */+  clear_proceed_status ();++  /* Let the remote process run. The -1 will continue. */+  proceed (addr, TARGET_SIGNAL_DEFAULT, 0);+}++static void+bdm_mourn_inferior (void)+{+  if (bdm_debug_level)+    printf_filtered ("bdm mourn inferior called\n");+  unpush_target (&bdm_ops);+  generic_mourn_inferior ();+}++/*+ * Load a file.+ */+static void+bdm_load (char *filename, int from_tty)+{+  if (bdm_debug_level)+    printf_filtered ("bdm load called\n");+  if ((bdm_get_status () & BDM_TARGETSTOPPED) == 0)+    bdm_stop_chip ();+  inferior_ptid = bdm_ptid = null_ptid;+  init_wait_for_inferior ();+  generic_load (filename, from_tty);+  bdm_prog_loaded = savestring (filename, strlen (filename));+  +}++/*+ * Fetch register REGNO, or all user registers if REGNO is -1.+ */+static void+bdm_fetch_register (int regno)+{+  unsigned long l;+  char cbuf[4];+  int ret;++  if (regno < 0) {+    for (regno = 0 ; regno < NUM_REGS ; regno++)+      bdm_fetch_register (regno);+  }+  else {+    /*+     * When the target is running the +     * cpu registers can not be accessed.+     */+    if (bdm_gdb_no_wait && (bdm_get_status () == 0)) {+      l = 0;+      ret = 0;+     }+    else {+      if (regno < 16) {+        ret = bdmReadRegister (regno, &l);+      }+      else {+        int cfreg = regno - 16;+        if (bdm_debug_level)+          printf_filtered ("bdm_fetch_register: special reg: %d\n", cfreg);+        if (cfreg < (sizeof (reg_to_dev_num) / sizeof (int))) {+          if (reg_to_dev_num[cfreg] < 0)+            return;+          if (bdm_debug_level)+            printf_filtered ("bdm_fetch_register: reg_to_dev_num: %d\n",+                             reg_to_dev_num[cfreg]);+          if (reg_to_dev_num[cfreg] < 0x100)+            ret = bdmReadSystemRegister (reg_to_dev_num[cfreg], &l);+          else+            ret = bdmReadControlRegister (reg_to_dev_num[cfreg], &l);+        }+        else {+          error ("Bad register number (%d)", regno); +          return;+        }+      }+    }+    if (ret < 0)+      bdm_report_error ();+    cbuf[0] = l >> 24;+    cbuf[1] = l >> 16;+    cbuf[2] = l >> 8;+    cbuf[3] = l;+    supply_register (regno, cbuf);+  }+}++void+bdm_prepare_to_store (void)+{+  /* Do nothing, since we can store individual regs */+}++/*+ * Store register REGNO, or all user registers if REGNO == -1.+ */+void+bdm_store_register (int regno)+{+  unsigned long l;+  int ret;++  if (bdm_gdb_no_wait && (bdm_get_status () == 0))+    return;+  +  if (regno == -1) {+    for (regno = 0 ; regno < NUM_REGS ; regno++)+      bdm_store_register (regno);+  }+  else {+    l = read_register (regno);+    if (regno < 16) {+      ret = bdmWriteRegister (regno, l);+    }+    else {+      int cfreg = regno - 16;+      if (bdm_debug_level)+        printf_filtered ("bdm_store_register: special reg: %d\n", cfreg);+      if (cfreg < (sizeof (reg_to_dev_num) / sizeof (int))) {+        if (reg_to_dev_num[cfreg] < 0)+          return;+        if (bdm_debug_level)+          printf_filtered ("bdm_store_register: reg_to_dev_num: %d\n",+                           reg_to_dev_num[cfreg]);+        if (reg_to_dev_num[cfreg] < 0x100)+          ret = bdmWriteSystemRegister (reg_to_dev_num[cfreg], l);+        else+          ret = bdmWriteControlRegister (reg_to_dev_num[cfreg], l);+      }+      else {+        error ("Bad register number (%d)", regno); +        return;+      }+    }+    if (ret < 0)+      bdm_report_error ();+  }+}++/*+ * Transfer memory contents between target and host+ */+static int+bdm_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr,+                          int len, int write,+                          struct  mem_attrib *attrib,+                          struct target_ops *t)+{+  int ret;++  if (write)+    ret = bdmWriteMemory (memaddr, myaddr, len);+  else+    ret = bdmReadMemory (memaddr, myaddr, len);+  if (ret < 0)+    bdm_report_error ();+  return len;+}++static void+bdm_files_info (struct target_ops *t)+{+  printf_filtered ("target %s is attached to %s\n", t->to_shortname, dev_name);+  if (bdm_prog_loaded) {+    printf_filtered ("and running program %s\n", bdm_prog_loaded);+  }+  else {+    printf_filtered ("no program loaded\n");+  }+}++/*+ * Toggle the no load variable.+ */+static void+bdm_toggle_no_load (char *args, int from_tty)+{+  if (!bdm_no_load) {+    bdm_no_load = 1;+    printf_filtered ("Image not loaded on run\n");+  }+  else {+    bdm_no_load = 0;+    printf_filtered ("Image loaded on run\n");+  }+}++/*+ * Select a CPU32 processor register set.+ */+static void+bdm_select_cpu32 (char *args, int from_tty)+{+  bdm_reg_names = cpu32_reg_names;+}++/*+ * Get or set the use of the PST signals when using a Coldfire.+ */+static void+bdm_cf_pst (char *args, int from_tty)+{+  int pst;+  +  if (!args)+  {+    if (bdmColdfireGetPST (&pst) < 0)+      printf_filtered ("error getting the PST state: %d\n", errno);+    else+      printf_filtered ("PST signal use: %s\n", pst ? "ENABLED" : "DISABLED");+  }+  else+  {+    pst = strtoul (args, 0, 0);+    if (pst)+      pst = 1;+    if (bdmColdfireSetPST (pst) < 0)+      printf_filtered ("error setting the PST state: %d\n", errno);+  }  +}++/*+ * Read or write control registers.+ */+static void+bdm_read_control_reg (char *exp, int from_tty)+{+  static LONGEST reg = -1;+  static char format = 'x';+  struct cleanup *old_chain = 0;+  struct expression *expr;+  struct value* val;+  struct type type;+  unsigned long l;+  +  if (!exp) {+    if (reg < 0)+      error ("you need to supply a 16bit register value, eg VBR = 0x801\n");+  }+  else {+    if (*exp == '/') {+      exp++;+      if (*exp == 'd' || *exp == 'x')+        format = *exp;+      else+        error ("format specifiers are 'd' or 'x\n");+      exp++;+    }+  +    expr = parse_expression (exp);+    old_chain = make_cleanup (free_current_contents, &expr);+    val = evaluate_expression (expr);++    if (VALUE_LVAL (val) == not_lval || VALUE_LVAL (val) == lval_internalvar)+      reg = unpack_long (VALUE_TYPE (val), VALUE_CONTENTS (val));+    else {+      reg = -1;+      format = 'x';+      do_cleanups (old_chain);+      error ("the register can be a literal or a gdb variable");+    }+    +    do_cleanups (old_chain);+  }+  +  if (bdmReadControlRegister (reg, &l) < 0)+    bdm_report_error ();++  if (format == 'x')+    printf_filtered ("0x%08lx\n", l);+  else+    printf_filtered ("%ld\n", l);+}++static void+bdm_write_control_reg (char *exp, int from_tty)+{+  static int reg = -1;+  static int l = 0x0;+  struct cleanup *old_chain = 0;+  struct expression *expr;+  struct value* val;+  char* end;+  +  if (!exp && (reg < 0))+    error ("you need to supply a 16bit register value, eg VBR = 0x801\n");+  +  /*+   * Do a little token parsing to split the expression into 2 separate parts+   * and then parse each one. There may be a better way but it will do.+   */++  end = strchr (exp, ' ');++  if (!end) {+    end = strchr (exp, '\t');+    if (!end)+      error ("write requires a register and a value to write\n");+  }++  *end = '\0';+  +  expr = parse_expression (exp);+  old_chain = make_cleanup (free_current_contents, &expr);+  val = evaluate_expression (expr);++  if (VALUE_LVAL (val) == not_lval || VALUE_LVAL (val) == lval_internalvar) {+    reg = unpack_long (VALUE_TYPE (val), VALUE_CONTENTS (val));+  }+  else {+    reg = -1;+    l = 0;+    do_cleanups (old_chain);+    error ("the register can be a literal or a gdb variable");+  }+    +  do_cleanups (old_chain);++  old_chain = 0;+  +  exp = end + 1;+  +  expr = parse_expression (exp);+  old_chain = make_cleanup (free_current_contents, &expr);+  val = evaluate_expression (expr);++  if (VALUE_LVAL (val) == not_lval || VALUE_LVAL (val) == lval_internalvar) {+    l = unpack_long (VALUE_TYPE (val), VALUE_CONTENTS (val));+  }+  else {+    reg = -1;+    l = 0;+    do_cleanups (old_chain);+    error ("the data to write can be a literal or a gdb variable");+  }+  +  do_cleanups (old_chain);++  if (bdmWriteControlRegister (reg, l) < 0)+    bdm_report_error ();+}++struct target_ops bdm_ops;++static void+init_bdm_ops(void)+{+  bdm_ops.to_shortname = "bdm";+  bdm_ops.to_longname =+    "CPU32 and Coldfire Background Debug Mode Interface" \+    " for downloading and remote debugging";+  bdm_ops.to_doc = "Uses the Public Domain Background Debug Mode Interface connected to the\n" \+    "BDM-port of the CPU32 or Coldfire based microcontroller and to a parallel port\n"+    "of the PC.\n" \+    "Usage: target bdm <device>\n" \+    "where <device> is the BDM character special file (e.g. /dev/bdm0).";+  bdm_ops.to_open = bdm_open;+  bdm_ops.to_close = bdm_close;+  bdm_ops.to_attach = bdm_attach;+  bdm_ops.to_detach = bdm_detach;+  bdm_ops.to_resume = bdm_resume;+  bdm_ops.to_wait = bdm_wait;+  bdm_ops.to_fetch_registers = bdm_fetch_register;+  bdm_ops.to_store_registers = bdm_store_register;+  bdm_ops.to_prepare_to_store = bdm_prepare_to_store;+  bdm_ops.to_xfer_memory = bdm_xfer_inferior_memory;+  bdm_ops.to_files_info = bdm_files_info;+  bdm_ops.to_insert_breakpoint = memory_insert_breakpoint;+  bdm_ops.to_remove_breakpoint = memory_remove_breakpoint;+  bdm_ops.to_kill = bdm_kill;+  bdm_ops.to_load = bdm_load;+  bdm_ops.to_stop = bdm_stop_chip;+  bdm_ops.to_create_inferior = bdm_create_inferior;+  bdm_ops.to_mourn_inferior = bdm_mourn_inferior;+  bdm_ops.to_can_run = bdm_can_run;+  bdm_ops.to_stratum = process_stratum;+  bdm_ops.to_has_all_memory = 1;+  bdm_ops.to_has_memory = 1;+  bdm_ops.to_has_stack = 1;+  bdm_ops.to_has_registers = 1;+  bdm_ops.to_has_execution = 1;+  bdm_ops.to_magic = OPS_MAGIC;+};++void+_initialize_remote_bdmcf (void)+{+  bdm_ptid = null_ptid;+  init_bdm_ops ();+  add_com ("bdm-reset", class_obscure,+     (void (*)(char *, int))bdm_reset,+     "Reset target and enter BDM mode.");+  add_com ("bdm-release", class_obscure,+     (void (*)(char *, int))bdm_release_chip,+     "Reset target without BDM-mode.");+  add_com ("bdm-status", class_obscure,+     (void (*)(char *, int))bdm_get_status_interactive,+     "Show status of bdm interface\n");+  add_com ("bdm-setdelay", class_obscure,+     bdm_setdelay_interactive,+     "set delay for download");+  add_com ("bdm-setdebug", class_obscure,+     bdm_setdebug_interactive,+     "enable/disable BDM diagnostic messages");+  add_com ("bdm-setdriverdebug", class_obscure,+     bdm_setdriverdebug_interactive,+     "enable/disable BDM driver diagnostic messages");+  add_com ("bdm-no-wait", class_obscure,+     bdm_set_no_wait,+     "Cause GDB to not wait for the target to stop when running.");+  add_com ("bdm-wait", class_obscure,+     bdm_set_wait,+     "Cause GDB to wait for the target to stop when running.");+  add_com ("bdm-stop", class_obscure,+     bdm_issue_stop,+     "Stop the target if running.");+  add_com ("bdm-select-cpu32", class_obscure,+     bdm_select_cpu32,+     "Selects the CPU32 register set rather than the default CPU32+.");+  add_com ("bdm-no-load", class_obscure,+     bdm_toggle_no_load,+     "Toggle the loading of the program to memory when asked to run.");+  add_com ("bdm-cf-pst", class_obscure,+     bdm_cf_pst,+     "Get or set the use of the PST signals.");+  add_com ("bdm-read-creg", class_obscure,+     bdm_read_control_reg,+     "Read a control register from the processor.");+  add_com ("bdm-write-creg", class_obscure,+     bdm_write_control_reg,+     "Write a control register from the processor.");+           +  add_target (&bdm_ops);+}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -