devices: Create Interrupt trait to abstract interrupt delivery

This commit anticipate the future need from having support for both
in kernel and userspace IOAPIC. The way to signal an interrupt from
the serial device will vary depending on the use case, but this should
be independent from the serial implementation itself.

That's why this patch provides a generic trait for the serial device
to call from, so that it can trigger interrupts independently from the
IOAPIC type chosen (in kernel vs userspace).

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2019-06-11 10:49:19 -07:00
committed by Samuel Ortiz
parent 2a7fbe8eae
commit c8c4a4d444
3 changed files with 41 additions and 23 deletions

View File

@@ -14,7 +14,7 @@ extern crate vm_memory;
extern crate vmm_sys_util;
use std::fs::File;
use std::io;
use std::{io, result};
mod bus;
pub mod legacy;
@@ -58,3 +58,7 @@ pub enum Error {
},
IoError(io::Error),
}
pub trait Interrupt: Send {
fn deliver(&self) -> result::Result<(), std::io::Error>;
}