@ GNU AS assembler header file for Econet
@ Written by DefMod (Dec  9 2012) on Sun Dec  9 15:49:35 2012
@ Jonathan Coxhead, jonathan@doves.demon.co.uk, 21 Aug 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.

#ifndef Econet_Hdr
#  define Econet_Hdr

#  ifndef Get_Types
#    define Get_Types
#    include "oslib/Types.Hdr"
#  endif

#  ifndef Get_OS
#    define Get_OS
#    include "oslib/OS.Hdr"
#  endif

@Symbols for constants
#  define Econet_StatusTransmitted 0x0
#  define Econet_StatusLineJammed 0x1
#  define Econet_StatusNetError 0x2
#  define Econet_StatusNotListening 0x3
#  define Econet_StatusNoClock 0x4
#  define Econet_StatusTxReady 0x5
#  define Econet_StatusTransmitting 0x6
#  define Econet_StatusRxReady 0x7
#  define Econet_StatusReceiving 0x8
#  define Econet_StatusReceived 0x9
#  define Econet_StatusNoReply 0xa
#  define Econet_StatusEscape 0xb
#  define Econet_StatusNotPresent 0xc
#  define Error_EconetTxReady 0x300
#  define Error_EconetTransmitting 0x301
#  define Error_EconetRxReady 0x302
#  define Error_EconetReceiving 0x303
#  define Error_EconetReceived 0x304
#  define Error_EconetTransmitted 0x305
#  define Error_EconetBadStation 0x306
#  define Error_EconetBadNetwork 0x307
#  define Error_EconetUnableToDefault 0x308
#  define Error_EconetBadPort 0x309
#  define Error_EconetBadControl 0x30a
#  define Error_EconetBadBuffer 0x30b
#  define Error_EconetBadSize 0x30c
#  define Error_EconetBadMask 0x30d
#  define Error_EconetBadCount 0x30e
#  define Error_EconetBadDelay 0x30f
#  define Error_EconetBadStatus 0x310
#  define Error_EconetNoHardware 0x311
#  define Error_EconetNoEconet 0x312
#  define Error_EconetNoMoreDomains 0x313
#  define Error_EconetBadDomain 0x314
#  define Error_EconetUnRegisteredDomain 0x315
#  define Error_EconetPortNotAllocated 0x316
#  define Error_EconetPortAllocated 0x317
#  define Error_EconetNoMorePorts 0x318
#  define Econet_ImmediatePeek 0x1
#  define Econet_ImmediatePoke 0x2
#  define Econet_ImmediateJSR 0x3
#  define Econet_ImmediateUserProcedureCall 0x4
#  define Econet_ImmediateOSProcedureCall 0x5
#  define Econet_ImmediateHalt 0x6
#  define Econet_ImmediateContinue 0x7
#  define Econet_ImmediateMachinePeek 0x8
#  define Econet_ImmediateGetRegisters 0x9
#  define Econet_OSCharFromNotify 0x0
#  define Econet_OSInitialiseRemote 0x1
#  define Econet_OSGetViewParameters 0x2
#  define Econet_OSCauseFatalError 0x3
#  define Econet_OSCharFromRemote 0x4
#  define Econet_ProtectionPeek 0x1
#  define Econet_ProtectionPoke 0x2
#  define Econet_ProtectionJSR 0x4
#  define Econet_ProtectionUserProcedureCall 0x8
#  define Econet_ProtectionOSProcedureCall 0x10
#  define Econet_ProtectionHalt 0x20
#  define Econet_ProtectionContinue 0x40
#  define Econet_ProtectionMachinePeek 0x80
#  define Econet_ProtectionGetRegisters 0x100
#  define Econet_ProtectionWriteCMOS 0x80000000
#  define Econet_TransportNotKnown 0x0
#  define Econet_TransportInternet 0x1
#  define Econet_TransportEconet 0x2
#  define Econet_TransportNexus 0x3
#  define Econet_StateOK 0x0
#  define Econet_StateNoClock 0x1
#  define Econet_NetFSStartLoad 0x10
#  define Econet_NetFSPartLoad 0x11
#  define Econet_NetFSFinishLoad 0x12
#  define Econet_NetFSStartSave 0x20
#  define Econet_NetFSPartSave 0x21
#  define Econet_NetFSFinishSave 0x22
#  define Econet_NetFSStartCreate 0x30
#  define Econet_NetFSPartCreate 0x31
#  define Econet_NetFSFinishCreate 0x32
#  define Econet_NetFSStartGetBytes 0x40
#  define Econet_NetFSPartGetBytes 0x41
#  define Econet_NetFSFinishGetBytes 0x42
#  define Econet_NetFSStartPutBytes 0x50
#  define Econet_NetFSPartPutBytes 0x51
#  define Econet_NetFSFinishPutBytes 0x52
#  define Econet_NetFSStartWait 0x60
#  define Econet_NetFSFinishWait 0x62
#  define Econet_NetFSStartBroadcastLoad 0x70
#  define Econet_NetFSPartBroadcastLoad 0x71
#  define Econet_NetFSFinishBroadcastLoad 0x72
#  define Econet_NetFSStartBroadcastSave 0x80
#  define Econet_NetFSPartBroadcastSave 0x81
#  define Econet_NetFSFinishBroadcastSave 0x82
#  define Econet_EconetStartTransmission 0xc0
#  define Econet_EconetFinishTransmission 0xc2
#  define Econet_EconetStartReception 0xd0
#  define Econet_EconetFinishReception 0xd2
#  define Econet_Second 0x3d0900
#  define Econet_kHz 0x1

