arm的GIC中断

一、gic V2

①、中断状态:

gic为每个中断维护着4个状态,inactive、pending、active、active and pending

The following states apply at each interface between the GIC and a connected processor:

Inactive: An interrupt that is not active or pending.

Pending: An interrupt from a source to the GIC that is recognized at asserted in hardware,or generated by software,and is waitting to be serviced by a target processor.

Active: An interrupt from a source to the GIC thar has been acknowledeged by a processor, and is beging serviced but has not completed.

Active and pending: A processor is servicing the interrupt and the GIC has a pending interrupt from the same source.

②、中断类型

gic支持的中断类型有外设中断、软件中断。其中外设中断源来自于硬件,软件中断通过软件写gic寄存器产生的。

Peripheral interrupt This ia an interrupt asserted by a signal to th GIC.The GIC architecture defines the following types of perpheral interrupt:

        Private Peripheral Interrupt(PPI):This is a peripheral interrupt that is specific to a single processor.

        Shared Peripheral Interrupt(SPI): This is a peripheral interrunpt that the Distributor can route to any o a specified combination of  processors.

        Each peripheral interrupt is either:

        Edge-triggered

                This is an interrupt that is asserted on detection of a rising edeg of an interruptt signal and then,regardless of the state of the signal,remains asserted until it is cleared by by the conditions defined by this specification. 

        Level-sensitive

                This is an interrupt that is asserted whenever the interrupt signal level is active,and deasserted whenever the level is not active.

Software-generated interrupt(SGI)

        This is an interrupt generated by software writing to a GICD_SGIR register in the GIC.The system uses SGIs for interprocessor communication.

        An SGI has edge-triggered properties. The software triggering of the interrupt is equivalent to the edge transition of the interrupt requeset signal.

        When an SIG occurs in a multiprocessor implementation, the CPUID field in the Interrupt Acknowledeg Register,GICC_IAR, or the Aliased Interrupt Acknowledeg Register, GICC_AIAR,identifies the processor that requested the interrupt.

        In an implementaion that includes the GIC Virtualization Extensions:

  •  when an SGI occurs, management registers in the GIC virtualization Extensions enable the requesting processor to be reported to the Guest OS
  • by writing to the management registers in the GIC Virtualization Extensions, a hypervisor can generate a virtual interrupt that appears to a virtual machine as an SGI.

③、gic v2架构划分

gic从逻辑上分为Distributor和CPU interface。Distributor是中断的统一入口,负责分发中断给具体的CPU。每个CPU都有一个CPU interface负责本CPU的中断屏蔽和抢占。

Distributor The Distributor block performs interrupt prioritization and distribution on the CPU interface blocks that connect to the processors in the system.

                    The Distributor block regisgers are identified by the GICD_prefix.

CPU Interfaces Each CPU interface block performs priority masking and prempting handling for a connected processor in the system

                   CPU interface block register are identified by the GICC_prefix.

                   When describing a GIC that includes the GIC Virtualization Extensions, a CPU interface is sometimes called a physical CPU interface, to avoid possibel confusion with cpu interface.

Distributor的编程接口主要有:

The Distributor provides a programming interface for:

  • Globally enabling the forwarding of interrupts to the CPU interfaces.
  • Enabling or disabling each interrupt.
  • Setting the priority level if each interrupt.
  • Setting the target processor list of each interrupt.
  • Setting each peripheral interrupt to be level-sensitive or edge-triggered.
  • Setting each interrupt as either Group 0 or Group 1.

参考连接:https://www.cnblogs.com/lvzh/p/15058027.html

④、中断ID和中断处理流程

Interrupt IDs

        Interrupts from sources are identifiled usring ID numbers.Each CPU interface can set up to 1020 interrupts.The banking of SPIs and PPIs increase the total number of interrupts supported by the Distributor.

        The GIC assigns interrupt ID numbers ID0-ID1019 as follows:

  •  Interrupt numbers ID32-ID1019 are used for SPIs.
  • Interrupt numbers ID0-ID31 are used for interrupts that are private to a CPU interface. These interrupts are banked in the Distributor.

        A banked interrupt is one where the Distributor can have multiple interrupts with the same ID.A banked interrupt is identified uniquely by its ID number and its associated CPU interface number. Of the banked interrupt IDS:

                                        ID0-ID15 are used for SGIs

                                        ID16-ID31 are used for PPIs

