FreeNOS
ARMGenericInterrupt.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019 Niek Linnenbank
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __LIBARCH_ARM_ARMGENERICINTERRUPT_H
19#define __LIBARCH_ARM_ARMGENERICINTERRUPT_H
20
21#include <IntController.h>
22#include "ARMIO.h"
23
39{
40 private:
41
44
49 {
50 GICD_CTRL = 0x0000,
51 GICD_TYPER = 0x0004,
52 GICD_GROUPR = 0x0080,
55 GICD_ICPENDR = 0x0280,
60 GICD_ICFGR = 0x0C00,
61 GICD_SGIR = 0x0F00,
63 GICD_ID2 = 0x0FE8
64 };
65
67 {
68 DistCtrlGroup0 = (1 << 0),
69 DistCtrlGroup1 = (1 << 1)
70 };
71
73 {
74 DistTypeIrqsMask = (0xf)
75 };
76
81 {
82 GICC_CTRL = 0x0000,
83 GICC_PMR = 0x0004,
84 GICC_IAR = 0x000C,
85 GICC_EOIR = 0x0010,
86 GICC_IDR = 0x00FC,
87 GICC_DIR = 0x1000
88 };
89
91 {
92 CpuCtrlGroup0 = (1 << 0),
93 CpuCtrlGroup1 = (1 << 1)
94 };
95
97 {
98 CpuIrqAckMask = (0x3ff),
99 };
100
101 public:
102
109 ARMGenericInterrupt(Address distRegisterBase,
110 Address cpuRegisterBase);
111
119 Result initialize(bool performReset = true);
120
129 virtual Result send(const uint targetCoreId, const uint irq);
130
138 virtual Result enable(uint irq);
139
147 virtual Result disable(uint irq);
148
160 virtual Result clear(uint irq);
161
169 virtual Result nextPending(uint & irq);
170
178 virtual bool isTriggered(uint irq);
179
180 private:
181
189 Size numRegisters(Size bits) const;
190
196 bool isSoftwareInterrupt(const uint irq) const;
197
198 private:
199
202
205
208
211};
212
219#endif /* __LIBARCH_ARM_ARMGENERICINTERRUPT_H */
ARM Generic Interrupt Controller (GIC) version 2.
Size m_numIrqs
Number of interrupts supported.
virtual bool isTriggered(uint irq)
Check if an IRQ vector is set.
ARMIO m_cpu
ARM Generic Interrupt Controller CPU Interface.
virtual Result enable(uint irq)
Enable hardware interrupt (IRQ).
virtual Result nextPending(uint &irq)
Retrieve the next pending interrupt (IRQ).
Result initialize(bool performReset=true)
Initialize the controller.
Size numRegisters(Size bits) const
Calculate the number of 32-bit registers needed to represent given number of bits per IRQ.
bool isSoftwareInterrupt(const uint irq) const
Check if the given IRQ is an SGI.
virtual Result disable(uint irq)
Disable hardware interrupt (IRQ).
static const Size NumberOfSoftwareInterrupts
Total number of software generated interrupts (SGI)
ARMIO m_dist
ARM Generic Interrupt Controller Distributor Interface.
virtual Result send(const uint targetCoreId, const uint irq)
Raise a software generated interrupt (SGI).
DistRegisters
Distributor register interface.
CpuRegisters
CPU register interface.
virtual Result clear(uint irq)
Clear hardware interrupt (IRQ).
u32 m_savedIrqAck
Saved value of the Interrupt-Acknowledge register.
Input/Output operations specific to the ARM architecture.
Definition ARMIO.h:40
Interrupt controller interface.
Result
Result codes.
unsigned int u32
Unsigned 32-bit number.
Definition Types.h:53
unsigned long Address
A memory address.
Definition Types.h:131
unsigned int uint
Unsigned integer number.
Definition Types.h:44
unsigned int Size
Any sane size indicator cannot go negative.
Definition Types.h:128