Windows CE内存管理机制

      Windows CE引入了虚拟内存机制管理多达4G的虚拟内存,最大支持512MB的物理内存.不同的CPU内存管理方法不同。对于MIPS和SHX系列CPU来说,地址映射是由CPU完成的,CE内核可以直接访问512MB的物理内存。对于x86系列和ARM系列的CPU来说,在内核启动过程中它会将现有物理内存地址全部映射到0x8000 0000以上的虚拟地址空间中供内核以后使用,这个虚实映射机制软件上通过OEMAddressTable实现,硬件上要求具备MMU.
         我的理解是在*.h文件中声明各虚拟地址,比如用到的寄存器结构体.在虚实地址映射文件(如ARM下的map.a)的OEMAddressTable中建立虚实地址的静态映射关系,包括RAM,FLASH各部分存储空间. (OS启动后所能够识别的物理内存). 接着在config.bib的MEMORY段(参考HELP里的Memory Section)把RAM映射后的虚拟地址进行分段,比如NK的大小,各种外设缓冲区的保留等.(注意这里是虚拟地址的划分,必须建立在映射基础上)  这种静态的虚拟地址只能够由内核层访问,如果在APP中访问,还必须建立动态映射.


posted on 2007-04-15 23:07 milkyway 阅读(4206) 评论(4)  编辑 收藏 引用 所属分类: Wince学习小结


# re: Windows CE内存管理机制 2007-04-17 13:41 相思酸中有甜

OEMAddressTable is a static (unchanging, available at startup without doing any work or setup) table of virtual -> physical mappings. The kernel is the only thing that has default access to the resources mapped by this table. If you are operating outside the OAL (i.e. in any kind of driver or application), you must use VirtualCopy() to copy or create memory page mappings. As mentioned above, you can copy any existing mapping as long as you have access to it. This includes a static mapping done by the OEMAddressTable. Some people will map all resources in the OEMAddressTable (so the kernel has access to everything), then just copy those mappings in drivers when they need to. This is not a best practice because it makes driver code less portable -- it is better to read the physical address of a component from the registry, then use the value found there to map to it. If you do this your driver code does not have to change if it is moved to a different platform or extended to use multiple components in different physical locations.

A mapping does not have to exist in OEMAddressTable in order for you to access the physical resources mapped. You can create a new mapping unknown to the OEMAddressTable by using VirtualCopy with the PAGE_PHYSICAL flag.

Config.bib reserves regions of memory that romimage knows about, but does not specify kernel memory regions.

by Kurt,
  回复  更多评论   

# re: Windows CE内存管理机制 2007-04-17 13:42 相思酸中有甜

OEMAddressTable mentioned in this blog applies only to h/w based TLB designs like x86 and ARM. For SHx and MIPS, there is a architecture pre-defined mapping (512Mb cached and uncached regions) at bootup.

-- On ARM v6/v7 there is a bit (eXecute Never XN) which can be used to mark individual page entries. Once this is set, then any attempt to execute code from that page will fault. This most likely will be supported in future releases of CE.

-- There seemed to be lot of confusion (party our fault since there are so many ways you can map physical or virtual memory) on these APIs. In general remember that VirtualCopy can be used to create a virtual address mapped to either a physical address or another virtual address range. Also all the flags are well documented in MSDN so you should take a look at that.

by thx.


  回复  更多评论   

# re: Windows CE内存管理机制 2007-04-18 09:09 milkyway

In Windows CE 5.0 and earlier, virtual allocations below 2MB *in size* will be allocated inside of the address space of the process calling it, while allocations above 2MB *in size* will be allocated out of the shared address space. I was not talking about the address of the allocation, I was talking about the size.

by Sue

  回复  更多评论   

# re: Windows CE内存管理机制 2008-07-29 15:55 wogo

hao!  回复  更多评论   

【推荐】超50万行VC++源码: 大型组态工控、电力仿真CAD与GIS源码库
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理




随笔皆原创,文章乃转载. 欢迎留言!