h_brazil 6.66 KB
Newer Older
Neil Turton's avatar
Neil Turton committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
; Copyright 1996 Acorn Computers Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
;     http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; -*- Mode: Assembler -*-
;* Lastedit: 08 Mar 90 12:05:26 by Harry Meekings *
; OS interface for Clibrary / shared kernel
; Copyright (C) Acorn Computers Ltd., 1988

; The version number below bears no resemblance to any release version
; numbers.  It must be incremented by one each time a non-downwards compatible
; version of the library is produced (ie one where the new stubs will not
; function correctly with an older library).
LibraryVersionNumber            *       6

26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
        GET     Hdr:ListOpts
        GET     Hdr:Machine.<Machine>
        GET     Hdr:APCS.<APCS>
        GET     Hdr:CPU.Generic26
        GET     Hdr:CPU.Generic32
        GET     Hdr:Macros
        GET     Hdr:SWIs
        GET     Hdr:RISCOS
        GET     Hdr:ModHand
        GET     Hdr:FPEmulator

        GBLL    StrongARM
        GBLL    SASTMhatbroken

StrongARM       SETL :DEF: AMBKernel
SASTMhatbroken  SETL {TRUE} :LAND: StrongARM

  [ StrongARM
        ;macro to synchronise to $Ncodewords words of code on (FD) stack
        MACRO
        SyncStackCode $Ncodewords
        STMFD  sp!,{r0-r2,lr}
        MOV    r0,#1                    ;means range specified in r1,r2
        ADD    r1,sp,#4*4               ;start address (allowing for stacked r0-r2,lr)
        ADD    r2,r1,#($Ncodewords-1)*4 ;end address (inclusive) for $Ncodewords words of code
        SWI    XOS_SynchroniseCodeAreas ;do the necessary
        LDMFD  sp!,{r0-r2,lr}
        MEND
  ]

Neil Turton's avatar
Neil Turton committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
X               EQU     1:SHL:17

; SWIs common to Brazil and Arthur
WriteC          EQU     X+0
WriteS          EQU     X+1
Write0          EQU     X+2
NewLine         EQU     X+3
ReadC           EQU     X+4
CLI             EQU     X+5
Byte            EQU     X+6
Word            EQU     X+7
File            EQU     X+8
Args            EQU     X+9
BGet            EQU     X+&a
BPut            EQU     X+&b
Multiple        EQU     X+&c
Open            EQU     X+&d
ReadLine        EQU     X+&e
Control         EQU     X+&f
GetEnv          EQU     X+&10
Exit            EQU     X+&11
SetEnv          EQU     X+&12
IntOn           EQU     X+&13
IntOff          EQU     X+&14
CallBack        EQU     X+&15
EnterSVC        EQU     X+&16
BreakPt         EQU     X+&17
BreakCtrl       EQU     X+&18
UnusedSWI       EQU     X+&19
KUpdateMEMC     EQU     X+&1A
SetCallBack     EQU     X+&1B
Mouse           EQU     X+&1C

WriteI          EQU     X+&100

; Arthur only SWIs
Module          EQU     X+&1E
ChangeEnv       EQU     X+&40
GenerateError   EQU     &2B               ; X form not sensible
ReadVarVal      EQU     X+&23
SetVarVal       EQU     X+&24
ExitAndDie      EQU     X+&4D

Lib_Init        EQU     &80680            ; shared library initialise

FPE_Version     EQU     X+&40480

Module_Claim    EQU     6                 ; Module reason codes
Module_Free     EQU     7
Module_Extend   EQU     13

; r0 values for swi ChangeEnv
Env_MemoryLimit         EQU     0
Env_UIHandler           EQU     1
Env_PAHandler           EQU     2
Env_DAHandler           EQU     3
Env_AEHandler           EQU     4
Env_ErrorHandler        EQU     6
Env_CallBackHandler     EQU     7
Env_EscapeHandler       EQU     9
Env_EventHandler        EQU     10
Env_ExitHandler         EQU     11
Env_ApplicationSpace    EQU     14
Env_UpCallHandler       EQU     16

Application_Base EQU    &8000

 [ ModeMayBeNonUser
        MACRO
        EnterLeafProcContainingSWI
126
        FunctionEntry
Neil Turton's avatar
Neil Turton committed
127 128 129 130
        MEND

        MACRO
        ExitLeafProcContainingSWI $cond
131
        Return
Neil Turton's avatar
Neil Turton committed
132 133 134 135 136 137 138 139 140 141
        MEND

  |

        MACRO
        EnterLeafProcContainingSWI
        MEND

        MACRO
        ExitLeafProcContainingSWI $cond
142
        Return "", LinkNotStacked
Neil Turton's avatar
Neil Turton committed
143 144 145 146 147
        MEND
 ]

 [ :DEF:DEFAULT_TEXT
        MACRO
148
        ErrorBlock $name, $string, $tag, $withdefault
Neil Turton's avatar
Neil Turton committed
149 150 151 152 153 154
E_$name
        &       Error_$name
        =       "$string", 0
        ALIGN
        ASSERT  "$tag" <> ""
        &       Error_$name
155
        =       "$tag", 0
Neil Turton's avatar
Neil Turton committed
156 157 158 159
        ALIGN
        MEND
 |
        MACRO
160
        ErrorBlock $name, $string, $tag, $withdefault
Neil Turton's avatar
Neil Turton committed
161 162 163
E_$name
        ASSERT  "$tag" <> ""
        &       Error_$name
164 165 166 167 168
  [ "$withdefault" <> ""
        =       "$tag:$string", 0
  |
        =       "$tag", 0
  ]
Neil Turton's avatar
Neil Turton committed
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
        ALIGN
        MEND
 ]

; Arthur error numbers
Error_NameNotFound              *       &124
Error_ValueTooLong              *       &125

Error_IllegalInstruction        *       &80000000
Error_PrefetchAbort             *       &80000001
Error_DataAbort                 *       &80000002
Error_AddressException          *       &80000003
Error_UnknownIRQ                *       &80000004
Error_BranchThroughZero         *       &80000005

Error_FPBase                    *       &80000200
Error_FPLimit                   *       &80000300

; Arthur errors generated by the library
CLib_Error_Base                 *       &800e80
CLib_Error_Range                *       &80

Error_BadMemory                 *       &800e80
Error_UnknownLib                *       &800e81
Error_StubCorrupt               *       &800e82
Error_StaticSizeWrong           *       &800e83
Error_StaticOffsetInconsistent  *       &800e84
Error_UnknownSWI                *       &800e85
197
Error_OldAPCS                   *       &800e86
Neil Turton's avatar
Neil Turton committed
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226

Error_SharedLibraryNeeded       *       &800e90
Error_OldSharedLibrary          *       &800e91
Error_NoVeneer                  *     &80800e92
 [ :DEF:NEW_SWIS
Error_UnknownFn                 *       &800e93
 ]

Error_ReadFail                  *     &80800ea0
Error_WriteFail                 *     &80800ea1

Error_RecursiveTrap             *       &800e00
Error_UncaughtTrap              *       &800e01
Error_NoMainProgram             *       &800e02
Error_NotAvailable              *       &800e03
Error_NoEnvFile                 *       &800e04
Error_NoRoomForEnv              *       &800e05
Error_BadReturnCode             *       &800e06
Error_NoStackForTrapHandler     *       &800e07
Error_Exit                      *       &800e08   ; in non-user mode
Error_NoWorkSpace               *       &800e09

Error_ReservedForOverlayManager1 *      &800efe
Error_ReservedForOverlayManager2 *      &800eff

Error_DivideByZero              *     &80000020
Error_StackOverflow             *     &80000021

        END