Specifications

Allocating Map Registers and Other Counted Resources
3.2 Allocating Counted Resource Items
Note
If a counted resource request does not specify a callback routine
(CRCTX$L_CALLBACK), IOC$ALLOC_CNT_RES does not insert
its CRCTX in the resource-wait queue. Rather, it returns SS$_
INSFMAPREG status to its caller.
A driver must not deallocate the CRCTX while the resource request it describes
is stalled by IOC$ALLOC_CNT_RES. (If the driver must cancel the allocation
request, it should call IOC$CANCEL_CNT_RES.)
When a counted resource deallocation occurs, the first CRCTX is removed from
the resource-wait queue and the allocation is attempted again. If IOC$ALLOC_
CNT_RES is now able to grant the requested number of resource items, it calls
the callback routine (CRCTX$L_CALLBACK), passing it the following values:
Location Contents
R0, R21 SS$_NORMAL
R1, R16 Address of CRAB
R2, R17 Address of CRCTX
R3, R18 Contents of CONTEXT1 argument at the time of the
original allocation request (CRCTX$Q_CONTEXT1)
R4, R19 Contents of CONTEXT2 argument at the time of the
original allocation request (CRCTX$Q_CONTEXT2)
R5, R20 Contents of CONTEXT3 at the time of the original
allocation request (CRCTX$Q_CONTEXT3)
The callback routine checks R0 to determine whether it has been called with
SS$_NORMAL or SS$_CANCEL status (from IOC$CANCEL_CNT_RES). If the
former, the routine typically proceeds to loads the map registers that have been
allocated.
The following example illustrates a call to IOC$ALLOC_CNT_RES:
40$: MOVL SCDRP$L_BOFF(R5),R0 ; Get byte offset
ADDL SCDRP$L_BCNT(R5),R0 ; Add in byte count
ADDL G^MMG$GL_BWP_MASK,R0 ; Round up to number of pages
ADDL G^MMG$GL_PAGE_SIZE,R0 ; Add extra "no access" page
ASHL G^MMG$GL_VA_TO_VPN,R0,- ; Get number of pages involved
CRCTX$L_ITEM_CNT(R2) ; Pass as number of contiguous
; registers to allocate
MOVAB G^SCS$MAP_RETRY,- ; SCS$MAP_RETRY is callback routine
CRCTX$L_CALLBACK(R2)
PUSHL R2 ; Push CRCTX as argument
PUSHL ADP$L_CRAB(R4) ; Push CRAB as argument
CALLS #2,IOC$ALLOC_CNT_RES ; Allocate the map registers
BLBC R0,110$ ; If allocation is not successful,
; branch; otherwise proceed
; to load map registers
.
.
.
3–4