; Assembler header file for OSModule
; Written by DefMod (Dec  9 2012) on Sun Dec  9 15:43:51 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.

        [       :LNOT: :DEF: OSModule_Hdr
        GBLS    OSModule_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

;Symbols for constants
OSModule_EntryStart             *       0
OSModule_EntryInit              *       4
OSModule_EntryDie               *       8
OSModule_EntryService           *       12
OSModule_EntryTitle             *       16
OSModule_EntryHelp              *       20
OSModule_EntryTable             *       24
OSModule_EntrySWIChunk          *       28
OSModule_EntrySWIEntry          *       32
OSModule_EntryNameTable         *       36
OSModule_EntryNameCode          *       40
OSModule_EntryMessageFile       *       44
OSModule_EntryFlagsOffset       *       48
OSModule_SWIChunkSize           *       64
OSModule_SWISystemBase          *       262144
OSModule_SWIApplicationBase     *       524288
OSModule_SWIUserBase            *       786432
OSModule_SectionSystem          *       &FFFFFFFF
OSModule_SectionCard0           *       &0
OSModule_SectionCard1           *       &1
OSModule_SectionCard2           *       &2
OSModule_SectionCard3           *       &3
OSModule_SectionROM1            *       &FFFFFFFE
OSModule_SectionROM2            *       &FFFFFFFD
OSModule_SectionROM3            *       &FFFFFFFC
OSModule_SectionROM4            *       &FFFFFFFB
OSModule_StatusUnsuitable       *       &FFFFFFFE
OSModule_StatusUnplugged        *       &FFFFFFFF
OSModule_StatusDormant          *       &0
OSModule_StatusActive           *       &1
OSModule_StatusRunning          *       &2
OSModule_InfoFSCommand          *       &80
OSModule_InfoConfiguration      *       &40
OSModule_InfoHelp               *       &20
OSModule_InfoLookupStrings      *       &10
OSModule_32BitCompatible        *       &1
OSModule_EarlyROMInitialisation *       &2
OSModule_ActionUnplug           *       &0
OSModule_ActionInsert           *       &1
OSModule_EventInitialisation    *       &0
OSModule_EventFinalisation      *       &1
OSModule_EventChangedPreferredInstance *       &2
OSModule_EventRenamedInstance   *       &3
Error_ModuleNotMod              *       &100
Error_ModuleMHNoRoom            *       &101
Error_ModuleRMNotFound          *       &102
Error_ModuleCantKill            *       &103
Error_ModuleCantKill2           *       &103
Error_ModuleWimpCantKill        *       &104
Error_ModuleBadModuleReason     *       &105
Error_ModuleBadDynamicArea      *       &105
Error_ModuleRMNotFoundInROM     *       &106
Error_ModuleModulePostfix       *       &107
Error_ModuleNoMoreModules       *       &108
Error_ModuleNoMoreIncarnations  *       &109
Error_ModulePostfixNeeded       *       &109
Error_ModuleIncarnationExists   *       &10B
Error_ModuleIncarnationNotFound *       &10C
Error_ModuleChunkNotRM          *       &10D
Error_ModuleBadRMHeaderField    *       &10E
Error_ModuleModuleTooOld        *       &10F
Error_ModuleModuleBadSWI        *       &110
Error_ModuleModuleInUse         *       &111
Error_ModuleBadFilingSystemOperation *       &112
Error_ModuleFilingSystemReadOnly *       &113
Error_ModuleNotADir             *       &114

;Symbols for structure offsets and sizes
        ^       0
        #       Int
OSModule_SectionNo              *       @

        ^       0
        #       Int
OSModule_Status                 *       @

        ^       0
        #       Bits
OSModule_InfoFlags              *       @

        ^       0
        #       Bits
OSModule_Flags                  *       @

        ^       0
        #       Int
OSModule_StateAction            *       @

        ^       0
        #       Int
OSModule_StateEvent             *       @


;Symbols for SWI's and SWI reason codes
XOS_Module                      *       &2001E
OS_Module                       *       &1E

OSModule_Run                    *       &0
   ;Entry
   ;  R0 = &0
   ;  R1 -> tail (String)

OSModule_Load                   *       &1
   ;Entry
   ;  R0 = &1
   ;  R1 -> tail (String)

OSModule_Enter                  *       &2
   ;Entry
   ;  R0 = &2
   ;  R1 -> module_name (String)
   ;  R2 -> args (String)

OSModule_Reinit                 *       &3
   ;Entry
   ;  R0 = &3
   ;  R1 -> tail (String)

OSModule_Kill                   *       &4
   ;Entry
   ;  R0 = &4
   ;  R1 -> module_name (String)

OSModule_Info                   *       &5
   ;Entry
   ;  R0 = &5
   ;Exit
   ;  R2 = max (Int)
   ;  R3 = free (Int)

OSModule_Alloc                  *       &6
   ;Entry
   ;  R0 = &6
   ;  R3 = size (Int)
   ;Exit
   ;  R2 = blk (pointer to Void)

OSModule_Free                   *       &7
   ;Entry
   ;  R0 = &7
   ;  R2 = blk (pointer to Void)

OSModule_Tidy                   *       &8
   ;Entry
   ;  R0 = &8

OSModule_Clear                  *       &9
   ;Entry
   ;  R0 = &9

OSModule_AddArea                *       &A
   ;Entry
   ;  R0 = &A
   ;  R1 -> module (data)

OSModule_CopyArea               *       &B
   ;Entry
   ;  R0 = &B
   ;  R1 -> module (data)
   ;  R2 = size (Int)

OSModule_Enumerate              *       &C
   ;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)