@Symbols for structure offsets and sizes
        .struct 0
        .skip   Int
Econet_Status                  : 

        .struct 0
        .skip   Int
Econet_ImmediateOp             : 

        .struct 0
        .skip   Ptr
Econet_ImmediateOSProcedure    : 

        .struct 0
        .skip   Bits
Econet_Protection              : 

        .struct 0
        .skip   Int
Econet_TransportType           : 

        .struct 0
        .skip   Int
Econet_State                   : 

@ abstract type
#  define Econet_RxCB 4

@ abstract type
#  define Econet_TxCB 4

        .struct 0
        .skip   Int
Econet_Action                  : 

        .struct 0
        .skip   Bits
Econet_MapFlags                : 


@Symbols for SWI's and SWI reason codes
.set XEconet_CreateReceive,0x60000
.set Econet_CreateReceive,0x40000
   @Entry
   @  R0 = port (Byte)
   @  R1 = station (Byte)
   @  R2 = net (Byte)
   @  R3 = buffer (pointer to data)
   @  R4 = size (Int)
   @Exit
   @  R0 = rx_cb (Econet_RxCB)
   @  R2 = nonlocal (Bool)

.set XEconet_ExamineReceive,0x60001
.set Econet_ExamineReceive,0x40001
   @Entry
   @  R0 = rx_cb (Econet_RxCB)
   @Exit
   @  R0 = status (Econet_Status)

.set XEconet_ReadReceive,0x60002
.set Econet_ReadReceive,0x40002
   @Entry
   @  R0 = rx_cb (Econet_RxCB)
   @Exit
   @  R0 = status (Econet_Status)
   @  R1 = flag (Byte)
   @  R2 = port (Byte)
   @  R3 = station (Byte)
   @  R4 = net (Byte)
   @  R5 = buffer (pointer to data)
   @  R6 = size (Int)

.set XEconet_AbandonReceive,0x60003
.set Econet_AbandonReceive,0x40003
   @Entry
   @  R0 = rx_cb (Econet_RxCB)
   @Exit
   @  R0 = status (Econet_Status)

.set XEconet_WaitForReception,0x60004
.set Econet_WaitForReception,0x40004
   @Entry
   @  R0 = rx_cb (Econet_RxCB)
   @  R1 = delay (Int)
   @  R2 = abort_on_escape (Bool)
   @Exit
   @  R0 = status (Econet_Status)
   @  R1 = flag (Byte)
   @  R2 = port (Byte)
   @  R3 = station (Byte)
   @  R4 = net (Byte)
   @  R5 = buffer (pointer to data)
   @  R6 = size (Int)

.set XEconet_EnumerateReceive,0x60005
.set Econet_EnumerateReceive,0x40005
   @Entry
   @  R0 = rx_cb_no (Int)
   @Exit
   @  R0 = rx_cb (Econet_RxCB)

.set XEconet_StartTransmit,0x60006
.set Econet_StartTransmit,0x40006
   @Entry
   @  R0 = flags (Byte)
   @  R1 = port (Byte)
   @  R2 = station (Byte)
   @  R3 = net (Byte)
   @  R4 = buffer (pointer to data)
   @  R5 = size (Int)
   @  R6 = count (Int)
   @  R7 = delay (Int)
   @Exit
   @  R0 = tx_cb (Econet_TxCB)
   @  R1 corrupted
   @  R2 corrupted
   @  R3 corrupted
   @  R4 = nonlocal (Bool)

