主頁 > 軟體設計 > ARM GIC(一) GIC V3架構基礎學習筆記。

ARM GIC(一) GIC V3架構基礎學習筆記。

2022-01-17 19:18:41 軟體設計

文章目錄

  • 1、Terms and Abbreviations
  • 2、Introduction
    • 2.2 Brief history of the GIC architecture
  • 3、GICv3 fundamentals
      • 3.1.1 ARM 中斷型別
      • 3.1.2 Interrupt Identifiers
    • 3.2 Interrupt state machine
      • 3.2.2 Edge-triggered(邊沿觸發處理)
    • 3.3 Affinity routing(親和路由)
    • 3.4 Security model
      • 3.4.1 Impact on software
      • 3.4.2 Support for single Security state(支持單一安全狀態)
    • 3.5 Programmers’ model

1、Terms and Abbreviations

在這里插入圖片描述

2、Introduction

本系列博客檔案準備轉譯通用中斷控制器體系結構的第3版(GICv3)手冊,它主要面向為ARMv8-A撰寫代碼的軟體工程師,

GIC 的全稱為 General Interrupt Controller,主要作用可以歸結為:接受硬體中斷信號并進行簡單處理,通過一定的設定策略,分給對應的CPU進行處理,

本博文提供了GICv3功能的以軟體為中心的概述,并描述了GICv3兼容中斷控制器的操作,它也是一本關于如何配置用于裸機環境的GICv3中斷控制器,

詳細描述請參考 ARM? Generic Interrupt Controller Architecture Specification
GIC architecture version 3.0 and 4.0.

2.2 Brief history of the GIC architecture

在這里插入圖片描述

3、GICv3 fundamentals

3.1.1 ARM 中斷型別

  • SGI: Software Generated Interrupt,軟體產生中斷,中斷號是 0-15,通過向SGI暫存器寫數觸發,可用于CPU間的通信,比如時間同步,全域行程調度資訊等,每個 PE 都有這么多 SGI 號,The Redistributor provides the configuration settings for PPIs and SGIs.
  • PPI: Private Peripheral Interrupt,私有外設中斷,中斷號是 16~31,這些中斷一般是發送給特定的CPU的,比如每個CPU有自己對應的 Generic Timer,產生的中斷信號就發送給這個特定的CPU進行處理,每個 PE 都有這么多 PPI 號,The Redistributor provides the configuration settings for PPIs and SGIs.
  • SPI: Shared Peripheral Interrupt,共享外設中斷,中斷號是 32~1019,比如按鍵觸發一個中斷,手機觸摸屏觸發的中斷,共享的意思是說可以從多個 PE 中選擇一個發送處理,當然也可以指定發送給某個 PE,The Distributor provides the routing configuration for SPIs, and holds all the associated routing and priority information.
    特殊中斷號,1020-1023,這個在 GICv3 中用于指示特別的場景,例如給 EL3 的軟體使用
    保留中斷號,1024-8191,
  • LPI: Locality-specific Peripheral Interrupt,區域外設中斷,中斷號 >=8192 ,LPI 沒有 active or active and pending state,得到回應后由處理器自動轉入 inactive 狀態,LPIs are new in GICv3, and they are different to the other types of interruptin a number of ways . In particular, LPIs are always message-based interrupts,and their configuration is held in tables in memory rather than registers. NOTE: LPIs are only supported when GICD_CTLR.ARE_NS==1.

3.1.2 Interrupt Identifiers

每個中斷源由一個ID號標識,稱為INTID,可用的
INTID分為多個范圍,每個范圍分配給一種特定型別的中斷,

在這里插入圖片描述### 3.1.3 How interrupts are signaled to the interrupt controller

傳統上,中斷是使用專用介面從外設向中斷控制器發送信號硬體信號,

在這里插入圖片描述GICv3支持此模型,另外還支持基于訊息的中斷,基于訊息的中斷是通過寫入中斷控制器中的暫存器來設定和清除的中斷,

