@ GNU AS assembler header file for OSModule
@ Written by DefMod (Dec  9 2012) on Sun Dec  9 15:47:40 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 OSModule_Hdr
#  define OSModule_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 OSModule_EntryStart 0x0
#  define OSModule_EntryInit 0x4
#  define OSModule_EntryDie 0x8
#  define OSModule_EntryService 0xc
#  define OSModule_EntryTitle 0x10
#  define OSModule_EntryHelp 0x14
#  define OSModule_EntryTable 0x18
#  define OSModule_EntrySWIChunk 0x1c
#  define OSModule_EntrySWIEntry 0x20
#  define OSModule_EntryNameTable 0x24
#  define OSModule_EntryNameCode 0x28
#  define OSModule_EntryMessageFile 0x2c
#  define OSModule_EntryFlagsOffset 0x30
#  define OSModule_SWIChunkSize 0x40
#  define OSModule_SWISystemBase 0x40000
#  define OSModule_SWIApplicationBase 0x80000
#  define OSModule_SWIUserBase 0xc0000
#  define OSModule_SectionSystem 0xffffffff
#  define OSModule_SectionCard0 0x0
#  define OSModule_SectionCard1 0x1
#  define OSModule_SectionCard2 0x2
#  define OSModule_SectionCard3 0x3
#  define OSModule_SectionROM1 0xfffffffe
#  define OSModule_SectionROM2 0xfffffffd
#  define OSModule_SectionROM3 0xfffffffc
#  define OSModule_SectionROM4 0xfffffffb
#  define OSModule_StatusUnsuitable 0xfffffffe
#  define OSModule_StatusUnplugged 0xffffffff
#  define OSModule_StatusDormant 0x0
#  define OSModule_StatusActive 0x1
#  define OSModule_StatusRunning 0x2
#  define OSModule_InfoFSCommand 0x80
#  define OSModule_InfoConfiguration 0x40
#  define OSModule_InfoHelp 0x20
#  define OSModule_InfoLookupStrings 0x10
#  define OSModule_32BitCompatible 0x1
#  define OSModule_EarlyROMInitialisation 0x2
#  define OSModule_ActionUnplug 0x0
#  define OSModule_ActionInsert 0x1
#  define OSModule_EventInitialisation 0x0
#  define OSModule_EventFinalisation 0x1
#  define OSModule_EventChangedPreferredInstance 0x2
#  define OSModule_EventRenamedInstance 0x3
#  define Error_ModuleNotMod 0x100
#  define Error_ModuleMHNoRoom 0x101
#  define Error_ModuleRMNotFound 0x102
#  define Error_ModuleCantKill 0x103
#  define Error_ModuleCantKill2 0x103
#  define Error_ModuleWimpCantKill 0x104
#  define Error_ModuleBadModuleReason 0x105
#  define Error_ModuleBadDynamicArea 0x105
#  define Error_ModuleRMNotFoundInROM 0x106
#  define Error_ModuleModulePostfix 0x107
#  define Error_ModuleNoMoreModules 0x108
#  define Error_ModuleNoMoreIncarnations 0x109
#  define Error_ModulePostfixNeeded 0x109
#  define Error_ModuleIncarnationExists 0x10b
#  define Error_ModuleIncarnationNotFound 0x10c
#  define Error_ModuleChunkNotRM 0x10d
#  define Error_ModuleBadRMHeaderField 0x10e
#  define Error_ModuleModuleTooOld 0x10f
#  define Error_ModuleModuleBadSWI 0x110
#  define Error_ModuleModuleInUse 0x111
#  define Error_ModuleBadFilingSystemOperation 0x112
#  define Error_ModuleFilingSystemReadOnly 0x113
#  define Error_ModuleNotADir 0x114

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

        .struct 0
        .skip   Int
OSModule_Status                : 

        .struct 0
        .skip   Bits
OSModule_InfoFlags             : 

        .struct 0
        .skip   Bits
OSModule_Flags                 : 

        .struct 0
        .skip   Int
OSModule_StateAction           : 

        .struct 0
        .skip   Int
OSModule_StateEvent            : 


