NAME | SYNOPSIS | FEATURES | DESCRIPTION | RETURN VALUES | ERRORS | ATTRIBUTES | SEE ALSO
#include <mem/chMem.h>int svPagesAllocate(VmAddr * address, VmSize size, VmFlags flags, KnCap * actcap);
MEM_FLAT, MEM_PROTECTED, MEM_VIRTUAL
The svPagesAllocate function allocates an amount of (usually discontiguous) physical memory and a range of virtual addresses within the supervisor address space. It then maps the physical memory to this address range.
The size argument specifies the size (in bytes) of the memory to be allocated. There are no alignment requirements on the size value, but svPagesAllocate always aligns the size of allocated memory to the next page boundary.
The starting address of the allocated virtual memory range is returned in the variable pointed to by the address argument.
The flags argument is a combination of the following flags:
If the K_NOWAITFORMEMORY flag is set, svPagesAllocate fails when there is not enough physical memory. In this case it returns the K_ENOMEM error; otherwise, svPagesAllocate waits for memory to become available as the result of memory swap out activity. If the swap outs is not available svPagesAllocate will never wait.
This flag is for internal operating system usage only.
The actcap argument specifies an actor with which the allocated memory will be associated. It is required for various functions, such as actor dumps. Note that allocated memory is not automatically freed when the corresponding actor is deleted using actorDelete (2K). If the actor association is not needed, K_SVACTOR can be specified. In this case the memory will be anonymous (not linked to any actor).
The svPagesFree call releases a virtual address range and the physical memory mapped to it. The address argument specifies the range's starting address and the size argument specifies its size in bytes.
The address range must be a sub-range of an address range previously allocated by a svPagesAllocate call. The range start address must be page aligned but there are no alignment requirements on the range size. Nevertheless svPagesFree always aligns the size of deallocated memory to the next page boundary.
The svPagesAllocate and svPagesFree calls may called by an interrupt handler. In this case svPagesAllocate must be called with K_NOWAITFORMEMORY.
The actcap argument specifies the actor from which the pages must be detached. It must match the actor that was specified when the pages were allocated.
If successful K_OK is returned, otherwise a negative error code is returned.
The address argument points to the outside of the caller's address space.
svPagesAllocate was called by an interrupt handler and K_NOWAITFORMEMORY flag was not specified.
The address argument of svPagesFree is not page aligned.
The size argument is equal to 0.
The system is out of memory.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Interface Stability | Evolving |
NAME | SYNOPSIS | FEATURES | DESCRIPTION | RETURN VALUES | ERRORS | ATTRIBUTES | SEE ALSO