.set XEconet_PollTransmit,0x60007
.set Econet_PollTransmit,0x40007
   @Entry
   @  R0 = tx_cb (Econet_TxCB)
   @Exit
   @  R0 = status (Econet_Status)

.set XEconet_AbandonTransmit,0x60008
.set Econet_AbandonTransmit,0x40008
   @Entry
   @  R0 = tx_cb (Econet_TxCB)
   @Exit
   @  R0 = status (Econet_Status)

.set XEconet_DoTransmit,0x60009
.set Econet_DoTransmit,0x40009
   @Entry
   @  R0 = flags (Byte)
   @  R1 = port (Byte)
   @  R2 = station (Byte)
   @  R3 = net (Byte)
   @  R4 = buffer (pointer to data)
   @  R5 = size (Int)
   @  R6 = count (Int)
   @  R7 = delay (Int)
   @Exit
   @  R0 = status (Econet_Status)
   @  R1 corrupted
   @  R2 corrupted
   @  R3 corrupted
   @  R4 = nonlocal (Bool)

.set XEconet_ReadLocalStationAndNet,0x6000a
.set Econet_ReadLocalStationAndNet,0x4000a
   @Exit
   @  R0 = station (Byte)
   @  R1 = net (Byte)

.set XEconet_ConvertStatusToString,0x6000b
.set Econet_ConvertStatusToString,0x4000b
   @Entry
   @  R0 = status (Econet_Status)
   @  R1 = buffer (pointer to String)
   @  R2 = size (Int)
   @  R3 = station (Byte)
   @  R4 = net (Byte)
   @Exit
   @  R0 corrupted
   @  R1 -> end (Char)
   @  R2 corrupted

.set XEconet_ConvertStatusToError,0x6000c
.set Econet_ConvertStatusToError,0x4000c
   @Entry
   @  R0 = status (Econet_Status)
   @  R1 = buffer (pointer to OS_Error)
   @  R2 = size (Int)
   @  R3 = station (Byte)
   @  R4 = net (Byte)

.set XEconet_ReadProtection,0x6000d
.set Econet_ReadProtection,0x4000d
   @Exit
   @  R0 = protection (Econet_Protection)

.set XEconet_SetProtection,0x6000e
.set Econet_SetProtection,0x4000e
   @Entry
   @  R0 = eor_mask (Econet_Protection)
   @  R1 = and_mask (Econet_Protection)
   @Exit
   @  R0 = old_protection (Econet_Protection)

.set XEconet_ReadStationNumber,0x6000f
.set Econet_ReadStationNumber,0x4000f
   @Entry
   @  R1 -> s (String)
   @Exit
   @  R1 -> end (Char)
   @  R2 = station (Int)
   @  R3 = net (Int)

.set XEconet_PrintBanner,0x60010
.set Econet_PrintBanner,0x40010

.set XEconet_ReadTransportType,0x60011
.set Econet_ReadTransportType,0x40011
   @Entry
   @  R0 = station (Byte)
   @  R1 = net (Byte)
   @  R2 = &2
   @Exit
   @  R2 = transport_type (Econet_TransportType)

.set XEconet_ReleasePort,0x60012
.set Econet_ReleasePort,0x40012
   @Entry
   @  R0 = port (Byte)

.set XEconet_AllocatePort,0x60013
.set Econet_AllocatePort,0x40013
   @Exit
   @  R0 = port (Byte)

.set XEconet_DeAllocatePort,0x60014
.set Econet_DeAllocatePort,0x40014
   @Entry
   @  R0 = port (Byte)

.set XEconet_ClaimPort,0x60015
.set Econet_ClaimPort,0x40015
   @Entry
   @  R0 = port (Byte)

.set XEconet_StartImmediate,0x60016
.set Econet_StartImmediate,0x40016
   @Entry
   @  R0 = op_type (Econet_ImmediateOp)
   @  R1 = procedure (Econet_ImmediateOSProcedure)
   @  R2 = station (Byte)
   @  R3 = net (Byte)
   @  R4 = buffer (pointer to data)
   @  R5 = size (Int)
   @  R6 = count (Int)
   @  R7 = delay (Int)
   @Exit
   @  R0 = tx_cb (Econet_TxCB)
   @  R1 corrupted
   @  R2 corrupted
   @  R3 corrupted
   @  R4 = nonlocal (Bool)

