设为首页 加入收藏

TOP

AArch32/AArch64应用程序级内存模型(五)(一)
2023-07-23 13:30:25 】 浏览:135
Tags:AArch32/AArch64 应用程
本文主要为了记录在学习armv8的过程中的一些感悟。由于原文部分章节晦涩难懂,作者参考了网上很多优秀博主的部分章节(可能是直接摘录)并结合自己的理解重新整理了当前这个版本。文中不免有部分章节讲解很浅,后续有新的理解会再来修改补充。更新于2020.02.28

1. 内存类型及属性

Armv8提供了以下互斥的内存类型:

类型 说明
Normal 这通常用于大容量内存操作,包括读/写和只读操作。系统中大部分内存都是这种类型
Device 对该种类型的内存进行读写可能具有连带效应(side-effects,指对一个内存位置的读写操作会影响其它内存位置)或者从该种内存中的一个位置装载的值可能随着装载的次数而变化。通常内存映射外设(指使用访问内存的方法来访问的外设)会采用这种内存类型

这里重点说明一下device memory:

The Device memory type attributes define memory locations where an access to the location can cause side-effects, or where the value returned for a load can vary depending on the number of loads performed. Typically, the Device memory attributes are used for memory-mapped peripherals and similar locations.

Device memory属性有三种,分别是Gathering,Reordering,Early Write Acknowledgement

1. Gathering
(1)G 表明内存具有Gathering属性;
(2)nG 表明内存具有non-Gathering属性;

Gathering属性表明是否有如下权限
(1)对同种类型,同块内存进行读或写操作可以合并成一个single transaction。例如:代码中有2次对同样的一个地址的读访问,那么处理器必须严格进行两次read transaction;
(2)对同种类型,不同内存进行读或写操作可以合并成一个single transaction。如两个byte write merge为一个halfword write;

对于Gathering属性的内存,只要遵循ordering和coherency这两个规则,如上两个行为是被允许的。

2. Reordering
(1)R 表示内存具有reordering属性。
(2)nR 表示内存不具有reordering属性。

Reordering表示允许处理器对内存访问指令进行(优化)重排。

3. Early Write Acknowledgement
(1)E 表示内存具有Early Write Acknowledgement属性
(2)nE 表示内存不具有Early Write Acknowledgement属性

对于内存系统来说,PE写操作的最终结束标志是得到应答。对于No Early Write Acknowledgement属性的内存需要保证:
(1)写操作必须获取最终目的的应答;
(2)不允许其他节点提前提供应答;

PE访问memory是有问有答的(更专业的术语叫做transaction),对于write而言,PE需要write ack操作以便确定完成一个write transaction。为了加快写的速度,系统的中间环节可能会设定一些write buffer。nE表示写操作的ack必须来自最终的目的地而不是中间的write buffer。

Device memory支持如下类型

类型 说明
Device-nGnRnE Device non-Gathering, non-Reordering, No Early write acknowledgement.
Equivalent to the Strongly-ordered memory type in earlier versions of the architecture
Device-nGnRE Device non-Gathering, non-Reordering, Early Write Acknowledgement.
Equivalent to the Device memory type in earlier versions of the architecture.
Device-nGRE Device non-Gathering, Reordering, Early Write Acknowledgement.
Armv8 adds this memory type to the translation table formats found in earlier versions of the architecture. The use of barriers is required to order accesses to Device-nGRE memory
Device-GRE Device Gathering, Reordering, Early Write Acknowledgement.
Armv8 adds this memory type to the translation table formats found in earlier versions ofthe architecture. Device-GRE memory has the fewest constraints. It behaves similar toNormal memory, with the restriction that Speculative accesses to Device-GRE memory is forbidden.

2. Arm架构中的原子性

本节主要解析ARMv8手册中的Atomicity这个概念。首先给出为何定义这样的概念,定义这个概念的作用为何?然后介绍Atomicity相关的概念,很多时候我们引用了手册的原文,但是由于这些原文可读性比较差,因此,我们使用程序员可理解的一些语言来描述这些概念。

2.1 Atomicity概述

2.1.1 什么是Atomicity?

??Atomicity是用来描述系统中的memory access的特性的一个术语。在 单核系统上,我们用Single-copy atomicity这个术语来描述,也就是说该内存访问操作是否是原子的,是否是可以被打断的。在多核系统中,用Single-copy atomicity来描述一次内存访问的原子性是不够的,因为即便是在执行该内存访问指令的CPU CORE上是Single-copy atomicity的,也只不过说明该指令不会被本CPU CORE的异常或者中断之类的异步事件打断,它并不能阻止其他CPU core上的内存访问操作对同一地址上的memory location进行操作,这时候,我们使用Multi-copy atomicity来描述 多个CPU CORE发起对同一个地址进行写入的时候,这些内存访问表现出来的特性是怎样的。

2.1.2 Atomicity的作用?

??主要是为了软件和硬件能够和谐工作在一起。对于软件工程师而言,我们必须了解硬件和软件的“接口”,即那些是HW完成,那些是需要软件完成的,只有这样,软件和CPU的硬件才能愉快的一起玩耍。对于硬件,其

首页 上一页 1 2 3 4 5 6 下一页 尾页 1/6/6
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇PHY驱动调试之 --- PHY控制器驱动.. 下一篇AArch32/AArch64系统级内存模型(..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目