在這里插入圖片描述使用一條訊息將中斷從外設轉發到中斷控制器將洗掉每個中斷源對專用信號的要求,這對于硬體來說是一個優勢大型系統的設計者,其中可能存在數百甚至數千個信號通過SoC布線,并在中斷控制器上會聚,在GICv3中,SPI可以是基于訊息的中斷,但LPI始終是基于訊息的中斷,不同的暫存器用于不同的中斷型別,如表4所示,
在這里插入圖片描述Impact of message-based interrupts on software

無論中斷是作為訊息發送還是使用專用信號發送,都不會對傳輸方式產生太大影響中斷處理代碼處理中斷,可能需要一些外圍設備的配置,例如,可能有必要指定中斷控制器的地址,

3.2 Interrupt state machine

中斷控制器為每個SPI、PPI和SGI中斷源維護一個狀態機,這

狀態機由四種狀態組成:

  • In’a’ctive 不活躍的
    中斷源當前未斷言,

  • Pending 掛起的
    中斷源已斷言,但中斷尚未確認PE首個被回應,

  • Active 忙碌的
    中斷源已被斷言,中斷已被PE確認,

  • Active and Pending 活動和掛起的
    中斷的一個實體已被確認,另一個實體正在掛起,

注意:LPI沒有活動或活動和掛起狀態,有

圖4顯示了狀態機的結構和可能的轉換,### 3.2.1 Level sensitive(電平觸發處理)
在這里插入圖片描述Inactive to Pending
An interrupt transitions from inactive to pending when the interrupt source is asserted.
At this point the GIC asserts the interrupt signal to the PE (if the interrupt is enabled and is of
sufficient priority).
Pending to Active & Pending
The interrupt transitions from pending to active and pending when a PE acknowledges the
interrupt by reading one of the IARs (Interrupt Acknowledge Registers) in the CPU interface. This
read is typically part of an interrupt handling routine that executes after an interrupt exception is
taken. However, software can also poll the IARs.
At this point the GIC deasserts the interrupt signal to the PE.
Active and Pending to Active
The interrupt transitions from active and pending to active when the peripheral de-asserts the
interrupt signal. This typically happens in response to the interrupt handling software that is
executing on the PE writing to a status register in the peripheral.
Active to Inactive
The interrupt goes from active to inactive when the PE writes to one of the EOIRs (End of
Interrupt Registers) in the CPU interface. This indicates that the PE has finished handling the
interrupt.

具體流程如下:
在這里插入圖片描述

  • 外部高電平中斷到達,中斷狀態置為pending狀態
  • 軟體讀取IAR暫存器,表示PE認可該中斷,但中斷依然為高,中斷狀態進入pending and active狀態
  • 軟體中斷處理完畢后,寫EOIR暫存器,表示優先級重置,過一段時間后,寫DIR暫存器,中斷狀態被置為idle狀態

3.2.2 Edge-triggered(邊沿觸發處理)

在這里插入圖片描述Inactive to Pending
An interrupt transitions from inactive to pending when the interrupt source is asserted.
At this point the GIC asserts the interrupt signal to the PE (if the interrupt is enabled and is of
sufficient priority).
Pending to Active
The interrupt transitions from pending to active when a PE acknowledges the interrupt by reading
one of the IARs in the CPU interface. This read is typically part of an interrupt handling routine
that executes after an interrupt exception is taken. However, software can also poll the IARs.
At this point the GIC de-asserts the interrupt signal to the PE.
Active to Active and Pending
The interrupt goes from active to active and pending if the peripheral re-asserts the interrupt
signal.
Active and Pending to Pending
The interrupt goes from active and pending to pending when the PE writes to one of the EOIRs in
the CPU interface. This indicates that the PE has finished handling the first instance of the
interrupt.
At this point the GIC re-asserts the interrupt signal to the PE.

具體流程如下:
在這里插入圖片描述

  • 外部邊沿中斷到達,中斷狀態被置為pending狀態
  • 軟體讀取IAR暫存器值,表示PE認可該中斷,中斷狀態被置為active狀態
  • 軟體中斷處理完畢后,寫EOIR暫存器,表示優先級重置,過一段時間后,寫DIR暫存器,中斷狀態被置為idle狀態

