Resources | Resources |



Physical and virtual memory

There are two types of memory: physical and virtual.

Physical memory

Physical memory is memory on a specific device with a physical memory address. Primary storage devices include RAM and ROM. Drivers from the underlying OS are needed to access physical memory at the kernel level. OS Services allows a developer to address specific physical memory addresses.

The PhysMemInfo structure, which consists of the starting address, size, and physical memory permissions, describes a contiguous physical memory space, as follows:

struct PhysMemInfo {

    /* Start of physical address for this contiguous region */
    uint32 ulStart;

    /* Size of this contiguous region */ 
    uint32 ulSize;

    /* Permissions associated with this region */
    uint32 ulPerms; 

A memory region's starting address is either a specific address or a physical address (MEMREGION_ANYADDR). A physical memory region can have read-only access (MEMREGION_ACCESS_READ), write-only access (MEMREGION_ACCESS_WRITE), or execute access (MEMREGION_ACCESS_EXECUTE):

const int32 MEMREGION_ACCESS_READ = 0x1
const int32 MEMREGION_ACCESS_WRITE = 0x2

Combinations of these permissions are allowed.

Multiple physical memory blocks are organized in a list:

typedef sequence SeqPhysMemInfo;

Virtual memory

User processes see virtual address space rather than physical address space. Each process has a separate virtual address space. Virtual memory space is divided into pages, each of which corresponds to a block of contiguous virtual memory addresses. The virtual memory system translates a user process's virtual address to a physical address, which is then used to retrieve memory contents. One contiguous virtual memory block can map to multiple individual physical memory blocks.

An OS Services process encapsulates the execution context of a program. Currently, all OS Services processes in a domain share the same virtual address space. A Memory Management Unit translates virtual memory addresses to physical memory addresses, as shown in the following figure: