LoginSignup
9
16

More than 5 years have passed since last update.

Raspberry Pi 3の割込みについてまとめる

Last updated at Posted at 2017-07-08

Raspberry Pi 3の割込み仕様について

Raspberry Piは、独自仕様の割込みコントローラを持っている。
ARM GICではない、かなり扱いづらい独自仕様である。

Raspberry Piの割込み仕様書は以下の2つのドキュメントに分かれている。

  1. 初期のシングルコアのRaspberry Piで定義された割込み仕様
    https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2835/BCM2835-ARM-Peripherals.pdf

  2. Raspberry Pi 2あたりから定義されたマルチコア拡張した割込み仕様
    https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2836/QA7_rev3.4.pdf

シングルコアで定義された割込み仕様

まずは、上記の1.から調べてみる。
初期のRaspberry Piはシングルコアだった。
シングルコア時代に定義された割込み仕様が、現在のマルチコアRaspberry Piにもそのまま残っている。

96個の割込みが定義されている。
96個のうち32個は、IRQ basicというコア内の割込みである。
残りの64個はIRQ 1 / IRQ 2という外部割込みである。

IRQ basic

番号 割込み
0 ARM Timer IRQ pending
1 ARM Mailbox IRQ pending
2 ARM Doorbell 0 IRQ pending
3 ARM Doorbell 1 IRQ pending
4 GPU0 halted IRQ pending (Or GPU1 halted if bit 10 of control register 1 is set)
5 GPU1 halted IRQ pending
6 Illegal access type 1 IRQ pending
7 Illegal access type 0 IRQ pending
8 One or more bits set in pending register 1
9 One or more bits set in pending register 2
10 GPU IRQ 7
11 GPU IRQ 9
12 GPU IRQ 10
13 GPU IRQ 18
14 GPU IRQ 19
15 GPU IRQ 53
16 GPU IRQ 54
17 GPU IRQ 55
18 GPU IRQ 56
19 GPU IRQ 57
20 GPU IRQ 62
21-31 unused

IRQ 1 / IRQ 2

番号 割込み 番号 割込み 番号 割込み 番号 割込み
0 16 32 48 smi
1 17 33 49 gpio_int[0]
2 18 34 50 gpio_int[1]
3 19 35 51 gpio_int[2]
4 20 36 52 gpio_int[3]
5 21 37 53 i2c_int
6 22 38 54 spi_int
7 23 39 55 pcm_int
8 24 40 56
9 25 41 57 uart_int
10 26 42 58
11 27 43 i2c_spi_slv_int 59
12 28 44 60
13 29 Aux int 45 pwa0 61
14 30 46 pwa1 62
15 31 47 63

割込み設定レジスタ

FIQ controlレジスタ以外は、各ビットが各割込み番号の設定を示すレジスタである。
例えば、IRQ basic pendingレジスタの0bit目は割込み番号0の割込みがpendingかどうかを示している。
FIQ controlレジスタはFIQ割込み(高速割込み)に関する設定である。

アドレス レジスタ名 概要
0x7e00b200 IRQ basic pending 各IRQ basicがpendingかどうか示す
0x7e00b204 IRQ pending 1 各IRQ 1がpendingかどうか示す
0x7e00b208 IRQ pending 2 各IRQ 2がpendingかどうか示す
0x7e00b20C FIQ control FIQの設定をする
0x7e00b210 Enable IRQs 1 各IRQ basicを有効にする
0x7e00b214 Enable IRQs 2 各IRQ 1を有効にする
0x7e00b218 Enable Basic IRQs 各IRQ 2を有効にする
0x7e00b21C Disable IRQs 1 各IRQ basicを無効にする
0x7e00b220 Disable IRQs 2 各IRQ 1を無効にする
0x7e00b224 Disable Basic IRQs 各IRQ 2を無効にする

FIQ controlレジスタ

ビット 概要
31:8 unused
7 FIQ enable : 1をセットするとFIQが有効になる
6:0 Select FIQ Source : FIQに使用する割込み番号を指定する
0-63    GPU Interrupts (See GPU IRQ table)
64      ARM Timer interrupt
65      ARM Mailbox interrupt
66      ARM Doorbell 0 interrupt
67      ARM Doorbell 1 interrupt
68      GPU0 Halted interrupt (Or GPU1)
69      GPU1 Halted interrupt
70      Illegal access type-1 interrupt
71      Illegal access type-0 interrupt
72-127  Do Not Use

マルチコア拡張された割込み仕様

ここで定義されているレジスタは、マルチコアで発生する割り込みを扱うことができる。
例えば、各コアにはタイマ割込みやコア間割込み(Mailbox)が付いているが、
これらの割込みをコアごとに個別に設定、処理することができる。

