File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,12 @@ _x86_64_asm_lidt:
119
119
lidt (%rdi )
120
120
retq
121
121
122
+ .global _x86_64_asm_sidt
123
+ .p2align 4
124
+ _x86_64_asm_sidt:
125
+ sidt (%rdi )
126
+ retq
127
+
122
128
.global _x86_64_asm_write_rflags
123
129
.p2align 4
124
130
_x86_64_asm_write_rflags:
Original file line number Diff line number Diff line change @@ -132,6 +132,12 @@ extern "C" {
132
132
) ]
133
133
pub ( crate ) fn x86_64_asm_lidt ( idt : * const crate :: instructions:: tables:: DescriptorTablePointer ) ;
134
134
135
+ #[ cfg_attr(
136
+ any( target_env = "gnu" , target_env = "musl" ) ,
137
+ link_name = "_x86_64_asm_sidt"
138
+ ) ]
139
+ pub ( crate ) fn x86_64_asm_sidt ( idt : * mut crate :: instructions:: tables:: DescriptorTablePointer ) ;
140
+
135
141
#[ cfg_attr(
136
142
any( target_env = "gnu" , target_env = "musl" ) ,
137
143
link_name = "_x86_64_asm_ltr"
Original file line number Diff line number Diff line change 1
1
//! Functions to load GDT, IDT, and TSS structures.
2
2
3
3
use crate :: structures:: gdt:: SegmentSelector ;
4
+ use crate :: VirtAddr ;
4
5
5
6
pub use crate :: structures:: DescriptorTablePointer ;
6
7
@@ -44,6 +45,25 @@ pub unsafe fn lidt(idt: &DescriptorTablePointer) {
44
45
crate :: asm:: x86_64_asm_lidt ( idt as * const _ ) ;
45
46
}
46
47
48
+ /// Get the address of the current IDT.
49
+ #[ inline]
50
+ pub fn sidt ( ) -> DescriptorTablePointer {
51
+ let mut idt: DescriptorTablePointer = DescriptorTablePointer {
52
+ limit : 0 ,
53
+ base : VirtAddr :: new ( 0 ) ,
54
+ } ;
55
+ #[ cfg( feature = "inline_asm" ) ]
56
+ unsafe {
57
+ asm ! ( "sidt [{}]" , in( reg) & mut idt, options( nostack) ) ;
58
+ }
59
+ #[ cfg( not( feature = "inline_asm" ) ) ]
60
+ unsafe {
61
+ crate :: asm:: x86_64_asm_sidt ( & mut idt as * mut _ ) ;
62
+ }
63
+
64
+ idt
65
+ }
66
+
47
67
/// Load the task state register using the `ltr` instruction.
48
68
///
49
69
/// ## Safety
You can’t perform that action at this time.
0 commit comments