; Assembler header file for DeviceFS
; Written by DefMod (Dec  9 2012) on Sun Dec  9 15:43:43 2012
; Jonathan Coxhead, jonathan@doves.demon.co.uk, 29 June 1995

; OSLib---efficient, type-safe, transparent, extensible,
; register-safe API coverage of RISC OS
; 
; Copyright (c) 1994-2012 Jonathan Coxhead and OSLib maintainers
; 
; Licence:
; 
;    OSLib is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 1, or (at your option)
; any later version - and this with the following clarification and
; special exception:
; 
;    Linking this library statically or dynamically with other modules
; is making a combined work based on this library. Thus, the terms
; and conditions of the GNU General Public License cover the whole
; combination.
; 
;    As a special exception, the copyright holders of this library
; give you permission to link this library with independent modules
; to produce an executable, regardless of the license terms of these
; independent modules, and to copy and distribute the resulting
; executable under terms of your choice, provided that you also meet,
; for each linked independent module, the terms and conditions of the
; license of that module. An independent module is a module which is
; not derived from or based on this library. If you modify this
; library, you may extend this exception to your version of the library,
; but you are not obliged to do so. If you do not wish to do so, delete
; this exception statement from your version.
; 
;    OSLib is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.
; 
;    You should have received a copy of the GNU General Public License
; along with this programme; if not, write to the Free Software
; Foundation, Inc, 675 Mass Ave, Cambridge, MA 02139, USA.

        [       :LNOT: :DEF: DeviceFS_Hdr
        GBLS    DeviceFS_Hdr

        [       :LNOT: :DEF: Get_Types
        GBLS    Get_Types
        ]
        [       :LNOT: :DEF: Types_Hdr
Get_Types                       SETS    "GET oslib/Types.Hdr"
        |
Get_Types                       SETS    ""
        ]
        $Get_Types

        [       :LNOT: :DEF: Get_OS
        GBLS    Get_OS
        ]
        [       :LNOT: :DEF: OS_Hdr
Get_OS                          SETS    "GET oslib/OS.Hdr"
        |
Get_OS                          SETS    ""
        ]
        $Get_OS

        [       :LNOT: :DEF: Get_OSArgs
        GBLS    Get_OSArgs
        ]
        [       :LNOT: :DEF: OSArgs_Hdr
Get_OSArgs                      SETS    "GET oslib/OSArgs.Hdr"
        |
Get_OSArgs                      SETS    ""
        ]
        $Get_OSArgs

        [       :LNOT: :DEF: Get_Buffer
        GBLS    Get_Buffer
        ]
        [       :LNOT: :DEF: Buffer_Hdr
Get_Buffer                      SETS    "GET oslib/Buffer.Hdr"
        |
Get_Buffer                      SETS    ""
        ]
        $Get_Buffer

;Symbols for constants
DeviceFS_DeviceBuffered         *       &1
DeviceFS_DeviceUsesPathVar      *       &2
DeviceFS_RegisterBlockDevice    *       &1
DeviceFS_RegisterFullDuplex     *       &2
DeviceFS_OpenForRx              *       &0
DeviceFS_OpenForTx              *       &1

;Symbols for structure offsets and sizes
        ^       0
        #       Bits
DeviceFS_Flags                  *       @

DeviceFS_D                      *       4 ;abstract type
DeviceFS_S                      *       4 ;abstract type
DeviceFS_H                      *       4 ;abstract type
        ^       0
DeviceFS_Device_name_offset     #       Int
DeviceFS_Device_flags           #       DeviceFS_Flags
DeviceFS_Device_rx_flags        #       Bits
DeviceFS_Device_rx_buffer_size  #       Int
DeviceFS_Device_tx_flags        #       Bits
DeviceFS_Device_tx_buffer_size  #       Int
DeviceFS_Device_reserved        #       Int
DeviceFS_Device                 *       @

        ^       0
DeviceFS_DeviceList_d           #       DeviceFS_Device
DeviceFS_DeviceList             *       @

        ^       0
        #       Bits
DeviceFS_RegisterFlags          *       @

        ^       0
        #       Bits
DeviceFS_InitialiseFlags        *       @


;Symbols for SWI's and SWI reason codes
XDeviceFS_Register              *       &62740
DeviceFS_Register               *       &42740
   ;Entry
   ;  R0 = flags (DeviceFS_RegisterFlags)
   ;  R1 -> devices (DeviceFS_DeviceList)
   ;  R2 = driver (pointer to code)
   ;  R3 = handle (Int)
   ;  R4 = workspace (pointer to Void)
   ;  R5 -> validation (String)
   ;  R6 = rx_limit (Int)
   ;  R7 = tx_limit (Int)
   ;Exit
   ;  R0 = d (DeviceFS_D)

XDeviceFS_Deregister            *       &62741
DeviceFS_Deregister             *       &42741
   ;Entry
   ;  R0 = d (DeviceFS_D)

XDeviceFS_RegisterObjects       *       &62742
DeviceFS_RegisterObjects        *       &42742
   ;Entry
   ;  R0 = d (DeviceFS_D)
   ;  R1 -> devices (DeviceFS_DeviceList)

XDeviceFS_DeregisterObjects     *       &62743
DeviceFS_DeregisterObjects      *       &42743
   ;Entry
   ;  R0 = d (DeviceFS_D)
   ;  R1 -> device_name (String)

XDeviceFS_CallDevice            *       &62744
DeviceFS_CallDevice             *       &42744

DeviceFSCallDevice_Initialise   *       &0
   ;Entry
   ;  R0 = &0
   ;  R1 = d (DeviceFS_D)
   ;  R2 = s (DeviceFS_S)
   ;  R3 = flags (DeviceFS_InitialiseFlags)
   ;  R6 -> decoded_special (data)
   ;Exit
   ;  R2 = h (DeviceFS_H)

DeviceFSCallDevice_Terminate    *       &1
   ;Entry
   ;  R0 = &1
   ;  R1 = d (DeviceFS_D)
   ;  R2 = h (DeviceFS_H)

DeviceFSCallDevice_TxWakeUp     *       &2
   ;Entry
   ;  R0 = &2
   ;  R1 = d (DeviceFS_D)
   ;  R2 = h (DeviceFS_H)
   ;Exit
   ;  R0 = woken_up (Bool)

DeviceFSCallDevice_RxWakeUp     *       &3
   ;Entry
   ;  R0 = &3
   ;  R1 = d (DeviceFS_D)
   ;  R2 = h (DeviceFS_H)

DeviceFSCallDevice_RxSleep      *       &4
   ;Entry
   ;  R0 = &4
   ;  R1 = d (DeviceFS_D)
   ;  R2 = h (DeviceFS_H)

DeviceFSCallDevice_EnumDir      *       &5
   ;Entry
   ;  R0 = &5
   ;  R1 = d (DeviceFS_D)
   ;  R2 -> file_name (String)

DeviceFSCallDevice_TxCreateBuffer *       &6
   ;Entry
   ;  R0 = &6
   ;  R1 = d (DeviceFS_D)
   ;  R2 = h (DeviceFS_H)
   ;  R3 = flags (Buffer_Flags)
   ;  R4 = size (Int)
   ;  R5 = b (Buffer_B)
   ;  R6 = threshold (Int)
   ;Exit
   ;  R3 = flags_out (Buffer_Flags)
   ;  R4 = size_out (Int)
   ;  R5 = b_out (Buffer_B)
   ;  R6 = threshold_out (Int)

DeviceFSCallDevice_RxCreateBuffer *       &7
   ;Entry
   ;  R0 = &7
   ;  R1 = d (DeviceFS_D)
   ;  R2 = h (DeviceFS_H)
   ;  R3 = flags (Buffer_Flags)
   ;  R4 = size (Int)
   ;  R5 = b (Buffer_B)
   ;  R6 = threshold (Int)
   ;Exit
   ;  R3 = flags_out (Buffer_Flags)
   ;  R4 = size_out (Int)
   ;  R5 = b_out (Buffer_B)
   ;  R6 = threshold_out (Int)

DeviceFSCallDevice_Halt         *       &8
   ;Entry
   ;  R0 = &8
   ;  R1 = d (DeviceFS_D)
   ;  R2 = h (DeviceFS_H)

DeviceFSCallDevice_Resume       *       &9
   ;Entry
   ;  R0 = &9
   ;  R1 = d (DeviceFS_D)
   ;  R2 = h (DeviceFS_H)

DeviceFSCallDevice_EndOfData    *       &A
   ;Entry
   ;  R0 = &A
   ;  R1 = d (DeviceFS_D)
   ;  R2 = h (DeviceFS_H)
   ;  R3 = &FFFFFFFF
   ;Exit
   ;  R3 = end_of_data (Bool)

DeviceFSCallDevice_StreamCreated *       &B
   ;Entry
   ;  R0 = &B
   ;  R1 = d (DeviceFS_D)
   ;  R2 = h (DeviceFS_H)
   ;  R3 = b (Buffer_B)

DeviceFSCallDevice_IOCtl        *       &E
   ;Entry
   ;  R0 = &E
   ;  R1 = d (DeviceFS_D)
   ;  R2 = h (DeviceFS_H)
   ;  R3 = parameters (pointer to OSArgs_IOCtlParameters)

XDeviceFS_Threshold             *       &62745
DeviceFS_Threshold              *       &42745
   ;Entry
   ;  R1 = s (DeviceFS_S)
   ;  R2 = threshold (Int)

XDeviceFS_ReceivedChar          *       &62746
DeviceFS_ReceivedChar           *       &42746
   ;Entry
   ;  R0 = b (Byte)
   ;  R1 = s (DeviceFS_S)

XDeviceFS_TransmitChar          *       &62747
DeviceFS_TransmitChar           *       &42747
   ;Entry
   ;  R1 = s (DeviceFS_S)
   ;Exit
   ;  R0 = b (Byte)

Service_DeviceFSStarting        *       &70
   ;Entry
   ;  R1 = &70

Service_DeviceFSDying           *       &71
   ;Entry
   ;  R0 = &0
   ;  R1 = &71

Service_DeviceDead              *       &79
   ;Entry
   ;  R0 = &0
   ;  R1 = &79
   ;  R2 = d (DeviceFS_D)
   ;  R3 -> device_name (String)

Service_DeviceFSCloseRequest    *       &81
   ;Entry
   ;  R1 = &81
   ;  R2 = file (OS_F)
   ;Exit
   ;  R1 = unclaimed (Bool)

Service_DeviceFSCloseRequestW   *       &81
   ;Entry
   ;  R1 = &81
   ;  R2 = file (OS_FW)
   ;Exit
   ;  R1 = unclaimed (Bool)

UpCall_StreamCreated            *       &A
   ;Entry
   ;  R0 = &A
   ;  R1 = d (DeviceFS_D)
   ;  R2 = tx_stream (Bool)
   ;  R3 = file (OS_F)
   ;  R4 = s (DeviceFS_S)

UpCall_StreamCreatedW           *       &A
   ;Entry
   ;  R0 = &A
   ;  R1 = d (DeviceFS_D)
   ;  R2 = tx_stream (Bool)
   ;  R3 = file (OS_FW)
   ;  R4 = s (DeviceFS_S)

UpCall_StreamClosed             *       &B
   ;Entry
   ;  R0 = &B
   ;  R1 = d (DeviceFS_D)
   ;  R2 = tx_stream (Bool)
   ;  R3 = file (OS_F)
   ;  R4 = s (DeviceFS_S)

UpCall_StreamClosedW            *       &B
   ;Entry
   ;  R0 = &B
   ;  R1 = d (DeviceFS_D)
   ;  R2 = tx_stream (Bool)
   ;  R3 = file (OS_FW)
   ;  R4 = s (DeviceFS_S)

UpCall_DeviceRxDataPresent      *       &F
   ;Entry
   ;  R0 = &F
   ;  R1 = d (DeviceFS_D)

UpCall_DeviceThresAbove         *       &10
   ;Entry
   ;  R0 = &10
   ;  R1 = d (DeviceFS_D)

UpCall_DeviceThresBelow         *       &11
   ;Entry
   ;  R0 = &11
   ;  R1 = d (DeviceFS_D)

Event_DeviceOverrun             *       &16
   ;Entry
   ;  R0 = &16
   ;  R1 = d (DeviceFS_D)
   ;  R2 = file (OS_F)
   ;  R3 = &0

Event_DeviceOverrunW            *       &16
   ;Entry
   ;  R0 = &16
   ;  R1 = d (DeviceFS_D)
   ;  R2 = file (OS_FW)
   ;  R3 = &0

        ]
        END
