Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions crates/pic8259_simple/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ impl ChainedPics {
pub fn handles_interrupt(&self, interrupt_id: u8) -> bool {
self.pics.iter().any(|p| p.handles_interrupt(interrupt_id))
}

// Function to set interrupt mask for master or slave
pub unsafe fn set_mask(&mut self, pic_no: usize, mask: u8) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is a really nice addition! But it takes a pic_size parameter, which means it should be declared on the Pic object, not on the Pics object.

let mut wait_port: cpuio::Port<u8> = cpuio::Port::new(0x80);
let mut wait = || { wait_port.write(0) };
self.pics[pic_no].data.write(mask);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, when we set the mask, we overwrite it completely. Many PIC 8259 implementations provide some way to read the current mask, set specific bits, and then write it back. One way to do this would be to add a get_mask function to Pic as well.

wait();
}

/// Figure out which (if any) PICs in our chain need to know about this
/// interrupt. This is tricky, because all interrupts from `pics[1]`
Expand Down