home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / m / modemdial / !ModemDial / SerialDev / BlockSpec next >
Text File  |  1996-06-11  |  19KB  |  537 lines

  1. Block Driver Specification                 Hugo Fiennes, Rev 12, 11th June 1996
  2. -------------------------------------------------------------------------------
  3.  
  4. Contact me as 'altman@cryton.demon.co.uk', for information about the latest
  5. version of the spec.
  6.  
  7. ARCterm 7 users - please see the notes on release 12 at the end of this
  8. document before installing the drivers.
  9.  
  10.  
  11. Aim
  12. -------------------------------------------------------------------------------
  13. To provide a standard way for applications to access serial devices. Any
  14. application supporting block drivers can be used with many serial devices, with
  15. no modification required to the application code - and it's easier to use than
  16. the serial SWIs anyway!
  17.  
  18.  
  19. Info
  20. -------------------------------------------------------------------------------
  21. This standard is public domain - the drivers supplied are freely distributable.
  22.  
  23. If you intend to use the block drivers, please distribute the whole block
  24. driver package (inc sample source, this file, and the complete !SerialDev
  25. application) with your program, making sure that you are distributing the
  26. latest version (available from ftp.demon.co.uk in the /pub/archimedes
  27. directory).
  28.  
  29. An application called !SerialDev holds the drivers - in your application !Run
  30. sequence you should check to see if <SerialDev$Path> is set, and if not, set it
  31. to your application directory, inside which is Modules.Internal at least, for
  32. your application to default to the internal port.
  33.  
  34. Eventually the idea is to have !SerialDev hold an application that handles the
  35. installation in a 'pretty way' - eg dragging new drivers to a window to install
  36. them, this would check to see if the driver was a later version of an existing
  37. driver and if so replace the old one, otherwise it would install the driver.
  38. Maybe this application could look a bit like ArtWorks !FontInst. Hint, hint,
  39. somebody write one...
  40.  
  41. The drivers each have their own directory just in case, possibly extensions
  42. with !Run files, modules, etc relating to the driver could be stored there.
  43. Of course, drivers know their own name and could load files into RMA on
  44. initialisation now and cause no problems.
  45.  
  46. ARCterm 7 1.44 and later use drivers of this specification. In this archive I
  47. have included some other drivers, documented below. Other programs that support
  48. block drivers are: Binkleyterm (2.11+), Hearsay 2 (2.17+), ARCfax (1.06+),
  49. ARCbbs (1.63+), RISCbbs (1.02+), Netway, KA9Q/!TCPIP, Freenet, Acorn's PPP.
  50.  
  51.  
  52. Calling drivers
  53. -------------------------------------------------------------------------------
  54. The drivers can be called in USR or SVC mode, and will use/corrupt r0-r3.
  55. All functions that return data do so in R0 for compatibility with C programs.
  56. Parameters to all functions go in via r0-r3.
  57.  
  58. The functions are called simply by branching to the start of the driver that
  59. has been loaded with the registers set up and a return address (in R14) set
  60. up correctly (remember - if you're calling from SVC mode, R14 must also
  61. include the correct CPU mode).
  62.  
  63. The first function that should be called after loading a driver (before even
  64. reading baudrate tables) is the initialise entry, which may fix up tables
  65. and other data depending on hardware capabilities.
  66.  
  67. An example program in BASIC and C is provided with the distribution for you to
  68. look at.
  69.  
  70. Function codes - Summary
  71. ------------------------
  72. r0=0    Put byte
  73. r0=1    Get byte
  74. r0=2    Put block
  75. r0=3    Get block
  76. r0=4    Check TX buffer
  77. r0=5    Check RX buffer
  78. r0=6    Flush TX buffer (and hardware FIFO if applicable)
  79. r0=7    Flush RX buffer (and hardware FIFO if applicable)
  80. r0=8    Control lines  R/W
  81. r0=9    Read modem control lines
  82. r0=10   Read RX errors
  83. r0=11   Send break
  84. r0=12   Examine byte (like Get byte but leaves it in the buffer)
  85. r0=13   TX Speed  R/W
  86. r0=14   RX Speed  R/W
  87. r0=15   Set word format   R/W
  88. r0=16   Set flow control  R/W
  89. r0=17   Initialise driver
  90. r0=18   Close down driver
  91. r0=19   Poll driver
  92.  
  93. Function codes - Description
  94. ----------------------------
  95.  
  96. r0=0  Put byte
  97.       --------
  98.       r1=port number
  99.       r2=byte to send
  100.  
  101.       Returns with r0=-1 if byte not inserted, r0=0 if byte inserted into
  102.       TX queue.
  103.  
  104. r0=1  Get byte
  105.       --------
  106.       r1=port number
  107.  
  108.       Returns with r0=-1 if no byte available, r0=byte if a byte was removed.
  109.  
  110. r0=2  Put block
  111.       ---------
  112.       r1=port number
  113.       r2=pointer to block
  114.       r3=number of bytes to try and insert
  115.  
  116.       Returns with r0=number of bytes successfully inserted.
  117.  
  118. r0=3  Get block
  119.       ---------
  120.       r1=port number
  121.       r2=pointer to block
  122.       r3=maximum number of bytes to put into buffer
  123.  
  124.       Returns with r0=number of bytes put in buffer.
  125.  
  126. r0=4  Check TX buffer
  127.       ---------------
  128.       r1=port number
  129.  
  130.       Returns with r0=number of bytes free in TX buffer
  131.  
  132. r0=5  Check RX buffer
  133.       ---------------
  134.       r1=port number
  135.  
  136.       Returns with r0=number of bytes used in RX buffer
  137.  
  138. r0=6  Flush TX buffer (and hardware FIFO if applicable)
  139.       ---------------
  140.       r1=port number
  141.  
  142. r0=7  Flush RX buffer (and hardware FIFO if applicable)
  143.       ---------------
  144.       r1=port number
  145.  
  146. r0=8  Control lines  R/W
  147.       ------------------
  148.       r1=port number
  149.       r2=-1 to read or new settings
  150.  
  151.       Returns r0=control line settings
  152.  
  153.       b0=DTR
  154.       b1=RTS
  155.       b2=If set, set TX data active (ie break state)
  156.  
  157. r0=9  Read modem control lines
  158.       ------------------------
  159.       r1=port number
  160.  
  161.       Returns r0=control line status
  162.  
  163.       b0=CTS
  164.       b1=DSR
  165.       b2=RI
  166.       b3=DCD
  167.  
  168. r0=10 Read RX errors
  169.       --------------
  170.       r1=port number
  171.  
  172.       Returns r0=bitset of errors seen since last read RX errors.
  173.  
  174.       b0=Overrun error
  175.       b1=Parity error
  176.       b2=Framing error
  177.       b3=Break received
  178.  
  179. r0=11 Send break
  180.       ----------
  181.       r1=port number
  182.       r2=break time (in centiseconds)
  183.  
  184.       This does not return until the break has been sent - although some
  185.       serial ports could multitask when sending a break, the internal port
  186.       can't. Check the driver flags to see if you can use a multitasking
  187.       break before using this call.
  188.  
  189. r0=12 Examine byte (like Get byte but leaves it in the buffer)
  190.       ------------
  191.       r1=port number
  192.  
  193.       Returns with r0=-1 if no byte available, r0=byte if a byte was
  194.       returned.
  195.  
  196. r0=13 TX Speed R/W
  197.       ------------
  198.       r1=port number
  199.       r2=speed to set or -1 to read
  200.  
  201.       Returns with r0=speed.
  202.  
  203. r0=14 RX Speed R/W
  204.       ------------
  205.       r1=port number
  206.       r2=speed to set or -1 to read
  207.  
  208.       Returns with r0=speed.
  209.  
  210. r0=15 Set word format R/W
  211.       -------------------
  212.       r1=port number
  213.       r2=word format to set or -1 to read
  214.  
  215.       Returns with r0=word format.
  216.  
  217. r0=16 Set flow control R/W
  218.       --------------------
  219.       r1=port number
  220.       r2=flow control method to set or -1 to read
  221.  
  222.       Returns with r0=method
  223.  
  224.       0=no flow control
  225.       1=hardware
  226.       2=xon/xoff
  227.       3=both
  228.  
  229. r0=17 Initialise driver
  230.       -----------------
  231.       r1=port number
  232.       r2=parameter string (optional)
  233.  
  234.       r2 optionally points to a null terminated string which can specify
  235.       device options.
  236.  
  237.       Returns with r0 pointing to error string if
  238.       initialisation unsuccessful, otherwise r0=0.
  239.  
  240.       NOTE! Do not read the baud rate tables or driver flags UNTIL AFTER
  241.       the initialise driver entry has been called. This allows for drivers
  242.       to configure themselves to the available hardware and adjust the
  243.       services offered accordingly.
  244.  
  245.       Release 10: There is now a flag, 'supports inquiry initialise' (see
  246.       above) which allows you to call the initialise entry with r1=-1,
  247.       which will not touch any hardware, just set all the baud tables,
  248.       driver flags, and count the number of ports installed (if necessary),
  249.       so you can read them and set up menus, etc.
  250.  
  251. r0=18 Close down driver
  252.       -----------------
  253.       r1=port number
  254.  
  255. r0=19 Poll driver
  256.       -----------
  257.       r1=port number
  258.  
  259.       This should be called regularly (eg in a polling loop) for the driver
  260.       to perform polling tasks - eg the econet driver needs to check internal
  261.       buffers and poll econet protocol tasks. Polls can be as infrequent as
  262.       three or four t