***************************************************************************
*                                                                         *
*  Project: RiscOS                                                        *
*                                                                         *
*  Module:  DeviceFS                                                      *
*                                                                         *
*  Created: Fri 12-Apr-91      By: David De Vorchik                       *
*                                                                         *
*  First version: 0.00                                                    *
*                                                                         *
*    Copyright:    (C) 1991, Acorn Computers Ltd., Cambridge, England.    *
*                                                                         *
***************************************************************************

Purpose:
========

Provide easy access to character based devices under RISC OS.

***************************************************************************


Change Log:
===========


---------------------------------------------------------------------------

Version: 0.00 Fri 12-Apr-91        David De Vorchik              

 02-Apr-91 0.00 DDV Some major redesign work.

---------------------------------------------------------------------------

Version: 0.04 Tue 16-Apr-91        David De Vorchik              

 04-Apr-91      DDV Implemented all device registering.
 05-Apr-91      DDV Issuing of Service_DeviceFSStarting on a call back added.
 05-Apr-91      DDV Started filing system bits, split to seperate file.
 06-Apr-91      DDV Added time stamping device registration (parent), new filing system bits added.
 06-Apr-91      DDV Added issuing of Service_DeviceFSDying (on reset/finalise)
 07-Apr-91      DDV Finished directory enumeration.
 07-Apr-91      DDV Now issues UpCalls to inform the outside world that things have changed.
 07-Apr-91      DDV Directory structure sorting added.
 08-Apr-91      DDV Sorted out duplicate files on enumeration, ie. $.test.fred, $.test.fred1 would result in two 'test' entries.
 08-Apr-91 0.01 DDV Device_CallDevice added.
 09-Apr-91      DDV Started opening, closing and general transfer operations.
 09-Apr-91      DDV Changed Device_CallDevice to accept new wacky parameters.
 09-Apr-91      DDV Called EnumDir event on internal update of dir structure, jumps and no longer issues SWI internally.
 09-Apr-91      DDV Delinking any device object now remakes all links properly.
 10-Apr-91      DDV All validation words reset when unlinked, as are original pointers (dr, fr and pr) -> &DEADDEAD
 10-Apr-91      DDV Added full duplex device flagging and improved flags word validation.
 10-Apr-91      DDV Added most of the file interfacing.
 10-Apr-91      DDV Added GBPB calls, added DeviceFS_RecievedByte and DeviceFS_TransmitByte.
 11-Apr-91 0.02 DDV Internationalised.
 11-Apr-91      DDV More robust version of BGET, BPUT and GBPB added.
 11-Apr-91      DDV Added DeviceFS_Thresold and UpCall decoding added.
 11-Apr-91 0.03 DDV Changed the handling of Service_Reset, now just marks vectors as not-owned.
 12-Apr-91      DDV Event_DeviceOverRun added for non-buffered devices.
 12-Apr-91      DDV Rationalised DeviceCalls, removing HaltRX/TX and ResumeRX/TX.
 12-Apr-91      DDV Bug fix; service call issued corretly.
 12-Apr-91      DDV Bug fix; stack inbalance.
 12-Apr-91      DDV If device is TX and buffer wake up occurs then WakeUpTX sent.
 12-Apr-91      DDV When last character removed from the buffer then marked as dormant.
 13-Apr-91      DDV Changed sending of TX on buffered devices as handled above.
 13-Apr-91      DDV Implementation of special fields added.
 14-Apr-91      DDV Bug fix; checks r1 not r0 in service handling (international only)
 14-Apr-91      DDV When device being removed it is called to close with an internal handle of zero.
 15-Apr-91      DDV r5 on call to open stream on device =-1, no threshold if >-1 on return then threshold setup.
 15-Apr-91      DDV Reordered the registers on pre-create calls for buffered devices.
 16-Apr-91      DDV Issuing of stream created messages added.
 16-Apr-91      DDV Intergration of special field handling finished.
 16-Apr-91      DDV Bug fix; resets buffer handle to -1.
 16-Apr-91 0.04 DDV Released for the 2.11 build.

---------------------------------------------------------------------------

Version: 0.05 Thu 18-Apr-91        David De Vorchik              

 18-Apr-91      DDV Bug fix; Calling Territoy_Collate now rechecks r0 on exit to see if records should swap.
 18-Apr-91      DDV Bug fix; Duplicate devices now ironed out correctly, although some work still required.
 18-Apr-91      DDV Tightened up handling of internationalised messages, only looked up when required.
 18-Apr-91      DDV Bug fix; Fix stack in-balance in duplicate devices code.
 18-Apr-91 0.05 DDV Some changes for new special field handling.