@Symbols for SWI's and SWI reason codes
.set XOS_Module,0x2001e
.set OS_Module,0x1e

#  define OSModule_Run 0x0
   @Entry
   @  R0 = &0
   @  R1 -> tail (String)

#  define OSModule_Load 0x1
   @Entry
   @  R0 = &1
   @  R1 -> tail (String)

#  define OSModule_Enter 0x2
   @Entry
   @  R0 = &2
   @  R1 -> module_name (String)
   @  R2 -> args (String)

#  define OSModule_Reinit 0x3
   @Entry
   @  R0 = &3
   @  R1 -> tail (String)

#  define OSModule_Kill 0x4
   @Entry
   @  R0 = &4
   @  R1 -> module_name (String)

#  define OSModule_Info 0x5
   @Entry
   @  R0 = &5
   @Exit
   @  R2 = max (Int)
   @  R3 = free (Int)

#  define OSModule_Alloc 0x6
   @Entry
   @  R0 = &6
   @  R3 = size (Int)
   @Exit
   @  R2 = blk (pointer to Void)

#  define OSModule_Free 0x7
   @Entry
   @  R0 = &7
   @  R2 = blk (pointer to Void)

#  define OSModule_Tidy 0x8
   @Entry
   @  R0 = &8

#  define OSModule_Clear 0x9
   @Entry
   @  R0 = &9

#  define OSModule_AddArea 0xa
   @Entry
   @  R0 = &A
   @  R1 -> module (data)

#  define OSModule_CopyArea 0xb
   @Entry
   @  R0 = &B
   @  R1 -> module (data)
   @  R2 = size (Int)

#  define OSModule_Enumerate 0xc
   @Entry
   @  R0 = &C
   @  R1 = module_no (Int)
   @  R2 = instance_no (Int)
   @Exit
   @  R1 = module_no_out (Int)
   @  R2 = instance_no_out (Int)
   @  R3 -> module (data)
   @  R4 = workspace (pointer to Void)
   @  R5 -> postfix (String)

#  define OSModule_Realloc 0xd
   @Entry
   @  R0 = &D
   @  R2 = blk (pointer to Void)
   @  R3 = size_increase (Int)
   @Exit
   @  R2 = blk_out (pointer to Void)

#  define OSModule_Instantiate 0xe
   @Entry
   @  R0 = &E
   @  R1 -> instance_name (String)

#  define OSModule_Rename 0xf
   @Entry
   @  R0 = &F
   @  R1 -> old_name (String)
   @  R2 -> new_postfix (String)

#  define OSModule_Prefer 0x10
   @Entry
   @  R0 = &10
   @  R1 -> instance_name (String)

#  define OSModule_AddPoduleArea 0x11
   @Entry
   @  R0 = &11
   @  R1 -> environment (String)
   @  R2 = chunk (Int)
   @  R3 = rom_section (OSModule_SectionNo)

#  define OSModule_Lookup 0x12
   @Entry
   @  R0 = &12
   @  R1 -> module_name (String)
   @Exit
   @  R1 = module_no (Int)
   @  R2 = instance_no (Int)
   @  R3 -> module (data)
   @  R4 = workspace (pointer to Void)
   @  R5 -> postfix (String)

#  define OSModule_EnumerateROM 0x13
   @Entry
   @  R0 = &13
   @  R1 = module_no (Int)
   @  R2 = section (OSModule_SectionNo)
   @Exit
   @  R1 = module_no_out (Int)
   @  R2 = section_out (OSModule_SectionNo)
   @  R3 -> module_name (String)
   @  R4 = status (OSModule_Status)
   @  R5 = chunk_no (Int)

#  define OSModule_EnumerateROMWithInfo 0x14
   @Entry
   @  R0 = &14
   @  R1 = module_no (Int)
   @  R2 = section (OSModule_SectionNo)
   @Exit
   @  R1 = module_no_out (Int)
   @  R2 = section_out (OSModule_SectionNo)
   @  R3 -> module_name (String)
   @  R4 = status (OSModule_Status)
   @  R5 = chunk_no (Int)
   @  R6 = bcd_version (Int)