中断处理流程    

        When the GIC recognizes an interrupt request, it marks its state as pending.Regenerating a pending interrupt does not affect the state of the interrupt.

        The GIC interrupt handling sequence is 

  1. The GIC determines the interrupts that are enabled.
  2. For each pending interrupt, the GIC determines the targeted processor or processors.
  3. For each CPU interface, The Distributor forwards the highest priority pending interrupt that targets that interface.
  4. Each CPU interface determnes whether to signal an interrupt request to its processor,and if required,does so.
  5. The processor acknoeledeg the interrupt,and the GIC returns the interrupt ID and updated the interrupt state.
  6. After processiong the interrupt, the processor signals End of Interrupt(EOI) to the GIC.

其中第五步,CPU读取GICC_IAR寄存器来响应该中断(一般是linux内核程序来读取寄存器),寄存器返回硬件中断号;第六步,CPU处理完中断后写GICC_EOIR寄存器来通知CPU interface。 

⑤、硬件中断号与Linux软件中断号的映射        

每一款ARM SOC在芯片设计阶段时,就会把各种中断和外设分配情况固定下来,因此对于底层软件来说,需要查询SOC的芯片手册来确定的外设的中断号。

随着芯片硬件的发展,使用直接映射的方式难以应对多个中断控制器级联的情况,Linux引入了irq domain的管理框架,irq domain框架可支持多个中断控制器并且完美地支持device tree机制。git_init_of->gic_init_bases->__irq_domain_add(),添加到全局变量irq_domain_list

注册中断的API函数request_irq()/requeset_threaded_irq()是使用内核软件中断号,而不是硬件中断号,那它们是如何映射的呢?
一般通过调用核心函数irq_of_parse_and_map来解析DTS中的硬件中断号,返回内核使用的IRQ中断号。
它初始化时在位图中寻找空闲的bit来分配描述符。
irq_of_parse_and_map()->irq_domain_alloc_irqs()->__irq_alloc_descs()->bitmap_find_next_zero_area()
在内核中有两种方式来分配struct irq_desc数据结构,一是内核配置了CONFIG_SPARSE_IRQ使用radix tree树结构来存储;二是采用数组的方式,定义一个全局的数组struct irq_desc irq_desc[NR_IRQS],每个中断对应一个元素。

struct irq_desc包含struct irq_data,其中irq是软件中断号,hwirq是硬件中断号,当这两个成员填写完成,即完成了硬件中断的注册。struct irq_data包含struct irq_chipstruct irq_chip是硬件中断控制器操作的抽象接口,如使能/去使能、响应、完成等接口。

struct irq_data {unsigned int	irq;unsigned long	hwirq;struct irq_chip	*chip;...
};
struct irq_chip {const char	*name;unsigned int	(*irq_startup)(struct irq_data *data);void		(*irq_shutdown)(struct irq_data *data);void		(*irq_enable)(struct irq_data *data);void		(*irq_disable)(struct irq_data *data);void		(*irq_ack)(struct irq_data *data);void		(*irq_mask)(struct irq_data *data);void		(*irq_mask_ack)(struct irq_data *data);void		(*irq_unmask)(struct irq_data *data);void		(*irq_eoi)(struct irq_data *data);...
};

参考:zhuanlan.zhihu.com/p/85353687

二、gic V3

①、gic v3变化点

  • 扩展性:v2架构最多支持8个PE,v3架构通过redistributor组件来引入affinity routing机制可以支持更多的PE
  • 中断分组:

        Group 0 physical interrupts are expected to be handled at the highest implemented Exceptionlevel.

        Secure Group 1 physical interrupts are expected to handled at Secure EL1 or Secure EL2.

        Non-secure Group 1 physical interrupts are excepted to handled at Non-secure EL1 or Non-secure EL2.

  • 将cpu interface独立出来,用户可以将其设计再core内部
  • 增加了LPI(Locality-specific Peripyeral Intertupt),使用ITS(Interrupt Translation Service)来解析。

②、v3逻辑架构图

  1. The Distributor provides the routing configuration for SPIs, and holds all the associated routing and priority
    information.
  2. The Redistributor provides the configuration settings for PPIs and SGIs.
  3. A Redistributor always presents the pending interrupt with the highest priority to the CPU interface in finite time.
  4. v3架构支持affinity routing,在MPIDR_EL1寄存器中,Aff3.Aff2.Aff1.Aff0。

③、中断路由

GICv3 使用 hierarchy 来标识一个具体的 core, 如下图是一个四层的结构(aarch64):

