home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 3
/
PDCD_3.iso
/
pocketbk
/
utilsm
/
psionics
/
devices
< prev
next >
Wrap
Text File
|
1995-01-17
|
26KB
|
740 lines
PSIONICS FILE - DEVICES
=======================
Device driver interfaces
Last modified 1994-09-13
========================
This document describes all known functions for all known device drivers. It
does not include file IO, even when done through the same interfaces.
The device drivers documented are:
SND: Sound device
TIM: Timer device
ALM: Alarm device
WLD: World device
TTY: Serial port device
PAR: Parallel port device
FRC: Free running counter
XMD: XModem driver
YMD: YModem driver
Console device
Types of device driver
----------------------
On the Series 3, much functionality, including the filing system, is provided
via device drivers. There are three kinds of device drivers:
* physical device drivers: these drive the hardware directly
* base logical device drivers: these provide a basic abstraction for working
with logical device drivers
* stacked logical device drivers: these provide higher levels of abstraction
Only logical device drivers need to know about physical device drivers; all
user applications operate through logical device drivers.
For example, the 3-Link pod and cable might be accessed through a physical
device driver called TTY.LNK: (all physical device drivers have a two part
name). This is automatically loaded the first time that the logical device
driver TTY: is opened, and TTY: will use it to actually communicate with the
pod.
When TTY: is opened, the kernel will return a handle. Read and write operations
on that handle will send data directly to and from the port. Alternatively,
the XMD: device driver could be stacked on top of TTY: on that handle. Once
this has been done, read and write on that handle will now be done via the XMD:
driver, which wraps the data in the XModem protocol and calls the TTY: driver
to do the actual output. There is no limit to how many device drivers can be
stacked upon one another.
Opening a handle
----------------
A base logical device driver is opened with the IOOPEN keyword or the IoOpen
system call; a stacked logical device driver is opened with IoOpen. The name is
examined to see whether it has a colon as the fourth character but not the
fifth; if so, it is split into a device name and a channel name. The kernel
then checks that the logical device exists; if not, or if the name does not
have the correct form, it prefixes "FIL:" to the name and tries again (FIL
is the filing system logical device driver). For example:
"SND:" device "SND" channel name ""
"TTY:A" device "TTY" channel name "A"
"FIL:A:XXX" device "FIL" channel name "A:XXX"
"HELLO.TXT" device "FIL" channel name "HELLO.TXT"
"ROM::XXX" device "FIL" channel name "ROM::XXX"
"FIL:TTY:" device "FIL" channel name "TTY:"
"QXV:" device "FIL" channel name "QXV:"
[the last example assumes there is no QXV device driver].
The filing system and the FIL: driver are described in the Psionics file
FILEIO. All other known drivers are described here.
IOOPEN and IoOpen are passed a mode to open the device or file. Drivers other
than the filing system and those specifically mentioning it ignore the mode.
It is recommended that a mode of -1 be used, as this is always rejected by the
filing system; thus an error in the device name or a missing driver will be
detected.
A driver may refuse to open a given channel name, or all channels, more than
a certain number of times without closing some first. For example, a TTY
driver might only allow one open handle at a time for each port.
Using the device driver
-----------------------
Once a device driver has been opened, it is accessed with the keywords IOW,
IOA, and IOC (Series 3a only). These keywords offer the same services, and
differ only in the way completion is indicated.
IOW waits until the operation completes, and then returns. No signal is
generated.
IOA has an extra status variable argument. The variable is set to -46 at the
start of the operation, and then to the final result when it completes; a
signal is generated at this moment (it can be collected with IOWAIT or
IOWAITSTAT). Note that some operations complete immediately, and so the
status of -46 is never seen.
IOC is like IOA, but if the operation completes immediately, it places the
result into the status variable and generates a signal. Thus the code
making the call can check the result in one place (after collecting the
signal) rather than two (after the call and after the signal).
Each call is passed a function number and two parameters for passing other
information. The latter identify blocks of memory; the actual argument can be
either the name of an OPL variable (typically the first element of an array),
in which case that variable marks the start of the block, or it can be the #
operator applied to the address of the block. The former is equivalent to
#ADDR(variable).
If the parameter is shown as "unused", then any variable or value can be used,
as it will be ignored; it is often convenient to use #0 as such an argument.
Unless stated otherwise, a successful call returns zero, and an unsuccessful
call some non-zero error code.
Standard functions
------------------
These functions apply to all drivers.
Function: 1 (read)
Function: 2 (write)
Argument 1: buffer
Argument 2: count (word)
These functions are equivalent to the IOREAD and IOWRITE keywords. They read
or write up to the specified number of bytes from or to the device; in the
case of function 1, the count is changed to the actual amount read.
These functions can be used with any handle that is using a driver labelled
as a data driver (such as the serial port device or the XModem driver).
Function: 3
Argument 1: unused
Argument 2: unused
This will close the handle; it is equivalent to the IOCLOSE keyword.
Function: 4
Argument 1: unused
Argument 2: unused
This will cancel any uncompleted function on the handle; the function will
complete immediately, with the status variable set to -48 ("I/O cancelled").
A signal will still be generated, and must be collected with IOWAITSTAT or
IOWAIT.
Sound device
------------
The sound device has the name "SND:". There are no channel names.
Function: 1 (sound channel 1)
Function: 2 (sound channel 2)
Argument 1: note information
Argument 2: word holding number of notes
This function is supported by the HC, MC, and Series 3a only.
This plays a sequence of notes on the specified sound channel. The note
information is an array of words, two per note; the first is the frequency of
the note (in Hz), and the second the duration in beats (see function 7).
The sound will not start until both these functions have been called (thus
ensuring the sound is synchronized on both channels). The function completes
when the specified channel finishes playing, even if the other has not.
Function: 7
Argument 1: 2 byte information block
Argument 2: unused
The characteristics of the sound system are set according to the block:
Offset 0 (byte): beats per minute (2 to 240, default 120)
Offset 1 (byte): volume (0 max to 5 min)
The beats per minute is only supported by the HC, MC, and Series 3a. On the
Series 3a, volumes 1 and 2 are identical, as are 4 and 5. On the Series 3s,
volumes 0 and 5 are unavailable.
Function: 8
Argument 1: 2 byte information block
Argument 2: unused
The block is filled in with information about the sound channel, using the
same format as function 7.
Function: 9
Argument 1: alarm type (0 = rings, 1 = chimes)
Argument 2: unused
The specified alarm is played; this function completes when the sound has
completely played.
Function: 10
Argument 1: phone number (cstr)
Argument 2: parameter block
This generates DTMF dialling sounds. The number contains the digits to be
dialled (0 to 9, *, #, and A to F can be used; E is the same as *, and F the
same as #). The parameter block has the format:
Offset 0 (byte): tone length )
Offset 1 (byte): delay length ) all in 1/32 seconds
Offset 2 (word): pause length )
Timer device
------------
The timer device has the name "TIM:". There are no channel names.
Function: 1
Argument 1: delay in 1/10 seco