home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / Pascal / BPASCAL.700 / D12 / TDDOC.ZIP / DBGBOARD.TD next >
Encoding:
Text File  |  1992-10-01  |  17.0 KB  |  457 lines

  1.                TURBO DEBUGGER HARDWARE DEBUGGER INTERFACE
  2.                ==========================================
  3.  
  4. Hardware debugging boards greatly speed up certain types of breakpoints;
  5. in particular, those that watch for an area of memory or a program variable
  6. to change. Turbo Debugger has a general interface for accessing these boards.
  7.  
  8. This appendix describes how to write a device driver that Turbo Debugger
  9. can communicate with in order to make use of the capabilities of a
  10. particular hardware debugger. This information is intended for vendors
  11. of hardware debuggers who want to make their boards usable with Turbo 
  12. Debugger. (Note that you must know the general architecture of DOS 
  13. device drivers. Refer to the DOS Technical Reference for more information 
  14. on how to write device drivers.)
  15.  
  16.  
  17. TDH386.SYS: 80386 hardware device driver
  18. ----------------------------------------
  19. The Turbo Debugger distribution disk contains the file TDH386.SYS,
  20. which is a hardware device driver that lets Turbo Debugger use the
  21. debug registers on the 80386 processor. You can use this driver by
  22. copying it to your DOS disk and putting the following line in your
  23. CONFIG.SYS file:
  24.  
  25.    DEVICE = TDH386.SYS
  26.  
  27. Turbo Debugger will then use the hardware assistance of the 80386
  28. whenever it can to speed up breakpoint processing.
  29.  
  30. This means, of course, that you can only use this device driver if
  31. your system uses the 80386 processor or higher.
  32.  
  33.  
  34. Setting hardware breakpoints
  35. ----------------------------
  36. If you need information on using the Turbo Debugger hardware debugging
  37. features, see the file HDWDEBUG.TD.
  38.  
  39.  
  40. Hardware debugger overview
  41. --------------------------
  42. The device driver interface provides device-independent access to the
  43. capabilities of different hardware debuggers. To accomplish this, the
  44. common features of several hardware debuggers have been combined into
  45. one generic hardware debugger. Turbo Debugger then uses this abstract
  46. model to make requests to the device driver. 
  47.  
  48. A particular board might not be able to support all the operations 
  49. specified by the abstract interface. In this case, the device driver 
  50. can inform Turbo Debugger that a requested operation can't be performed. 
  51. A hardware board also might offer more capabilities than the abstract 
  52. interface defines. In this case, Turbo Debugger can't make use of the 
  53. added features of the board.
  54.  
  55. Because we expect the device driver interface to encompass new features
  56. in future releases, we have defined an "implementation level" status
  57. field that the device driver returns when requested. This lets Turbo
  58. Debugger know what the device driver is capable of doing and provides
  59. compatibility with older drivers, while allowing new drivers to take
  60. advantage of capabilities in future releases of the interface.
  61.  
  62. The hardware debugger interface breaks the capabilities of debugger
  63. boards into three main areas of functionality:
  64.  
  65. o memory and I/O access breakpoints
  66.  
  67. o instruction trace-back memory
  68.  
  69. o extra onboard memory for symbol tables
  70.  
  71. This version of the interface supports only the first category. Future
  72. releases will define an interface that accesses the other features.
  73. When you write a device driver, keep in mind that these other
  74. capabilities will be supported at a later date.
  75.  
  76.  
  77. Device driver interface
  78. -----------------------
  79. The device driver is an ordinary character-type device driver named
  80. TDH386.SYS. You must put the following statement in your CONFIG.SYS
  81. file in order for the driver to be loaded when you boot the system:
  82.  
  83.    DEVICE = <drvrname.ext>
  84.  
  85. <drvrname.ext> is the name of the device driver file you have created.
  86.  
  87.  
  88. Device driver function calls
  89. ----------------------------
  90. The device driver must support the following function calls:
  91.  
  92.  
  93. INIT (command code = 0)
  94.   Called once when the device driver is first loaded. Your code for this
  95.   function must make sure that the hardware board is disabled and in a
  96.   quiescent state.
  97.  
  98.  
  99. READ (command code = 4)
  100.   Called by Turbo Debugger to read the status block from the last
  101.   command sent to the device driver. You should keep the last status in
  102.   a data area inside the driver and return as many bytes as requested.
  103.   Each time a read is issued, you must start sending from the beginning
  104.   of the status block, even if the previous read request was not long
  105.   enough to send the entire block.
  106.  
  107.   The section "Status blocks returned by the device driver" describes
  108.   the various status blocks the device driver can return in response to
  109.   different command blocks.
  110.  
  111.  
  112. READNOWAIT (command code = 5)
  113.   Returns the first byte of the status block. The busy bit should always
  114.   be set to 0, indicating that data is available at all times.
  115.  
  116.  
  117. READSTATUS (command code = 6)
  118.   Always sets the busy bit to 0, indicating that a subsequent read
  119.   request would complete immediately.
  120.  
  121.  
  122. READFLUSH (command code = 7)
  123.   Simply sets the done bit in the return status.
  124.  
  125.  
  126. WRITE (command code = 8)
  127.   Called by Turbo Debugger to send a command to the device driver. The
  128.   command will have a variable length depending on the command type.
  129.   You can either copy the data into a work area inside the device
  130.   driver or access it directly using the data pointer that is part 
  131.   of the device driver request.
  132.  
  133.  
  134. The following function calls are command blocks Turbo Debugger can 
  135. send to the device driver:
  136.  
  137.  
  138. WRITEVERIFY (command code = 9)
  139.   Does the same thing as WRITE (command code 8).
  140.  
  141.  
  142. WRITESTATUS (command code = 10)
  143.   Simply sets the done bit in the return status.
  144.  
  145.  
  146. WRITEFLUSH (command code = 11)
  147.   Simply sets the done bit in the return status.
  148.  
  149. All other function calls should set the error bit (bit 15) in the
  150. return status word, and put an "Unknown command" error code (3) in the
  151. low byte of the status word.
  152.  
  153.  
  154. Command blocks sent to driver
  155. -----------------------------
  156. All command blocks sent to the device driver by the WRITE function
  157. call start with a byte that describes the operation to perform. The
  158. subsequent bytes provide additional information for the particular
  159. command.
  160.  
  161. When a hardware breakpoint is set, it is the device driver's
  162. responsibility to check that it has been handed an acceptable
  163. parameter block. It can't just ignore fields that request an operation
  164. it can't perform. You must check each field to make sure that the
  165. hardware can support the requested operation, and if it can't, you
  166. must set the appropriate return code.
  167.  
  168. The first byte can contain one of the following command codes:
  169.  
  170. 0   Install vectors
  171. 1   Get hardware capabilities
  172. 2   Enable the hardware breakpoints
  173. 3   Disable the hardware breakpoints
  174. 4   Set a hardware breakpoint
  175. 5   Clear a hardware breakpoint
  176. 6   Set I/O base address, resets hardware
  177. 7   Remove vectors
  178.  
  179. The following commands send additional data after the command code:
  180.  
  181. 0 (Install vectors)
  182.   
  183.   4 bytes     Far pointer to vector routine
  184.  
  185.               This is a 32-bit pointer, the first word being the offset,
  186.               and the second being the segment. You must save this address
  187.               to enable the device driver to jump to it when a hardware
  188.               breakpoint occurs. This routine should also install any
  189.               interrupt vectors that the device driver needs. Turbo Debugger
  190.               calls this routine once when it first starts up. The Remove
  191.               Vectors (code 10) function is called once by Turbo Debugger
  192.               when it no longer needs to use the hardware debugger device
  193.               driver. At this time, you should replace any vectors that you
  194.               took over when function 0 was called and make sure the hardware
  195.               is disabled.
  196.  
  197.  
  198. 4 (Set a hardware breakpoint)
  199.  
  200.   1 byte      Breakpoint type
  201.  
  202.               0   Memory read
  203.               1   Memory write
  204.               2   Memory read or write
  205.               3   I/O read
  206.               4   I/O write
  207.               5   I/O read or write
  208.               6   Instruction fetch
  209.  
  210.   1 byte      Address-matching mode
  211.  
  212.               0   Match any address, don't care
  213.               1   Equal to test value
  214.               2   Not equal to test value
  215.               3   Above test value
  216.               4   Below test value
  217.               5   Below or equal to test value
  218.               6   Above or equal to test value
  219.               7   Within inclusive range
  220.               8   Outside range
  221.  
  222.   4 bytes     Low address
  223.  
  224.               A memory address in 32-bit linear form. If the address-matching
  225.               mode requires one or more addresses to test against, any single 
  226.               value or the low value of multiple addresses comes here.
  227.  
  228.   4 bytes     High address
  229.  
  230.               A memory address, in 32-bit linear form. If the address-matching
  231.               mode requires two addresses to test against a range, the second 
  232.               and higher value comes here.
  233.  
  234.   2 bytes     Pass count
  235.  
  236.   1 byte      Data-matching size: 1 = byte, 2 = word, 4 = doubleword
  237.  
  238.   1 byte      Source of matched bus cycle:
  239.  
  240.               1   CPU
  241.               2   DMA
  242.               3   Either CPU or DMA
  243.                  
  244.   1 byte      Data-matching mode
  245.  
  246.               0   Match any data, don't care
  247.               1   Equal to test value
  248.               2   Not equal to test value
  249.               3   Above test value
  250.               4   Below test value
  251.               5   Below or equal to test value
  252.               6   Above or equal to test value
  253.               7   Within inclusive range
  254.               8   Outside range
  255.  
  256.   4 bytes     Low data value
  257.  
  258.               If the data-matching mode requires one or more data values, 
  259.               this field supplies the first or only value. The data-matching
  260.               size determines how many bytes of this field are significant.
  261.  
  262.   4 bytes     High data value
  263.  
  264.               If the data-matching mode requires two data values, this field
  265.               supplies the second value. The data-matching size determines 
  266.               how many bytes of this field are significant.
  267.  
  268.   4 bytes     Data mask
  269.  
  270.               If the hardware supports it, this field controls which bits in
  271.               the data are examined for the match condition.
  272.  
  273.  
  274. 5 (Clear a hardware breakpoint)
  275.  
  276.   1 byte      The handle of the breakpoint to clear. The handle was given
  277.               to Turbo Debugger by command 4 (Set Hardware Breakpoint).
  278.  
  279.  
  280. 6 (Set I/O board base address)
  281.  
  282.   2 bytes     The base address of the hardware debugger board.
  283.  
  284.  
  285. Status blocks returned by device driver
  286. ---------------------------------------
  287. The READ function call returns the status block from the device
  288. driver. Different commands written to the device driver result in
  289. various status blocks being built to report what happened. All the
  290. status blocks start with a single byte that describes the overall
  291. result of the requested operation. The subsequent bytes return
  292. additional information particular to the command that generated the
  293. status block.
  294.  
  295. The following status codes can be returned in the first byte:
  296.  
  297. 0   Command was successful.
  298.  
  299. 1   Invalid handle supplied.
  300.  
  301. 2   Full, can't set any more breakpoints.
  302.  
  303. 3   Breakpoint was too complex for the hardware.
  304.  
  305.     The breakpoint could never be set because the hardware is not capable
  306.     of supporting the combination of bus cycle, address, and data-matching
  307.     that Turbo Debugger requested.
  308.  
  309. 4   Command can't be performed due to restrictions imposed by a
  310.     previous command.
  311.  
  312.     The command could have been performed if it weren't for some previous
  313.     operation's preventing it. This could happen, for example, if the
  314.     hardware only permits a single data match value, but Turbo Debugger
  315.     tries to set a second hardware breakpoint with a different data match
  316.     value than the first breakpoint.
  317.  
  318. 5   The device driver can't find the hardware board.
  319.  
  320. 6   A hardware failure has occurred.
  321.  
  322. 7   An invalid command code was sent to the driver.
  323.  
  324. 8   The driver hasn't been initialized with function code 0, so
  325.     nothing can be done yet.
  326.  
  327. The following commands return additional status information after the
  328. status code byte:
  329.  
  330. 1 (Get hardware capabilities)
  331.  
  332.   2 bytes     Device driver interface version number. The current 
  333.               version is 1.
  334.  
  335.   2 bytes     Device driver software version number.
  336.  
  337.               For each released version of your device driver that behaves
  338.               differently, this field should contain a different number. 
  339.               This lets Turbo Debugger take special measures if necessary, 
  340.               based on this field.
  341.  
  342.   1 byte      Maximum number of hardware breakpoints that this
  343.               driver and board combination can support.
  344.  
  345.   1 byte      Configuration bits
  346.  
  347.               Bit  Meaning when set
  348.               ---  ----------------
  349.                0   can distinguish between CPU and DMA accesses
  350.                1   can detect DMA transfers
  351.                2   has data mask
  352.                3   breakpoints have hardware pass counter
  353.                4   can match on data as well as address
  354.  
  355.   1 byte      Breakpoint types supported (bit mask)
  356.  
  357.               Bit  Function
  358.               ---  --------
  359.                0   Memory read
  360.                1   Memory write
  361.                2   Memory read or write
  362.                3   I/O read
  363.                4   I/O write
  364.                5   I/O read or write
  365.                6   Instruction fetch
  366.  
  367.   2 bytes     Addressing match modes supported (bit mask)
  368.  
  369.               Bit  Function
  370.               ---  --------
  371.                0   Match any address, don't care
  372.                1   Equal to test value
  373.                2   Not equal to test value
  374.                3   Above test value
  375.                4   Below test value
  376.                5   Below or equal to test value
  377.                6   Above or equal to test value
  378.                7   Within inclusive range
  379.                8   Outside range
  380.  
  381.   2 bytes     Data-matching modes supported (bit mask)
  382.  
  383.               Bit  Function
  384.               ---  --------
  385.  
  386.                0   Match any data, don't care
  387.                1   Equal to test value
  388.                2   Not equal to test value
  389.                3   Above test value
  390.                4   Below test value
  391.                5   Below or equal to test value
  392.                6   Above or equal to test value
  393.                7   Within inclusive range
  394.                8   Outside range
  395.  
  396.   1 byte      Maximum data match length
  397.  
  398.               Set to 1, 2, or 4 depending on the widest data match or 
  399.               mask that the hardware can perform.
  400.  
  401.   2 bytes     Size of onboard memory in kilobytes.
  402.  
  403.   2 bytes     Maximum number of trace-back events that can be recalled.
  404.  
  405.   2 bytes     Address of hardware breakpoint enable byte
  406.  
  407.               Specifies the segment address where Turbo Debugger must 
  408.               write a byte with a value of 1 to enable hardware breakpoints. 
  409.               The field must contain 0 if the device driver does not or 
  410.               cannot support this capability. If it is supported, this 
  411.               byte lets Turbo Debugger inform the device driver that it 
  412.               has finished writing to the address space of the program 
  413.               being debugged, and that subsequent accesses can cause 
  414.               hardware breakpoints.
  415.  
  416. 4 (Set a hardware breakpoint)
  417.  
  418.   1 byte      A handle that Turbo Debugger will use to refer to this
  419.               breakpoint in the future. The device driver also uses this 
  420.               handle when calling back into Turbo Debugger after a hardware
  421.               breakpoint has occurred. The handle must be greater than or
  422.               equal to zero (0). Negative values (top bit on) indicate a
  423.               special condition when the device driver calls Turbo Debugger
  424.               with a hardware breakpoint.
  425.  
  426. -2 (Recursive entry)
  427.  
  428.   1 byte      The special value FE (hex) can be returned by the hardware
  429.               device driver if it has been recursively entered while 
  430.               processing a hardware breakpoint. This can happen if a 
  431.               hardware breakpoint has been set in the 6 bytes below the
  432.               current top of stack in the program being debugged. If
  433.               Turbo Debugger receives this entry code, it displays a
  434.               message that the device driver can't proceed because of
  435.               a breakpoint's being set near the top of the stack.
  436.  
  437.  
  438. Device driver call into Turbo Debugger
  439. --------------------------------------
  440. When the hardware board and the device driver software have determined
  441. that a hardware breakpoint has occurred, control must be transferred
  442. to the address inside Turbo Debugger that was specified with command
  443. code 0 (Set Hardware Breakpoint Vector).
  444.  
  445. The vector address must be jumped to with the CPU state exactly as it
  446. was when the hardware breakpoint occurred, but with the program's AX
  447. register pushed on the stack and an entry code now in the AH register.
  448. The entry code can be
  449.  
  450. >= 0        The handle of the triggered breakpoint
  451.  
  452. -1 (FF)     The breakout button was pressed
  453.  
  454. Turbo Debugger will never return to the device driver once it is
  455. jumped into from a hardware breakpoint.
  456.  
  457.