#  define OSModule_EnumerateWithPrivateWord 0x16
   @Entry
   @  R0 = &16
   @  R1 = module_no (Int)
   @  R2 = incarnation_number (Int)
   @Exit
   @  R1 = module_no_out (Int)
   @  R2 = incarnation_number_out (Int)
   @  R3 -> module_code (data)
   @  R4 -> private_word (Int)
   @  R5 -> postfix (String)

#  define OSModule_ChangeState 0x17
   @Entry
   @  R0 = &17
   @  R1 -> module_name (String)
   @  R2 = action (OSModule_StateAction)
   @  R3 = podule_number (Int)

#  define Service_UKCommand 0x4
   @Entry
   @  R0 -> command (String)
   @  R1 = &4
   @Exit
   @  R0 -> error (OS_Error)
   @  R1 = unclaimed (Bool)

#  define Service_Error 0x6
   @Entry
   @  R0 -> error (OS_Error)
   @  R1 = &6

#  define Service_UKByte 0x7
   @Entry
   @  R1 = &7
   @  R2 = byte (Int)
   @  R3 = arg0 (Int)
   @  R4 = arg1 (Int)
   @Exit
   @  R1 = unclaimed (Bool)
   @  R2 = res0 (Int)
   @  R3 = res1 (Int)

#  define Service_UKWord 0x8
   @Entry
   @  R1 = &8
   @  R2 = word (Int)
   @  R3 -> block (data)
   @Exit
   @  R1 = unclaimed (Bool)

#  define Service_Help 0x9
   @Entry
   @  R0 -> command (String)
   @  R1 = &9
   @Exit
   @  R1 = unclaimed (Bool)

#  define Service_UKConfig 0x28
   @Entry
   @  R0 -> tail (String)
   @  R1 = &28
   @Exit
   @  R0 -> error (OS_Error)
   @  R1 = unclaimed (Bool)

#  define Service_UKStatus 0x29
   @Entry
   @  R0 -> tail (String)
   @  R1 = &29
   @Exit
   @  R1 = unclaimed (Bool)

#  define Service_NewApplication 0x2a
   @Entry
   @  R1 = &2A
   @Exit
   @  R1 = unclaimed (Bool)

#  define Service_LookupFileType 0x42
   @Entry
   @  R1 = &42
   @  R2 = file_type (Bits)
   @Exit
   @  R1 = unclaimed (Bool)
   @  R2 = name1 (Bits)
   @  R3 = name2 (Bits)

#  define Service_PostInit 0x73
   @Entry
   @  R1 = &73

#  define Service_SyntaxError 0x8c
   @Entry
   @  R1 = &8C
   @  R2 -> offset (Int)
   @  R3 = base (pointer to data)
   @  R4 -> command (String)
   @Exit
   @  R0 -> error (OS_Error)
   @  R1 = unclaimed (Bool)

#  define Service_ModulePreInit 0xb9
   @Entry
   @  R0 -> module (data)
   @  R1 = &B9
   @  R2 = length_plus_four (Int)

#  define Service_ModuleStatus 0xd8
   @Entry
   @  R0 = event (OSModule_StateEvent)
   @  R1 = &D8
   @  R2 -> module (data)
   @  R3 -> private_word (Int)
   @  R4 -> title (String)
   @  R5 -> postfix (String)

#  define Service_ModuleStatusInstanceRenamed 0xd8
   @Entry
   @  R0 = &3
   @  R1 = &D8
   @  R2 -> module (data)
   @  R3 -> private_word (Int)
   @  R4 -> title (String)
   @  R5 -> postfix (String)
   @  R6 -> new_instance_name (String)

#  define Service_ModulePostInit 0xda
   @Entry
   @  R0 -> module (data)
   @  R1 = &DA
   @  R2 -> title (Char)
   @  R3 -> postfix (String)
   @  R4 = bcd_version (Int)

#  define Service_ModulePostFinal 0xdb
   @Entry
   @  R0 -> module (data)
   @  R1 = &DB
   @  R2 -> title (Char)
   @  R3 -> postfix (String)
   @  R4 = bcd_version (Int)

#endif
