Specifications
System Macros Invoked by Drivers
DEVICELOCK
• Calls either SMP$ACQUIREL or SMP$ACQNOIPL, depending upon the
presence of condition=NOSETIPL. SMP$ACQUIREL raises IPL to device
IPL prior to obtaining the lock, determining appropriate IPL from the device
lock’s data structure (SPL$B_IPL).
In both processing environments, the DEVICELOCK macro performs the
following tasks:
• Preserves the current IPL at the specified location (if savipl is specified)
• Sets the SMP-modified bit in the driver prologue table (DPT$V_SMPMOD in
DPT$L_FLAGS)
Example
DEVICELOCK -
LOCKADDR=UCB$L_DLCK(R5),- ;Lock device access
LOCKIPL=UCB$B_DIPL(R5),- ;Raise IPL
SAVIPL=-(SP),- ;Save current IPL
PRESERVE=YES ;Save R0
SETIPL #31 ;Disable all interrupts
BBC #UCB$V_POWER,- ;If clear - no power failure
UCB$W_STS(R5),L1 ;...
;Service power failure!
.
.
.
DEVICEUNLOCK -
LOCKADDR=UCB$L_DLCK(R5),- ;Unlock device access
NEWIPL=(SP)+,- ;Restore IPL
PRESERVE=YES ;Save R0
BRW RETREG ;Exit
L1: ;Return for no power failure
.
.
.
WFIKPCH RETREG,#2 ;Wait for interrupt
The start-I/O routine of DLDRIVER invokes the DEVICELOCK macro to
synchronize access to the device’s registers and UCB fields. Thus synchronized
at device IPL, and holding the device lock in a multiprocessing environment, the
routine raises IPL to IPL$_POWER (IPL 31) to check for a power failure on the
local processor. If a power failure has occurred, the routine releases the device
lock and pops the saved IPL from the stack before servicing the failure. If a
power failure has not occurred, the routine branches to set up the I/O request.
Note that, in this instance, it is the wait-for-interrupt routine, invoked by the
WFIKPCH macro, that issues the DEVICEUNLOCK macro and pops the saved
IPL from the stack.
2–18