アドレス レジスタ名
0x4000_0000 Control register
0x4000_0004 unused
0x4000_0008 Core timer prescaler
0x4000_000C GPU interrupts routing
0x4000_0010 Performance Monitor Interrupts routing-set
0x4000_0014 Performance Monitor Interrupts routing-clear
0x4000_0018 unused
0x4000_001C Core timer access LS 32 bits
0x4000_0020 Core timer access MS 32 bits
0x4000_0024 Local Interrupt 0 [1-7] routing
0x4000_0028 Local Interrupts 8-15 routing
0x4000_002C Axi outstanding counters
0x4000_0030 Axi outstanding IRQ
0x4000_0034 Local timer control & status
0x4000_0038 Local timer write flags
0x4000_003C unused
0x4000_0040 Core0 timers Interrupt control
0x4000_0044 Core1 timers Interrupt control
0x4000_0048 Core2 timers Interrupt control
0x4000_004C Core3 timers Interrupt control
0x4000_0050 Core0 Mailboxes Interrupt control
0x4000_0054 Core1 Mailboxes Interrupt control
0x4000_0058 Core2 Mailboxes Interrupt control
0x4000_005C Core3 Mailboxes Interrupt control
0x4000_0060 Core0 IRQ Source
0x4000_0064 Core1 IRQ Source
0x4000_0068 Core2 IRQ Source
0x4000_006C Core3 IRQ Source
0x4000_0070 Core0 FIQ Source
0x4000_0074 Core1 FIQ Source
0x4000_0078 Core2 FIQ Source
0x4000_007C Core3 FIQ Source
0x4000_0080 Core 0 Mailbox 0 write-set (WO)
0x4000_0084 Core 0 Mailbox 1 write-set (WO)
0x4000_0088 Core 0 Mailbox 2 write-set (WO)
0x4000_008C Core 0 Mailbox 3 write-set (WO)
0x4000_0090 Core 1 Mailbox 0 write-set (WO)
0x4000_0094 Core 1 Mailbox 1 write-set (WO)
0x4000_0098 Core 1 Mailbox 2 write-set (WO)
0x4000_009C Core 1 Mailbox 3 write-set (WO)
0x4000_00A0 Core 2 Mailbox 0 write-set (WO)
0x4000_00A4 Core 2 Mailbox 1 write-set (WO)
0x4000_00A8 Core 2 Mailbox 2 write-set (WO)
0x4000_00AC Core 2 Mailbox 3 write-set (WO)
0x4000_00B0 Core 3 Mailbox 0 write-set (WO)
0x4000_00B4 Core 3 Mailbox 1 write-set (WO)
0x4000_00B8 Core 3 Mailbox 2 write-set (WO)
0x4000_00BC Core 3 Mailbox 3 write-set (WO)
0x4000_00C0 Core 0 Mailbox 0 read & write-high-to-clear
0x4000_00C4 Core 0 Mailbox 1 read & write-high-to-clear
0x4000_00C8 Core 0 Mailbox 2 read & write-high-to-clear
0x4000_00CC Core 0 Mailbox 3 read & write-high-to-clear
0x4000_00D0 Core 1 Mailbox 0 read & write-high-to-clear
0x4000_00D4 Core 1 Mailbox 1 read & write-high-to-clear
0x4000_00D8 Core 1 Mailbox 2 read & write-high-to-clear
0x4000_00DC Core 1 Mailbox 3 read & write-high-to-clear
0x4000_00E0 Core 2 Mailbox 0 read & write-high-to-clear
0x4000_00E4 Core 2 Mailbox 1 read & write-high-to-clear
0x4000_00E8 Core 2 Mailbox 2 read & write-high-to-clear
0x4000_00EC Core 2 Mailbox 3 read & write-high-to-clear
0x4000_00F0 Core 3 Mailbox 0 read & write-high-to-clear
0x4000_00F4 Core 3 Mailbox 1 read & write-high-to-clear
0x4000_00F8 Core 3 Mailbox 2 read & write-high-to-clear
0x4000_00FC Core 3 Mailbox 3 read & write-high-to-clear

Core0-3 IRQ/FIQ source

このレジスタはコア数ぶん存在しており、
コアごとに各割込みがpending状態かどうかを示す

ビット 概要
31-28 Reserved
17-12 Peripheral 1..15 interrupt (Currently not used)
11 Local timer interrupt
10 AXI-outstanding interrupt (For core 0 only!) all others are 0
9 PMU interrupt
8 GPU interrupt (Can be high in one core only)
7 Mailbox 3 interrupt
6 Mailbox 2 interrupt
5 Mailbox 1 interrupt
4 Mailbox 0 interrupt
3 CNTVIRQ interrupt
2 CNTHPIRQ interrupt
1 CNTPNSIRQ interrupt
0 CNTPSIRQ interrupt (Physical Timer -1)

追記中・・・

9
16
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
16