用 <affinity level 3>.<affinity level 2>.<affinity level 1>.<affinity level 0> 的形式组成一个 PE 的路由。每一个 core 的 affnity 值可以通过 MPDIR_EL1 寄存器获取, 每一个 affinity 占用8bit。配置对应 core 的 MPIDR 值,可以将中断路由到该 core 上。

https://oss-emcsprod-public.modb.pro/wechatSpider/modb_20210802_1251295a-f365-11eb-a003-00163e068ecd.png

各个 affinity 的定义是根据 SOC 自己的定义,比如:

<group of groups>. <group of processors>.<processor>.<core>
<group of processors>.<processor>.<core>.<thread>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/47025.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Python面试宝典第14题:背包问题

题目 现有编号从 0 到 n - 1 的 n 个背包&#xff0c;给你两个下标从 0 开始的整数数组 capacity 和 rocks 。第 i 个背包最大可以装 capacity[i] 块石头&#xff0c;当前已经装了 rocks[i] 块石头&#xff08;0 < rocks[i] < capacity[i]&#xff09;。另给你一个整数 a…

深度学习入门——神经网络的学习

前言 这里所说的“学习”是指从训练数据中自动获取最优权重参数的过程。 为了使神经网络能进行学习&#xff0c;将导入损失函数这一指标 为了找出尽可能小的损失函数的值&#xff0c;本章我们将介绍利用了函数斜率的梯度法 从数据中学习 本章将介绍神经网络的学习&#xff0c;…

ubuntu上模拟串口通信

前言 有时候写了一些串口相关的程序&#xff0c;需要调试的时候&#xff0c;又没有硬件&#xff0c;或者需要等其他模块完成才能一起联调。这样搭建环境费时费力&#xff0c;很多问题等到最后联调才发现就已经很晚了。 本文提供一种在ubuntu环境下模拟串口&#xff0c;直接就可…

opencv—常用函数学习_“干货“_5

