NonStop S-Series Server Description Manual (G06.24+)
TNS Execution Modes
HP NonStop S-Series Server Description Manual—520331-003
6-78
Gateway Tables
Gateway Tables
When a process that is operating in TNS mode calls a CALLABLE system procedure, 
there is necessarily a transition to privileged mode.
In the case of programs that use TNS mode, such a transition to privileged mode takes 
place in the millicode for the calling instruction (XCAL, PCAL, or DPCL). That is the 
normal case for the TNS architecture, and it is based on the layout of the procedure 
entry point (PEP) table for the segment containing the called procedure. However, in 
the case of accelerated programs, use of the PEP table is generally skipped. Thus 
there needs to be a separate mechanism for providing secure transitions to privileged 
mode, and that is the function of the gateway tables.
Gateway tables are built by the Accelerator and, as shown in Figure 6-42, immediately 
follow the accelerated code in the object code file. Gateway tables exist only for those 
code areas that actually contain callable privileged procedures. User code (UC) and 
user library (UL) seldom have such CALLABLE procedures and so rarely have 
gateway tables. In fact, most CALLABLE procedures are in the system library (SL) 
area. The example shown in Figure 6-42 illustrates the gateway table for the system 
library, which resides in user space. (Calls to callable procedures in the SC area 
require an additional mechanism to make the “far jump” to SC; for efficiency, the far-
jump mechanism is combined with the gateway table and so calls to SC are described 
separately in the next topic.)
Note the major elements of the example shown, all highlighted in white. These are the 
calling instructions in the accelerated user code (on the left) and the gateway table and 
called procedure code in the accelerated code part of the system library code (on the 
right). The example assumes the procedure being called is the READ procedure.
As indicated, the last instruction of the calling instructions in the user code is a jump to 
the appropriate entry (READ) in the gateway table. Each entry of the gateway table 
consists of two instructions: a special load-byte instruction and a jump instruction. The 
load-byte instruction attempts to load a certain byte of the scratchpad page (SPAD), 
which is located in privileged memory (Kseg2). Such a reference requires privileged 
mode.  For the privileged caller, the load occurs and the jump immediately follows. But 
for the nonprivileged caller, an address error exception occurs. This invokes the 
exception handler, which checks to assure that the exception occurred within the 
gateway table, and allows the process to proceed in privileged state.
The exception handler returns to the first instruction of the gateway; this time the load-
byte instruction completes without incident, and the jump instruction sends control to 
the entry point of the called procedure (READ in this example). The called procedure 
now executes in privileged mode and performs the indicated operation. The EXIT 
millicode, at procedure’s end, sets the RISC status register back to the state of the 
caller (nonprivileged in this case) and exits back to the user code.










