1use hvdef::Vtl;
8use std::sync::Arc;
9use virt::X86Partition;
10use vm_topology::processor::VpIndex;
11use vmcore::line_interrupt::LineSetTarget;
12
13pub struct ApicLintLineTarget<T: X86Partition> {
15 partition: Arc<T>,
16 vtl: Vtl,
17}
18
19impl<T: X86Partition> ApicLintLineTarget<T> {
20 pub fn new(partition: Arc<T>, vtl: Vtl) -> Self {
22 Self { partition, vtl }
23 }
24}
25
26impl<T: X86Partition> LineSetTarget for ApicLintLineTarget<T> {
27 fn set_irq(&self, vector: u32, high: bool) {
28 if !high {
29 return;
30 }
31 let vp_index = VpIndex::new(vector / 2);
32 let lint = vector % 2;
33 self.partition.pulse_lint(vp_index, self.vtl, lint as u8);
34 }
35}