#arm #driver #aarch64 #gic #interrupt-controller #patch

no-std arm-gic

A driver for the Arm Generic Interrupt Controller version 3 or 4

3 releases

new 0.1.2 Nov 21, 2024
0.1.1 Aug 9, 2024
0.1.0 Apr 17, 2023

#1539 in Embedded development

Download history 116/week @ 2024-08-01 198/week @ 2024-08-08 96/week @ 2024-08-15 134/week @ 2024-08-22 95/week @ 2024-08-29 96/week @ 2024-09-05 153/week @ 2024-09-12 73/week @ 2024-09-19 81/week @ 2024-09-26 75/week @ 2024-10-03 138/week @ 2024-10-10 89/week @ 2024-10-17 39/week @ 2024-10-24 55/week @ 2024-10-31 66/week @ 2024-11-07 39/week @ 2024-11-14

226 downloads per month
Used in libhermit-rs

MIT/Apache

28KB
439 lines

Arm Generic Interrupt Controller driver

crates.io page docs.rs page

This crate provides a Rust driver for the Arm Generic Interrupt Controller version 3 or 4 (GICv3 and GICv4).

Currently it only supports AArch64. Patches are welcome to add support for AArch32 and other GIC versions.

This is not an officially supported Google product.

License

Licensed under either of

at your option.

Contributing

If you want to contribute to the project, see details of how we accept contributions.


lib.rs:

Driver for the Arm Generic Interrupt Controller version 3 or 4, on aarch64.

This top level module contains functions that are not specific to any particular interrupt controller, as support for other GIC versions may be added in future.

Example

use arm_gic::{
    gicv3::{GicV3, IntId, SgiTarget},
    irq_enable,
};

// Base addresses of the GICv3 distributor and redistributor.
const GICD_BASE_ADDRESS: *mut u64 = 0x800_0000 as _;
const GICR_BASE_ADDRESS: *mut u64 = 0x80A_0000 as _;

// Initialise the GIC.
let mut gic = unsafe { GicV3::new(GICD_BASE_ADDRESS, GICR_BASE_ADDRESS) };
gic.setup();

// Configure an SGI and then send it to ourself.
let sgi_intid = IntId::sgi(3);
GicV3::set_priority_mask(0xff);
gic.set_interrupt_priority(sgi_intid, 0x80);
gic.enable_interrupt(sgi_intid, true);
irq_enable();
GicV3::send_sgi(
    sgi_intid,
    SgiTarget::List {
        affinity3: 0,
        affinity2: 0,
        affinity1: 0,
        target_list: 0b1,
    },
);

Dependencies

~105KB