FileSwitch

Introduction and Overview

FileSwitch has been extended with support for enumerating file handles, a catalogue filename width, IOCtl operations, and a reminder about the redeclaration of filing systems.

Technical Details

Enumerate Handles

A reason code is available within FileSwitch version 2.44 onward to enumerate file handles. This allows clients to obtain information on open files using a defined interface rather than relying on knowledge of the earlier restriction within FileSwitch of 255 file handles, allocated sequentially downward from 255. This reason code is used by clients wishing to enumerate open file handles. Clients should be aware that filing system operations may occur during the enumeration process and should take appropriate action. See SWI OS_FSControl 3A.

Catalogue filename width

A variable, FileSwitch$NameWidth, can be set to give the width of filenames in the *Cat display. It has a minimum value of 12, and a maximum value of 255. This can be set at any time and will be read per-use of *Cat. It is present in all versions of FileSwitch since RISC OS 4.

IOCtl operations

From FileSwitch 2.36 onward support has been added for IOCtl calls. These allow 'control' commands from the client opening the file. An OS_Args reason code has been added to support this, and a new bit added to the extra filing system information word. See SWI OS_Args 9. This operation will be passed to the FileSystem Args entry as reason code 11.

The IOCtl parameter block takes the following form :

OffsetContents
0Flags:
Bit(s)Meaning
0-15IOCtl reason code
16-23IOCtl group code:
ValueMeaning
0Serial group operations
1Parallel group operations
255Generic group operations
24-29Reserved (must be 0)
30Set to read data
31Set to write data
4...Data for operation

Parallel IOCtl operations

The following parallel IOCtl operation reason codes are supported by the parallel device driver :

  • Read Device ID size
  • Read Device ID data
  • Read Reverse Nibble status size
  • Read Reverse Nibble status data

In each case the first word of the data indicates the size of the buffer.

FIXME: The IOCtl reason code numbers for the parallel operations are not documented.

Serial IOCtl operations

The following serial IOCtl operation reason codes are defined for serial devices :

ReasonOperationData
1Baud rateOne word containing the baud rate (bits per second)
2Data formatOne word containing flags indicating data format:
Bit(s)Meaning
0-7Data length (5,6,7 or 8)
8-15Number of stop bits (1 or 2)
16-23Parity encoded as:
ValueMeaning
0No parity
1Even parity
2Odd parity
3+Reserved
24-31Reserved
3HandshakeOne word containing the handshaking type:
ValueMeaning
0No handshaking
1RTS/CTS handshaking
2XON/XOFF handshaking
3DTR/DSR handshaking
4+Reserved
4Buffer sizeSize of buffer used for transfers
5Buffer ThresholdTrigger for handshaking or upcall notification
6Control linesOne word containing flags:
Bit(s)Meaning
0DTR (read/write)
1RTS (read/write)
2-15Reserved (read/write)
16CTS (read only)
17DSR (read only)
18RI (read only)
19DCD (read only)
20FIFOs enabled (read only)
21-31Reserved (read only)
7FIFO triggerNumber of bytes in FIFO before an interrupt is generated.
8Read number of baud ratesReturns a word containing the number of baud rates available
9Read baud rate indexSupplies one word of index numbers and reads the baud rate associated with that index.
10Flush bufferFlushes buffer on write; undefined on read
11Read IR capabilitiesOne word containing flags:
Bit(s)Meaning
0IrDA capable
1Consumer IR capable
2ASK-IR capable
3-31Reserved
12IR statusOne word containing the type of IR:
ValueMeaning
0Wired
1IrDA
2ConsumerIR
3Ask-IR
4+Reserved

Generic IOCtl operations

The following IOCtl operations have been defined for generic operations :

  • Non-blocking operation. A word containing 0 for blocking operation, any other value indicating non-blocking operation
  • Buffer threshold. A word indicating a point in the buffer at which a notification will be raised.
  • Flush stream. No data; writing causes all pending data to be discarded
  • Timeout. Time in centiseconds before a blocking operation should be considered failed.

FIXME: The IOCtl reason code numbers for the generic operations are not documented.

Filing system redeclaration

As a reminder, PRM 2-524 indicates that filing systems should redeclare themselves to FileSwitch when Service_FSRedeclare is issued. Some external filing systems do not do this and thus cannot cope when the FileSwitch module is restarted.

SWI Calls

OS_FSControl 3AOS_FSControl_EnumerateHandlesSWI &29
Enumerate file handles
R0=58 (reason code)
R1=Last handle, or -1 to start at first handle
R0=Stream status word, or preserved if no more handles exist
R1=File handle, or -1 if no more handles exist
R2=Filing system info word, or preserved if no more handles exist
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

This reason code is used by clients wishing to enumerate open file handles. Clients should be aware that filing system operations may occur during the enumeration process and should take appropriate action.

OS_Args 9OS_Args_IOCtlSWI &9
IOCtl
R0=9 (reason code)
R1=File handle
R2=Pointer to parameter block
R0 - R2=Preserved
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

This call is used by clients wishing to control devices at the other end of a file handle. This may be used for filing specific operations. This operation will be passed to the FileSystem Args entry as reason code 11.