---------------------------------------------------------------------------

Version: 0.06 Mon 22-Apr-91        David De Vorchik              

 20-Apr-91      DDV Intergrated issuing of Service_DeviceDead.
 20-Apr-91      DDV Intergrated new special field handling code.
 20-Apr-91      DDV Changed DeviceFS_DeviceDead; r3 contains 0 if parent else -> device name.
 21-Apr-91      DDV Bug fix: Expansion of special field strings.
 21-Apr-91      DDV Bug fix: Access attributes can now return wr, not just exclusing access for read or write.
 21-Apr-91      DDV Bug fix: Special field parser now ensures that blocks are scanned correctly, skipping unused ones.
 21-Apr-91      DDV Added decoding for user special fields, ie. passing through if -> 0
 21-Apr-91      DDV Improved decoding of my returned block.
 21-Apr-91 0.06 DDV Removed handling for multiple buffers

---------------------------------------------------------------------------

Version: 0.07 Wed 01-May-91        David De Vorchik              

 (plus lots of new documentation)

 25-Apr-91      DDV Bug fix: Stop non-buffered devices becoming buffered if buffer forced!
 25-Apr-91      DDV Bug fix: TransmitCharacter no longer explodes on end-of-data.
 30-Apr-91      DDV Improved linking and unlinking of blocks within the DeviceFS workspace.
 30-Apr-91 0.07 DDV Bug fix: Deregister by name now works even if the parent handle is invalid.

---------------------------------------------------------------------------

Version: 0.08 Wed 01-May-91        David De Vorchik              
                          
 01-May-91      DDV Fix bug: fs_close not updating stream counts correctly.
 01-May-91 0.08 DDV Added special fields when setting path variables.

---------------------------------------------------------------------------

Version: 0.09 Tue 14-May-91        David De Vorchik              

 14-May-91 0.09 DDV Added UpCall_StreamCreated and UpCall_StreamClosed.
---------------------------------------------------------------------------

