diff --git a/Cargo.lock b/Cargo.lock index 079c658d..2524fd8f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1467,7 +1467,7 @@ dependencies = [ [[package]] name = "uhyve-interface" -version = "0.1.1" +version = "0.1.2" dependencies = [ "aarch64", "log", diff --git a/uhyve-interface/Cargo.toml b/uhyve-interface/Cargo.toml index facf7e90..03c2cdc7 100644 --- a/uhyve-interface/Cargo.toml +++ b/uhyve-interface/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uhyve-interface" -version = "0.1.1" +version = "0.1.2" edition = "2021" authors = [ "Jonathan Klimt ", diff --git a/uhyve-interface/src/lib.rs b/uhyve-interface/src/lib.rs index 9fb3f298..3758f6e1 100644 --- a/uhyve-interface/src/lib.rs +++ b/uhyve-interface/src/lib.rs @@ -72,6 +72,7 @@ pub enum HypercallAddress { /// Port address = `0x880` SerialBufferWrite = 0x880, } +// TODO: Remove this in the next major version impl From> for HypercallAddress { fn from(value: Hypercall) -> Self { match value { @@ -89,6 +90,23 @@ impl From> for HypercallAddress { } } } +impl From<&Hypercall<'_>> for HypercallAddress { + fn from(value: &Hypercall) -> Self { + match value { + Hypercall::Cmdsize(_) => Self::Cmdsize, + Hypercall::Cmdval(_) => Self::Cmdval, + Hypercall::Exit(_) => Self::Exit, + Hypercall::FileClose(_) => Self::FileClose, + Hypercall::FileLseek(_) => Self::FileLseek, + Hypercall::FileOpen(_) => Self::FileOpen, + Hypercall::FileRead(_) => Self::FileRead, + Hypercall::FileWrite(_) => Self::FileWrite, + Hypercall::FileUnlink(_) => Self::FileUnlink, + Hypercall::SerialWriteByte(_) => Self::Uart, + Hypercall::SerialWriteBuffer(_) => Self::SerialBufferWrite, + } + } +} /// Hypervisor calls available in Uhyve with their respective parameters. See the [module level documentation](crate) on how to invoke them. #[non_exhaustive] @@ -114,6 +132,7 @@ pub enum Hypercall<'a> { SerialWriteBuffer(&'a SerialWriteBufferParams), } impl<'a> Hypercall<'a> { + // TODO: Remove this in the next major version /// Get a hypercall's port address. pub fn port(self) -> u16 { HypercallAddress::from(self) as u16