• Aucun résultat trouvé

Detaching from a Global Region

Dans le document RT–11 System Internals Manual (Page 183-188)

Memory Mapping

W. NOFF =: 10 NLEN =: 12

3.7 Flow of Control Within Each Programmed Request

3.7.5 Detaching from a Global Region

Issue the .ELRG macro to detach a local region from a global region, in the same manner as you use it to eliminate a local region. Memory allocated to the local region within the global region is retained by the global region and is not returned to the free memory list.

The following example illustrates detaching the local region attached in the example shown in Section 3.13.

Detaching a local region from a global region decrements the count of attachments for that global region kept in GR.SHC (byte 5 in the global region control block).

In a multi-job mapped system, the reference count in GR.SHC controls automatic global elimination (see Section 3.7.12).

3.7.6 Creating a Window: .CRAW

Issue the .CRAW programmed request to create a virtual address window.

Prior to performing its main functions, the .CRAW programmed request does the following initial procedure:

• The routine clears the following bits in the window status word: WS.CRW, WS.UNM, WS.ELW, WS.DSI, and WS.IDD.

• If D-space of the requested mode is inactive and WS.I is set in the window status word, the routine sets WS.DSI in the window status word.

• If the mode requested is not active, or if WS.D is set and WS.I is cleared in the window status word and D-space is inactive in the requested mode, the routine returns error code 178.

• If WS.D and WS.I are both set in the window status word, and D-space is inactive for the requested mode, the routine sets WS.DSI in the window status word and processes the request for only I-space.

First, the monitor’s .CRAW routine checks W.NAPR in the window definition block for a valid value. The request returns with error code 0 in $ERRBY (byte 52) if the number of the Active Page Register set is invalid for any reason.

Next, the routine shifts W.NAPR to set up the window’s base address in W.NBAS, which is also located in the window definition block.

The routine then checks W.NSIZ in the window definition block to make sure that you requested a valid size for the window (the window cannot exceed the 32K-word boundary). If there is any problem with the size, the request returns with error code 0 in $ERRBY.

The next check is to see if the new window will overlap with an existing window. If the job is a virtual or completely virtual job and the new window overlaps with the static window, the request returns with error code 0. In all other situations where the new window overlaps an existing window, the routine eliminates the existing window. If the existing window is mapped, the routine unmaps it. The .CRAW routine sets WS.ELW in the window status word if it eliminates a window to create the new one. It sets WS.UNM if it also unmaps a window as it eliminates it.

Next, the routine looks for an available window control block. The request returns with error code 1 if there are no free window control blocks.

The request succeeds when the monitor modifies the appropriate data structures.

It puts values in W.BSIZ, W.BLVR, and W.BFPD in the window control block; it puts the window identification in W.NID in the window definition block, and it sets WS.CRW in the window status word.

If WS.MAP in the window status word was set when you issued the .CRAW request, the routine now maps the window to the region whose identification is stored in the window definition block. To do this, the routine follows the steps outlined for the .MAP programmed request’s main functions.

3.7.7 Mapping a window to a Region: .MAP

Issue the .MAP programmed request to map a virtual address window to a physical address region. The window definition block must contain the identification of the region to which the window will map.

Prior to performing its main functions, the .MAP programmed request does the following initial procedure:

• The routine clears the following bits in the window status word: WS.CRW, WS.UNM, WS.ELW, WS.DSI, and WS.IDD.

• If D-space of the requested mode is inactive and WS.I is set in the window status word, the routine sets WS.DSI in the window status word.

• If the mode requested is not active, or if WS.D is set and WS.I is cleared in the window status word and D-space is inactive in the requested mode, the routine returns error code 178.

• If WS.D and WS.I are both set in the window status word, and D-space is inactive for the requested mode, the routine sets WS.DSI in the window status word and processes the request for only I-space.

• If both I-space and D-space operations are requested and D-space is active, the routine verifies that the windows involved in the operation are identical. If they are not, the routine sets WS.IDD in the window status word.

First, the monitor’s .MAP routine finds the window control block that corresponds to the window you specify in the request. It checks W.NID to do this, and returns with error code 3 if the value is 0 and the window is not Supervisor mode or otherwise not valid.

Next, the routine finds the region control block for the region to which this window will map. The request returns with error code 2 if the region identification is invalid for any reason.

The routine looks at the offset into the region at which the window is to begin mapping. This value is contained in W.NOFF in the window definition block. If the offset is beyond the end of the region, the request returns with error code 4.

The routine checks the length of the window it is to map. This value is contained in W.NLEN in the window definition block. If the value is 0, the routine picks up the size of the region from the offset value to the end of the region. If this amount of memory is bigger than the window, the routine reduces the amount until it equals the window size, which it stores in W.NLEN. Note, that if you put 0 into W.NLEN, the value that is there after the .MAP request executes is not 0, but is instead the actual length of the window that was mapped. When WS.D and WS.I are both set in the window status word, W.NLEN is returned with I-space information. If WS.IDD

is cleared in the window status word, the value returned in W.NLEN reflects D-space information as well. If WS.IDD is set, the corresponding value in W.NLEN for D-space is indeterminate.

