| Crates.io | arm-gic-driver |
| lib.rs | arm-gic-driver |
| version | 0.15.8 |
| created_at | 2024-10-08 08:18:00.510052+00 |
| updated_at | 2025-08-26 01:30:59.917654+00 |
| description | A driver for the Arm Generic Interrupt Controller. |
| homepage | |
| repository | https://github.com/rcore-os/arm-gic-driver |
| max_upload_size | |
| id | 1400886 |
| size | 176,198 |
A Rust driver for the ARM Generic Interrupt Controller (GIC), designed for bare-metal and OS kernel environments.
#![no_std] compatible for embedded environmentsuse arm_gic_driver::v3::*;
let mut gic = unsafe { Gic::new(0xF901_0000.into(), 0xF902_0000.into()) };
gic.init();
// Every CPU should initialize its own CPU interface
let mut cpu = gic.cpu_interface();
cpu.init_current_cpu().unwrap();
// It implements `Send` and `Sync` traits, so it can be used as static value in trap handler easily.
let trap = cpu.trap_operations();
// Enable an Timer interrupt
let irq_id = IntId::ppi(14);
gic.set_irq_enable(irq_id, true);
// Set interrupt priority
gic.set_priority(irq_id, 0x80);
// Acknowledge and handle interrupts group1
let ack = trap.ack1();
if !ack.is_special() {
trap.eoi1(ack);
if trap.eoi_mode() {
trap.dir(ack);
}
}
This driver supports multiple ARM GIC versions:
rust-toolchain.toml)The project includes comprehensive test suites for different platforms and GIC versions:
# Test GICv2 on AArch64
./test.sh
# Test with EL2 support
./test-el2.sh
# Test GICv3
./test_v3.sh
VirtAddr: Type-safe virtual address wrapperIntId: Interrupt identifier with validationv2::Gic, v3::Gic: Version-specific GIC implementationsSee the itest/ directory for comprehensive examples of using the driver in different scenarios.
Contributions are welcome! Please ensure that:
cargo test --workspacecargo fmtcargo clippyThis project is licensed under the Mulan PSL v2 License. See the LICENSE file for details.