Version: 0.10 Fri 19-Jul-91        Tim Dobson                    

 31-May-91 0.10 TMD Fixed bug in service code, reorganise some code.
 04-Jun-91      TMD Fixed bug in filename matching.
 12-Jul-91      TMD Updated to work with new FileSwitch (filenames don't have "$" on them)
                    Improved error tidying up in registerdev
 16-Jul-91      TMD Fixed CallDevice, Threshold so they don't try to translate external errors.
                    Made unknown SWI use global message
                    Changed definition of <device>$Path to include a dot at the end

---------------------------------------------------------------------------

Version: 0.11 Mon 22-Jul-91        Tim Dobson                    

 22-Jul-91 0.11 TMD Fixed corruption of R9 and R10 on fs_file ReadInfo entry

---------------------------------------------------------------------------

Version: 0.12 Thu 01-Aug-91        Tim Dobson                    

 29-Jul-91 0.12 TMD Changed wake up TX call to allow devices to stay dormant.
                    Added reserved field to the device record.
 31-Jul-91      TMD Service_Reset code only executed on soft reset.

---------------------------------------------------------------------------

Version: 0.14 Tue 13-Aug-91        Tim Dobson                    

 01-Aug-91 0.14 TMD "Stream created" call now passes in buffer handle.
 02-Aug-91      TMD Made Escape error use global message.
 08-Aug-91      TMD Fixed bug in escape from BGET (returned VC)
 13-Aug-91      TMD Fixed bug in UpCall handler which stored device's error
                     pointer in wrong place on stack.

---------------------------------------------------------------------------

Version: 0.15 Tue 20-Aug-91        Tim Dobson                    

 14-Aug-91 0.15 TMD Fixed some erroneous error handling.
 16-Aug-91      TMD Put in code to issue service to request closure of files.
                    Changed DeviceFS_CallDevice to return all device's flags, not just V.
                    Fixed bug that stopped wake-up calls happening

---------------------------------------------------------------------------

Version: 0.16 Sat 07-Sep-91        Tim Dobson                    

 07-Sep-91 0.16 TMD Optimised messages.
                    Acknowledge escape before returning "Escape" error.
                    Added stand-alone messages option.
                    Also purges output buffer on escape from BPUT or GBPB.

---------------------------------------------------------------------------

Version: 0.17 Mon 23-Sep-91        Tim Dobson                    

 20-Sep-91 0.17 TMD Fixed bug to do with getting used inputs/outputs wrong after offering
                     Service_DeviceFSCloseRequest

---------------------------------------------------------------------------

Version: 0.18 Thu 26-Sep-91        RISC OS Build                 

 Return to 0.16 version for Amber RISC OS release.

---------------------------------------------------------------------------

Version: 0.19 Fri 27-Sep-91        RISC OS Build                 

 Restore 0.17 sources.

---------------------------------------------------------------------------

Version: 0.20 Mon 03-Feb-92        Tim Dobson                    

 21-Jan-92 0.18 TMD Fixed bug in ScanSpecial in alphabetic checking.
 03-Feb-92 0.20 TMD Changed version number to be consistent with SrcFiler version.

---------------------------------------------------------------------------

Version: 0.21 Mon 03-Feb-92        Jonathan Roach                

 03-Feb-92 0.21 JSR Adjust service call entry for changed Service_MessageFileClosed.

---------------------------------------------------------------------------

Version: 0.22 Thu 20-Feb-92        Tim Dobson                    

 20-Feb-92 0.22 TMD Call Buffer_UnlinkDevice when stream closed.
                    Made it refuse to detach from the buffer if stream is open (bug G-RO-9690).

---------------------------------------------------------------------------

Version: 0.23 Thu 20-Feb-92        Tim Dobson                    

 20-Feb-92 0.23 TMD Made OS_GBPB read work, rather than storing the data at location zero.

---------------------------------------------------------------------------

Version: 0.24 Mon 24-Feb-92        Tim Dobson                    

 21-Feb-92 0.24 TMD Made DecodeSpecial return errors correctly.
                    Made ScanSpecial and handle_escape translate their errors.
                    Fixed bug RP-1048 (special field validation strings not working).

---------------------------------------------------------------------------

Version: 0.25 Mon 09-Mar-92        Tim Dobson                    

 06-Mar-92 0.25 TMD Added detach code which offers Service_DeviceFSCloseRequest.

---------------------------------------------------------------------------

Version: 0.26 Mon 09-Mar-92        Tim Dobson                    

 09-Mar-92 0.26 TMD Don't unlink device when freeing file block if we never linked it!

---------------------------------------------------------------------------

Version: 0.27 Thu 03-Jun-93        Steve Cormie                  

 03-Jun-93 0.27 SMC Use new buffer manager interface.
                JSR Optimise CallBuffMan to call with LDMIA
                    Fix bug in create buffer for TX to quote internal handle, not external one.
                    Fix bug is fs_get where 2nd time round loop would try args_eof with a duff file handle.
                    fs_get calls MonitorRX if goes round loop more than once.
                    fs_put calls MonitorTX if goes round loop more than once.
                    Fix bug in gbpb_get to not ignore checkescape.
                    Add MonitorTX to gbpb_put and MonitorRX to gbpb_get.
                    Fix bug in gbpb_put to not ignore checkescape.
                    Add MonitorEOF flag to fs_get and fs_gbpb read.
                    Fix bug in gbpb_put where escape got swallowed by purgebuffer.
                    Ignore rather than return error on Args_SetEXT. This is to ensure
                       compatibility with C file I/O.

---------------------------------------------------------------------------

Version: 0.28 Tue 07-Sep-93        Steve Cormie                  

 07-Sep-93 0.28 SMC Escape now returns error number 17.
                    Fixed bug in fs_put where Escape was ignored.

---------------------------------------------------------------------------

Version: 0.29 Fri 04-Feb-94        Tim Dobson                    

 04-Feb-94 0.29 TMD No change to object code, just moved GET Hdr:Territory
                    below GET Hdr:NewErrors so it assembles again.
***************************************************************************
                      MEDUSA - RISC OS 3.50 build
***************************************************************************
*                                                                         *
*  Project: Black                                                         *
*                                                                         *
*  Module:  DeviceFS                                                      *
*                                                                         *
*  Created: Tue 21-Jun-94      By: Aideen McConville                      *
*                                                                         *
*  First version: 0.29                                                    *
*                                                                         *
*    Copyright:    (C) 1994, Acorn Computers Ltd., Cambridge, England.    *
*                                                                         *
***************************************************************************

Purpose:
========



***************************************************************************


Change Log:
===========


---------------------------------------------------------------------------

Version: 0.29 Tue 21-Jun-94        Aideen McConville             

Moved to new source tree.

---------------------------------------------------------------------------

Version: 0.30 Mon 31-Oct-94        Steve Cormie                  

* Added directed comments to Messages file for message tokenisation.