Document ref: | 1309,424/FS |
Project: | |
Revision: | 0.04 |
Date: | 18-Aug-1998 |
Author(s): | Rich Buckley, William Turner |
AMR: |
Overview | |
Technical background | |
User interface | |
Programmer interface |
This documentation describes the programmers interface provided by the new serial device driver. It is intended that any other serial/uart type devices that are to be supported under RiscOS and NC-OS will conform to this interface but use a different device name. Device names will be allocated by Acorn.
OS_Arg
reason code has been allocated OSArgs_IOCtl
this has the following arguments.
On entry r0 = 9 (reason code) r1 = file handle r2 -> ioctl parameter block On exit r0 preserved r1 preserved r2 preservedA new bit has been allocated in the extra filing system information word (PRM 2-523) as follows
Bit Meaning if set
3 Filing system supports OS_Arg IOCtl
.
Filing systems should set this bit if they intend to support OS_Arg IOCtl
. Existing filing systems will have this bit clear so will never be asked to handle this call.
If the registered filing system supports the IOCtl OS_Arg
swi, the call will be dispatched using the normal entry point and reason code. It is up to the underlying filing system to impose a meaning on the registers r2-r7.
OS_Arg IOCtl
.
A new DeviceFS_CallDevice
reason code has been allocated DeviceCall_IOCtl
this has the following arguments when received.
DeviceDriver_Entry 14 IOCtl On entry r0 = 14 (reason code) r1 = file handle r2 = stream handle r3 -> ioctl parameter block as passed in r2 of OS_Args call On exit r0 preserved r1 preserved r2 preserved r3 preservedThis call is dispatched to the underlying device driver whenever the
OS_Arg IOCtl
swi is called or the swi DeviceFS_CallDevice (14)
is called.
On entry r2 -> ioctl parameter block On exit r2 preservedwhere ioctl control block is a pointer to the following structure
typedef struct { unsigned int reason : 16; /* ioctl reason code */ unsigned int group : 8; /* ioctl group code */ unsigned int reserved : 6; /* should be zero */ unsigned int read : 1; /* read flag */ unsigned int write : 1; /* write flag */ unsigned int data; /* actual data */ } ioctl_t;In the case of an
ioctl
called with both read and write flags set, the returned value will be the new or latest value of the parameter being accessed.
The serial data input/output interface is provided through the DeviceFS interface with data transfers analogous to file read/writes. The control interface is provided by ioctls
as documented below.
Input and/or output to DeviceFS streams should be made on the file path : devices:$.<stream name>
DeviceFS also establishes an environment variable to allow simpler access to this path. This would be constructed as : <stream name>:
devices:$
. The following streams are present for NC and Phoebe hardware (serial1 not present on the latter if port1 is in backwards-compatible mode).
serial1
- serial port 1 on the combo chip
serial2
- serial port 2 on the combo chip
Support for further serial devices would require device name allocations with the relavent driver registering the new device with DeviceFS alongside the existing ports. Examples would be serial3:
, modem1:
.
Wheredevices#<configuration options>:$.serial1
<configuration options>
can be made up of any of the following entries in order. Some fields may be omitted and this will leave the option unchanged. Currently due to a problem with DeviceFS, the options should be given in order. A semicolon ';' is used to separate option fields.
baud<n>
- baud rate in bps
data<n>
- data length in bits
stop<n>
- number of start/stop bits
[noparity|even|odd]
- type of parity required
[nohandshake|rts|xon|dtr]
- type of handshaking required
size<n>
- size of buffer
thres<n>
- buffer threshold point
#baud19200;data8;stop1;noparity;rts;size1024;thres32
'. In fact this is the default state of the driver on initialisation. Except the tx buffer will default to 512 bytes. It should be noted that the current behaviour of DeviceFS requires the above special string fields to be presented in the exact order given above. This may be fixed in future versions of DeviceFS.
If any of the parameters are invalid, for example baud rate not supported, the request to open the stream is refused.
type devices:$.serial1
- echo's to the screen any characters received on serial port 1.
copy <filename> devices:$.serial1
- copies the data in file <filename>
to serial port 1.
OS_Find
to open a stream for tx/rx
OS_GBPB 2,4
to perform block read/writes from/to the stream
OS_BPut
to transmit a character
OS_BGet
to fetch a character
OS_Args 2
to obtain the amount of data in rx stream buffer and amount of free space in tx stream buffer
To obtain the functionality of swi OS_Args 2
required a change to DeviceFS to allow this information to be returned. You therefore require version 0.31 or greater of DeviceFS in order to implement this functionality.
It should also be noted that the behaviour of DeviceFS means that the functions to read data from an input stream are blocking. OS_Args 2
should therefore be used to check the amount of data present in an input stream before a read is requested.
On entry r0 = 15 (upcall code Upcall_DeviceRxDataPresent) r1 = stream handle
On entry r0 = 16 (upcall code UpCall_DeviceThresAbove) r1 = stream handle
On entry r0 = 17 (upcall code UpCall_DeviceThresBelow) r1 = stream handle
On entry r0 = 7 (event code Event_RS423Error) r1 = flags SerialEvent_Parity bit 5 SerialEvent_Overrun bit 4 SerialEvent_Framing bit 3 SerialEvent_DSR bit 2 SerialEvent_DCD bit 1 r2 = input stream handle
This document must not be copied, reproduced or disclosed in part or whole. |
by Acorn Network Computing, UK. © Acorn Computers Ltd 1997 |