Action Taken: Cross Memory Communications
1) SRB
2) Basic Cross memory mode
3) Access Register mode
4) Synchronous Cross Memory
Basic Cross Memory : Cross memory mode was introduced after the SRB, and allowed a program to access memory in another address space before the invention of access registers and PC instructions. To use this, the caller:
* Sets AXSET=1 to allow access to any address space.
* Uses SSAR to set the secondary space to the remote address space.
* Uses MVCS and MVCP to move data between address spaces.
* Uses SSAR to set secondary space back.
* Sets AXSET=0.
This is not very clearly documented by IBM, but works fine when the target address space is non-swappable. If the target address space is swapped out, a S0C4 abend will occur.
Advantages
* Easy to understand – no complicated synchronous cross memory.
* Easy to code.
Disadvantages
* Remote address space must be non-swappable.
* If another task has set AXSET to something other than 1 or 0, you can't then set it to 1. You're locked out.
* Cannot access memory in more than two address spaces (primary and secondary) at the same time.
* Caller must be APF authorised.
* Must use MVCP and MVCS to move data between the primary and secondary address spaces - cannot use other instructions like CLC, MVST, MVCL to address anything in the secondary address space.
Sample Code
In this sample routine, the ASID of the target (remote) address space is already stored in the RMTASID word.
* ---------------------------------------------------
* Setup everything
* ---------------------------------------------------
XC RMTASN,RMTASN
LH R1,RMTASID Get remote ASID
ST R1,REQASN+2 Save it
XR R2,R2
ESAR R2 Get Our ASN
ST R2,HOMEASN Save Our ASN
* ---------------------------------------------------
* Get into cross memory mode
* ---------------------------------------------------
MODESET KEY=ZERO,MODE=PROB Into key 0
LA R2,1
AXSET AX=(R2) Auth index = 1 (all)
L R2,RMTASN
SSAR R2 Into Cross memory mode
* ---------------------------------------------------
* Move storage
* ---------------------------------------------------
(use MVCS and MVCP for copying storage)
* ---------------------------------------------------
* Get out of cross memory mode
* ---------------------------------------------------
MODESET KEY=NZERO,MODE=PROB Back to key 8
L R2,OURASN
SSAR R2
XR R2,R2
AXSET AX=(R2) Auth index = 0 (none)
* ---------------------------------------------------
* Back to caller
* ---------------------------------------------------
BR R14
* ---------------------------------------------------
* Storage
* ---------------------------------------------------
HOMEASN DS F Home ASN
RMTASN DS F Remote ASN
The basic cross memory facility introduced the idea of home, primary and secondary address spaces:
* Home - where the program was called from, or where the program's TCB is.
* Primary - where the instructions for the program are, and the default area where the data is.
* Secondary - a second address space where data can be accessed.
In the above example, the instruction SSAR is used to set the secondary address space, and ESAR to get it. EPAR can be used to get the primary address space (but there's no instruction to set it).
Many macros and services cannot be called in cross memory mode. Check the relevant documentation before using them.