Memory Addressing (Windows Embedded CE 6.0)

1/5/2010

There are two kinds of addresses in Windows Embedded CE: physical addresses and mapped virtual addresses.

  • Physical addresses can be actual RAM or device memory that needs to be accessed by the OS. It is defined by the physical address space from a CPU perspective. The CPU cannot access this directly once the MMU is enabled.
    The kernel can only manage 512 MB of physical memory.
    On some CPUs, like MIPS and SHx, the kernel can only directly manipulate the first 1 GB of memory defined by the processors, 512 MB cached and 512 MB uncached but aliased to the same 512 MB of physical memory.
    On x86 and ARM processors, you can divide this physical range by using OEMAddressTable.
  • Mapped virtual addresses define a mapping between the virtual and physical that can be used by user-mode and kernel applications.
    There are two types of mapped virtual addresses: static and dynamic.
    • Static virtual addresses provide a mapping table for the kernel that covers what virtual address range maps to a physical address range. This mapping does not change over time and is created at boot time. OEMAddressTable defines this static virtual to physical mapping on the x86 and ARM processors. On MIPS and SHx, the CPU and kernel define this mapping. The static mapping can also be extended after boot time by calling CreateStaticMapping or NKCreateStaticMapping. Mappings created with CreateStaticMapping and NKCreateStaticMapping are accessible only by the kernel.
    • A dynamically mapped virtual address is one that creates a virtual-to-physical mapping that can be defined and then released when not in use. This type of mapping is accessible to user-mode applications and is created by calling VirtualCopy.

Using VirtualCopy with the PAGE_PHYSICAL flag, an application can map a physical address to a process-specific static virtual address.

The process starts by calling VirtualAlloc to allocate a virtual address range in your process to map the physical address.

This is followed by a call to VirtualCopy to complete the mapping process and make the physical memory available in the process.

A driver typically uses VirtualCopy to map device-specific memory into its user-mode process space. The same region can be mapped by more than one process.

CreateStaticMapping is like VirtualCopy in that it creates a mapping between physical memory and static virtual memory. The main difference is that the static virtual address is mapped in the kernel address space. This makes the static address accessible only by the kernel.

CreateStaticMapping is typically used to map some device-specific memory into the kernel so that an interrupt service routine (ISR) can access it. The same physical address can also be mapped by using VirtualCopy.

See Also

Concepts

Customizing Memory