EnsureRMA 1.56 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
; 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.
;
; >     s.EnsureRMA

;       Make sure that RMA has at least 16K free so that !Maestro can start.

        GET     Hdr:ListOpts
        GET     Hdr:Macros
        GET     Hdr:System
        GET     Hdr:ModHand
        GET     Hdr:Proc

Steve Revill's avatar
Steve Revill committed
25 26 27
        AREA    |Asm$$Code|, CODE, READONLY, PIC

        Entry   "r0-r3"
Neil Turton's avatar
Neil Turton committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45

        MOV     r0, #ModHandReason_RMADesc
        SWI     XOS_Module
        EXIT    VS
        CMP     r3, #16*1024                    ; If free space >= 16K then
        EXIT    GE                              ;   do nothing.

        RSB     r3, r3, #16*1024                ; Otherwise, find out how much we need.
        CMP     r3, r2                          ; If we need less than the size of the largest block then
        ADDLE   r3, r2, #1024                   ;   claiming would not increase RMA size so ask for more than largest.
        MOV     r0, #ModHandReason_Claim
        SWI     XOS_Module
        MOVVC   r0, #ModHandReason_Free
        SWIVC   XOS_Module

        EXIT

        END