pub struct ChainedPics { /* private fields */ }Expand description
The two 8259 PICs, chained together.
Implementations§
Source§impl ChainedPics
impl ChainedPics
Sourcepub const unsafe fn new(master_offset: u8, slave_offset: u8) -> Self
pub const unsafe fn new(master_offset: u8, slave_offset: u8) -> Self
Create an interface for the two 8259 PICs, specifying the desired interrupt offsets for both.
§Safety
It is important to pass the correct offsets. The default PIC configuration, which sends interrupt vector numbers in the range of 0 to 15, is not usable in protected mode since the numbers in that range are occupied by CPU exceptions in protected mode. If you return to real mode from protected mode (for whatever reason), you must restore the PICs to their default configurations.
Sourcepub unsafe fn initialize(&mut self)
pub unsafe fn initialize(&mut self)
Initialize both of the PICs. You can read more about the initialization process by checking out the following links:
- https://k.lse.epita.fr/internals/8259a_controller.html
- https://www.eeeguide.com/8259-programmable-interrupt-controller
- https://www.thesatya.com/8259.html
§Safety
Please read the Safety section of ChainedPics::new.
Sourcepub unsafe fn read_master_interrupt_mask(&mut self) -> u8
pub unsafe fn read_master_interrupt_mask(&mut self) -> u8
Read the interrupt mask of the master PIC.
Sourcepub unsafe fn read_slave_interrupt_mask(&mut self) -> u8
pub unsafe fn read_slave_interrupt_mask(&mut self) -> u8
Read the interrupt mask of the slave PIC.
Sourcepub unsafe fn read_interrupt_masks(&mut self) -> [u8; 2]
pub unsafe fn read_interrupt_masks(&mut self) -> [u8; 2]
Read the interrupt masks of both PICs.
Sourcepub unsafe fn write_master_interrupt_mask(&mut self, mask: u8)
pub unsafe fn write_master_interrupt_mask(&mut self, mask: u8)
Write to the interrupt mask of the master PIC.
Sourcepub unsafe fn write_slave_interrupt_mask(&mut self, mask: u8)
pub unsafe fn write_slave_interrupt_mask(&mut self, mask: u8)
Write to the interrupt mask of the slave PIC.
Sourcepub unsafe fn write_interrupt_masks(&mut self, master_mask: u8, slave_mask: u8)
pub unsafe fn write_interrupt_masks(&mut self, master_mask: u8, slave_mask: u8)
Write to the interrupt masks of both PICs.
Sourcepub unsafe fn disable(&mut self)
pub unsafe fn disable(&mut self)
Convenience function for disabling both PICs by masking all interrupts.
Sourcepub fn handles_interrupt(&self, irq_id: u8) -> bool
pub fn handles_interrupt(&self, irq_id: u8) -> bool
Check if the master or slave PIC handles the IRQ specified by the given ID.
Sourcepub unsafe fn notify_end_of_interrupt(&mut self, irq_id: u8)
pub unsafe fn notify_end_of_interrupt(&mut self, irq_id: u8)
Figure out which, if any, PIC in the chain needs to know about this interrupt. If the IRQ originated from the master PIC, we only need to send the EOI command to the master PIC. Otherwise, the EOI command needs to be sent to both PICs in the chain.
§Safety
It is important to pass the correct interrupt vector number. If the incorrect interrupt vector number is passed, it can lead to deleting an unsent interrupt or a hanging system.