3.3 Affinity routing(親和路由)

GICv3使用關聯路由來識別連接的PE,并將中斷路由到特定PE或PEs組,PE的關聯性表示為四個8位欄位:
<affinity level 3>.<affinity level 2>.<affinity level 1>.<affinity level 0>
在這里插入圖片描述

在關聯級別0上有一個重新分發器,每個重分發器都連接到一個CPU介面,再分配者控制SGI、PPI和LPI,見第4章,親和性方案與ARMv8-A中使用的方案相匹配,與中報告的PE的親和性相匹配MPIDR_EL1,系統設計者必須確保MPIDR_EL1指示的關聯值為與連接至PE的再分配器的GICR_TYPE3指示的相同,不同親和力級別的確切含義由特定處理器和SoC定義,

以下是一些例子:
. ..
...

在一個實作中不太可能存在所有可能的節點,例如,一個移動設備的SoC可以具有類似以下布局:
0.0.0.[0:3] Cores 0 to 3 of a Cortex-A53 processor
0.0.1.[0:1] Cores 0 to 1 of a Cortex-A57 processor

In ARMv8-A, AArch64 state supports four levels of affinity. AArch32 state, and ARMv7, can
only support three levels of affinity. This means a design that uses AArch32 state is limited to a
single node at affinity level 3 (0.x.y.z). GICD_TYPER.A3V indicates whether the interrupt
controller can support multiple level 3 nodes.
NOTE: Although each level 1 node can host up to 256 Redistributors at level 0, in practice it is
likely to be 16 or fewer. This is because of the way the target PEs for an SGI are encoded, as
described in Chapter 7.

在ARMv8-A中,AArch64狀態支持四個級別的關聯,AArch32狀態和ARMv7可以僅支持三個級別的關聯,這意味著使用AArch32狀態的設計僅限于關聯級別為3(0.x.y.z)的單個節點,GICD_TYPER.A3V表示中斷是否中斷控制器可以支持多個級別3節點,

注意:盡管每個級別1節點在級別0上最多可以承載256個重分發器,但實際上是這樣的可能是16個或更少,這是由于SGI的目標PE的編碼方式,

3.4 Security model

GICv3體系結構支持ARM信任區技術,必須為每個INTID分配一個組和安全設定,GICv3支持三種組合,如表5所示,
在這里插入圖片描述

Group 0中斷始終以FIQ的形式發出信號,Group 1中斷信號為IRQ或FIQ取決于PE的當前安全狀態和例外級別,
在這里插入圖片描述這些規則旨在補充ARMv8-A安全狀態和例外級別路由控制,圖8顯示了一個簡化的軟體堆疊,以及不同型別的在EL0執行時發出中斷信號:

在這里插入圖片描述在本例中,IRQ路由到EL1(SCR_EL3.IRQ0),而FIQ路由到EL3(SCR_EL3.FIQ1),給定表6中描述的規則,在EL1或EL0執行時當前安全狀態的第1組中斷被視為IRQ,另一個安全狀態的中斷觸發FIQ,例外被帶到EL3,這然后允許在EL3執行的軟體執行必要的背景關系切換,

3.4.1 Impact on software

配置中斷時,軟體控制INTID到中斷組的分配控制器,只有在安全狀態下執行的軟體才能將INTID分配給中斷組,

通常,只有在安全狀態下執行的軟體才能訪問的設定和狀態安全中斷(Group 0和安全Group 1),

可以啟用從非安全狀態到安全中斷設定和狀態的訪問,這是使用GICD_NSACRn和GICR_NSACR暫存器分別控制每個INTID,

注:復位時INTID所屬的中斷組由實作定義,
注:LPI始終被視為非安全的第1組中斷,

3.4.2 Support for single Security state(支持單一安全狀態)

