#interrupt #kernel #controller #no-std

no-std pic8259

Abstractions for the 8259 and 8259A interrupt controllers

6 releases

0.11.0 Mar 11, 2024
0.10.4 Apr 13, 2023
0.10.3 Mar 9, 2023
0.10.2 Aug 22, 2021
0.10.1 May 17, 2021

#70 in Hardware support

Download history 1069/week @ 2024-01-17 1076/week @ 2024-01-24 837/week @ 2024-01-31 1129/week @ 2024-02-07 1397/week @ 2024-02-14 1194/week @ 2024-02-21 1166/week @ 2024-02-28 1222/week @ 2024-03-06 1113/week @ 2024-03-13 1149/week @ 2024-03-20 1144/week @ 2024-03-27 1067/week @ 2024-04-03 1047/week @ 2024-04-10 1151/week @ 2024-04-17 1189/week @ 2024-04-24 1036/week @ 2024-05-01

4,533 downloads per month
Used in 8 crates (7 directly)


91 lines


Abstractions for 8259 and 8259A Programmable Interrupt Controllers (PICs).

This project is a fork of the pic8259_simple crate created by @emk.

Things we may not handle very well yet include:

  1. Dealing with spurious interrupts.
  2. Non-standard configurations.

This code is based on the OSDev Wiki PIC notes, but it's not a complete implementation of everything they discuss. Also note that if you want to do more sophisticated interrupt handling, especially on multiprocessor systems, you'll probably want to read about the newer APIC and IOAPIC interfaces.


This is a very basic interface to the 8259 and 8259A interrupt controllers, which are used on single processor systems to pass hardware interrupts to the CPU.

To use this crate, add it to your Cargo.toml file, along with an appropriate kernel-space mutex implementation such as spin:

pic8259 = "0.10.0"
spin = "0.9.0"

You can then declare a global, lockable ChainedPics object as follows:

use pic8259::ChainedPics;
use spin::Mutex;

// Map PIC interrupts to 0x20 through 0x2f.
static PICS: Mutex<ChainedPics> =
    Mutex::new(unsafe { ChainedPics::new(0x20, 0x28) });

To perform runtime PIC intialization, call initialize before enabling interrupts:


When you've finished handling an interrupt, run:


It's safe to call notify_end_of_interrupt after every interrupt; the notify_end_of_interrupt function will try to figure out what it needs to do.

All public PIC interfaces are unsafe, because it's really easy to trigger undefined behavior by misconfiguring the PIC or using it incorrectly.

Crate Feature Flags

  • nightly - Uses features that are only usable on nightly Rust. Enabled by default.
  • stable - Enable this feature flag to build this crate on stable Rust. You have to add default-features = false, features = ["stable"] to your Cargo.toml.


Licensed under the Apache License, Version 2.0 or the MIT license, at your option.


~11K SLoC