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 / utils / amd-udi / udi / udip2iss.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-23  |  15.9 KB  |  402 lines

  1. /******************************************************************************
  2. *       The process  and all routines contained  herein are the
  3. *       property and trade secrets of AMD Inc. 
  4. *       Except as  provided  for by licence agreement, this code 
  5. *       shall  not  be duplicated,  used or  disclosed  for  any 
  6. *       purpose or reason, in whole or part, without the express 
  7. *       written consent of AMD.
  8. *       Copyright  AMD Inc.  1991
  9. *
  10. *********************************************************************** MODULE
  11. *       $NAME     @(#)udip2iss.c    1.2 91/06/14
  12. *       AUTHORS   UDI Team Members
  13. *       This module implements the UDI Procedural interface
  14. *    for the ISS simulator.
  15. ********************************************************************** HISTORY
  16. *
  17. *
  18. **************************************************************** INCLUDE FILES
  19. */
  20. #include "stdio.h"
  21. #include "udiproc.h"
  22.  
  23.  
  24. /*********************************************************** UDI_GET_ERROR_MSG
  25.      Errors above the value ERRUDI_TIP indicate that the
  26.      TIP  was  not able to complete the request for some
  27.      target   specific    reason.     The    DFE    uses
  28.      UDIGetErrorMsg() to get the descriptive text for
  29.      the error message which can then  be  displayed  to
  30.      the user.
  31. */
  32. UDIError UDIGetErrorMsg(error_code, msg)
  33. UINT32          error_code;    /* in */
  34. UDIHostMemPtr  msg;        /* out -- text of msg */
  35. {
  36. }
  37.  
  38. /*************************************************************** UDI_TERMINATE
  39.      UDITerminate() is used to tell the  TIP  that  the
  40.      DFE is finished.
  41. */
  42. UDITerminate()
  43. {
  44. }
  45.  
  46. /******************************************************* UDI_GET_TARGET_CONFIG
  47.      UDIGetTargetConfig() gets information about  the
  48.      target.  I_mem_start/size defines the start address
  49.      and   length    of    instruction    RAM    memory.
  50.      D_mem_start/size  defines  the  start  address  and
  51.      length     of     instruction     Data      memory.
  52.      IR_mem_start/size  defines  the  start  address and
  53.      length of instruction ROM memory.  coprocessor  de-
  54.      fines the type of coprocessor present in the target
  55.      if any.  max_breakpoints defines the maximum number
  56.      of   breakpoints   which  the  target  can  handle.
  57.      max_steps defines the maximum number  of  stepcount
  58.      that can be used in the UDIStep command.
  59. */
  60. UDIError UDIGetTargetConfig(I_mem_start, I_mem_size, D_mem_start,
  61.         D_mem_size, R_mem_start, R_mem_size, cpu_prl, copro_prl)
  62. UDIOffset  *I_mem_start;/* out */
  63. UDIOffset  *I_mem_size;    /* out */
  64. UDIOffset  *D_mem_start;/* out */
  65. UDIOffset  *D_mem_size;    /* out */
  66. UDIOffset  *R_mem_start;/* out */
  67. UDIOffset  *R_mem_size;    /* out */
  68. UINT32       *cpu_prl;    /* out */
  69. UINT32       *copro_prl;    /* out */
  70. {
  71. }
  72.  
  73. /********************************************************** UDI_CREATE_PRCOESS
  74.      UDICreateProcess() tells the  target  OS  that  a
  75.      process is to be created and gets a pID back unless
  76.      there is some error.
  77. */
  78. UDIError UDICreateProcess(pid)
  79. UDIPID    *pid;    /* out */
  80. {
  81. }
  82.  
  83. /********************************************************** UDI_SET_DEFALUT_PID
  84.      UDISetDefaultPid  uses   a   pid   supplied   by
  85.      UDICreateProcess  and  sets it as the default for all
  86.      udi calls until a new default is set.  A user of  a
  87.      single-process OS would only have to use this once.
  88. */
  89. UDIError UDISetDefaultPid(pid)
  90. UDIPID    pid;    /* in */
  91. {
  92. }
  93.  
  94. /********************************************************* UDI_DESTROY_PROCESS
  95.      UDIDestroyProcess() frees a process resource pre-
  96.      viously created by UDICreateProcess().
  97. */
  98. UDIError UDIDestroyProcess(pid)
  99. UDIPID   pid;    /* in */
  100. {
  101. }
  102.  
  103. /****************************************************** UDI_INITIALIZE_PROCESS
  104.      UDIInitializeProcess() is called after  the  code
  105.      for a process has been loaded.  The pid used is the
  106.      one  set  by  UDISetDfaultPid.   The  parameter
  107.      text_addr  defines  the lowest and highest text ad-
  108.      dresses  used  by  the  process.    The   parameter
  109.      data_addr  defines  the lowest and highest data ad-
  110.      dresses  used  by  the   process.    The   paramter
  111.      entry_point defines the entry point of the process.
  112.      The parameters mem_stack_size  and  reg_stack  size
  113.      define  the sizes of the memory and register stacks
  114.      required  by  the  process.   The   special   value
  115.      UDI_DEFAULT  implies  that  the default stack sizes
  116.      for the target OS should be  used.   The  parameter
  117.      argstring  defines a character string that will get
  118.      parsed into the argv array for  the  process.   The
  119.      target  OS will use the supplied information to set
  120.      up the heaps and stacks and the  program  arguments
  121.      if any.  On return; the PC will be set to the entry
  122.      point of the process.
  123. */
  124. UDIError  UDIInitializeProcess( text_addr, data_addr, entry_point,
  125.             mem_stack_size, reg_stack_size, argstring)
  126. UDIRange    text_addr;        /* in--lowest and highest text addrs */
  127. UDIRange    data_addr;        /* in--lowest and highest data addrs */
  128. UDIResource entry_point;    /* in--process entry point */
  129. CPUSizeT    mem_stack_size;    /* in--memory stack size */
  130. CPUSizeT    reg_stack_size;    /* in--register stack size */
  131. char*        argstring;    /* in--argument string used to */
  132. {
  133. }
  134.  
  135. /****************************************************************** UDI_READ
  136.      UDIRead() reads a block of objects from  a  target
  137.      address+space  to host space.  The parameter struc-
  138.      ture "from" specifies the address space and  offset
  139.      of  the  source.   The parameter "to" specifies the
  140.      destination address in the DFE on  the  host.   The
  141.      parameter  count specifies the number of objects to
  142.      be transferred and "size"  specifies  the  size  of
  143.      each  object.
  144.      The size parameter is used by the TIP to
  145.      perform byte-swapping if the target is not the same
  146.      endian as the  host.   On  completion;  the  output
  147.      parameter  count_done  is  set to the number of ob-
  148.      jects successfully transferred.
  149. */
  150.  
  151. UDIError UDIRead (from, to, count, size, count_done, host_endian)
  152. UDIResource    from;        /* in - source address on target */
  153. UDIVoidPtr    to;        /* out - destination address on host */
  154. UDICount    count;        /* in -- count of objects to be transferred */
  155. UDISize        size;        /* in -- size of each object */
  156. UDICount    *count_done;    /* out - count actually transferred */
  157. UDIBool        host_endian;    /* in -- flag for endian information */
  158. {
  159. }
  160.  
  161. /****************************************************************** UDI_WRITE
  162.      UDIWrite() writes a block  of  objects  from  host
  163.      space  to  a  target  address+space  The  parameter
  164.      "from" specifies the source address in the  DFE  on
  165.      the  host.   The parameter structure "to" specifies
  166.      the address space and offset of the destination  on
  167.      the  target.   The  parameter  count  specifies the
  168.      number of objects  to  be  transferred  and  "size"
  169.      specifies the size of each object. The size parameter
  170.      is used by the TIP to perform byte-swapping if
  171.      the target is not the same endian as the host.   On
  172.      completion;  the output parameter count_done is set
  173.      to the number of objects successfully transferred.
  174. */
  175. UDIError UDIWrite( from, to, count, size, count_done, HostEndian )
  176. UDIResource    from;        /* in -- destination address on host */
  177. UDIResource    to;        /* in -- source address on target */
  178. UDICount    count;        /* in -- count of objects to be transferred */
  179. UDISize        size;        /* in -- size of each object */
  180. UDICount    *count_done;    /* out - count actually transferred */
  181. UDIBool        HostEndian;    /* in -- flag for endian information */
  182. {
  183. }
  184.  
  185. /******************************************************************** UDI_COPY
  186.      UDICopy() copies a block of objects from one  tar-
  187.      get  address/space to another target address/space.
  188.      If the source and destination overlap; the copy  is
  189.      implemented as if a temporary buffer was used.  The
  190.      parameter structure "from"  specifies  the  address
  191.      space  and offset of the destination on the target.
  192.      The parameter structure "to" specifies the  address
  193.      space  and offset of the destination on the target.
  194.      The parameter count specifies the number of objects
  195.      to  be transferred and "size" specifies the size of
  196.      each object.  On completion; the  output  parameter
  197.      count_done is set to the number of objects success-
  198.      fully transferred.
  199. */
  200. UDIError UDICopy(from, to, count, size, count_done, direction )
  201. UDIResource    from;        /* in -- destination address on target */
  202. UDIResource    to;        /* in -- source address on target */
  203. UDICount    count;        /* in -- count of objects to be transferred */
  204. UDISize        size;        /* in -- size of each object */
  205. UDICount    *count_done;    /* out - count actually transferred */
  206. UDIBool        direction;    /* in -- high-to-low or reverse */
  207. {
  208. }
  209.  
  210. /***************************************************************** UDI_EXECUTE
  211.      UDIExecute() continues execution  of  the  default
  212.      process from the current PC.
  213. */
  214. UDIError UDIExecute()
  215. {
  216. }
  217.  
  218. /******************************************************************** UDI_STEP
  219.      UDIStep()  specifies  a  number  of  "instruction"
  220.      steps  to  make.  The step can be further qualified
  221.      to state whether CALLs  should  or  should  not  be
  222.      stepped over; whether TRAPs should or should not be
  223.      stepped over; and whether stepping should halt when
  224.      the PC gets outside a certain range.  The semantics
  225.      of UDIStep imply that progress  is  made;  ie;  at
  226.      least  one  instruction is executed before traps or
  227.      interrupts are handled.
  228. */
  229. UDIError UDIStep(steps, steptype, range)
  230. UINT32          steps;          /* in -- number of steps */
  231. UDIStepType   steptype;       /* in -- type of stepping to be done */
  232. UDIRange      range;          /* in -- range if StepInRange is TRUE */
  233. {
  234. }
  235.  
  236. /******************************************************************** UDI_STOP
  237.      UDIStop() stops the default process
  238. */
  239. UDIError UDIStop(stop_pc)
  240. UDIResource    *stop_pc;    /* out -- value of PC where we stopped */
  241. {
  242. }
  243.  
  244. /******************************************************************** UDI_WAIT
  245.      UDIWait() returns the state of the target  proces-
  246.      sor.  The TIP is expected to return when the target
  247.      state is no longer RUNNING  or  when  maxtime  mil-
  248.      liseconds have elapsed; whichever comes first.  The
  249.      special maxtime value UDI_WAIT_FOREVER  essentially
  250.      means  that  the  DFE blocks until the target is no
  251.      longer RUNNING.  On completion; pid is used to  re-
  252.      port  which  process  stopped (necessary for multi-
  253.      process targets).  On completion; stop_pc is usual-
  254.      ly set to the PC where execution stopped.
  255.  
  256.      The return status STDIN_NEEDED allows  the  TIP  to
  257.      tell  the DFE that the target program is requesting
  258.      input  and  the  TIP's  own  internal   buffer   of
  259.      charcters is empty.  The DFE can inform the user of
  260.      this situation if it desires.
  261.  
  262.      Possible states are:
  263.          NOT EXECUTING
  264.              RUNNING
  265.              STOPPED (due to UDIStop)
  266.              BREAK   (breakpoint hit)
  267.              STEPPED (completed number of steps requested by UDIStep)
  268.              WAITING (wait mode bit set)
  269.              HALTED  (at a halt instruction)
  270.              WARNED  (not executing because WARN line asserted)
  271.              TRAPPED (invalid trap taken; indicates trap number)
  272.              STDOUT_READY (stopped waiting for stdout to be output)
  273.              STDERR_READY (stopped waiting for stderr to be output)
  274.              STDIN_NEEDED (stopped waiting for stdin to be supplied)
  275. */
  276. UDIError UDIWait(maxtime, pid, stop_reason)
  277. INT32      maxtime;        /* in -- maximum time to wait for completion */
  278. UDIPID     *pid;           /* out -- pid of process which stopped if any */
  279. UINT32     *stop_reason;   /* out -- PC where process stopped */
  280. {
  281. }
  282.  
  283. /********************************************************** UDI_SET_BREAKPOINT
  284.      UDISetBreakpoint() sets a breakpoint  at  an  ad-
  285.      dress  and  uses  the  passcount  to state how many
  286.      times that instruction should  be  hit  before  the
  287.      break  occurs.   The  passcount  continues to count
  288.      down; even if a different breakpoint is hit and  is
  289.      reinitialized  only when this breakpoint is hit.  A
  290.      passcount value of 0 indicates a non-sticky  break-
  291.      point  that  will  be  removed  whenever  execution
  292.      stops.
  293. */
  294. UDIError UDISetBreakpoint (addr, passcount, type)
  295. UDIResource    addr;        /* in -- where breakpoint gets set */
  296. INT32        passcount;    /* in -- passcount for breakpoint  */
  297. UDIBreakType    type;        /* in -- breakpoint type */
  298. {
  299. }
  300.  
  301. /******************************************************** UDI_QUERY_BREAKPOINT
  302. */
  303. UDIError UDIQueryBreakpoint (addr, count)
  304. UDIResource    addr;        /* in -- where breakpoint gets set */
  305. UINT32        *count;        /* out - passcount for breakpoint  */
  306. {
  307. }
  308.  
  309. /******************************************************** UDI_CLEAR_BREAKPOINT
  310.      UDIClearBreakpoint() is used to  clear  a  break-
  311.      point.
  312. */
  313. UDIError UDIClearBreakpoint (addr)
  314. UDIResource    addr;    /* in -- which breakpoint to clear */
  315. {
  316. }
  317.  
  318. /************************************************************** UDI_GET_STDOUT
  319.      UDIGetStdout()  is  called   when   a   call   to
  320.      UDIWait()  returns  with  the status STDOUT_READY.
  321.      The parameter "buf" specifies the DFE's buffer  ad-
  322.      dress  which  is  expected to be filled by the TIP.
  323.      The parameter "bufsize" specifies the size of  this
  324.      buffer.  On return; count_done is set to the number
  325.      of bytes actually written to buf.  The  DFE  should
  326.      keep  calling  UDIGetStdout() until count_done is
  327.      less than bufsize.
  328. */
  329. UDIError UDIGetStdout(buf, bufsize, count_done)
  330. UDIHostMemPtr    buf;        /* out -- buffer to be filled */
  331. CPUSizeT    bufsize;    /* in -- buffer size in bytes */
  332. CPUSizeT    *count_done;    /* out -- number of bytes written to buf */
  333. {
  334. }
  335.  
  336. /************************************************************** UDI_GET_STDERR
  337.      UDIGetStderr()  is  called   when   a   call   to
  338.      UDIWait()  returns  with  the status STDERR_READY.
  339.      In   other    respects    it    is    similar    to
  340.      UDIGetStdout().
  341. */
  342. UDIError UDIGetStderr(buf, bufsize, count)
  343. UDIHostMemPtr buf;    /* out -- buffer to be filled */
  344. UINT32    bufsize;    /* in  -- buffer size in bytes */
  345. INT32    *count;        /* out -- number of bytes written to buf */
  346. {
  347. }
  348.  
  349. /*************************************************************** UDI_PUT_STDIN
  350.      UDIPutStdin() is called whenever the DFE wants to
  351.      deliver an input character to the TIP.  This may be
  352.      in response to a status STDIN_NEEDED but  need  not
  353.      be.   (Some  target  operating  systems  will never
  354.      block for input).  Any buffering and  line  editing
  355.      of  the  stdin  characters is done under control of
  356.      the TIP.
  357. */
  358. INT32    UDIPutStdin (buf, bufsize, count)
  359. UDIHostMemPtr buf;    /* out - buffer to be filled */
  360. UINT32    bufsize;    /* in -- buffer size in bytes */
  361. INT32    *count;        /* out - number of bytes written to buf */
  362. {
  363. }
  364.  
  365. /*************************************************************** UDI_PUT_TRANS
  366.      UDIPutTrans() is used to feed input to  the  pass-
  367.      thru  mode.   The  parameter "buf" is points to the
  368.      input data in DFE memory.   The  parameter  "count"
  369.      specifies the number of bytes.
  370. */
  371. INT32    UDIPutTrans (buf, count)
  372. UDIHostMemPtr    buf;    /* in -- buffer address containing input data */
  373. CPUSizeT    count;    /* in -- number of bytes in buf */
  374. {
  375. }
  376.  
  377. /*************************************************************** UDI_GET_TRANS
  378.      UDIGetTrans() is used to get output lines from the
  379.      pass-thru mode The parameter "buf" specifies to the
  380.      buffer to be filled in DFE space.  "bufsize" speci-
  381.      fies the size of the buffer and; on return, "count"
  382.      is set to the number of bytes put  in  the  buffer.
  383.      The DFE should continue to call UDIGetTrans() un-
  384.      til count is less than bufsize.  Other possible re-
  385.      turn values are:
  386.              EOF -- leave transparent mode
  387.              UDI_GET_INPUT -- host should get  some  in-
  388.      put;                                  then     call
  389.      UDIPutTrans().
  390. */
  391. INT32    UDIGetTrans (buf, bufsize, count)
  392. UDIHostMemPtr    buf;        /* out -- buffer to be filled */
  393. CPUSizeT    bufsize;    /* in  -- size of buf */
  394. CPUSizeT    *count;        /* out -- number of bytes in buf */
  395. {
  396. }
  397.