; PCIMgrASM.s
;
; This library code is (c) 2003 MicroDigital Ltd,
; but is made available on an open-source basis to assist programmers
; in developing Risc OS drivers for PCI expansion cards.
; If you use any of it in your own code, please mention MicroDigital in the credits.
; You may redistribute this library providing it is complete and unmodified.
; If you make any improvements, please email them to "dprosser@microdigital.co.uk"
; to include in future releases, so other programmers can benefit.
;
; TODO: check 32bit compatibility...

         EXPORT  PCIMgr_DA_handler

         AREA    PCIMgrAsm,PIC,CODE

         ALIGN

; handler for dynamic areas: this one tries to force the allocated pages
; to be contiguous in physical as well as logical memory spaces
; note that for areas bigger than 128K, this is likely to be reentered
; several times as the growing of the area happens in stages

; enter with workspace ptr setup with /ptr to/ initial page number

PCIMgr_DA_handler

         CMP     a1, #0
         MOVNES  pc, lr        ; quit if not PreGrow

; PreGrow handler

         STMFD   sp!, {a2, a3, a4, lr}
         LDR     a4, [ip]
DAHlp1
         STR     a4, [a2], #12 ; set up page number required
         ADD     a4, a4, #1
         SUBS    a3, a3, #1    ; page count
         BGT     DAHlp1

         STR     a4, [ip]      ; keep current value for next stage of growth
         LDMFD   sp!, {a2, a3, a4, pc} ^

         END
; EOF