home *** CD-ROM | disk | FTP | other *** search
- Alternative Block Driver Specification
- --------------------------------------
-
- Hugo Fiennes, Rev 4, 27th January 1993
-
- Contact me on 0749 670058 (altman@cryton.demon.co.uk, fidonet 2:252/102.0)
- for information about the latest version of the spec.
-
- An application called !SerialDev holds the drivers - in your application !Run
- sequence you should check to see if <SerialDev$Path> is set, and if not, set
- it to your application directory, inside which is Modules.Internal at least,
- for your application to default to the internal port.
-
- Eventually the idea is to have !SerialDev hold an application that handles
- the intstallation in a 'pretty way' - eg dragging new drivers to a window to
- install them, this would check to see if the driver was a later version of an
- existing driver and if so replace the old one, otherwise it would install the
- driver. Maybe this application could look a bit like ArtWorks !FontInst.
- Hint, hint, somebody write one...
-
- The drivers each have their own directory just in case, possibly extensions
- with !Run files, modules, etc relating to the driver could be stored there.
- Of course, drivers know their own name and could load files into RMA on
- initialisation now and cause no problems.
-
- ARCterm 7 1.44 and later use drivers of this specification. In this
- archive I have included the (tested) internal serial port driver.
- I've also done a driver for the Serial Port dual serial card, but this
- will be released with the card itself.
-
- Note that these drivers will probably need RO3.1, due to the use of the
- vectors which were more unpredictable under RO2.
-
- C headers have been provided for C programmers. BASIC/Assembler people
- should have no problems working it out either.
-
- REVISION 4 : Added 'wont empty' and 'dont overlay io' flags for pipes and
- (unfixed) RO3.10 serial ports.
-
- Internal driver (driver number=0)
- ---------------
-
- Needs RO3.1 for block operations.
-
- II_Dual driver (not supplied with this release)
- --------------
-
- This has been coded, but only works with the (as yet unreleased) version 3.x
- module. A tested version will be released as soon as possible.
-
- Serial Port Dual Serial (not supplied with this release)
- -----------------------
-
- No known problems.
-
- Econet driver (not supplied with this release)
- -------------
-
- This works with ARCterm's modem server to allow remote serial access. To
- support connection, etc, it has 3 special functions:
-
- Connect (function code 128)
- r1=handle/net/station (handle in bits 16-23,net in bits 8-15, station in 0-7)
- r2-> password, null terminated
-
- Tries to set up a connection with the modem server. Returns 0 for success,
- 1 for no reply, 2 for already connected, or a pointer to an error block if
- r0 is 'big' on return.
-
- Disconnect (function code 129)
- Disconnects from the modem server.
-
- Scan for modem servers (function code 130)
- r1=buffer to fill of format:
- 0 station
- 1 net
- 2 handle
- 3 modem driver number as defined in the modem server config file
- 4-63 modem ID string (null terminated)
- r2=max number of entries table can handle
-
- PipeA and PipeB (not supplied with this release)
- ---------------
-
- This works in conjunction with the ARCbbs pipe module currently - when I put
- RO3 in the BBS machine it will probably be modified to work with RO3's PipeFS.
- The idea is, you open a port (of 16) on pipeA and data sent appears in the
- input of the corresponding port on pipeB (and vice-versa). DTR at one end
- is translated to DCD at the other (ditto for RTS-CTS). In this way, any
- application which supports the block driver spec can talk to another, for
- example, with ARCbbs and the ARCterm modem server on the same machine,
- some ARCbbs ports could be given over to network access via the modem
- server.
-
- The pipes use the flag 'wont empty' as you can't wait for the pipe to
- 'finish sending' as the other end of the pipe may be waiting for the same
- thing (unlike a serial port, where the data will go away eventually).
-
- -------------------------------------------------------------------------------
- Driver layout
- -------------------------------------------------------------------------------
-
- 0x000 Entry point to call routines
-
- In: r0=function code
- r1-r3=data
-
- Out: r0=result
-
- This entry point should only be called in user mode, so the driver
- does not need to preserve r14_svc - this should be fine for the majority
- of applications.
-
- r0-r3 can be corrupted, r4-r12 should be preserved. r14 contains the
- return address
-
- Callers note that r13 should point to a full, descending stack
- with a decent amount of space free on it.
-
- Example handler code follows:
-
- entry
- CMP R0,#((endoftable-table)/4)
- ADDCC PC,PC,R0,LSL#2
- MOV PC,R14
-
- table
- B func_0
- B func_1
- endtable
-
- 0x080 Driver information string (31 bytes max, 0 terminated)
- 0x0A0 Manufacturer information string (31 bytes max, 0 terminated)
- 0x0C0 Version number (top 16 bits major, low 16 bits minor)
- 0x0C4 Driver flags
-
- 0x00000001 - More than one port availiable
- 0x00000002 - Supports split rates
- 0x00000004 - Has >1 byte hardware FIFO
- 0x00000008 - Can use Set control lines to generate a break
- 0x00000010 - Requires polling (by function 19)
- 0x00000020 - Won't empty (is a shared buffer)
- 0x00000040 - Supports block get/put operations
- 0x00000080 - Prefer not to overlap serial IO and disk IO
-
- 0xdd...... - Top byte is highest port number supported (numbered from 0)
- 0x0C8 Driver number. This is allocated by me, and always has the lowest byte
- as 0. The purpose of the driver number is for the Device_Claim protocol:
- when a serial port is specified, the port number is used to specify
- which port is to be claimed/released. The internal port is port 0 and
- driver number 0. To make the port number to use you add the sub-port
- number and the driver number together. eg, say the II dual card was
- driver number 1 (0x00000100) and you wanted to claim port 5, you
- would use the port number 0x00000105. This is unique and hopefully
- would cause no problems.
-
- 0x0CC - 0x0FF reserved
-
- 0x100 Supported speed table. One word per speed, terminated with a null word.
-
- 0x180-> driver code.
-
- Function codes
- --------------
-
- r0=0 Put byte
- --------
- r1=port number
- r2=byte to send
-
- Returns with r0=-1 if byte not inserted, r0=0 if byte inserted into
- TX queue.
-
- r0=1 Get byte
- --------
- r1=port number
-
- Returns with r0=-1 if no byte availiable, r0=byte if a byte was removed.
-
- r0=2 Put block
- ---------
- r1=port number
- r2=pointer to block
- r3=number of bytes to try and insert
-
- Returns with r0=number of bytes sucessfully inserted.
-
- r0=3 Get block
- ---------
- r1=port number
- r2=pointer to block
- r3=maximum number of bytes to put into buffer
-
- Returns with r0=number of bytes put in buffer.
-
- r0=4 Check TX buffer
- ---------------
- r1=port number
-
- Returns with r0=number of bytes free in TX buffer
-
- r0=5 Check RX buffer
- ---------------
- r1=port number
-
- Returns with r0=number of bytes used in RX buffer
-
- r0=6 Flush TX buffer (and hardware FIFO if applicable)
- ---------------
- r1=port number
-
- r0=7 Flush RX buffer (and hardware FIFO if applicable)
- ---------------
- r1=port number
-
- r0=8 Control lines
- -------------
- r1=port number
- r2=-1 to read or new settings
-
- Returns r0=control line settings
-
- b0=DTR
- b1=RTS
- b2=If set, set TX data active (ie break state)
-
- r0=9 Read modem control lines
- ------------------------
- r1=port number
-
- Returns r0=control line status
-
- b0=CTS
- b1=DSR
- b2=RI
- b3=DCD
-
- r0=10 Read RX errors
- --------------
- r1=port number
-
- Returns r0=bitset of errors seen since last read RX errors.
-
- b0=Overrun error
- b1=Parity error
- b2=Framing error
- b3=Break received
-
- r0=11 Send break
- ----------
- r1=port number
- r2=break time (in centiseconds)
-
- This does not return until the break has been sent - although some
- serial ports could multitask when sending a break, the internal port
- can't. Check the driver flags to see if you can use a multitasking
- break before using this call.
-
- r0=12 Examine byte (like Get byte but leaves it in the buffer)
- ------------
- r1=port number
-
- Returns with r0=-1 if no byte availiable, r0=byte if a byte was
- returned.
-
- r0=13 TX Speed
- --------
- r1=port number
- r2=speed to set or -1 to read
-
- Returns with r0=speed.
-
- r0=14 RX Speed
- --------
- r1=port number
- r2=speed to set or -1 to read
-
- Returns with r0=speed.
-
- r0=15 Set word format
- ---------------
- r1=port number
- r2=word format to set or -1 to read
-
- Returns with r0=word format.
-
- r0=16 Set flow control
- ----------------
- r1=port number
- r2=flow control method to set or -1 to read
-
- Returns with r0=method
-
- 0=no flow control
- 1=hardware
- 2=xon/xoff
- 3=both
-
- r0=17 Initialise driver
- -----------------
- r1=port number
-
- r0=18 Close down driver
- -----------------
- r1=port number
-
- r0=19 Poll driver
- -----------
- r1=port number
-
- This should be called regularly (eg in a polling loop) for the driver
- to perform polling tasks - eg the econet driver needs to check internal
- buffers and poll econet protocol tasks.
-