mapsome 2.22 KB
; 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.mapsome

; handle mapping in of some of slot
; (used to implement 'mapenoughslot' for Wimp_TransferBlock)

; entry:
;     R0 = &103 (reason code 3, bit 8 set for mapsome)
;     R1 = start (logical address)
;     R2 = handle
;     R3 = offset to start of mapping (pages into slot)
;     R4 = no. of pages to map

mapsome
        Push    "R0-R7,LR"

        CMP     R1,#0
        MOVEQ   R1,#ApplicationStart

      [ ValidateAMBHandles
        ;validate handle
        LDR     R0,AMBNhandles
        CMP     R2,R0
        BGT     badmapsome
        CMP     R2,#1
        BLT     badmapsome
      ]

        LDR     R0,AMBNodeHandles   ; R0 -> handle array
        LDR     R0,[R0,R2,LSL #2]   ; R0 -> node

      [ ValidateAMBHandles
        ;check we have a proper id for node handle
        LDR     R6,=AMBMagicNodeID
        LDR     LR,[R0,#AMBNode_id]
        CMP     LR,R6
        BNE     badmapsome
      ]

        LDR     R6,[R0,#AMBNode_Npages]
        ADD     LR,R3,R4
        CMP     LR,R6
        BGT     badmssize

        MOV     R7,R3
        MOV     R3,R4
        ADD     R4,R0,#AMBNode_pages
        ADD     R4,R4,R7,LSL #2
        MOV     R5,R1
        CMP     R5,#-1
        MOVEQ   R6,#AP_Duff
        MOVNE   R6,#0
        ;entry: R3 = no. of pages, R4 -> list of page entries,
        ;       R5 := start logical address, R6 = PPL
        BL      AMB_SetMemMapEntries

        Pull    "R0-R7,LR"
        B       SLVK

    LTORG

badmssize
;return with V set but no error block (Wimp handles that)
        Pull    "R0-R7,LR"
        B       SLVK_SetV

      [ ValidateAMBHandles
badmapsome
        Pull    "R0-R7,LR"
        B       badhandle
      ]

    END