ARM笔记(中断)

什么是中断?
在处理器中,所谓中断,是一个过程,即CPU在正在执行程序过程中,遇到外部/内部紧急事件需要处理,暂时中止当前程序执行转而去
为事件服务,待服务完毕,再返回到暂停处(断点)继续执行原来的程序。为事件服务的程序称之为中断服务程序或中断处理程序。严格来说上述过 程是针对硬件中断而言的,用软件方法也可以引起中断。 硬件原因引起的中断过程中是不可测的,随机的,软件中断是可以人为控制的
断点:一个地址,程序在该处中断,转而取执行中断程序的地址。


中断源:引起中断的信号源。

异常优先级的概念
同时出现两个中断源,就会出现先处理哪个中断的问题。出现这种问题以后,这里就产生一个中断优先级的概念。
ARM处理器中有7种类型的异常,按照优先级从高到低的排列顺序如下:
1.复位异常(reset)
2.数据异常(data abort)
3.快速中断异常(fiq)
4.外部中断异常(irq)
5.预取异常(prefetch abort)
6.软件中断(swi)
7.未定义指令异常(undef)

中断:
  1. 硬中断 内部中断(不可),外部中断(可屏蔽),外部中断:外部中断一般是指由计算机外设发出的中断请求,如:键盘中断、打印机中断、定时器中断等。外部中断是可以屏蔽的中断,也就是说,利用中断控制器可以屏蔽这些外部设备的中断请求。内部中断:内部中断是指因硬件出错(如突然掉电、奇偶校验错等)或运算出错(除数为零、运算溢出、单步中断等)所引起的中断。内部中断是不可屏蔽的中断。
  2. 软中断(不可),软件中断其实并不是真正的中断,它们只是可被调用执行的一般程序

中断响应流程图

通用中断控制器generic interrupt control

中断号:每个中断源都被分配了一个独一无二的中断号(0-1019)
中断掩码:在汇编语言中进行中断前,需要对相应的中断状态字进行授权允许或屏蔽相关中断的操作。
GIC支持的三种中断类型
  1. 软件产生的中断SGI,软件生成的中断寄存器(ICDSGIR)。 每个SGI都可以定位多个处理器。 在里面分销商和有针对性的处理器中,SGI通过其中断的组合来唯一标识编号,ID0-ID15和发出处理器的处理器源ID(CPUID0-CPUID7)SGI。(SGI号 0-15)
  2. 私有的外设中断PPI,在特定模式下使用的中断Interrupt numbers ID16-ID31 are used for interrupts that are private to a CPU interface and are banked in theDistributor。(PPI号 0-15)
  3. 共享的外设中断SPI,外设产生的可以发送给一个或多个核心处理的中断源。Interrupt numbers ID32-ID1019 are used for SPIs.(SPI号 0-987)

中断源

GIC中断控制器框图

The main blocks of the GIC are:
 AMBA slave interface  AMBA从属接口
 Distributor 分配器
 CPU interface CPU接口
 Clock and reset 时钟和重置
 Enable and match signals  启用和匹配信号

GIC主要功能模块:分配器和CPU接口
分配器接收中断,并向相应的CPU接口提供最高优先级的中断。 一个
优先级较低的中断在成为最高优先级时转发到相应的CPU接口
待处理中断。
GIC支持160个中断,Total 160 interrupts including Software Generated Interrupts (SGIs[15:0], ID[15:0]), Private Peripheral Interrupts (PPIs[15:0], ID[31:16]) and Shared Peripheral Interrupts (SPIs[127:0], ID[159:32]) are supported. For SPI, you can
service a maximal 32 * 4 = 128 interrupt requests(SPI号)
分配器框架图

The Distributor provides a programming interface for:
 Enabling the forwarding of interrupts to the CPU interfaces globally. 
 Enabling or disabling each interrupt.
 Setting the priority level of 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 secure or Non-secure if the GIC implements the Security Extensions.
 Sending an SGI to one or more target processors.
启用全局中断向CPU接口的转发。
启用或禁用每个中断。
设置每个中断的优先级。
设置每个中断的目标处理器列表。
将每个外设中断设置为电平敏感或边沿触发。
如果GIC执行安全扩展,则将每个中断设置为安全或不安全。
将SGI发送到一个或多个目标处理器。
查看任意中断的状态
提供软件方式设置或清除任意中断的挂起状态
中断使用中断号进行标识,每个接口可以处理多达1020个中断
Interrupts from sources are identified using ID numbers. Each CPU interface can see up to 1020 interrupts. The
distributor supports up to 1244 interrupts because of banking of SPIs and PPIs.

CPU接口

Programming interface for:
 Enabling the signaling of interrupt requests by the CPU interface.
 Acknowledging an interrupt.
 Indicating completion of the processing of an interrupt.
 Setting an interrupt priority mask for the processor.
 Defining the preemption policy for the processor.
 Determining the highest priority pending interrupt for the processor.
编程接口
通过CPU接口发出中断请求的信号。
确认中断。
指示完成中断的处理。
为处理器设置一个中断优先级掩码。
为处理器定义抢占策略。
确定处理器的最高待处理中断。

中断状态转换图
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值