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
use {crate::hypercall, displaydoc::Display};
#[derive(Display, Debug)]
pub enum Error {
Hypercall(hypercall::Error),
Operation(GrantStatusError),
}
impl From<hypercall::Error> for Error {
fn from(e: hypercall::Error) -> Self {
Self::Hypercall(e)
}
}
impl From<GrantStatusError> for Error {
fn from(e: GrantStatusError) -> Self {
Self::Operation(e)
}
}
#[derive(Debug, Display)]
pub enum GrantStatusError {
GeneralError,
BadDomain,
BadGntRef,
BadHandle,
BadVirtAddr,
BadDevAddr,
NoDeviceSpace,
PermissionDenied,
BadPage,
BadCopyArg,
AddressTooBig,
Eagain,
NoSpace,
}
impl From<i16> for GrantStatusError {
fn from(status: i16) -> Self {
match status {
-1 => Self::GeneralError,
-2 => Self::BadDomain,
-3 => Self::BadGntRef,
-4 => Self::BadHandle,
-5 => Self::BadVirtAddr,
-6 => Self::BadDevAddr,
-7 => Self::NoDeviceSpace,
-8 => Self::PermissionDenied,
-9 => Self::BadPage,
-10 => Self::BadCopyArg,
-11 => Self::AddressTooBig,
-12 => Self::Eagain,
-13 => Self::NoSpace,
_ => panic!("unknown status"),
}
}
}