24.05.2014 Views

AIX Version 4.3 Differences Guide

AIX Version 4.3 Differences Guide

AIX Version 4.3 Differences Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

3.2.2.7 Optimizations for One or Two Parameters<br />

The library-side and the kernel-side remap routines have optimizations built into<br />

them to pass one or two parameters by value if possible. This provides a<br />

significant improvement over requiring a full copyin64() of the kremap structure<br />

every time. There are three cases that the remap() code has to handle:<br />

• The output library remapping resulted in only one remapping or remap struct<br />

(R_IN_LINE - see the following).<br />

• The output remapping resulted in two remappings, and __remap2() was called<br />

(with two addr structs only).<br />

• The output remapping resulted in more than one remapping if __remap() was<br />

called.<br />

The low order bit of the cookie passed to the kernel remap services, all the way<br />

from the library, identifies what the cookie actually is. For example, although<br />

remap_64() is documented to have a struct remap() passed to it, if the<br />

R_IN_LINE bit is not set in this, then this struct remap is a pointer to a struct<br />

kremap, on which a copyin64() must be performed. If, however, the R_IN_LINE<br />

bit is set on input, then that indicates that all of the parameters collapsed into a<br />

single remapping in the library (case 1), and remap_64() can call remap1_64() to<br />

do the work. This avoids the copyin() when many parameters reside in the same<br />

segment (ESID). This should be a common case.<br />

The R_IN_LINE flag is interpreted differently by the remap2_64() kernel service.<br />

The __remap2() subroutine sets the R_IN_LINE flag in the first remap struct if the<br />

output remappings collapsed into one. This indicates that the second parameter<br />

to remap2_64() should be ignored. See the next section for coding and calling<br />

conventions for __remap2().<br />

3.2.2.8 Using the Remapping Services<br />

There are very rigid rules on how to invoke the remapping services and how to<br />

handshake with the kernel-side remapping wrappers. Typically, whatever library<br />

remapping service was invoked for a particular wrapper, it should have the<br />

corresponding kernel remapping service called as well. For example, if<br />

__remap2() is called in the library wrapper, the kernel-extension should call<br />

remap2_64().<br />

The following is very important:<br />

• For a given system call, it is only permissible to make a single call to the<br />

remapping kernel services. In other words, it is not legal to call remap_64()<br />

twice on the same system call. Similarly, it is not legal to call remap1_64() and<br />

then remap2_64() on the same system call.<br />

To detect potential misuse of the remapping services, the remap data structures<br />

are coded with a unique code for whichever library remap service created them. If<br />

a kernel service other than the correct one for a given library service is called, an<br />

error will result. For example, callers of __remap1() must call remap1_64().<br />

Typically, a library wrapper will call a remap service and check if the return code<br />

is -1. If so, it will fail. After that, the returned value remap structure from the<br />

particular __remap* service is passed as the first parameter. If this is a<br />

__remap2() call, the first parameter is kremap.r[0], and the second parameter is<br />

kremap.r[1]. Of course, each of these parameters is split into two 32-bit registers.<br />

64-Bit Enablement 45

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!