一些嵌入式系统都具有多任务的能力,在这些系统上会涉及到多个任务对于系统资源的使用,对这些系统资源的保护,也就是本章的主题。
有两种方法控制对系统资源的访问。第一种是unprotected:这种系统依赖于软件层面对于资源的保护,没有专用的硬件监管内存和外设的使用。第二种是protected system:通过软件和硬件对系统资源进行保护,具有专用的硬件确认和限制对资源的访问。在这种系统中,任务行为需要符合运行环境定义的一系列规则也要接受硬件的制约,硬件层面给程序监控资源提供了特权。因此第二种方法比第一种方法具有更好的保护能力。
ARM提供了一系列具有硬件层面保护系统资源的处理器。分为2类,第一类是配备了MPU(memory protection units)的处理器, hardware protection over several software-designated regions.第二类是配备MMU的处理器,提供了硬件保护并且增加了虚拟内存的能力。
本章就是讲述MPU的处理器,下一章再讲解MMU。
本章内容如下
1. Protected Regions
2. Initializing the MPU, Caches , and Write buffer
3. Demonstration of an MPU System
在开始本章之前先大致讲解一下region是什么,才能进一步讲解MPU是如何在regions的基础上提供硬件保护能力的。
Region
A region is a set of attributes associated with an area of memory.The processor core holds these attributes in several CP15 registers and identifies each region by a number, which ranges between 0 and 7.
A region’s memory boundaries are configured using two attributes,
attributes | |
---|---|
the starting address | |
its length | which can be any power of two between 4 KB and 4 GB |
the operation system assigns additional attributes to these regions
additional attributes | |
---|---|
access rights | The access to a region in memory is set as read-write, read-only, or no access and is subject to additional rights based on the current processor mode, which is either privileged or user. |
the cache and write buffer policies | which controls cache and write buffer attributes. |
For example, one region can be set to access memory using a writethrough policy, while another operates as noncached and nonbuffered.
访问region过程:
When the processor accesses a region in main memory, the MPU compares the region’s access permission attributes with the current processor mode to determine what action it will take. If the request satisfies the region access criteria, the core is allowed to read or write to main memory. However, if the memory request results in a memory access violation, the MPU will generate an abort signal.
abort handler会决定abort类型是prefetch or data abort。
region生命周期
region可以被创建并且持续整个嵌入式系统的生命周期,又或者临时创建用来满足某一特殊的操作然后就移除。
如何安排和创建regions就是接下来一节的内容。
Protected Regions |
当前的ARM产品中包含MPU的有如下几个:
the ARM740T, ARM940T, ARM946E-S, and the ARM1026EJ-S.
The ARM740T, ARM946E-S,