NonStop S-Series Server Description Manual (G06.24+)
Native Execution Mode
HP NonStop S-Series Server Description Manual—520331-003
7-8
Example of TNS Call to a Native Library Procedure
Example of TNS Call to a Native Library
Procedure
The example illustrated in Figure 7-4 assumes that some user code (UC) process is
executing in either TNS mode or accelerated mode, using variables on the TNS stack
(1). At some point in its execution the process executes an XCAL to a system library
procedure (2), such as DNUMOUT. Because DNUMOUT exists as a native mode
procedure, the processor must be put into native mode.
The interpreter performs the first part of the XCAL normally, using the XCAL entry
number to fetch the XEP table entry. Because CS = 1 in that entry, the interpreter uses
the other 15 bits of the entry as an index into the shell map, and fetches the designated
address. If that address is zero, the XEP entry was invalid; otherwise it designates
either a to-RISC shell or an accelerated procedure.
The low-order bit of the shell map entry distinguishes the two valid cases: if it is odd,
this address -1 designates an acccelerated procedure in the SC or SL part of the
system library; the interpreter switches to accelerated mode and jumps to that code.
For accelerated procedures, such as LASTADDRX, the address is in the shell map
position indicated by bits <1:15> of the normal XEP entry for the TNS code of that
procedure.
An even address designates a to-RISC shell, so the interpreter puts the process into
accelerated mode and calls the shell. Shells are assigned arbitrary XEP entry values
corresponding to nonexistent TNS code segments, such as SC.00 through SC.04.
In this case, the address in the shell map transfers control (3) to the to-RISC shell
called $DNUMOUT in the RISC portion of the system library (SLr in the 7C region).
The to-RISC shell performs several functions. It switches the processor mode to
native mode. It saves the TNS return information in a special stack frame created on
the appropriate RISC stack (either the main stack or the privileged stack) and switches
the stack pointer to that frame. Then the RISC shell calls the entry point of the called
RISC procedure (6). (The procedure generally has the same name that the TNS caller
used to invoke it.) The RISC procedure now executes in native mode, using the main
stack or the privileged stack (7).
The shell chooses the privileged stack if the called procedure runs privileged, because
either the shell is callable or the calling TNS procedure is already privileged.
Upon completion of the called procedure, the procedure exits normally to the
procedure that called it, the to-RISC shell. The shell restores TNS values to
appropriate registers, sets the process mode to accelerated or TNS, and returns to the
calling procedure through the saved return information.
When the original call was TNS code, as in our example, the shell returns into the code
interpreter in millicode, which resumes execution of the original code stream following
the XCAL.