VMSA内存管理单元

VMSA内存管理单元

本文介绍了启用的ARMv7 VMSA内存管理单元?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 所以,基本上,我想在一个ARMv7的核心启用内存管理单元。实际过程是pretty很多琐碎。我只需要使用控制寄存器转换表的地址加载到 TTBR0 并启用MMU。So, basically, I want to enable the memory management unit on an ARMv7 core. The actual procedure is pretty much trivial. I just need to load the address of the translation table into TTBR0 and enable the MMU using the control register./* enable mmu */mcr p15, 0, r0, c2, c0, 0mrc p15, 0, r12, c1, c0, 0orr r12, r12, #0x1mcr p15, 0, r12, c1, c0, 0现在,这个问题只要MMU启用出现,因为ARMv7体系(不同于ARM架构的一些其它版本),CPU开始从虚拟地址立即获取。因此,如果引导程序是在 0x10000000处运行,然后启用MMU,除非它首先进入的标识映射,下一次取指在 0x10000004 将导致prefetch中止。现在,我知道,这是可能做到这一点最初的启用MMU的期间使用标识映射。然而,也将切换转换表时发生同样的问题(装载新的值到 TTBR0 )。Now, the problem arises as soon as the MMU is enabled, because on ARMv7 (unlike on some other versions of the ARM architecture), the CPU begins fetching from the virtual address immediately. So, if the bootloader is running at 0x10000000 and then enables the MMU, unless it enters an identity mapping first, the next fetch at 0x10000004 will cause a prefetch abort. Now, I'm aware that it's possible to do this using an identity mapping during the initial enabling of the MMU. However, the same problem will also occur when switching translation tables (loading new values into TTBR0).所以,基本上,我在寻找一个装载新值 TTBR0 (或仅开启MMU),然后,一个或多或少直接的方法立即跳转到一个新地址后,这将是在新的地图中有效。因为下面的启用MMU或更改状态是从旧地址取的指令至少4个指令,这是有可能较早架构。理想情况下,我希望能够做到这一点,而不依赖于令人难以置信的丑陋的黑客,你必须创建一个身份要切换页表或关闭MMU上每一次映射。So, essentially, I'm looking for a more or less straightforward way of loading a new value into TTBR0 (or just turning the MMU on) and then, immediately jumping to a new address, which will be valid in the new map. This was possible on earlier architectures because at least 4 instructions following the instruction that enabled the MMU or changed the state were fetched from the old address. Ideally, I want to be able to do that without relying on incredibly ugly hacks where you have to create an identity mapping every time you want to switch page tables or turn the MMU on.要澄清我的意思,当我说的是较旧的架构,这里是给ARM信息中心页面的链接解释如何打开MMU ARM720T上:的 7.16.1。启用MMUTo clarify what I meant when I was talking about older architectures, here is a link to the ARM infocenter page explaining how to turn on the MMU on ARM720T: 7.16.1. Enabling the MMU推荐答案简单的回答是,没有确切你的ARMv7-A问做什么的方式。该ARM720T的例子是一个非常具体的微体系结构的黑客,可能永远不会被保证是不同处理器之间进行移植。The short answer is that there is no way of doing exactly what you ask in ARMv7-A.The ARM720T example was an extremely microarchitecture-specific hack and could never have been guaranteed to be portable between different processors.有关的ARMv7-A没有使用身份映射用于打开MMU /关闭的没有可移植的方法,但作为更新转换表:你能做什么(这是不是在ARM720T用)是使用TTBR1 / TTBR0组合握住你的描述符。在TTBCR的N字段配置TTBR0表重叠的TTBR1之一的大小。这样一来,只要你的TTB开关code驻留在通过不同的TTBR比你所更新描述一个地区,没有地图的冲突。For ARMv7-A There is no portable way of not using an identity mapping for turning MMU on/off, but as for updating translation tables:What you can do (which was not available in ARM720T) is to use the combination of TTBR1/TTBR0 to hold your descriptors. The N field in TTBCR configures the size of the TTBR0 table overlaying the TTBR1 one. This way, as long as your TTB switching code resides in a region described through a different TTBR than the one you are updating, there is no conflict of maps.的其他选择是将改写由TTBR0所述的转换表,而不是切换The other option would be to rewrite the translation tables described by TTBR0 rather than switching. 这篇关于启用的ARMv7 VMSA内存管理单元?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-29 07:11