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
use segmentation;
pub type TaskStateDescriptorLow = segmentation::SegmentDescriptor;
pub type TaskStateDescriptorHigh = u64;
#[derive(Debug)]
#[repr(C, packed)]
pub struct TaskStateSegment {
pub reserved: u32,
pub rsp: [u64; 3],
pub reserved2: u64,
pub ist: [u64; 7],
pub reserved3: u64,
pub reserved4: u16,
pub iomap_base: u16,
}
impl TaskStateSegment {
pub fn new() -> TaskStateSegment {
TaskStateSegment {
reserved: 0,
rsp: [0, 0, 0],
reserved2: 0,
ist: [0, 0, 0, 0, 0, 0, 0],
reserved3: 0,
reserved4: 0,
iomap_base: 0,
}
}
}
pub unsafe fn load_ltr(sel: segmentation::SegmentSelector) {
asm!("ltr $0" :: "r" (sel));
}