.set XEconet_DoImmediate,0x60017
.set Econet_DoImmediate,0x40017
   @Entry
   @  R0 = op_type (Econet_ImmediateOp)
   @  R1 = procedure (Econet_ImmediateOSProcedure)
   @  R2 = station (Byte)
   @  R3 = net (Byte)
   @  R4 = buffer (pointer to data)
   @  R5 = size (Int)
   @  R6 = count (Int)
   @  R7 = delay (Int)
   @Exit
   @  R0 = status (Econet_Status)
   @  R1 corrupted
   @  R2 corrupted
   @  R3 corrupted
   @  R4 = nonlocal (Bool)

.set XEconet_AbandonAndReadReceive,0x60018
.set Econet_AbandonAndReadReceive,0x40018
   @Entry
   @  R0 = rx_cb (Econet_RxCB)
   @Exit
   @  R0 = status (Econet_Status)
   @  R1 = flag (Byte)
   @  R2 = port (Byte)
   @  R3 = station (Byte)
   @  R4 = net (Byte)
   @  R5 = buffer (pointer to data)
   @  R6 = size (Int)

.set XEconet_Version,0x60019
.set Econet_Version,0x40019
   @Entry
   @  R0 = station (Byte)
   @  R1 = net (Byte)
   @Exit
   @  R2 = version (Int)

.set XEconet_NetworkState,0x6001a
.set Econet_NetworkState,0x4001a
   @Entry
   @  R0 = station (Byte)
   @  R1 = net (Byte)
   @Exit
   @  R2 = state (Econet_State)

.set XEconet_PacketSize,0x6001b
.set Econet_PacketSize,0x4001b
   @Entry
   @  R0 = station (Byte)
   @  R1 = net (Byte)
   @Exit
   @  R2 = packet_limit (Int)

.set XEconet_ReadTransportName,0x6001c
.set Econet_ReadTransportName,0x4001c
   @Entry
   @  R0 = station (Byte)
   @  R1 = net (Byte)
   @Exit
   @  R2 -> transport_name (String)

.set XEconet_InetRxDirect,0x6001d
.set Econet_InetRxDirect,0x4001d

.set XEconet_EnumerateMap,0x6001e
.set Econet_EnumerateMap,0x4001e
   @Entry
   @  R0 = flags (Econet_MapFlags)
   @  R4 = context (Int)
   @Exit
   @  R1 = net (Byte)
   @  R2 -> net_name (String)
   @  R3 = ip_subnetwork_address (Int)
   @  R4 = context_out (Int)

.set XEconet_EnumerateTransmit,0x6001f
.set Econet_EnumerateTransmit,0x4001f
   @Entry
   @  R0 = tx_cb_no (Int)
   @Exit
   @  R0 = tx_cb (Econet_TxCB)

.set XEconet_HardwareAddresses,0x60020
.set Econet_HardwareAddresses,0x40020
   @Exit
   @  R0 = hardware_address (pointer to data)
   @  R1 = register_address (pointer to data)
   @  R2 = register_mask (Bits)

.set XEconet_NetworkParameters,0x60021
.set Econet_NetworkParameters,0x40021
   @Exit
   @  R0 = period (Int)
   @  R1 = frequency (Int)
   @  R2 corrupted
   @  R3 corrupted

#  define EconetV 0x21
   @Entry
   @  R0 = action (Econet_Action)
   @  R1 = count (Int)
   @  R9 = &21

#  define Service_ReallocatePorts 0x48
   @Entry
   @  R1 = &48

#  define Service_EconetDying 0x56
   @Entry
   @  R1 = &56

#  define Service_ProtocolDying 0x83
   @Entry
   @  R1 = &83

#  define Service_FindNetworkDriver 0x84
   @Entry
   @  R1 = &84

#  define Service_NetworkDriverStatus 0x8b
   @Entry
   @  R1 = &8B

#  define Event_EconetUserRPC 0x8
   @Entry
   @  R0 = &8
   @  R1 -> args (data)
   @  R2 = procedure (Econet_ImmediateOSProcedure)
   @  R3 = station (Byte)
   @  R4 = net (Byte)

#  define Event_EconetRx 0xe
   @Entry
   @  R0 = &E
   @  R1 = rx_cb (Econet_RxCB)
   @  R2 = status (Econet_Status)

#  define Event_EconetTx 0xf
   @Entry
   @  R0 = &F
   @  R1 = tx_cb (Econet_TxCB)
   @  R2 = status (Econet_Status)

#  define Event_EconetOSProc 0x10
   @Entry
   @  R0 = &10
   @  R1 -> args (data)
   @  R2 = procedure (Econet_ImmediateOSProcedure)
   @  R3 = station (Byte)
   @  R4 = net (Byte)

#endif
