VxWorks Reference Manual : Libraries

vmBaseLib

NAME

vmBaseLib - base virtual memory support library

ROUTINES

vmBaseLibInit( ) - initialize base virtual memory support
vmBaseGlobalMapInit( ) - initialize global mapping
vmBaseStateSet( ) - change the state of a block of virtual memory
vmBasePageSizeGet( ) - return the page size

DESCRIPTION

This library provides the minimal MMU (Memory Management Unit) support needed in a system. Its primary purpose is to create cache-safe buffers for cacheLib. Buffers are provided to optimize I/O throughput.

A call to vmBaseLibInit( ) initializes this library, thus permitting vmBaseGlobalMapInit( ) to initialize the MMU and set up MMU translation tables. Additionally, vmBaseStateSet( ) can be called to change the translation tables dynamically.

This library is a release-bundled complement to vmLib and vmShow, modules that offer full-featured MMU support and virtual memory information display routines. The vmLib and vmShow libraries are distributed as the unbundled virtual memory support option, VxVMI.

CONFIGURATION

Bundled MMU support is included in VxWorks when the configuration macro INCLUDE_MMU_BASIC is defined. If the configuration macro INCLUDE_MMU_FULL is also defined, the default is full MMU support (unbundled).

INCLUDE FILES

sysLib.h, vmLib.h

SEE ALSO

vmBaseLib, vmLib, vmShow, VxWorks Programmer's Guide: Virtual Memory


Libraries : Routines

vmBaseLibInit( )

NAME

vmBaseLibInit( ) - initialize base virtual memory support

SYNOPSIS

STATUS vmBaseLibInit
    (
    int pageSize /* size of page */
    )

DESCRIPTION

This routine initializes the virtual memory context class and module-specific data structures. It is called only once during system initialization, and should be followed with a call to vmBaseGlobalMapInit( ), which initializes and enables the MMU.

RETURNS

OK.

SEE ALSO

vmBaseLib, vmBaseGlobalMapInit( )


Libraries : Routines

vmBaseGlobalMapInit( )

NAME

vmBaseGlobalMapInit( ) - initialize global mapping

SYNOPSIS

VM_CONTEXT_ID vmBaseGlobalMapInit
    (
    PHYS_MEM_DESC * pMemDescArray,        /* pointer to array of mem descs */
    int             numDescArrayElements, /* no. of elements in pMemDescArray */
    BOOL            enable                /* enable virtual memory */
    )

DESCRIPTION

This routine creates and installs a virtual memory context with mappings defined for each contiguous memory segment defined in pMemDescArray. In the standard VxWorks configuration, an instance of PHYS_MEM_DESC (called sysPhysMemDesc) is defined in sysLib.c; the variable is passed to vmBaseGlobalMapInit( ) by the system configuration mechanism.

The physical memory descriptor also contains state information used to initialize the state information in the MMU's translation table for that memory segment. The following state bits may be or'ed together:

VM_STATE_VALID VM_STATE_VALID_NOT valid/invalid
VM_STATE_WRITABLE VM_STATE_WRITABLE_NOT writable/write-protected
VM_STATE_CACHEABLE VM_STATE_CACHEABLE_NOT cacheable/not-cacheable
Additionally, mask bits are or'ed together in the initialStateMask structure element to describe which state bits are being specified in the initialState structure element:

 VM_STATE_MASK_VALID
 VM_STATE_MASK_WRITABLE
 VM_STATE_MASK_CACHEABLE

If enable is TRUE, the MMU is enabled upon return.

RETURNS

A pointer to a newly created virtual memory context, or NULL if memory cannot be mapped.

SEE ALSO

vmBaseLibInit( )


Libraries : Routines

vmBaseStateSet( )

NAME

vmBaseStateSet( ) - change the state of a block of virtual memory

SYNOPSIS

STATUS vmBaseStateSet
    (
    VM_CONTEXT_ID context,   /* context - NULL == currentContext */
    void *        pVirtual,  /* virtual address to modify state of */
    int           len,       /* len of virtual space to modify state of */
    UINT          stateMask, /* state mask */
    UINT          state      /* state */
    )

DESCRIPTION

This routine changes the state of a block of virtual memory. Each page of virtual memory has at least three elements of state information: validity, writability, and cacheability. Specific architectures may define additional state information; see vmLib.h for additional architecture-specific states. Memory accesses to a page marked as invalid will result in an exception. Pages may be invalidated to prevent them from being corrupted by invalid references. Pages may be defined as read-only or writable, depending on the state of the writable bits. Memory accesses to pages marked as not-cacheable will always result in a memory cycle, bypassing the cache. This is useful for multiprocessing, multiple bus masters, and hardware control registers.

The following states are provided and may be or'ed together in the state parameter:

VM_STATE_VALID VM_STATE_VALID_NOT valid/invalid
VM_STATE_WRITABLE VM_STATE_WRITABLE_NOT writable/write-protected
VM_STATE_CACHEABLE VM_STATE_CACHEABLE_NOT cacheable/not-cacheable
Additionally, the following masks are provided so that only specific states may be set. These may be or'ed together in the stateMask parameter.

 VM_STATE_MASK_VALID
 VM_STATE_MASK_WRITABLE
 VM_STATE_MASK_CACHEABLE

If context is specified as NULL, the current context is used.

This routine is callable from interrupt level.

RETURNS

OK, or ERROR if the validation fails, pVirtual is not on a page boundary, len is not a multiple of the page size, or the architecture-dependent state set fails for the specified virtual address.

ERRNO

S_vmLib_NOT_PAGE_ALIGNED, S_vmLib_BAD_STATE_PARAM, S_vmLib_BAD_MASK_PARAM

SEE ALSO

vmBaseLib


Libraries : Routines

vmBasePageSizeGet( )

NAME

vmBasePageSizeGet( ) - return the page size

SYNOPSIS


int vmBasePageSizeGet (void)

DESCRIPTION

This routine returns the architecture-dependent page size.

This routine is callable from interrupt level.

RETURNS

The page size of the current architecture.

SEE ALSO

vmBaseLib