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
pub mod ioapic;
pub mod x2apic;
pub mod xapic;
#[repr(u64)]
pub enum DeliveryMode {
Fixed = 0b000,
LowestPriority = 0b001,
SMI = 0b010,
_Reserved = 0b11,
NMI = 0b100,
Init = 0b101,
StartUp = 0b110,
}
#[repr(u64)]
pub enum DestinationMode {
Physical = 0,
Logical = 1,
}
#[repr(u64)]
pub enum DeliveryStatus {
Idle = 0,
SendPending = 1,
}
#[repr(u64)]
pub enum Level {
Deassert = 0,
Assert = 1,
}
#[repr(u64)]
pub enum TriggerMode {
Edge = 0,
Level = 1,
}
#[repr(u64)]
pub enum DestinationShorthand {
NoShorthand = 0b00,
Myself = 0b01,
AllIncludingSelf = 0b10,
AllExcludingSelf = 0b11,
}
pub struct Icr(u64);
impl Icr {
pub fn new(
vector: u8,
destination: u8,
destination_shorthand: DestinationShorthand,
delivery_mode: DeliveryMode,
destination_mode: DestinationMode,
delivery_status: DeliveryStatus,
level: Level,
trigger_mode: TriggerMode,
) -> Icr {
Icr((destination as u64) << 56
| (destination_shorthand as u64) << 18
| (trigger_mode as u64) << 15
| (level as u64) << 14
| (delivery_status as u64) << 12
| (destination_mode as u64) << 11
| (delivery_mode as u64) << 8
| (vector as u64))
}
pub fn lower(&self) -> u32 {
self.0 as u32
}
pub fn upper(&self) -> u32 {
(self.0 >> 32) as u32
}
}