Skip to content

Commit c103e41

Browse files
mkroeningIsaacWoods
authored andcommitted
feat: add EndpointHeader::update_interrupt
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
1 parent 7cde1c8 commit c103e41

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,19 @@ impl EndpointHeader {
413413
let data = unsafe { access.read(self.0, 0x3c) };
414414
(data.get_bits(8..16) as u8, data.get_bits(0..8) as u8)
415415
}
416+
417+
pub fn update_interrupt<F>(&mut self, access: &impl ConfigRegionAccess, f: F)
418+
where
419+
F: FnOnce((InterruptPin, InterruptLine)) -> (InterruptPin, InterruptLine),
420+
{
421+
let mut data = unsafe { access.read(self.0, 0x3c) };
422+
let (new_pin, new_line) = f((data.get_bits(8..16) as u8, data.get_bits(0..8) as u8));
423+
data.set_bits(8..16, new_pin.into());
424+
data.set_bits(0..8, new_line.into());
425+
unsafe {
426+
access.write(self.0, 0x3c, data);
427+
}
428+
}
416429
}
417430

418431
/// PCI-PCI Bridges have a Type-1 header, so the remainder of the header is of the form:

0 commit comments

Comments
 (0)