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:
119119 lidt (%rdi )
120120 retq
121121
122+ .global _x86_64_asm_sidt
123+ .p2align 4
124+ _x86_64_asm_sidt:
125+ sidt (%rdi )
126+ retq
127+
122128.global _x86_64_asm_write_rflags
123129.p2align 4
124130_x86_64_asm_write_rflags:
Original file line number Diff line number Diff line change @@ -132,6 +132,12 @@ extern "C" {
132132 ) ]
133133 pub ( crate ) fn x86_64_asm_lidt ( idt : * const crate :: instructions:: tables:: DescriptorTablePointer ) ;
134134
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+
135141 #[ cfg_attr(
136142 any( target_env = "gnu" , target_env = "musl" ) ,
137143 link_name = "_x86_64_asm_ltr"
Original file line number Diff line number Diff line change 11//! Functions to load GDT, IDT, and TSS structures.
22
33use crate :: structures:: gdt:: SegmentSelector ;
4+ use crate :: VirtAddr ;
45
56pub use crate :: structures:: DescriptorTablePointer ;
67
@@ -44,6 +45,25 @@ pub unsafe fn lidt(idt: &DescriptorTablePointer) {
4445 crate :: asm:: x86_64_asm_lidt ( idt as * const _ ) ;
4546}
4647
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+
4767/// Load the task state register using the `ltr` instruction.
4868///
4969/// ## Safety
You can’t perform that action at this time.
0 commit comments