Support for two Security states is OPTIONAL in ARMv8-A and GICv3. An implementation can
choose to implement only a single Security state or two Security states.

In a GICv3 implementation that supports two Security states, one Security state can be disabled.
This is controlled by GICD_CTLR.DS.

GICD_CTLR.DS == 0
Two Security states (Secure and Non-secure) are supported

GICD_CTLR.DS == 1
Only a single Security state is supported. On implemenations that only implement a
single Security state, this bit is RAO/WI.

3.5 Programmers’ model

The register interface of a GICv3 interrupt controller is split into three groups:

  • Distributor interface.
  • Redistributor interface.
  • CPU interface.
    在這里插入圖片描述Distributor (GICD_*)

The Distributor registers are memory-mapped, and contain global settings that affect all PEs
connected to the interrupt controller. The Distributor provides a programming interface for:
Interrupt prioritization and distribution of SPIs.

  • Enabling and disabling SPIs.
  • Setting the priority level of each SPI.
  • Routing information for each SPI.
  • Setting each SPI to be level-sensitive or edge-triggered.
  • Generating message-based SPIs.
  • Controlling the active and pending state of SPIs.
  • Controls to determine the programmers’ model that is used in each Security state (affinity
    routing or legacy).

Distributor (GICD_*)

For each connected PE there is a Redistributor. The Redistributors provides a programming
interface for:

  • Enabling and disabling SGIs and PPIs.
  • Setting the priority level of SGIs and PPIs.
  • Setting each PPI to be level-sensitive or edge-triggered.
  • Assigning each SGI and PPI to an interrupt group.
  • Controlling the state of SGIs and PPIs.
  • Base address control for the data structures in memory that support the associated interrupt properties and pending state for LPIs.
    Power management support for the connected PE.

CPU interfaces (ICC_*_ELn)
Each Redistributor is connected to a CPU interface. The CPU interface provides a programming
interface for:

  • General control and configuration to enable interrupt handling.
  • Acknowledging an interrupt.
  • Performing a priority drop and deactivation of interrupts.
  • Setting an interrupt priority mask for the PE.
  • Defining the preemption policy for the PE.
  • Determining the highest priority pending interrupt for the PE.

在GICv3中,CPU介面暫存器作為系統暫存器(ICC)訪問,在使用這些暫存器之前,軟體必須啟用系統暫存器介面,這是可控的通過ICC_SRE_ELn暫存器中的SRE位,其中“n”指定例外級別(EL1)-EL3),

注:在GICv1和GICv2中,CPU介面暫存器為記憶體映射(GICC_*),
注:軟體可以通過讀取ID_AA64PFR0_EL1來檢查GIC系統暫存器支持
PE,請參閱ARM?體系結構參考手冊,ARMv8,了解有關的ARMv8-A體系結構組態檔
細節,

轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/413335.html

標籤:其他

上一篇:composer 多應用配置

