📄 vmlib.html
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/vmLib.html - generated by refgen from vmLib.c --> <title> vmLib </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.htm"><i>VxWorks API Reference : OS Libraries</i></a></p></blockquote><h1>vmLib</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>vmLib</strong> - architecture-independent virtual memory support library (VxVMI Option) </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><a href="./vmLib.html#vmLibInit">vmLibInit</a>( )</b> - initialize the virtual memory support module (VxVMI Option)<br><b><a href="./vmLib.html#vmGlobalMapInit">vmGlobalMapInit</a>( )</b> - initialize global mapping (VxVMI Option)<br><b><a href="./vmLib.html#vmContextCreate">vmContextCreate</a>( )</b> - create a new virtual memory context (VxVMI Option)<br><b><a href="./vmLib.html#vmContextDelete">vmContextDelete</a>( )</b> - delete a virtual memory context (VxVMI Option)<br><b><a href="./vmLib.html#vmStateSet">vmStateSet</a>( )</b> - change the state of a block of virtual memory (VxVMI Option)<br><b><a href="./vmLib.html#vmStateGet">vmStateGet</a>( )</b> - get the state of a page of virtual memory (VxVMI Option)<br><b><a href="./vmLib.html#vmMap">vmMap</a>( )</b> - map physical space into virtual space (VxVMI Option)<br><b><a href="./vmLib.html#vmGlobalMap">vmGlobalMap</a>( )</b> - map physical pages to virtual space in shared global virtual memory (VxVMI Option)<br><b><a href="./vmLib.html#vmGlobalInfoGet">vmGlobalInfoGet</a>( )</b> - get global virtual memory information (VxVMI Option)<br><b><a href="./vmLib.html#vmPageBlockSizeGet">vmPageBlockSizeGet</a>( )</b> - get the architecture-dependent page block size (VxVMI Option)<br><b><a href="./vmLib.html#vmTranslate">vmTranslate</a>( )</b> - translate a virtual address to a physical address (VxVMI Option)<br><b><a href="./vmLib.html#vmPageSizeGet">vmPageSizeGet</a>( )</b> - return the page size (VxVMI Option)<br><b><a href="./vmLib.html#vmCurrentGet">vmCurrentGet</a>( )</b> - get the current virtual memory context (VxVMI Option)<br><b><a href="./vmLib.html#vmCurrentSet">vmCurrentSet</a>( )</b> - set the current virtual memory context (VxVMI Option)<br><b><a href="./vmLib.html#vmEnable">vmEnable</a>( )</b> - enable or disable virtual memory (VxVMI Option)<br><b><a href="./vmLib.html#vmTextProtect">vmTextProtect</a>( )</b> - write-protect a text segment (VxVMI Option)<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This library provides an architecture-independent interface to the CPU'smemory management unit (MMU). Although <b><a href="./vmLib.html#top">vmLib</a></b> is implemented witharchitecture-specific libraries, application code need never referencedirectly the architecture-dependent code in these libraries.<p>A fundamental goal in the design of <b><a href="./vmLib.html#top">vmLib</a></b> was to permit transparentbackward compatibility with previous versions of VxWorks that did not usethe MMU. System designers may opt to disable the MMU because of timingconstraints, and some architectures do not support MMUs; therefore VxWorksfunctionality must not be dependent on the MMU. The resulting designpermits a transparent configuration with no change in the programmingenvironment (but the addition of several protection features, such as textsegment protection) and the ability to disable virtual memory in systemsthat require it.<p>The <b><a href="./vmLib.html#top">vmLib</a></b> library provides a mechanism for creating virtual memory contexts,<b><a href="./vmLib.html#vmContextCreate">vmContextCreate</a>( )</b>. These contexts are not automatically created for individual tasks, but may be created dynamically by tasks, and swapped in and out in an application specific manner. <p>All virtual memory contexts share a global transparent mapping of virtualto physical memory for all of local memory and the local hardware devicespace (defined in <b>sysLib.c</b> for each board port in the <b>sysPhysMemDesc</b>data structure). When the system is initialized, all of local physicalmemory is accessible at the same address in virtual memory (this is donewith calls to <b><a href="./vmLib.html#vmGlobalMap">vmGlobalMap</a>( )</b>.) Modifications made to this global mappingin one virtual memory context appear in all virtual memory contexts. Forexample, if the exception vector table (which resides at address 0 inphysical memory) is made read only by calling <b><a href="./vmLib.html#vmStateSet">vmStateSet</a>( )</b> on virtualaddress 0, the vector table will be read only in all virtual memorycontexts.<p>Private virtual memory can also be created. When physical pages aremapped to virtual memory that is not in the global transparent region,this memory becomes accessible only in the context in which it wasmapped. (The physical pages will also be accessible in the transparenttranslation at the physical address, unless the virtual pages in theglobal transparent translation region are explicitly invalidated.) Statechanges (writability, validity, etc.) to a section of private virtualmemory in a virtual memory context do not appear in other contexts. Tofacilitate the allocation of regions of virtual space, <b><a href="./vmLib.html#vmGlobalInfoGet">vmGlobalInfoGet</a>( )</b>returns a pointer to an array of booleans describing which portions of thevirtual address space are devoted to global memory. Each successive arrayelement corresponds to contiguous regions of virtual memory the size ofwhich is architecture-dependent and which may be obtained with a call to<b><a href="./vmLib.html#vmPageBlockSizeGet">vmPageBlockSizeGet</a>( )</b>. If the boolean array element is true, thecorresponding region of virtual memory, a "page block", is reserved forglobal virtual memory and should not be used for private virtual memory.(If <b><a href="./vmLib.html#vmMap">vmMap</a>( )</b> is called to map virtual memory previously defined as global,the routine will return an error.)<p>All the state information for a block of virtual memory can be set in asingle call to <b><a href="./vmLib.html#vmStateSet">vmStateSet</a>( )</b>. It performs parameter checking and checksthe validity of the specified virtual memory context. It may also be usedto set architecture-dependent state information. See <b>vmLib.h</b> for additionalarchitecture-dependent state information.<p>The routine <b><a href="./vmShow.html#vmContextShow">vmContextShow</a>( )</b> in <b><a href="./vmShow.html#top">vmShow</a></b> displays the virtual memory contextfor a specified context. For more information, see the manual entry forthis routine.<p></blockquote><h4>CONFIGURATION</h4><blockquote><p><p>Full MMU support (<b><a href="./vmLib.html#top">vmLib</a></b>, and optionally, <b><a href="./vmShow.html#top">vmShow</a></b>) is included in VxWorkswhen the configuration macro <b>INCLUDE_MMU_FULL</b> is defined. If theconfiguration macro <b>INCLUDE_MMU_BASIC</b> is also defined, the default isfull MMU support (unbundled).<p>The <b>sysLib.c</b> library contains a data structure called <b>sysPhysMemDesc</b>,which is an array of <b>PHYS_MEM_DESC</b> structures. Each element of the arraydescribes a contiguous section of physical memory. The description ofthis memory includes its physical address, the virtual address where itshould be mapped (typically, this is the same as the physical address, butnot necessarily so), an initial state for the memory, and a mask definingwhich state bits in the state value are to be set. Default configurationsare defined for each board support package (BSP), but these mappings maybe changed to suit user-specific system configurations. For example, theuser may need to map additional VME space where the backplane networkinterface data structures appear.<p></blockquote><h4>AVAILABILITY</h4><blockquote><p>This library and <b><a href="./vmShow.html#top">vmShow</a></b> are distributed as the unbundled virtual memorysupport option, VxVMI. A scaled down version, <b><a href="./vmBaseLib.html#top">vmBaseLib</a></b>, isprovided with VxWorks for systems that do not permit optional use of theMMU, or for architectures that require certain features of the MMU toperform optimally (in particular, architectures that rely heavily oncaching, but do not support bus snooping, and thus require the ability tomark interprocessor communications buffers as non-cacheable.) Mostroutines in <b><a href="./vmBaseLib.html#top">vmBaseLib</a></b> are referenced internally by VxWorks; they are notcallable by application code.<p></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>vmLib.h</b> <p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./sysLib.html#top">sysLib</a></b>, <b><a href="./vmShow.html#top">vmShow</a></b>,<i>VxWorks Programmer's Guide: Virtual Memory </i><hr><a name="vmLibInit"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>vmLibInit( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>vmLibInit( )</strong> - initialize the virtual memory support module (VxVMI Option)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS vmLibInit ( int pageSize /* size of page */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine initializes the virtual memory context class.It is called only once during system initialization.<p></blockquote><h4>AVAILABILITY</h4><blockquote><p>This routine is distributed as a component of the unbundled virtual memorysupport option, VxVMI.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./vmLib.html#top">vmLib</a></b><hr><a name="vmGlobalMapInit"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>vmGlobalMapInit( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>vmGlobalMapInit( )</strong> - initialize global mapping (VxVMI Option)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>VM_CONTEXT_ID vmGlobalMapInit ( PHYS_MEM_DESC * pMemDescArray, /* pointer to array of mem descs */ int numDescArrayElements, /* num of elements in pMemDescArray */ BOOL enable /* enable virtual memory */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine is a convenience routine that creates and installs a virtualmemory context with global mappings defined for each contiguous memorysegment defined in the physical memory descriptor array passed as anargument. The context ID returned becomes the current virtual memorycontext. <p>The physical memory descriptor also contains state informationused to initialize the state information in the MMU's translation tablefor that memory segment. The following state bits may be or'ed together:<p><table><tr valign=top><td align=left><b>VM_STATE_VALID</b> </td><td align=left> <b>VM_STATE_VALID_NOT</b> </td><td align=left> valid/invalid</tr><tr valign=top><td align=left><b>VM_STATE_WRITABLE</b> </td><td align=left> <b>VM_STATE_WRITABLE_NOT</b> </td><td align=left> writable/write-protected</tr><tr valign=top><td align=left><b>VM_STATE_CACHEABLE</b></td><td align=left> <b>VM_STATE_CACHEABLE_NOT</b></td><td align=left> cacheable/not-cacheable</tr><tr valign=top><td align=left></tr></tr></table>Additionally, mask bits are or'ed together in the <b>initialStateMask</b> structureelement to describe which state bits are being specified in the <b>initialState</b>structure element:<p> <b>VM_STATE_MASK_VALID</b><br> <b>VM_STATE_MASK_WRITABLE</b><br> <b>VM_STATE_MASK_CACHEABLE</b><p>If the <i>enable</i> parameter is TRUE, the MMU is enabled upon return. The <b><a href="./vmLib.html#vmGlobalMapInit">vmGlobalMapInit</a>( )</b> routine should be called only after <b><a href="./vmLib.html#vmLibInit">vmLibInit</a>( )</b> has beencalled.<p></blockquote><h4>AVAILABILITY</h4><blockquote><p>This routine is distributed as a component of the unbundled virtual memorysupport option, VxVMI.<p></blockquote><h4>RETURNS</h4><blockquote><p>A pointer to a newly created virtual memory context, orNULL if the memory cannot be mapped.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./vmLib.html#top">vmLib</a></b><hr><a name="vmContextCreate"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>vmContextCreate( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>vmContextCreate( )</strong> - create a new virtual memory context (VxVMI Option)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>VM_CONTEXT_ID vmContextCreate (void)</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine creates a new virtual memory context. The newly createdcontext does not become the current context until explicitly installed bya call to <b><a href="./vmLib.html#vmCurrentSet">vmCurrentSet</a>( )</b>. Modifications to the context state (mappings,state changes, etc.) may be performed on any virtual memory context, evenif it is not the current context.<p>This routine should not be called from interrupt level.<p></blockquote><h4>AVAILABILITY</h4><blockquote><p>This routine is distributed as a component of the unbundled virtual memorysupport option, VxVMI.<p></blockquote><h4>RETURNS</h4><blockquote><p>A pointer to a new virtual memory context, or NULL if the allocation or initialization fails.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./vmLib.html#top">vmLib</a></b><hr><a name="vmContextDelete"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>vmContextDelete( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -