
EMB426 Windows CE Memory Architecture Steve Maillet CEO/Chief Software Architect EmbeddedFusion MEDC DevCon 2005
EMB426 Windows CE Memory Architecture Steve Maillet CEO/Chief Software Architect EmbeddedFusion

Microsoft MEDC Mobile Embedded DevCon 2005 May9-12,2005 Las Vegas Microsoft

Part I Architecture and concepts Virtual Memory Kernel Mode versus User Mode © Statically mapped memory Process memory System API Calls Access Permissions
Part I Architecture and concepts Virtual Memory Kernel Mode versus User Mode Statically mapped memory Process memory System API Calls Access Permissions

Virtual Memory Model Single 32-bit (4 Gigabyte)flat virtual memory address space Permits efficient use of physical memory with protection Virtual addresses translated to physical addresses by MMU A valid virtual address maps to a physical address Static or Dynamically mapped virtual addressing
Virtual Memory Model Single 32-bit (4 Gigabyte) flat virtual memory address space Permits efficient use of physical memory with protection Virtual addresses translated to physical addresses by MMU A valid virtual address maps to a physical address Static or Dynamically mapped virtual addressing

Virtual Memory Total4 GB Virtual Space FFFF FFFF Kernel Space User Space 7FFF FFFF Kernel Addresses: 2GB Slots 33-63 KPAGE,Trap Area, Kernel E0000000 Others Object Store and Space Memory-Mapped Files Reserved C4000000 Slot 97:NK.EXE C2000000 42000000 Reserved Slots 2-32-Processes C0000000 Statically Mapped 2GB Virtual Addresses: Un-Cached User A0000000 Statically Mapped Space 04000000 Virtual Addresses: Slot 1-XIP DLL code 02000000 Cached 80000000 Slot-Current Process0
Virtual Memory 2 GB User Space Slot 97: NK.EXE Reserved Statically Mapped Virtual Addresses: Un-Cached Statically Mapped Virtual Addresses: Cached Slot 0 – Current Process Slot 1 – XIP DLL code Slots 2-32 - Processes Slots 33-63 Object Store and Memory-Mapped Files FFFF FFFF E000 0000 C400 0000 C200 0000 C000 0000 A000 0000 8000 0000 7FFF FFFF 4200 0000 0400 0000 0200 0000 0000 0000 Total 4 GB Virtual Space 2 GB Kernel Space Kernel Space User Space Reserved Kernel Addresses: KPAGE, Trap Area, Others

Kernel Mode Versus User Mode ONLY Difference is access to different regions Kernel mode code has full access to all memory Process protection still applies! User Mode code only has access to User Space Kernel Space(0x80000000-0xFFFFFFFF) Used only by Kernel-mode code with privileged access (“Kmode") SetKMode()protected API or ROMFLAGS Setting for ALL threads in the system User Space(0x00000000-0x7FFFFFFF) Organized as 64 slots of 32 MB(225 bytes)each Applications,DLLs and Data located here
Kernel Mode Versus User Mode ONLY Difference is access to different regions Kernel mode code has full access to all memory Process protection still applies! User Mode code only has access to User Space Kernel Space (0x80000000 – 0xFFFFFFFF) Used only by Kernel-mode code with privileged access (“Kmode”) SetKMode() protected API or ROMFLAGS Setting for ALL threads in the system User Space (0x00000000 – 0x7FFFFFFF) Organized as 64 slots of 32 MB (225 bytes) each Applications, DLLs and Data located here

Statically Mapped Memory Physical Memory Virtual Memory FFFFFFFF Kernel Space -C0000000 32 MB Flash cached 512MB 64 MB RAM A0000000 5 82000000 32 MB Flash 32 MB Flash 64 MB RAM 04000000 80000000 64 MB RAM Address User 00000000 Translation Space -00000000
Statically Mapped Memory User 2 GB 512 MB Uncached Cached 512 MB 32 MB Flash Physical Memory Virtual Memory 04000000 82000000 8000 0000 A000 0000 C000 0000 00000000 64 MB RAM 0000 0000 64 MB RAM 32 MB Flash 64 MB RAM FFFF FFFF Address Translation 32 MB Flash Kernel Space User Space

Statically Mapped Memory ⊙x86,ARM OEM provides OEMAddressTable in OAL to define initial mappings ⊙MIPS,SHx Mapping is fixed in the MMU architecture
Statically Mapped Memory x86, ARM OEM provides OEMAddressTable in OAL to define initial mappings MIPS, SHx Mapping is fixed in the MMU architecture

Process Memory c4000000 Slot 97 32 MB Process Space nk.exe c2000000 01FF FFFF DLL Virtual Memory Allocations 80000000 ROM DLLs:R/WData Slot 63 Resource DLLs 7E000000 42000000 Slot 32 Free Virtual Space 40000000 3E000000 Slot 31 General Virtual MemoryAllocations Slot 30 Process VirtualAlloc cals 3c000000 TM时S水 Proces Heap 0c000000 Slot 5 0A000000 gwes.exe Tesa Slot 4 08000000 device.exe Process Code +Data Slot 3 06000000 shellexe 00010000 Slot 2 filesys.exe Guard Section (64k)+UserKInfo 04000000 00000000 Slot 1 XIP ROM DLLs 02000000 Slot 0 00000000 Current Process
Process Memory 01FF FFFF 0001 0000 0000 0000 32 MB Process Space Free Virtual Space Slot 30 Slot 31 Slot 32 . . . Slot 63 . . . Current Process XIP ROM DLLs nk.exe filesys.exe shell.exe device.exe gwes.exe Resource DLLs Slot 2 Slot 3 Slot 4 Slot 5 Slot 1 Slot 0 . . . Slot 97 C400 0000 C200 0000 0A00 0000 3E00 0000 3C00 0000 4000 0000 4200 0000 0000 0000 0400 0000 0200 0000 0600 0000 0800 0000 0C00 0000 8000 0000 7E00 0000

System API Calls Application DLLInterface Function Call Coredll.dll Win32 Local Process Services Heap Process Interface 0…… Traps N.EXE Nklib filesys.exe gwes.exe device.exe PSL Process Switching Loader Synchronization shell.exe services.exe Memory-Mapped File Hardware Abstraction OAL Interrupt Bus Map Handling
System API Calls Application Win32 API Thunks Local Process Services PSL Process Switching Virtual Memory filesys.exe gwes.exe device.exe Process/Thread Exception Handling Scheduling Loader Synchronization Initialization Process Switching Memory-Mapped File Hardware Abstraction Memory Map Interrupts Bus Map Function Call Traps Process Interface DLL Interface Interrupt Handling OAL Heap Coredll.dll N.EXE Nk.lib shell.exe services.exe