下一篇:“一圖一庫”助力行業資訊化轉型,TDengine在交通運輸行業的落地應用

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 面試突擊第一季,第二季,第三季

    第一季必考 https://www.bilibili.com/video/BV1FE411y79Y?from=search&seid=15921726601957489746 第二季分布式 https://www.bilibili.com/video/BV13f4y127ee/?spm_id_fro ......

    uj5u.com 2020-09-10 05:35:24 more
  • 第三單元作業總結

    1.前言 這應該是本學期最后一次寫作業總結了吧。總體來說,對作業的節奏也差不多掌握了,作業做起來的效率也更高了。雖然和之前的作業一樣,作業中都要用到新的知識,但是相比之前,更加懂得了如何利用工具以及資料。雖然之間卡過殼,但總體而言,這幾次作業還算完成的比較好。 2.作業程序總結 相比前兩個單元,此單 ......

    uj5u.com 2020-09-10 05:35:41 more
  • 北航OO(2020)第四單元博客作業暨課程總結博客

    北航OO(2020)第四單元博客作業暨課程總結博客 本單元作業的架構設計 在本單元中,由于UML圖具有比較清晰的樹形結構,因此我對其中需要進行查詢操作的元素進行了包裝,在樹的父節點中存盤所有孩子的參考。考慮到性能問題,我采用了快取機制,一次查詢后盡可能快取已經遍歷過的資訊,以減少遍歷次數。 本單元我 ......

    uj5u.com 2020-09-10 05:35:48 more
  • BUAA_OO_第四單元

    一、UML決議器設計 ? 先看下題目:第四單元實作一個基于JDK 8帶有效性檢查的UML(Unified Modeling Language)類圖,順序圖,狀態圖分析器 MyUmlInteraction,實際上我們要建立一個有向圖模型,UML中的物件(元素)可能與同級元素連接,也可與低級元素相連形成 ......

    uj5u.com 2020-09-10 05:35:54 more
  • 6.1邏輯運算子

    邏輯運算子 1. && 短路與 運算式1 && 運算式2 01.運算式1為true并且運算式2也為true 整體回傳為true 02.運算式1為false,將不會執行運算式2 整體回傳為false 03.只要有一個運算式為false 整體回傳為false 2. || 短路或 運算式1 || 運算式2 ......

    uj5u.com 2020-09-10 05:35:56 more
  • BUAAOO 第四單元 & 課程總結

    1. 第四單元:StarUml檔案決議 本單元采用了圖模型決議UML。 UML檔案可以抽象為圖、子圖、邊的邏輯結構。 在實作中,圖的節點包括類、介面、屬性,子圖包括狀態圖、順序圖等。 采用了三次遍歷UML元素的方法建圖,第一遍遍歷建點,第二、三次遍歷設定屬性、連邊,實作圖物件的初始化。這里借鑒了一些 ......

    uj5u.com 2020-09-10 05:36:06 more
  • 談談我對C# 多型的理解

    面向物件三要素:封裝、繼承、多型。 封裝和繼承,這兩個比較好理解,但要理解多型的話,可就稍微有點難度了。今天,我們就來講講多型的理解。 我們應該經常會看到面試題目:請談談對多型的理解。 其實呢,多型非常簡單,就一句話:呼叫同一種方法產生了不同的結果。 具體實作方式有三種。 一、多載 多載很簡單。 p ......

    uj5u.com 2020-09-10 05:36:09 more
  • Python 資料驅動工具:DDT

    背景 python 的unittest 沒有自帶資料驅動功能。 所以如果使用unittest,同時又想使用資料驅動,那么就可以使用DDT來完成。 DDT是 “Data-Driven Tests”的縮寫。 資料:http://ddt.readthedocs.io/en/latest/ 使用方法 dd. ......

    uj5u.com 2020-09-10 05:36:13 more
  • Python里面的xlrd模塊詳解

    那我就一下面積個問題對xlrd模塊進行學習一下: 1.什么是xlrd模塊? 2.為什么使用xlrd模塊? 3.怎樣使用xlrd模塊? 1.什么是xlrd模塊? ?python操作excel主要用到xlrd和xlwt這兩個庫,即xlrd是讀excel,xlwt是寫excel的庫。 今天就先來說一下xl ......

    uj5u.com 2020-09-10 05:36:28 more
  • 當我們創建HashMap時,底層到底做了什么?

    jdk1.7中的底層實作程序(底層基于陣列+鏈表) 在我們new HashMap()時,底層創建了默認長度為16的一維陣列Entry[ ] table。當我們呼叫map.put(key1,value1)方法向HashMap里添加資料的時候: 首先,呼叫key1所在類的hashCode()計算key1 ......

    uj5u.com 2020-09-10 05:36:38 more
