NXMemCtl

Controls memory by changing the attributes of a specified region of memory.

Library:LibC
Classification:NKS
Service:Memory Management

Syntax

  #include <nks/memory.h>
   
  int NXMemCtl (
     void           *start, 
     size_t          size, 
     unsigned long   flags);
  

Parameters

start

(IN) Points to the starting address of the region to which the control operation is to be applied. This address must be page aligned.

size

(IN) Specifies the size, in pages, of the target region.

flags

(IN) Specifies the control operations to apply to the target region by specifying one of the following flags:

Flag

Value

Operation

NX_MEM_UNLOCK

0x00000000

Unlocks the specified set of pages. Unlocked pages are reserved and can be relocated to another address at any time.

NX_MEM_LOCK

0x00000001

Locks the specified set of pages to the given address. Locked pages are committed and cannot be relocated.

Return Values

If successful, returns zero; otherwise returns one of the following:

Decimal

Hex

Constant

Description

9

0x09

NX_EINVAL

Invalid starting address or flags argument.

24

0x18

NX_EAGAIN

Insufficient resources.

69

0x45

NX_EPERM

You do not have sufficient rights to perform the specified operation.

Remarks

The lock and unlock flags can pertain to state, rather than rights. NXMemCtl allows you to move pages (or any subset of pages) back and forth between a committed and reserved state.

For sample code, see Memory.c.

See Also