home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / gdb-4.16-base.tgz / gdb-4.16-base.tar / fsf / gdb / sim / z8k / iface.c < prev    next >
C/C++ Source or Header  |  1995-10-13  |  3KB  |  194 lines

  1. /* gdb->simulator interface.
  2.    Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
  3.  
  4. This file is part of Z8KSIM
  5.  
  6. Z8KSIM is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. Z8KSIM is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with Z8KZIM; if not, write to the Free Software
  18. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  19.  
  20. #include <ansidecl.h>
  21. #include "sim.h"
  22. #include "tm.h"
  23. #include "signal.h"
  24. #include "callback.h"
  25. #include "../../gdb/remote-sim.h"
  26.  
  27. void
  28. sim_store_register (regno, value)
  29.      int regno;
  30.      unsigned char *value;
  31. {
  32.   /* FIXME: Review the computation of regval.  */
  33.   int regval = (value[0] << 24) | (value[1] << 16) | (value[2] << 8) | value[3];
  34.  
  35.   tm_store_register (regno, regval);
  36. }
  37.  
  38. void
  39. sim_fetch_register (regno, buf)
  40.      int regno;
  41.      unsigned char *buf;
  42. {
  43.   tm_fetch_register (regno, buf);
  44. }
  45.  
  46. int
  47. sim_write (where, what, howmuch)
  48.      SIM_ADDR where;
  49.      unsigned char *what;
  50.      int howmuch;
  51. {
  52.   int i;
  53.  
  54.   for (i = 0; i < howmuch; i++)
  55.     tm_write_byte (where + i, what[i]);
  56.   return howmuch;
  57. }
  58.  
  59. int
  60. sim_read (where, what, howmuch)
  61.      SIM_ADDR where;
  62.      unsigned char *what;
  63.      int howmuch;
  64. {
  65.   int i;
  66.  
  67.   for (i = 0; i < howmuch; i++)
  68.     what[i] = tm_read_byte (where + i);
  69.   return howmuch;
  70. }
  71.  
  72. static void 
  73. control_c (sig, code, scp, addr)
  74.      int sig;
  75.      int code;
  76.      char *scp;
  77.      char *addr;
  78. {
  79.   tm_exception (SIM_INTERRUPT);
  80. }
  81.  
  82. void
  83. sim_resume (step, sig)
  84.      int step;
  85.      int sig;
  86. {
  87.   void (*prev) ();
  88.  
  89.   prev = signal (SIGINT, control_c);
  90.   tm_resume (step);
  91.   signal (SIGINT, prev);
  92. }
  93.  
  94. void
  95. sim_stop_reason (reason, sigrc)
  96.      enum sim_stop *reason;
  97.      int *sigrc;
  98. {
  99.   switch (tm_signal ())
  100.     {
  101.     case SIM_DIV_ZERO:
  102.       *sigrc = SIGFPE;
  103.       break;
  104.     case SIM_INTERRUPT:
  105.       *sigrc = SIGINT;
  106.       break;
  107.     case SIM_BAD_INST:
  108.       *sigrc = SIGILL;
  109.       break;
  110.     case SIM_BREAKPOINT:
  111.       *sigrc = SIGTRAP;
  112.       break;
  113.     case SIM_SINGLE_STEP:
  114.       *sigrc = SIGTRAP;
  115.       break;
  116.     case SIM_BAD_SYSCALL:
  117.       *sigrc = SIGILL;
  118.       break;
  119.     case SIM_BAD_ALIGN:
  120.       *sigrc = SIGSEGV;
  121.       break;
  122.     case SIM_DONE:
  123.       *sigrc = 1;
  124.       *reason = sim_exited;
  125.       return;
  126.     default:
  127.       abort ();
  128.     }
  129.   *reason = sim_stopped;
  130. }
  131.  
  132. void
  133. sim_info (verbose)
  134.      int verbose;
  135. {
  136.   sim_state_type x;
  137.  
  138.   tm_state (&x);
  139.   tm_info_print (&x);
  140. }
  141.  
  142. void
  143. sim_open (args)
  144.      char *args;
  145. {
  146.   /* nothing to do */
  147. }
  148.  
  149. void
  150. sim_close (quitting)
  151.      int quitting;
  152. {
  153.   /* nothing to do */
  154. }
  155.  
  156. int
  157. sim_load (prog, from_tty)
  158.      char *prog;
  159.      int from_tty;
  160. {
  161.   /* Return non-zero so gdb will handle it.  */
  162.   return 1;
  163. }
  164.  
  165. void
  166. sim_create_inferior (start_address, argv, env)
  167.      SIM_ADDR start_address;
  168.      char **argv;
  169.      char **env;
  170. {
  171.   tm_store_register (REG_PC, start_address);
  172. }
  173.  
  174. void
  175. sim_kill ()
  176. {
  177.   /* nothing to do */
  178. }
  179.  
  180. void
  181. sim_do_command (cmd)
  182.      char *cmd;
  183. {
  184.  
  185. }
  186.  
  187.  
  188. void
  189. sim_set_callbacks (ptr)
  190. struct host_callback_struct *ptr;
  191. {
  192.  
  193. }
  194.