If the value of W.NLEN is not 0 at the start of the .MAP routine, it indicates the explicit length of the window to map. If the value is larger than the window size, or if the window would extend beyond the bounds of the region, the request returns with error code 4.

The routine increments R.BNWD in the region control block, which maintains a count of the number of windows mapped to this region.

If this window is already mapped elsewhere, this routine unmaps it and sets WS.UNM in the window status word; otherwise, this routine clears WS.UNM.

The routine next loads the User mode Active Page Register set with the correct values to map this window to this region.

Finally, the routine updates the window control block values W.BRCB, W.BHVR, W.BOFF, W.BNPD, and W.BLPD.

3.7.8 Getting the Mapping Status: .GMCX

Issue the .GMCX programmed request to obtain the current mapping status of a particular virtual address window.

Prior to performing its main functions, the .GMCX programmed request does the following initial procedure:

• The routine clears the following bits in the window status word: WS.CRW, WS.UNM, WS.ELW, WS.DSI, and WS.IDD.

• If D-space of the requested mode is inactive and WS.I is set in the window status word, the routine sets WS.DSI in the window status word.

• If the mode requested is not active, or if WS.D is set and WS.I is cleared in the window status word and D-space is inactive in the requested mode, the routine returns error code 178.

• If WS.D and WS.I are both set in the window status word, and D-space is inactive for the requested mode, the routine sets WS.DSI in the window status word and processes the request for only I-space.

• If both I-space and D-space operations are requested and D-space is active, the routine verifies that the windows involved in the operation are identical. If they are not, the routine sets WS.IDD in the window status word.

If both WS.I and WS.D are requested, the routine only returns information for I-space.

First, the .GMCX monitor routine looks at the corresponding window control block for this window. If you specify a window whose identification is 0, you obtain the status of the static window for a virtual job. User mode (either address space) window 0 is reserved in a privileged job. If there is any problem with the window, the request returns with error code 3.

The routine sets W.NAPR in the window definition block to be equal to the top three bits of W.BLVR in the window control block. This sets up the starting Active Page Register set number.

Next, the routine puts values into W.NBAS, W.NSIZ, and W.NRID in the window definition block.

If the window is not currently mapped, the routine clears W.NOFF and W.NLEN in the window definition block. It also clears all bits in the window status word, except for WS.RO, WS.SPA, and WS.MOD, which it leaves unmodified.

If the window is mapped, the routine puts the offset into the region in W.NOFF, puts the length of the window in W.NLEN, and sets the bit WS.MAP in the window status word. If the window is mapped read-only, the routine also sets bit WS.RO in the window status word; otherwise it clears WS.RO.

3.7.9 Unmapping a Window: .UNMAP

Issue the .UNMAP programmed request to explicitly unmap a window from a region.

Prior to performing its main functions, the .UNMAP programmed request does the following initial procedure:

• The routine clears the following bits in the window status word: WS.CRW, WS.UNM, WS.ELW, WS.DSI, and WS.IDD.

• If D-space of the requested mode is inactive and WS.I is set in the window status word, the routine sets WS.DSI in the window status word.

• If the mode requested is not active, or if WS.D is set and WS.I is cleared in the window status word and D-space is inactive in the requested mode, the routine returns error code 178.

• If WS.D and WS.I are both set in the window status word, and D-space is inactive for the requested mode, the routine sets WS.DSI in the window status word and processes the request for only I-space.

• If both I-space and D-space operations are requested and D-space is active, the routine verifies that the windows involved in the operation are identical. If they are not, the routine sets WS.IDD in the window status word.

First, the monitor’s .UNMAP routine finds the appropriate window control block. It checks W.NID in the window definition block. If the value is 0 and the window is not a Supervisor mode window, or if it is invalid for any reason, the request returns with error code 3. If the window is not currrently mapped, the request returns with error code 5.

To unmap the window, the routine modifies the appropriate data structures. It clears W.BRCB in the window control block and decrements R.BNWD in the region control block.

If the job is virtual or completely virtual, the routine clears the Page Descriptor Registers that correspond to this window so that your program can no longer reference the virtual addresses in this window.

If the job is privileged, the monitor copies the kernel Page Descriptor Register (PDR) values into the PDR for the specified mode, so that the mapping defaults to that of kernel mode.

Finally, the routine sets WS.UNM in the window status word.

3.7.10 Eliminating a Local Region: .ELRG

Issue the .ELRG programmed request to eliminate a physical address region.

First, the monitor’s .ELRG routine checks to see if the region identification you specified is 0. In a virtual job, a region identification of 0 indicates the static region, which you cannot eliminate. In a privileged job, region 0 is reserved. In either case, the request returns with error code 2.

Next, the routine looks for the corresponding region control block for this region.

If the region identification is invalid for any reason, the request returns with error code 2.

Then, the routine clears RS.CRR and RS.UNM in the region status word. If there are any windows mapped to this region, the routine unmaps them and sets RS.UNM.

The routine deallocates the region by returning its physical address space to the monitor’s list of free memory.

Finally, the routine clears the region control block.

Dans le document RT–11 System Internals Manual (Page 183-188)