最新发布
  • 【中介者設計模式詳解】C/Java/JS/Go/Python/TS不同語言實作

    * 中介者模式是一種行為型設計模式,它可以用來減少類之間的直接依賴關系,
    * 將物件之間的通信封裝到一個中介者物件中,從而使得各個物件之間的關系更加松散。
    * 在中介者模式中,物件之間不再直接相互互動,而是通過中介者來中轉訊息。 ......

    uj5u.com 2023-04-20 08:20:47 more
  • 露天煤礦現場調研和交流案例分享

    他們集團的資訊化公司及研究院在一個礦區正在做智能礦山的統一平臺的 試點,專案投資大概1億,包括了礦山的各方面的內容,顯示得我們這次交流有點多余。他們2年前開始做智能礦山的規劃,有很多煤礦行業專家的加持,他們的描述是非常完美,但是去年底應該上線的平臺,現在還沒有看到影子。他們確實有很多場景需求,但是被... ......

    uj5u.com 2023-04-20 08:20:25 more
  • 《社區人員管理》實戰案例設計&個人案例分享

    設計是一個讓人夢想成真程序,開始編碼、測驗、除錯之前進行需求分析和架構設計,才能保證關鍵方面都做正確 ......

    uj5u.com 2023-04-20 08:20:17 more
  • 軟體架構生態化-多角色交付的探索實踐

    作為一個技術架構師,不僅僅要緊跟行業技術趨勢,還要結合研發團隊現狀及痛點,探索新的交付方案。在日常中,你是否遇到如下問題 “ 業務需求排期長研發是瓶頸;非研發角色感受不到研發技改提效的變化;引入ISV 團隊又擔心質量和安全,培訓周期長“等等,基于此我們探索了一種新的技術體系及交付方案來解決如上問題。 ......

    uj5u.com 2023-04-20 08:20:10 more
  • 【中介者設計模式詳解】C/Java/JS/Go/Python/TS不同語言實作

    * 中介者模式是一種行為型設計模式,它可以用來減少類之間的直接依賴關系,
    * 將物件之間的通信封裝到一個中介者物件中,從而使得各個物件之間的關系更加松散。
    * 在中介者模式中,物件之間不再直接相互互動,而是通過中介者來中轉訊息。 ......

    uj5u.com 2023-04-20 08:19:44 more
  • 露天煤礦現場調研和交流案例分享

    他們集團的資訊化公司及研究院在一個礦區正在做智能礦山的統一平臺的 試點,專案投資大概1億,包括了礦山的各方面的內容,顯示得我們這次交流有點多余。他們2年前開始做智能礦山的規劃,有很多煤礦行業專家的加持,他們的描述是非常完美,但是去年底應該上線的平臺,現在還沒有看到影子。他們確實有很多場景需求,但是被... ......

    uj5u.com 2023-04-20 08:19:07 more
  • 《社區人員管理》實戰案例設計&個人案例分享

    設計是一個讓人夢想成真程序,開始編碼、測驗、除錯之前進行需求分析和架構設計,才能保證關鍵方面都做正確 ......

    uj5u.com 2023-04-20 08:18:57 more
  • 軟體架構生態化-多角色交付的探索實踐

    作為一個技術架構師,不僅僅要緊跟行業技術趨勢,還要結合研發團隊現狀及痛點,探索新的交付方案。在日常中,你是否遇到如下問題 “ 業務需求排期長研發是瓶頸;非研發角色感受不到研發技改提效的變化;引入ISV 團隊又擔心質量和安全,培訓周期長“等等,基于此我們探索了一種新的技術體系及交付方案來解決如上問題。 ......

    uj5u.com 2023-04-20 08:18:49 more
  • 05單件模式

    #經典的單件模式 public class Singleton { private static Singleton uniqueInstance; //一個靜態變數持有Singleton類的唯一實體。 // 其他有用的實體變數寫在這里 //構造器宣告為私有,只有Singleton可以實體化這個類! ......

    uj5u.com 2023-04-19 08:42:51 more
  • 【架構與設計】常見微服務分層架構的區別和落地實踐

    軟體工程的方方面面都遵循一個最基本的道理:沒有銀彈,架構分層模型更是如此,每一種都有各自優缺點,所以請根據不同的業務場景,并遵循簡單、可演進這兩個重要的架構原則選擇合適的架構分層模型即可。 ......

    uj5u.com 2023-04-19 08:42:41 more