Download presentation
Presentation is loading. Please wait.
Published byAsher Wells Modified over 9 years ago
2
Windows CE 5.0 Memory Architecture Li-Ming Fan Escalation Engineer Microsoft GCR-GTSC
3
Part I Architecture and concepts Virtual Memory Kernel Mode versus User Mode Statically mapped memory Process memory System API Calls Access Permissions
4
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.
5
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.
6
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.
7
Statically Mapped Memory 2 GB User 512 MB Uncached 512 MB Cached 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
8
Statically Mapped Memory x86, ARM –OEM provides OEMAddressTable in OAL to define initial mappings MIPS, SHx –Mapping is fixed in the MMU architecture
9
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
10
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.
11
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
12
Check memory space with Platform Builder “MI FULL” command can provide a detailed look at virtual allocations in a process slot.
13
VirtualAlloc() All virtual allocations are 64kB-aligned. Pages may be committed within a virtual allocation on a page granularity (4kB) Limitation and Workarounds
14
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
15
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
16
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
17
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)
18
System API Calling Mechanism User mode thread Win32 API Thunks Function Call Coredll.dll App.exe Kernel Trap Win32 API Dispatch Nk.exe Jump Function Code system EXE Return Call
19
Access Permissions System 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
20
Part II Build Configuration BIB Files BIB Memory Types ROMOFFSET Example System
21
BIB Files MEMORY section –Defines the platform memory information –Partitions the physical memory into Data memory and Program memory ;NameStart address Size (bytes)Type ;----------------------------------------------- NK8030000001E00000 RAMIMAGE ; (30M) "ROM" RAM8210000001E00000 RAM ; (30M) ;NameStart address Size (bytes)Type ;----------------------------------------------- NK8030000001E00000 RAMIMAGE ; (30M) "ROM" RAM8210000001E00000 RAM ; (30M)
22
BIB Memory section types TypeDescription RAMIMAGEOS Image (Read + Execute ONLY) MUST start on a 64K boundary! RAMRAM for OS to partition RESERVEDReserved region OS won’t use NANDIMAGEUsed with BINFS to mark memory region for paging Files From NAND storage devices FIXUPVARUsed to set the value of a variable during image build time
23
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 ;NamePathMemory Type ------------------------------------------------------- Tahoma.ttf $(_FLATRELEASEDIR)\Tahoma.ttf NK SHU ;NamePathMemory Type ------------------------------------------------------- Tahoma.ttf $(_FLATRELEASEDIR)\Tahoma.ttf NK SHU Taskman.exe$(_FLATRELEASEDIR)\Taskman.exe NK –The MODULES section: Specifies object module to be loaded in memory
24
BIN File Format Header Block B000FF\x0AStart AddressImage Length StartLengthChecksumData… 0Starting IP0 BIN Record(s) Terminating Record
25
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
26
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
27
OEMAddressTable Cached Address Physical Address Size (MB) Description 0x800000000x0820000032RAM 0x9CD000000x0000000032FLASH 0x9FF000000x012000001On Chip Devices 000NULL Terminator
28
Static Mapped Memory Cached RAMIMAGE RAM... SDRAM 0x9FFFFFFF On-Chip Devices... FLASH 0x9FF00000 0x9ED00000 0x9CD00000 0x82000000 0x80200000 0x80000000
29
Static Mapped Memory Uncached RAMIMAGE RAM... SDRAM 0xBFFFFFFF On-Chip Devices... FLASH 0xBFF00000 0xBED00000 0xBCD00000 0xA2000000 0xA0200000 0xA0000000
30
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
31
Tools & Resources msdn.microsoft.com/ embedded microsoft.public. windowsxp.embedded windowsce.platbuilder windowsce.platbuilder windowsce.embedded.vc windowsce.embedded.vc blogs.msdn.com/ mikehall Windows CE 5.0 Eval Kit Windows XP Embedded Eval Kit msdn.microsoft.com/ mobility microsoft.public. pocketpc.developer smartphone.developer dotnet.framework.compactframework blogs.msdn.com/ windowsmobile vsdteam netcfteam Windows Mobile 5.0 Eval Kit Websites Newsgroups Blogs Tools Build Develop
32
请在课程结束后填写课程培训反馈表,参加抽奖。 请填写资料袋内的蓝色大会满意度反馈表,到大会接待台领取 《 Windows Mobile 手机应用开发》工具书。 您还可以: 参加 Windows Mobile 动手实验室; 参观微软及合作伙伴展区; 体验基于 Windows Mobile 平台开发的最新硬件产品及解决方案。 大会注意事项
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.