1 / 33

Windows CE 5.0 Memory Architecture

Windows CE 5.0 Memory Architecture. Li-Ming Fan Escalation Engineer Microsoft GCR-GTSC. Part I Architecture and concepts. Virtual Memory Kernel Mode versus User Mode Statically mapped memory Process memory System API Calls Access Permissions. Virtual Memory Basic.

terri
Download Presentation

Windows CE 5.0 Memory Architecture

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Windows CE 5.0Memory Architecture Li-Ming Fan Escalation Engineer Microsoft GCR-GTSC

  2. Part IArchitecture and concepts • Virtual Memory • Kernel Mode versus User Mode • Statically mapped memory • Process memory • System API Calls • Access Permissions

  3. Virtual Memory Basic • Single Flat 32-bit Virtual Address Space • Virtual Addresses refer to any address referenced by the CPU while MMU is active. • Physical Addresses are not directly addressable by the CPU except during initialization before the kernel has enabled the MMU. • Every valid virtual address must map to some real physical address that can be used to identify a physical resource such as ROM, RAM, Flash, CPU registers, SoC components, bus-mapped components, etc.

  4. 32-bit Virtual Address Space • Kernel Space is only accessible by threads with privileged access, called KMode. • User Space is accessible by all threads but is limited by process space protection.

  5. Kernel Address Space • Kernel Address Space contains: • Statically mapped virtual addresses • NK.EXE pseudo-slot • Other kernel mappings. • Up to 512 MB of physical resources can be mapped in the main statically mapped areas.

  6. Statically Mapped Memory Virtual Memory Physical Memory FFFF FFFF Kernel Space C000 0000 512 MBUncached 32 MB Flash 64 MB RAM A000 0000 512 MBCached 32 MB Flash 82000000 32 MB Flash 64 MB RAM 8000 0000 04000000 64 MB RAM 2 GBUser AddressTranslation UserSpace 00000000 0000 0000

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

  8. User Address Space • Divided into 64 “slots” with 32 MB each • Slot is the basic unit for virtual memory maintenance within the Windows CE kernel

  9. Slot Usage Grouping • Slot 0 - An alias to the currently running process’s slot. • Slot 1 – Used for XIP DLLs • Slot 2 ~ 32 – Used for Process • A maximum of 32 processes can be running at one time. • Threads may only access addresses within slots in which they have permissions. • Slot 33 ~ Slot 62 - Used for object store, memory mapped files and resource mappings. • Object store is protected from all access outside of the file system manager. • All memory mapped files are accessible by all threads. • Slot 63 – Used for resource only DLLs • DLL Resources are accessible by all threads.

  10. Process Slot • 32MB Process slot is shared by DLL, process, and all of its virtual allocations. • DLL allocations in a slot start at the high addresses and grow down. • Process and general allocations start at the low addresses and grow up. • XIP DLL R/W data

  11. Check memory space with Platform Builder • “MI FULL” command can provide a detailed look at virtual allocations in a process slot.

  12. VirtualAlloc() • All virtual allocations are 64kB-aligned. • Pages may be committed within a virtual allocation on a page granularity (4kB) • Limitation and Workarounds

  13. Map Physical Memory (Dynamically) • VirtualCopy() • Specifies the process specific physical to virtual mapping • Usable by the process that performed the mapping • Extends the OS memory support beyond 512MB • Must first allocate virtual space with VirtualAlloc and map physical address to the VirtualAlloc’d area • Used for mapping • Device I/O • Device specific memory

  14. Allocate Physical Contiguous Memory • AllocPhysMem() • Useful for DMA, sharing to external devices • Guaranteed to be contiguous if successful • Succeeds only if the allocation size exists • No reshuffling of virtual to physical mappings

  15. Access Permissions • Process Access Permissions • Access permissions set on per-thread basis • GetProcPermissions() / SetProcPermissions() • Threads accessing other process slots require permission • Violations cause exceptions reported to the Kernel • Structured exception handling allows process to trap its faults

  16. Access Permissions • Resource DLLs and Memory-Mapped files • Accessible by threads in all processes • Shared Heaps • Writable by threads in creating process • Read Only by threads in other processes • Object Store (Optional) • Accessible only by kernel file system (filesys.exe)

  17. App.exe Nk.exe system EXE User mode thread ReturnCall Function Call Coredll.dll KernelTrap Jump Win32 API Thunks Win32 API Dispatch Function Code System API Calling Mechanism

  18. Access PermissionsSystem call process contexts • GetCurrentProcess() • Process context in which the current thread is running • GetOwnerProcess() • Original process that created the current thread • GetCallerProcess • Process that thread most recently migrated from • MapCallerPtr() • Adjusts a pointer to a specific process slot while validating caller has access to the data • Typically maps a Slot 0 relative address to the owing processes slot so a driver can use it

  19. Part IIBuild Configuration • BIB Files • BIB Memory Types • ROMOFFSET • Example System

  20. BIB Files • MEMORY section • Defines the platform memory information • Partitions the physical memory into Data memory and Program memory • ;Name Start address Size (bytes) Type • ;----------------------------------------------- • NK 80300000 01E00000 RAMIMAGE ; (30M) "ROM" • RAM 82100000 01E00000 RAM ; (30M)

  21. BIB Memory section types

  22. BIB Files • Indicate the modules and components that should be included in the image • Text files with four types of sections • The FILES section: Memory reservation for static data files ;Name Path Memory Type ------------------------------------------------------- Tahoma.ttf $(_FLATRELEASEDIR)\Tahoma.ttf NK SHU • The MODULES section: Specifies object module to be loaded in memory Taskman.exe $(_FLATRELEASEDIR)\Taskman.exe NK

  23. BIN File Format • Header Block • BIN Record(s) • Terminating Record

  24. ROMOFFSET • ROMOFFSET is used to adjust the address of records in the Microsoft BIN file format • Boot loader uses physical memory • Boot loader copies image from flash to RAM

  25. Example System • ARM core CPU • OEMAddressTable required • 32M Ram at physical address 0x08200000 • 32M Flash at physical address 0x00000000 • 1M Block of “On-Chip” devices at physical address 0x01200000

  26. OEMAddressTable

  27. Static Mapped MemoryCached 0x9FFFFFFF On - Chip Devices 0x9FF00000 0x9ED00000 ... 0x9CD00000 FLASH ... 0x82000000 RAM 0x80200000 SDRAM RAMIMAGE 0x80000000

  28. Static Mapped MemoryUncached 0xBFFFFFFF On - Chip Devices 0xBFF00000 0xBED00000 ... 0xBCD00000 FLASH ... 0xA2000000 RAM 0xA0200000 SDRAM RAMIMAGE 0xA0000000

  29. Summary • Virtual memory central to Windows CE • Configuration controlled by OEMs • CONFIG.BIB • Device developers need to understand and keep total system in mind when configuring their device images

  30. Tools & Resources Build Develop Websites msdn.microsoft.com/embedded msdn.microsoft.com/mobility Newsgroups microsoft.public.pocketpc.developer smartphone.developer dotnet.framework.compactframework microsoft.public.windowsxp.embedded windowsce.platbuilder windowsce.embedded.vc Blogs blogs.msdn.com/mikehall blogs.msdn.com/windowsmobilevsdteamnetcfteam Tools Windows CE 5.0 Eval KitWindows XP Embedded Eval Kit Windows Mobile 5.0 Eval Kit

  31. 大会注意事项 请在课程结束后填写课程培训反馈表,参加抽奖。 请填写资料袋内的蓝色大会满意度反馈表,到大会接待台领取 《Windows Mobile手机应用开发》工具书。 您还可以: 参加Windows Mobile动手实验室; 参观微软及合作伙伴展区; 体验基于 Windows Mobile平台开发的最新硬件产品及解决方案。

More Related