.th K_remap II 4/21/86
.sh NAME
K_remap - remap virtual address space
.sh "MODULA SYNOPSIS"
.nh
.na
 CONST inSeg: seg_des;
.br
 CONST inLoc: virt_loc;
.br
 CONST inAcc: acc_mode;
.br
 CONST outSeg: seg_des;
.br
 CONST outSize: seg_size;
.br
 CONST choice: selector;
.br
 VAR stat: K_err_num;
.br
 . . .
.br
 stat := NK_remap(inSeg, inLoc, inAcc, outSeg, outSize, choice);
.br
.hy
.ad
.sp
.sh "C SYNOPSIS"
.nh
.na
 seg_des inSeg;
.br
 virt_loc inLoc;
.br
 acc_mode inAcc;
.br
 seg_des outSeg;
.br
 seg_size outSize;
.br
 selector choice;
.br
 int stat;
.br
 . . .
.br
 stat = K_remap (inSeg, inLoc, inAcc, outSeg, outSize, choice);
.br
.hy
.ad
.sh DESCRIPTION
The K_remap primitive permits the process to change its segment map.
The outgoing segment is no longer directly addressable by the process
through machine instructions.  The incoming segment becomes directly
addressable by the process.  The outgoing segment is not released.
However, the memory management hardware of the segment to be removed
from the current mapped set may be used to satisfy the hardware
requirements of the incoming segment.  When a process segment is mapped
into the current addressable set of segments, it occupies the virtual
address vector defined by the arguments to K_remap.  Either or both of
the segment descriptors may be null.  If both are null the call has no
effects.  The incoming segment must fit into the virtual memory and
memory management resources available after the outbound segment is
unmapped.  If it does not, or if any of the other error conditions
occur, or if both segment descriptors are null, the call has no effect
on the segment mapping.
.sp
If the alter virtual location flag (vlFlg) within the choice parameter
is TRUE, the incoming segment is mapped into the location specified as
arguments to the call, and its status information adjusted to reflect
this as a permanent change.  Otherwise, the segment is mapped into the
location specified in its permanent status information.
.sp
If the alter discretionary access information flag (daFlg) within the
choice parameter is TRUE, the modes in which this process will access
the segment are checked against the permitted access modes for the
segment, and if allowed, will become the access modes for the segment.
This may alter the settings of memory management hardware when the
segment is mapped back in.
.sp
If the alter size flag (osFlg) within the choice parameter is TRUE, the
size of the outbound segment is set to the value outsize.  The
expansion or truncation of the segment is performed at the end of the
segment specified by the growth attribute of the segment specified when
built.  Expanded parts of segments are filled with zeros.  The size
change can only be applied to segments that are not sharable.

Selector bit positions within the choice parameter are:

.nf
	 remap_inLoc     01      (vlFlg)
	 remap_inAcc     02      (daFlg)
	 remap_outSize   04      (osFlg)
.fi

.sh EXCEPTIONS
.lp 22 15
XbSgRng        Bad segment range:  set of addresses specified for the segment
would lie outside a 64 K address space.
.lp 22 15
XbSgDes        Bad segment descriptor:  this segment descriptor is inactive.
.lp 22 15
XinSgAldMp     Incoming segment already mapped.
.lp 22 15
XncnDo         Cannot do:  global resource exhaustion.
.lp 22 15
XnoAcc         No access:  cannot access this object.
.lp 22 15
XnPgSg         No page in segment:  segment address range does not cross or is not
adjacent to some multiple of 8K (address range must include an 8K multiple or
have a top address that is one less than an 8K multiple).
.lp 22 15
XoutSgAldUmp   Outgoing segment already unmapped.
.lp 22 15
XvrtMmCfl      Virtual memory conflict:  some subset of the address range
of this segment would use a page register(s) already in use by an existing
segment (high-order three bits are the same).
.i0
.sh "SEE ALSO"
K_build_segment(II),
acc_mode(IIa),
selector(IIa),
virt_loc(IIa)
