天天看点

GIC 之二

GIC架构可以分为Distributor,CPUinterface和VirtualCPU interface三大部分。VirtualCPU interface只在支持VirtualizationExtensions的系统存在。

Ø  Distributor

Distributor主要完成中断优先级处理(interrupt prioritization)和分配(distribution)中断到相应的CPU interface。

Ø  CPU interface

主要完成中断优先级屏蔽(prioritymasking)和抢占处理(preemptionhandling)。

Distributor管理所有的中断源,决定每个中断优先级,并为每个CPUinterface选择出最高优先级的中断。一个Distributor可以支持8个CPUinterface。

Distributor提供如下编程接口:

Ø  使能挂起中断是否传递(forward)到CPUinterface

DistributorControl Register

Ø  使能和禁用任意中断

InterruptSet-Enable Registers/ Interrupt Clear-Enable Registers

Ø  设定任意中断优先级

Interrupt PriorityRegisters

Ø  设置任意中断的目标处理器(target processor list)

InterruptProcessor Targets Registers

Ø  设置中断为电平触发(level-sensitive)或者边沿触发(edge-triggered)

Interrupt ConfigurationRegisters

Ø  设置中断为0组或者1组

Interrupt GroupRegisters

Ø  传递(Forwarding)任意SGI到一个或者多个目标处理器(target processor)

Software GeneratedInterrupt Register

Ø  查看任意中断的状态

Ø  提供软件方式设置或清除任意PI(peripheral)的挂起状态

InterruptSet-Pending Registers/ Interrupt Clear-Pending Registers

SGI Clear-PendingRegisters/ SGI Set-Pending Registers

中断使用中断号(Interrupt ID)来标识。每个CPUinterface可以处理多达1020个中断。The Banking of SPI and PPI增加了Distributor支持的中断数目。

GIC将ID_0~ID_1019分为:

Ø  SPI的中断号为ID_32~ID_1019

Ø  Banking interrupt 的中断号ID_0 ~ ID_31

n  SGI 中断号为ID_0 ~ ID_15

一般被用来作为核间中断IPI(Inter-ProcessorInterrupt)。

n  PPI 中断号ID_16 ~ ID_31

2.3 CPU interface

 每个CPU interface为连接到GIC上的一个processor提供接口。每个CPU interface提供如下编程接口:

Ø  使能通知processor中断请求

CPU InterfaceControl Register

Ø   应答中断

InterruptAcknowledge Register

Ø  指示中断处理完成

End of InterruptRegister

Ø  设置processor的中断优先级屏蔽(Interruptpriority mask)

Interrupt PriorityMask Register

Ø  定义processor中断抢占策略

Ø  为processor决定最高优先级的挂起中断

Highest PriorityPending Interrupt Register

CPU interface根据中断优先级屏蔽和中断抢占策略决定将最高优先级的挂起中断的中断请求发给processor。