目录 十五、图像分割 简单阈值分割 (threshold) 自适应阈值分割 (adaptiveThreshold) 颜色范围分割 (inRange) 分水岭算法 (watershed) 泛洪填充 (floodFill) GrabCut算法 (grabCut) 距离变换 (distanceTransform) 最大稳定极值区域检测 (MSER) 均值漂移滤波 (pyrMean…

【Web服务与Web应用开发】【C#】VS2019 创建ASP.NET Web应用程序,以使用WCF服务

目录 0.简介 1.环境 2.知识点 3.详细过程 1&#xff09;创建空项目 2&#xff09;添加Web表单 3&#xff09;使用Web表单的GUI设计 4&#xff09;添加服务引用 5&#xff09;在Web的button函数中调用服务&#xff0c;获取PI值 6&#xff09;测试 0.简介 本文属于一个…

Mysql的JSON格式字段实用操作函数JSON_CONTAINS、JSON_SEARCH、JSON_EXTRACT

文章目录 前言一、示例数据二、使用1.JSON_CONTAINS2.JSON_SEARCH3.JSON_EXTRACT 总结 前言 在开发中难免会遇见在Mysql字段存储JSON格式数据的业务情况&#xff0c;记录几种常用函数的 用法。 一、示例数据 建一张表&#xff0c;字段memo存储JSON格式数据 CREATE TABLE use…

摄像头 RN6752v1 视频采集卡

摄像头 AHD倒车摄像头比较好&#xff0c;AHD英文全名Analog High Definition&#xff0c;即模拟高清&#xff0c;拥有比较好的分辨率与画面质感。 RN6752v1 GQW AKKY2 usb 采集卡 FHD&#xff08;1080p&#xff09;、HD&#xff08;720p&#xff09;和D1&#xff08;480i&am…

MySQL第七次作业

Product表内容 字段名 字段描述 数据类型 主键 外键 非空 唯一 自增 Id 产品编号 Int(10) 是 否 是 是 否 Name 产品功能 Varchar(20) 否 否 是 否 否 Function 主要功能 Varchar(50) 否 否 否 否 否 Company 生产厂家 Varchar(20) 否 否 是 否 否 Address 家庭住址 Varchar(20…

支持大量边缘盒子集中管理调度的智慧物流开源了。

智慧物流视频监控平台是一款功能强大且简单易用的实时算法视频监控系统。它的愿景是最底层打通各大芯片厂商相互间的壁垒&#xff0c;省去繁琐重复的适配流程&#xff0c;实现芯片、算法、应用的全流程组合&#xff0c;从而大大减少企业级应用约95%的开发成本。用户只需在界面上…

404/400、Flask、WSGI

对于404和400错误&#xff1a; 1.404 Not Found​ 表示客户端能够与服务器通信&#xff0c;但服务器找不到请求的资源。 2.400 Bad Request​ 表示服务器无法理解客户端的请求&#xff0c;通常是由于请求语法错误、请求参数错误或请求头不正确等原因。 解决&#xff1a; 对于 4…

AR0132AT 1/3 英寸 CMOS 数字图像传感器(AR0132AT6R、AR0132AT6C)适用于监控和高清视频等多种应用

AR0132AT 1/3 英寸 CMOS 数字图像传感器&#xff0c;带 1280H x 960V 有效像素阵列。它能在线性或高动态模式下捕捉图像&#xff0c;且带有卷帘快门读取。它包含了多种复杂的摄像功能&#xff0c;如自动曝光控制、开窗&#xff0c;以及视频和单帧模式。它适用于低光度和高动态范…

大模型学习笔记十一:视觉大模型

一、判别式模型和生成式模型 1&#xff09;判别式模型Discriminative ①给某一个样本&#xff0c;判断属于某个类别的概率&#xff0c;擅长分类任务&#xff0c;计算量少。&#xff08;学习策略函数Y f(X)或者条件概率P(YIX)&#xff09; ②不能反映训练数据本身的特性 ③学习…

精准打击:Conda中conda remove命令的高效使用指南

精准打击&#xff1a;Conda中conda remove命令的高效使用指南 在Python项目开发中&#xff0c;Conda作为Anaconda发行版中的包管理器&#xff0c;不仅用于安装和管理包&#xff0c;还提供了强大的环境管理功能。随着项目的发展&#xff0c;有时需要从环境中移除不再需要的包。…

SpringMVC 控制层框架-上

一、SpringMVC简介 1. 介绍 Spring Web MVC 是基于Servlet API构建的原始Web框架&#xff0c;从一开始就包含在Spring Framework 中。在控制层框架经历Srust、WebWork、Strust2等诸多产品的历代更迭之后&#xff0c;目前业界普遍选择了SpringMVC 作为Java EE项目表述层开发的首…

解读|http和https的区别,谁更好用

在日常我们浏览网页时&#xff0c;有些网站会看到www前面是http&#xff0c;有些是https&#xff0c;这两种有什么区别呢&#xff1f;为什么单单多了“s”&#xff0c;会有人说这个网页会更安全些&#xff1f; HTTP&#xff08;超文本传输协议&#xff09;和HTTPS&#xff08;…

[Labview] 表格单元格外边框 二维图片叠加绘图

最终效果如下所示 转行做Labview都没到三个月&#xff0c;主程居然让我做这么复杂的功能&#xff0c;真是看得起我/(ㄒoㄒ)/~~ 思路大致分为两步 1、确定每个框体的左上/右下单元格位置&#xff0c;转换为表格表格坐标并在二维图片上绘制生成&#xff1b; 2、为二维图片添加…

权威认可 | 海云安开发者安全助手系统通过信通院支撑产品功能认证并荣获信通院2024年数据安全体系建设优秀案例

近日&#xff0c;2024全球数字经济大会——数字安全生态建设专题论坛&#xff08;以下简称“论坛”&#xff09;在京成功举办。由全球数字经济大会组委会主办&#xff0c;中国信息通信研究院及公安部第三研究所共同承办&#xff0c;论坛邀请多位专家和企业共同参与。 会上颁发…

简谈设计模式之桥接模式

桥接模式是一种结构型设计模式, 它将抽象部分和它的实现部分分离, 使它们可以独立变化. 这意味着可以改变它的抽象和它的实现, 而不会相互影响 桥接模式结构 抽象 (Abstraction): 定义抽象类, 并包含一个对实现类对象的引用拓展抽象 (Refined Abstraction): 拓展抽象类, 通过…

PHP开发工具:打造高效的编码体验

本文由 ChatMoney团队出品 在PHP开发领域&#xff0c;选择正确的工具可以极大地提升开发效率和代码质量。 集成开发环境(IDE) PHPStorm 是一个强大的IDE&#xff0c;专为PHP开发设计。它提供了丰富的功能&#xff0c;如智能代码补全、代码分析、实时错误预防、重构工具、数据…

android预置apk

在framework开发中&#xff0c;有一些需求是需要预装应用的&#xff0c;有些是预置应用源码&#xff0c;有些是预置apk。今天我们就分享下怎样预置apk 一般系统有自定义的目录&#xff0c;比如我的项目中根目录下有一个文件夹vendor&#xff0c;这里没都是自定义的一些功能。预…