OSModule_Realloc                *       &D
   ;Entry
   ;  R0 = &D
   ;  R2 = blk (pointer to Void)
   ;  R3 = size_increase (Int)
   ;Exit
   ;  R2 = blk_out (pointer to Void)

OSModule_Instantiate            *       &E
   ;Entry
   ;  R0 = &E
   ;  R1 -> instance_name (String)

OSModule_Rename                 *       &F
   ;Entry
   ;  R0 = &F
   ;  R1 -> old_name (String)
   ;  R2 -> new_postfix (String)

OSModule_Prefer                 *       &10
   ;Entry
   ;  R0 = &10
   ;  R1 -> instance_name (String)

OSModule_AddPoduleArea          *       &11
   ;Entry
   ;  R0 = &11
   ;  R1 -> environment (String)
   ;  R2 = chunk (Int)
   ;  R3 = rom_section (OSModule_SectionNo)

OSModule_Lookup                 *       &12
   ;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)

OSModule_EnumerateROM           *       &13
   ;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)

OSModule_EnumerateROMWithInfo   *       &14
   ;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)

OSModule_EnumerateWithPrivateWord *       &16
   ;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)

OSModule_ChangeState            *       &17
   ;Entry
   ;  R0 = &17
   ;  R1 -> module_name (String)
   ;  R2 = action (OSModule_StateAction)
   ;  R3 = podule_number (Int)

Service_UKCommand               *       &4
   ;Entry
   ;  R0 -> command (String)
   ;  R1 = &4
   ;Exit
   ;  R0 -> error (OS_Error)
   ;  R1 = unclaimed (Bool)

Service_Error                   *       &6
   ;Entry
   ;  R0 -> error (OS_Error)
   ;  R1 = &6

Service_UKByte                  *       &7
   ;Entry
   ;  R1 = &7
   ;  R2 = byte (Int)
   ;  R3 = arg0 (Int)
   ;  R4 = arg1 (Int)
   ;Exit
   ;  R1 = unclaimed (Bool)
   ;  R2 = res0 (Int)
   ;  R3 = res1 (Int)

Service_UKWord                  *       &8
   ;Entry
   ;  R1 = &8
   ;  R2 = word (Int)
   ;  R3 -> block (data)
   ;Exit
   ;  R1 = unclaimed (Bool)

Service_Help                    *       &9
   ;Entry
   ;  R0 -> command (String)
   ;  R1 = &9
   ;Exit
   ;  R1 = unclaimed (Bool)

Service_UKConfig                *       &28
   ;Entry
   ;  R0 -> tail (String)
   ;  R1 = &28
   ;Exit
   ;  R0 -> error (OS_Error)
   ;  R1 = unclaimed (Bool)

Service_UKStatus                *       &29
   ;Entry
   ;  R0 -> tail (String)
   ;  R1 = &29
   ;Exit
   ;  R1 = unclaimed (Bool)

Service_NewApplication          *       &2A
   ;Entry
   ;  R1 = &2A
   ;Exit
   ;  R1 = unclaimed (Bool)

Service_LookupFileType          *       &42
   ;Entry
   ;  R1 = &42
   ;  R2 = file_type (Bits)
   ;Exit
   ;  R1 = unclaimed (Bool)
   ;  R2 = name1 (Bits)
   ;  R3 = name2 (Bits)

Service_PostInit                *       &73
   ;Entry
   ;  R1 = &73

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

Service_ModulePreInit           *       &B9
   ;Entry
   ;  R0 -> module (data)
   ;  R1 = &B9
   ;  R2 = length_plus_four (Int)

Service_ModuleStatus            *       &D8
   ;Entry
   ;  R0 = event (OSModule_StateEvent)
   ;  R1 = &D8
   ;  R2 -> module (data)
   ;  R3 -> private_word (Int)
   ;  R4 -> title (String)
   ;  R5 -> postfix (String)

Service_ModuleStatusInstanceRenamed *       &D8
   ;Entry
   ;  R0 = &3
   ;  R1 = &D8
   ;  R2 -> module (data)
   ;  R3 -> private_word (Int)
   ;  R4 -> title (String)
   ;  R5 -> postfix (String)
   ;  R6 -> new_instance_name (String)

Service_ModulePostInit          *       &DA
   ;Entry
   ;  R0 -> module (data)
   ;  R1 = &DA
   ;  R2 -> title (Char)
   ;  R3 -> postfix (String)
   ;  R4 = bcd_version (Int)

Service_ModulePostFinal         *       &DB
   ;Entry
   ;  R0 -> module (data)
   ;  R1 = &DB
   ;  R2 -> title (Char)
   ;  R3 -> postfix (String)
   ;  R4 = bcd_version (Int)

        ]
        END
