1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
//! Parameters for hypercalls.
use x86_64::PhysAddr;
use crate::MAX_ARGC_ENVC;
/// Parameters for a [`Cmdsize`](crate::Hypercall::Cmdsize) hypercall which provides the lengths of the items in the argument end environment vector.
#[repr(C, packed)]
#[derive(Debug, Copy, Clone)]
pub struct CmdsizeParams {
/// Nr of items in the kernel command line.
pub argc: i32,
/// Lengths of the items in the kernel command line.
pub argsz: [i32; MAX_ARGC_ENVC],
/// Nr of items in the environment.
pub envc: i32,
/// Length of the items in the environment.
pub envsz: [i32; MAX_ARGC_ENVC],
}
/// Parameters for a [`Cmdval`](crate::Hypercall::Cmdval) hypercall, which copies the arguments end environment of the application into the VM's memory.
#[repr(C, packed)]
#[derive(Debug, Copy, Clone)]
pub struct CmdvalParams {
/// Pointer to a memory section in the VM memory large enough to store the argument string.
pub argv: PhysAddr,
/// Pointer to a memory section in the VM memory large enough to store the environment values.
pub envp: PhysAddr,
}
/// Parameters for a [`Exit`](crate::Hypercall::Exit) hypercall.
#[repr(C, packed)]
#[derive(Debug, Copy, Clone)]
pub struct ExitParams {
/// The return code of the guest.
pub arg: i32,
}
/// Parameters for a [`FileUnlink`](crate::Hypercall::FileUnlink) hypercall.
#[repr(C, packed)]
#[derive(Debug, Copy, Clone)]
pub struct UnlinkParams {
/// Address of the file that should be unlinked.
pub name: PhysAddr,
/// On success, `0` is returned. On error, `-1` is returned.
pub ret: i32,
}
/// Parameters for a [`FileWrite`](crate::Hypercall::FileWrite) hypercall.
#[repr(C, packed)]
#[derive(Debug, Copy, Clone)]
pub struct WriteParams {
/// File descriptor of the file.
pub fd: i32,
/// Buffer to be written into the file.
pub buf: PhysAddr,
/// Number of bytes in the buffer to be written.
pub len: usize,
}
/// Parameters for a [`FileRead`](crate::Hypercall::FileRead) hypercall.
#[repr(C, packed)]
#[derive(Debug, Copy, Clone)]
pub struct ReadPrams {
/// File descriptor of the file.
pub fd: i32,
/// Buffer to read the file into.
pub buf: PhysAddr,
/// Number of bytes to read into the buffer.
pub len: usize,
/// Number of bytes read on success. `-1` on failure.
pub ret: isize,
}
/// Parameters for a [`FileClose`](crate::Hypercall::FileClose) hypercall.
#[repr(C, packed)]
#[derive(Debug, Copy, Clone)]
pub struct CloseParams {
/// File descriptor of the file.
pub fd: i32,
/// Zero on success, `-1` on failure.
pub ret: i32,
}
/// Parameters for a [`FileOpen`](crate::Hypercall::FileOpen) hypercall.
#[repr(C, packed)]
#[derive(Debug, Copy, Clone)]
pub struct OpenParams {
/// Pathname of the file to be opened.
pub name: PhysAddr,
/// Posix file access mode flags.
pub flags: i32,
/// Access permissions upon opening/creating a file.
pub mode: i32,
/// File descriptor upon successful opening or `-1` upon failure.
pub ret: i32,
}
/// Parameters for a [`FileLseek`](crate::Hypercall::FileLseek) hypercall
#[repr(C, packed)]
#[derive(Debug, Copy, Clone)]
pub struct LseekParams {
/// File descriptor of the file.
pub fd: i32,
/// Offset in the file.
pub offset: isize,
/// `whence` value of the lseek call.
pub whence: i32,
}